alertmanager filter by tag (timescale backend)

Viewed 155

I am using alertmanager configured to read from a timescale db shared with other Prometheus/alertmanager systems.

I would like to set/check alerts only for services including a specific tag, therefore wondering how could I configure prometheus to apply only for specific tags?

This is what currently I am using:

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets: ['localhost:9093']

remote_write:
  - url: https://promscale.host:9201/write

remote_read:
  - url: https://promscale.host:9201/read
    read_recent: true
...

I found there is an option alert_relabel_configs but is unclear for me the usage of it.

Any ideas?

1 Answers

FYI, alert_relabel_configs are used for alert relabeling to alerts before they are sent to the Alertmanager

To use alert_relabel_configs below is the example to add a new tag on matching the relabel config set:

   alert_relabel_configs:
    - source_labels: [ log_level ]
      regex: warn
      target_label: severity
      replacement: warn 

Note: The alerts are only changed when sent to alertmanager. They are not changed in the Prometheus UI.

To test the relabel config online you can use https://relabeler.promlabs.com/

If you are using Prometheus Operator configuring alert relabeling rules should be done in additionalAlertRelabelConfigs of PrometheusSpec, more details: https://github.com/prometheus-operator/prometheus-operator/issues/1805

Related