This repo contains example YAML for enabling ArgoCD Notifications as New Relic Change Tracking events.
- Define your New Relic User API Key in your
argocd-notifications-secret
Secret.
An example can be found here.
...
stringData:
newrelic-apiKey: NRAK-YOURAPIKEYGOESHERE
...
- Add the New Relic
trigger
,template
, andservice
to yourargocd-notifications-cm
ConfigMap.
The default catalog can be found here.
...
trigger.app-deployed: |
- description: Application is synced and healthy. Triggered once per commit.
oncePer: app.status.sync.revision
send:
- newrelic-app-deployed
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
template.newrelic-app-deployed: |
webhook:
newrelic:
method: POST
body: |
mutation {
changeTrackingCreateDeployment(
deployment: {
version: "{{.app.status.sync.revision}}",
entityGuid: "{{.app.metadata.annotations.entityguid}}",
commit: "{{.app.status.sync.revision}}",
user: "ArgoCD",
deploymentType: BASIC,
description: "New version of an application {{.app.metadata.name}} has been deployed."
}
) {
deploymentId
entityGuid
}
}
service.webhook.newrelic: |
url: https://api.newrelic.com/graphql
headers:
- name: Content-Type
value: application/graphql
- name: Api-Key
value: $newrelic-apiKey
...
- Apply the changes to your ArgoCD instance.
kubectl apply -f argocd-notifications-secret.yaml -n argocd
kubectl apply -f argocd-notifications-cm.yaml -n argocd
An ArgoCD Application needs to "subscribe" to notifications so you'll need to add the following annotations to your application.
Check out the example application here.
...
annotations:
notifications.argoproj.io/subscribe.newrelic-app-deployed.newrelic: ""
entityguid: "<NEW RELIC ENTITY GUID>"
...
entityguid
is the New Relic entity guid for the APM application. You'll need to perform an initial deployment of your app in order to generate an entity guid in the New Relic platform. Subsequent deployments can then be associated with this guid.
After the ArgoCD deployment process completes, you should see the change tracking event and the before and after state of the application in New Relic.