Skip to content

feat(grafana-oncall): enrich notification payload with monitor details, tags and type-specific fields#263

Open
brewle wants to merge 1 commit into0xfurai:mainfrom
brewle:feat/notification-oncall-enrich
Open

feat(grafana-oncall): enrich notification payload with monitor details, tags and type-specific fields#263
brewle wants to merge 1 commit into0xfurai:mainfrom
brewle:feat/notification-oncall-enrich

Conversation

@brewle
Copy link
Copy Markdown

@brewle brewle commented Feb 26, 2026

Problem

The existing Grafana OnCall provider sent minimal payload with only title, message and state, making it impossible to build meaningful alert grouping and routing in Grafana OnCall.

Changes

1. shared/monitor.model.go
Added Tags []string field to Monitor model to make monitor tags available across the codebase.

2. monitor/monitor.sql.repository.go
Extended FindByID to load tag names via a second query joining monitor_tags and tags tables.

3. notification_channel/providers/grafana_oncall.go
Enriched payload with:

  • Common fields for all monitor types: status, ping_ms, retries, time, monitor_id, monitor_type, tags
  • HTTP monitors (http, http-keyword, http-json-query): monitor_url, http_status_code
  • Host-based monitors (tcp, ping, dns, grpc-keyword): monitor_host
  • DB/infra monitors (mysql, postgres, redis, etc.): base payload only – DSN may contain credentials

Example payloads

Alert:

{
  "title": "example.com is down",
  "message": "HTTP request failed with status: 503",
  "state": "alerting",
  "status": "DOWN",
  "ping_ms": 685,
  "retries": 2,
  "time": "2026-02-27T00:21:00Z",
  "http_status_code": "503",
  "monitor_id": "3215c0fd-...",
  "monitor_type": "http",
  "monitor_url": "https://example.com",
  "tags": ["severity:critical", "country:ua"]
}

Resolve:

{
  "title": "example.com is up",
  "message": "200 - 200 OK",
  "state": "ok",
  "status": "UP",
  "ping_ms": 167,
  "retries": 0,
  "time": "2026-02-27T00:25:00Z",
  "http_status_code": "200",
  "monitor_id": "3215c0fd-...",
  "monitor_type": "http",
  "monitor_url": "https://example.com",
  "tags": ["severity:critical", "country:ua"]
}

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 26, 2026

Deploy Preview for peekaping ready!

Name Link
🔨 Latest commit b37f50c
🔍 Latest deploy log https://app.netlify.com/projects/peekaping/deploys/69a0bc1fb450cd0008d49b14
😎 Deploy Preview https://deploy-preview-263--peekaping.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 26, 2026

Deploy Preview for docspeekaping ready!

Name Link
🔨 Latest commit b37f50c
🔍 Latest deploy log https://app.netlify.com/projects/docspeekaping/deploys/69a0bc1f0a4da40008da2b63
😎 Deploy Preview https://deploy-preview-263--docspeekaping.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant