Skip to content

Add per-tenant Grafana Explore URL format for alert GeneratorURL#7302

Open
CharlieTLe wants to merge 2 commits intocortexproject:masterfrom
CharlieTLe:809
Open

Add per-tenant Grafana Explore URL format for alert GeneratorURL#7302
CharlieTLe wants to merge 2 commits intocortexproject:masterfrom
CharlieTLe:809

Conversation

@CharlieTLe
Copy link
Member

Summary

  • Add support for tenants to configure alert GeneratorURL to use Grafana Explore format instead of the default Prometheus /graph format
  • Introduce three new per-tenant runtime config settings: ruler_alert_generator_url_format, ruler_grafana_datasource_uid, and ruler_grafana_org_id
  • Add per-tenant ruler_external_url override so tenants can have different external URLs without changing the global ruler config

When ruler_alert_generator_url_format is set to grafana-explore, the GeneratorURL in fired alerts becomes a Grafana Explore link (e.g. http://grafana:3000/explore?schemaVersion=1&panes=...&orgId=1) with the alert expression and datasource UID pre-filled. Clicking "See source" on an alert in Grafana opens Explore with the correct query, datasource, and time range.

New per-tenant config options

Setting Description Default
ruler_external_url Per-tenant external URL override for the ruler "" (uses global)
ruler_alert_generator_url_format URL format: prometheus or grafana-explore "" (prometheus)
ruler_grafana_datasource_uid Grafana datasource UID for Explore links ""
ruler_grafana_org_id Grafana org ID for Explore links 1

Example runtime config

overrides:
  my-tenant:
    ruler_external_url: "http://grafana.example.com:3000"
    ruler_alert_generator_url_format: "grafana-explore"
    ruler_grafana_datasource_uid: "my-cortex-ds"
    ruler_grafana_org_id: 1

Test plan

  • Unit tests for grafanaExploreLink URL generation with various expressions and special characters
  • Unit tests for userExternalURL tracking per-tenant URL changes
  • Unit tests for SendAlerts with custom generator URL function
  • Unit tests for ruler manager factory wiring the per-tenant overrides
  • Validated exporter test updated for new limit fields
  • Manual e2e test: Docker Compose stack with Cortex + Grafana, always-firing alert rule, runtime config with grafana-explore format — confirmed the "See source" link opens Grafana Explore with correct datasource and query

🤖 Generated with Claude Code

Add support for tenants to configure alert GeneratorURL to use Grafana
Explore format instead of the default Prometheus /graph format. This is
controlled by three new per-tenant settings: ruler_alert_generator_url_format,
ruler_grafana_datasource_uid, and ruler_grafana_org_id.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
@dosubot dosubot bot added the component/rules Bits & bobs todo with rules and alerts: the ruler, config service etc. label Feb 27, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/rules Bits & bobs todo with rules and alerts: the ruler, config service etc. size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant