200 words
1 minute
ArgoCD Discord Webhooks

I had a lot of trouble with setting up ArgoCD. It was not a fun time, that being said once it’s set up it runs smoothly. The hardest part was getting my notifications set up. I like to funnel all of my non-urgent notifications into my discord server. I’ll show you how to do that with argo cd

I’m using helm, so these changes should be added to your values file

notifications:
 enabled: true
 notifiers:
   trigger.on-app-health-degraded: |
     - when: app.status.health.status == 'Degraded'
       send: [app-health-degraded:]
   subscriptions: |
   - recipients:
     - discord
     triggers:
       - on-app-health-degraded
   service.webhook.discord: |
     url: FULL DISCORD URL WEBHOOK SECRET
     headers:
     - name: Content-Type
       value: application/json
   template.app-health-degraded: |
     webhook:
       discord:
         method: POST
         body: |
           {
             "embeds": [
               {
                 "title": "Application {{.app.metadata.name}} has degraded",
                 "url": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
                 "fields": [
                   {
                     "name": "Health Status",
                     "value": "{{.app.status.health.status}}",
                     "inline": "true"
                   },
                   {
                     "name": "Repository",
                     "value": "{{.app.spec.source.repoURL}}",
                     "inline": "false"
                   }
                   {{range $index, $c := .app.status.conditions}}
                   {{if not $index}},{{end}}
                   {{if $index}},{{end}}
                   {
                     "name": "{{$c.type}}",
                     "value": "{{$c.message}}",
                     "inline": "true"
                   }
                   {{end}}
                 ]
               }
             ]
           }

That above change to your values file will create a new discord webhook service and subscribe all of your applications to the on degraded hook. Anytime your application degrades it will send a discord message.

ArgoCD Discord Webhooks
https://edwardbeazer.com/posts/argocd-discord-webhooks/
Author
Edward Beazer
Published at
2024-02-19