Add per-tenant alert generator URL template for customizable alert source links#7302
Open
CharlieTLe wants to merge 12 commits intocortexproject:masterfrom
Open
Add per-tenant alert generator URL template for customizable alert source links#7302CharlieTLe wants to merge 12 commits intocortexproject:masterfrom
CharlieTLe wants to merge 12 commits intocortexproject:masterfrom
Conversation
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 <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Charlie Le <[email protected]>
yeya24
reviewed
Mar 1, 2026
Contributor
yeya24
left a comment
There was a problem hiding this comment.
@rajagopalanand Can you help take a look?
friedrichg
reviewed
Mar 16, 2026
Member
friedrichg
left a comment
There was a problem hiding this comment.
I gave a review, but I think we do not care what parameters are send to the url. We don't care about grafana org IDs
I think we should make this general enough to be used by any metrics explorer.
Maybe consider renaming the function as explore and not have any grafana
I am thinking of something that would support for example:
explore
what do you think?
…nerator URLs Replace the 3 Grafana-specific per-tenant config fields (ruler_alert_generator_url_format, ruler_grafana_datasource_uid, ruler_grafana_org_id) with a single generic field: ruler_alert_generator_url_template. This field accepts a Go text/template string with .ExternalURL and .Expression variables, plus built-in functions like urlquery. Users can construct any URL format (Grafana, Perses, etc.) without Cortex needing to understand specific UI formats. The ruler_external_url per-tenant override and SendAlerts signature (func(expr string) string) are kept unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Add per-tenant Alertmanager datasources (tenant-a, tenant-b) to Grafana provisioning so alerts are visible in Grafana's alerting UI. Add runtime-config.yaml with per-tenant overrides: - tenant-a: Grafana Explore URL template with full pane JSON - tenant-b: Perses explore URL template with PrometheusTimeSeriesQuery Update Perses from v0.49 to v0.53.1 and enable the explorer feature (frontend.explorer.enable: true). Rename project from "default" to "cortex" to match template URLs. Add Step 7 to the getting-started guide with instructions for: - Configuring per-tenant alert generator URL templates - Loading alertmanager configs and demo alert rules - Viewing alerts in Grafana at /alerting/groups?groupBy=alertname - Verifying generator URLs via the API Also configure ruler.alertmanager_url and ruler.external_url, and set an explicit UID on the Grafana Cortex datasource for use in templates. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Charlie Le <[email protected]>
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 <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Charlie Le <[email protected]>
…nerator URLs Replace the 3 Grafana-specific per-tenant config fields (ruler_alert_generator_url_format, ruler_grafana_datasource_uid, ruler_grafana_org_id) with a single generic field: ruler_alert_generator_url_template. This field accepts a Go text/template string with .ExternalURL and .Expression variables, plus built-in functions like urlquery. Users can construct any URL format (Grafana, Perses, etc.) without Cortex needing to understand specific UI formats. The ruler_external_url per-tenant override and SendAlerts signature (func(expr string) string) are kept unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Add per-tenant Alertmanager datasources (tenant-a, tenant-b) to Grafana provisioning so alerts are visible in Grafana's alerting UI. Add runtime-config.yaml with per-tenant overrides: - tenant-a: Grafana Explore URL template with full pane JSON - tenant-b: Perses explore URL template with PrometheusTimeSeriesQuery Update Perses from v0.49 to v0.53.1 and enable the explorer feature (frontend.explorer.enable: true). Rename project from "default" to "cortex" to match template URLs. Add Step 7 to the getting-started guide with instructions for: - Configuring per-tenant alert generator URL templates - Loading alertmanager configs and demo alert rules - Viewing alerts in Grafana at /alerting/groups?groupBy=alertname - Verifying generator URLs via the API Also configure ruler.alertmanager_url and ruler.external_url, and set an explicit UID on the Grafana Cortex datasource for use in templates. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Resolve conflict in schemas/cortex-config-schema.json: keep both the upstream results_cache_ttl entry and our ruler_alert_generator_url_template. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Resolve conflict in schemas/cortex-config-schema.json: keep both results_cache_ttl and ruler_alert_generator_url_template entries. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Charlie Le <[email protected]>
Signed-off-by: Charlie Le <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ruler_alert_generator_url_templatefield that accepts a Gotext/templatestringruler_external_urloverride so tenants can have different external URLs without changing the global ruler configWhen
ruler_alert_generator_url_templateis set, the ruler evaluates the template with.ExternalURLand.Expressionvariables to produce the alert'sGeneratorURL. Built-in Go template functions likeurlqueryare available for URL encoding. If the template is empty, the default Prometheus/graphformat is used.New per-tenant config options
ruler_external_url""(uses global)ruler_alert_generator_url_template""(Prometheus format)Example runtime config
Getting-started docker-compose example
The PR includes a working docker-compose example in
docs/getting-started/with:Test plan
executeGeneratorURLTemplatewith various expressions,urlquery, and invalid templatesuserExternalURLtracking per-tenant URL changesSendAlertswith custom generator URL function (default + template formats)Limits.Validate()catches invalid templates at config load time🤖 Generated with Claude Code