Integrations3 min read
Grafana
Receive Grafana alerts in OpsKnight
Grafana Integration
Receive alerts from Grafana (Legacy Alerting or Unified Alerting) and create incidents automatically.
Endpoint
POST /api/integrations/grafana?integrationId=YOUR_INTEGRATION_ID
Setup
Step 1: Create Integration in OpsKnight
- Go to Services and select your service
- Click Integrations tab
- Click Add Integration
- Select Grafana
- Copy the Integration ID
- (Optional) Generate a Signing Secret for security
Step 2: Configure Grafana Contact Point
Grafana 8+ (Unified Alerting)
- Go to Alerting → Contact points
- Click + Add contact point
- Configure:
| Field | Value |
|---|---|
| Name | OpsKnight |
| Integration | Webhook |
| URL | https://YOUR_OPSKNIGHT_URL/api/integrations/grafana?integrationId=YOUR_INTEGRATION_ID |
- Click Save contact point
- Click Test to verify
Grafana Legacy Alerting
- Go to Alerting → Notification channels
- Click Add channel
- Configure:
| Field | Value |
|---|---|
| Name | OpsKnight |
| Type | webhook |
| URL | https://YOUR_OPSKNIGHT_URL/api/integrations/grafana?integrationId=YOUR_INTEGRATION_ID |
- Click Save
Step 3: Add to Notification Policy
- Go to Alerting → Notification policies
- Edit or create a policy
- Add OpsKnight as a contact point
- Save
Security
Strict Security Enforcement: If you generate a Signing Secret in OpsKnight, you MUST configure signature sending from your source. OpsKnight will reject any requests without a valid signature if a secret exists.
Supported Formats
Unified Alerting Format
{
"title": "CPU Usage High",
"message": "CPU usage exceeded 90%",
"state": "alerting",
"ruleId": 12345,
"ruleName": "High CPU Alert",
"ruleUrl": "https://grafana.example.com/alerting/12345/view",
"evalMatches": [
{
"metric": "cpu_usage",
"value": 95.5,
"tags": {
"host": "web-01"
}
}
],
"tags": {
"severity": "critical"
},
"dashboardId": 1,
"panelId": 2,
"orgId": 1
}
Alertmanager Format
Grafana can also send Prometheus Alertmanager-compatible payloads:
{
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "HighCPU",
"severity": "critical"
},
"annotations": {
"summary": "CPU usage is high",
"description": "CPU above 90%"
},
"startsAt": "2024-01-15T10:00:00Z"
}
],
"groupLabels": {
"alertname": "HighCPU"
},
"commonLabels": {
"severity": "critical"
},
"commonAnnotations": {
"summary": "CPU usage is high"
}
}
Event Mapping
| Grafana State | OpsKnight Action |
|---|---|
alerting |
Trigger incident |
no_data |
Trigger incident |
ok |
Resolve incident |
pending, paused |
No action |
For Alertmanager format:
status: firingtriggers incidentstatus: resolvedorendsAtpresent resolves incident
Severity Mapping
| Grafana State | OpsKnight Severity |
|---|---|
alerting |
critical |
no_data |
warning |
| Alertmanager format | critical (default) |
Incident Title
The incident title is extracted in this order:
titleruleNamemessage- For Alertmanager format:
annotations.summary→annotations.description→labels.alertname - Fallback: "Grafana Alert"
Deduplication
Dedup keys are generated as:
- Unified Alerting:
grafana-{ruleId} - Alertmanager format:
grafana-{labels.alertname} - Fallback:
grafana-{timestamp}
Testing
Using Grafana UI
- Go to Alerting → Contact points
- Click on OpsKnight contact point
- Click Test
- Verify incident appears in OpsKnight
Using cURL
Send a test payload directly:
curl -X POST "https://YOUR_OPSKNIGHT_URL/api/integrations/grafana?integrationId=YOUR_ID" \
-H "Content-Type: application/json" \
-d '{
"title": "Test Alert from Grafana",
"message": "This is a test alert",
"state": "alerting",
"ruleId": 999999,
"ruleName": "Test Alert Rule"
}'
Troubleshooting
Alerts Not Appearing
- Check contact point URL is correct
- Verify integration ID is valid
- Test contact point in Grafana settings
- Check notification policy includes OpsKnight
401 Unauthorized Error
- Check signing secret if configured
- Remove secret from OpsKnight if not using signature verification
Incidents Not Resolving
- Ensure alert rules send OK state
- Verify
state: okis being sent
Wrong Severity
Grafana alerts default to critical severity. To customize:
- Use Alertmanager format with severity labels
- Or accept default severity mapping
Related Topics
- Prometheus Integration — Prometheus Alertmanager
- Events API — Programmatic event submission
- Integrations Overview — All integrations
Last updated for v1
Edit this page on GitHub