feat(alerts): configurable GeneratorURL templates (#736) - #798
Merged
Conversation
Promxy hardcodes the alert GeneratorURL to a link to its own graph page for the alert expression, matching upstream Prometheus. When promxy is the central evaluation point for many backends and operators triage alerts elsewhere (Grafana alerting, an incident manager, a per-tenant dashboard), that URL is not useful -- and points at the wrong backend for series that originated in e.g. VictoriaMetrics. Add an opt-in pkg/alerttemplate that renders the GeneratorURL from Go templates configured under promxy.alert_templates: a default template, reusable named templates, and label-matched rules (first match wins). Templates are compiled once on config (re)load behind a RWMutex and selected per-alert in sendAlerts; with no configuration promxy falls back to the exact built-in URL, so default behavior is unchanged. Reimplementation of the approach in #737, rebased onto the post-Prometheus-3.5 master and scoped down (no template directory / .tmpl loader, no CLI flags -- inline named templates cover the use cases in #736). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jacksontj
force-pushed
the
feat/alert-generator-url-templates
branch
from
July 3, 2026 05:04
11636bf to
4c1dce4
Compare
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.
Fixes #736. Reimplements the approach from #737 on top of the current (post-Prometheus-3.5)
master.Problem
Promxy hardcodes the alert
GeneratorURLto a link to its own graph page for the alert expression (matching upstream Prometheus). When promxy is the central evaluation point for many backends and operators triage alerts elsewhere — Grafana alerting, an incident manager, a per-tenant dashboard — that URL isn't useful, and it points at the wrong backend for series that originated in e.g. VictoriaMetrics.Change
New opt-in
pkg/alerttemplaterenders theGeneratorURLfrom Go templates configured underpromxy.alert_templates:default— template used when no rule matches (inline body or anamedreference)named— reusable inline templates addressable fromdefault/rulesrules— label-matched selectors, evaluated top-to-bottom, first match winsTemplate data:
.ExternalURL,.Expr,.AlertName,.Labels,.Annotations; plusurlquery/urlpathfuncs.Templates are compiled once on config (re)load behind a
RWMutexand selected per-alert insendAlerts. With no configuration, promxy falls back to the exact built-in URL, so default behavior is unchanged. An invalid template fails the config reload loudly and keeps the previous good config.Scope vs. #737 / #736
Kept it minimal and close to upstream:
.tmplloader and the CLI flags — inlinenamedtemplates cover the use cases in Configurable Alert GeneratorURL Templates #736 without filesystem/flag surface. Easy to add later if wanted.Tests
pkg/alerttemplate— rule ordering, multi-label AND, named-vs-inline, data fields, render-error fallback, invalid-config rejection, bad-reload-keeps-previous-config.pkg/config—alert_templatesYAML round-trips into a manager-accepted config.cmd/promxy/config.yaml.Credit to @ramessesii2 for the original implementation and design in #737.
🤖 Generated with Claude Code