apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
# ---------------------------------------------------------------------------
# 1. CONTEXT (Replace with your actual Argo CD URL for clickable links)
# ---------------------------------------------------------------------------
context: |
argocdUrl: https://argocd.your-domain.com
# ---------------------------------------------------------------------------
# 2. SLACK SERVICE CONFIGURATION
# ---------------------------------------------------------------------------
service.slack: |
token: $slack-token
username: ArgoCD
# icon: :rocket: <-- Do not use this line, it causes YAML parsing errors.
# ---------------------------------------------------------------------------
# 3. GLOBAL SUBSCRIPTION (Applies to ALL Applications)
# ---------------------------------------------------------------------------
subscriptions: |
- recipients:
- slack:jenkins-ntfy # <--- Change to your Slack Channel name
triggers:
- on-sync-succeeded
- on-sync-failed
- on-health-degraded
- on-deployed
# ---------------------------------------------------------------------------
# 4. TRIGGERS (Logic for when to fire alerts)
# ---------------------------------------------------------------------------
trigger.on-sync-succeeded: |
- description: Application syncing has succeeded
send: [app-sync-succeeded]
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
trigger.on-sync-failed: |
- description: Application syncing has failed
send: [app-sync-failed]
when: app.status.operationState.phase in ['Error', 'Failed']
trigger.on-health-degraded: |
- description: Application has degraded
send: [app-health-degraded]
when: app.status.health.status == 'Degraded'
trigger.on-deployed: |
- description: Application is synced and healthy. Triggered once per commit.
oncePer: app.status.operationState.syncResult.revision
send: [app-deployed]
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
# ---------------------------------------------------------------------------
# 5. TEMPLATES (The "CloudWatch-Style" Message Design)
# ---------------------------------------------------------------------------
# β
SYNC SUCCEEDED
template.app-sync-succeeded: |
message: |
β
Application {{.app.metadata.name}} Synced.
slack:
attachments: |
[{
"color": "#18be52",
"title": "β
Sync Succeeded: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "Repo URL",
"value": "{{.app.spec.source.repoURL}}",
"short": true
},
{
"title": "Commit",
"value": "`{{.app.status.operationState.syncResult.revision}}`",
"short": true
},
{
"title": "Status",
"value": "Sync: {{.app.status.operationState.phase}}\nHealth: {{.app.status.health.status}}",
"short": true
},
{
"title": "π¦ Changed Objects",
"value": "```{{range .app.status.operationState.syncResult.resources}}β’ {{.kind}} {{.name}}: {{.message}}\n{{end}}```",
"short": false
}
],
"footer": "Argo CD"
}]
# β SYNC FAILED
template.app-sync-failed: |
message: |
β Application {{.app.metadata.name}} Failed to Sync.
slack:
attachments: |
[{
"color": "#ff0000",
"title": "β Sync Failed: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "Error Message",
"value": "```{{.app.status.operationState.message}}```",
"short": false
},
{
"title": "Commit",
"value": "`{{.app.status.operationState.syncResult.revision}}`",
"short": true
}
],
"footer": "Argo CD"
}]
# β οΈ HEALTH DEGRADED
template.app-health-degraded: |
message: |
β οΈ Application {{.app.metadata.name}} is Degraded.
slack:
attachments: |
[{
"color": "#ffca00",
"title": "β οΈ Health Degraded: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "Health Status",
"value": "{{.app.status.health.status}}",
"short": true
}
],
"footer": "Argo CD"
}]
# π DEPLOYED (Triggered on new commit syncs)
template.app-deployed: |
message: |
π New Version Deployed: {{.app.metadata.name}}
slack:
attachments: |
[{
"color": "#2eb886",
"title": "π Deployed: {{.app.metadata.name}}",
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"fields": [
{
"title": "Application",
"value": "<{{.context.argocdUrl}}/applications/{{.app.metadata.name}}|{{.app.metadata.name}}>",
"short": true
},
{
"title": "New Commit",
"value": "`{{.app.status.operationState.syncResult.revision}}`",
"short": true
},
{
"title": "π¦ Affected Objects",
"value": "```{{range .app.status.operationState.syncResult.resources}}β’ {{.kind}} {{.name}} -> {{.message}}\n{{end}}```",
"short": false
}
],
"footer": "Argo CD"
}]