ArgoCD Discord Webhooks

Send application status to discord with argo cd

Mon, 19 Feb 2024

I had a lot of trouble with setting up ArgoCD. It was not a fun time, that being said once its 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.

Buy Me A CoffeeDigitalOcean Referral Badge
Loading...
Edward Beazer

Edward Beazer - I just like to build shit. Sometimes I get stuck for hours, even days while trying to figure out how to solve an issue or implement a new feature. Hope my tips and tutorials can save you some time.

DigitalOcean Referral Badge