grafana / mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
https://grafana.com/oss/mimir/
GNU Affero General Public License v3.0
3.98k stars 503 forks source link

[mimir-distributed] Add additionalRuleLabels to PrometheusRule alerts #8153

Open WhiteDiamondz opened 3 months ago

WhiteDiamondz commented 3 months ago

Is your feature request related to a problem? Please describe.

Custom labels added to alerts are always useful and are often used for routing purposes. The mimir-distributed helm chart allows the user to deploy default PrometheusRules (alerts and recording rules). However, no option exists to add a custom label to all the alerts (and rules?) deployed.

Describe the solution you'd like

Much like it is the case for other helm charts like Loki, a posibility would be to create and configure a key like:

metaMonitoring:
  prometheusRule:
    additionalRuleLabels:
      custom_label: custom_value

Describe alternatives you've considered

Unfortunately with my knowledge I currently don't see other alternatives.

Additional context

Even if the structure is different, an example of this feature exists for the Loki helm chart: https://github.com/grafana/loki/pull/9020

narqo commented 3 months ago

Some pointers to start looking at the issue:

The source of truth for the alerting rules is currently defined in mimir's jsonnet mixin. The jsonnet files are compiled into static YAML, which is injected into k8s PrometheusRule object via Helm template (ref. source code).

Note that jsonnet mixin already allows adding additional labels to the alerting rules, via $._config.alert_extra_labels (ref. source code). This is, of course, doesn't help the Helm chart's users, unfortunately.