Skip to content

Commit

Permalink
add instana release events
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvaughn authored and bbelyeu committed Mar 28, 2020
1 parent 8a59485 commit bed787a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ env:

# Deploy Events

Currently NewRelic, Slack, Datadog, & Microsoft Teams deploy events are supported.
Currently NewRelic, Slack, Datadog, Instana, & Microsoft Teams deploy events are supported.

In Gitlab for NewRelic, you'll need to add a secret variable with the NewRelic API key and App Ids
for each stage you want a deployment event for. Like:
Expand Down Expand Up @@ -320,6 +320,33 @@ TEAMS_STAGING_WEBHOOK=xxx
TEAMS_PRODUCTION_WEBHOOK=xxx
```

For Instana, you *must* set your Instana API Token & Instana Base URL with:

```
INSTANA_API_TOKEN=xxx
INSTANA_BASE_URL=https://<dashboard-url>
```

If you want notifications for specific stages use the following format.

```
INSTANA_{{STAGE}}_API_TOKEN
```

E.g.

```
INSTANA_STAGING_API_TOKEN=xxx
INSTANA_PRODUCTION_API_TOKEN=xxx
```

Per Instana's docs it's important to note:

The used API Token requires the permission “Configuration of releases”.
A release has no scope and is therefore globally applied to the whole monitored system.

Based on that last note you can set these variables at a group level and not have to manage them at the project level.

# Manifest-less Deploys
Starting in 3.1.0, we added an option for manifest-less deploys to help us migrate away from Deis Workflow. In order for this to work, we had to make some very opinionated decisions regarding our manifests. These may not work for your organization. If this is the case, we encourage you to fork our project and make your own default manifests. They can be found in the manifests directory.

Expand Down
15 changes: 15 additions & 0 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,20 @@ if [ "$TEAMS_WEBHOOK_URL" ]; then
}" $TEAMS_WEBHOOK_URL > /dev/null || true
fi

if [ "$INSTANA_API_TOKEN" ] && [ "$INSTANA_BASE_URL" ]; then
echo "Sending deploy event to Instana..."
URL="$INSTANA_BASE_URL/api/releases"
# this gets the epoch in milliseconds (does not work on macOS)
start_time=$(date +%s%3N)
curl --silent -X POST \
-H 'Content-type: application/json' \
-H "Authorization: apiToken $INSTANA_API_TOKEN" \
-d \
"{
\"name\": \"$KUBE_NAMESPACE env:$REAL_JOB_STAGE\",
\"start\": $start_time
}" "$URL" > /dev/null || true
fi

echo "Application is accessible at: ${CI_ENVIRONMENT_URL}"
echo ""
11 changes: 11 additions & 0 deletions src/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,15 @@ get_deploy_events() {
fi
done
fi

if env | grep -i -e '^INSTANA' > /dev/null; then
INSTANA=$(env | grep -i -e '^INSTANA')
for i in $INSTANA; do
if echo "$i" | grep -i -e "$CI_JOB_STAGE" | grep -i -e "API_TOKEN" > /dev/null; then
export INSTANA_API_TOKEN=$(echo $i | cut -d'=' -f2)
elif echo "$i" | grep -i -e "^INSTANA_API_TOKEN" > /dev/null; then
export INSTANA_API_TOKEN=$(echo $i | cut -d'=' -f2)
fi
done
fi
}

0 comments on commit bed787a

Please sign in to comment.