Slack Integration
Send alerts to Slack channels via incoming webhooks.
Prerequisites
- A Slack workspace with admin access
- An incoming webhook URL
Creating a Webhook
- Go to Slack Apps
- Create a new app or select existing
- Enable Incoming Webhooks
- Add webhook to your channel
- Copy the webhook URL
Configuration
Create the Secret
Store the webhook URL in a Kubernetes secret:
kubectl create secret generic slack-webhook \
--from-literal=url=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
Create the AlertChannel
slack-channel.yaml
apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
name: team-slack
spec:
type: slack
slack:
webhookSecretRef:
name: slack-webhook
namespace: default
key: url
Apply:
kubectl apply -f slack-channel.yaml
Customization
Channel Override
Send to a different channel than the webhook default:
spec:
type: slack
slack:
webhookSecretRef:
name: slack-webhook
namespace: default
key: url
defaultChannel: "#alerts-critical"
info
Custom username and icon override are not currently supported. The webhook's default settings will be used.
Message Template
Customize the message format:
spec:
type: slack
slack:
webhookSecretRef:
name: slack-webhook
namespace: default
key: url
messageTemplate: |
*{{ .Severity | upper }}*: {{ .Title }}
{{ .Message }}
*CronJob*: {{ .Namespace }}/{{ .CronJobName }}
*Time*: {{ .Timestamp }}
{{ if .SuggestedFix }}
*Suggested Fix*:
{{ .SuggestedFix }}
{{ end }}
Rate Limiting
Prevent alert floods by configuring rate limits at the AlertChannel level:
spec:
type: slack
slack:
webhookSecretRef:
name: slack-webhook
namespace: default
key: url
rateLimiting:
burstLimit: 10
maxAlertsPerHour: 100
Complete Example
slack-complete.yaml
apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
name: ops-slack
spec:
type: slack
slack:
webhookSecretRef:
name: slack-webhook
namespace: default
key: url
defaultChannel: "#cronjob-alerts"
rateLimiting:
burstLimit: 20
maxAlertsPerHour: 200
Testing
Test the channel from the dashboard:
- Go to Channels
- Find your Slack channel
- Click Test
Or via API:
curl -X POST http://localhost:8080/api/v1/channels/ops-slack/test
Alert Format
Slack alerts include:
- Color-coded attachment: Red (critical), yellow (warning), blue (info)
- Title: Alert type and CronJob name
- Fields: Namespace, status, timestamps
- Logs section: Recent pod logs (if enabled)
- Suggested fix: Actionable remediation steps
Troubleshooting
Webhook Not Working
- Verify secret exists:
kubectl get secret slack-webhook - Check secret content:
kubectl get secret slack-webhook -o jsonpath='{.data.url}' | base64 -d - Test webhook directly:
curl -X POST -H 'Content-type: application/json' --data '{"text":"test"}' YOUR_WEBHOOK_URL
Rate Limited
If you're hitting rate limits:
- Increase
suppressDuplicatesForon monitors - Use
alertDelayto batch alerts - Review if too many CronJobs are failing
Channel Not Found
- Ensure the webhook is configured for the correct channel
- The
channeloverride must match an existing Slack channel
Related
- Alert Configuration - Monitor alerting settings
- PagerDuty - Alternative alerting
- Webhook - Custom integrations