Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Add support for alert relabeling (#151)
Browse files Browse the repository at this point in the history
[minor] All other forms of relabeling (targets, metrics, remote write) are
already supported, but alert relabeling wasn't possible yet because it's
not part of the Prometheus Alertmanager configuration.

The most common use case for alert relabeling is dropping the "replica"
label of an HA Prometheus pair, so I chose that as an example.
  • Loading branch information
juliusv authored and paulfantom committed Oct 7, 2018
1 parent 74f9085 commit 3b866fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ prometheus_alertmanager_config: []
# - targets: ["127.0.0.1:9093"]
# proxy_url: "127.0.0.2"

prometheus_alert_relabel_configs: []
# prometheus_alert_relabel_configs:
# - action: labeldrop
# regex: replica

prometheus_global:
scrape_interval: 15s
scrape_timeout: 10s
Expand Down
3 changes: 3 additions & 0 deletions molecule/alternative/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
static_configs:
- targets: ["127.0.0.1:9090"]
proxy_url: "127.0.0.2"
prometheus_alert_relabel_configs:
- action: labeldrop
regex: replica
prometheus_global:
scrape_interval: 3s
scrape_timeout: 2s
Expand Down
4 changes: 4 additions & 0 deletions templates/prometheus.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ rule_files:
alerting:
alertmanagers:
{{ prometheus_alertmanager_config | to_nice_yaml(indent=2) | indent(2,False) }}
{% if prometheus_alert_relabel_configs | length > 0 %}
alert_relabel_configs:
{{ prometheus_alert_relabel_configs | to_nice_yaml(indent=2) | indent(2,False) }}
{% endif %}
{% endif %}

scrape_configs:
Expand Down

0 comments on commit 3b866fd

Please sign in to comment.