Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing and empty label queries act differently to Prometheus #2342

Closed
Skepfyr opened this issue Aug 4, 2020 · 2 comments · Fixed by #2403
Closed

Missing and empty label queries act differently to Prometheus #2342

Skepfyr opened this issue Aug 4, 2020 · 2 comments · Fixed by #2403

Comments

@Skepfyr
Copy link

Skepfyr commented Aug 4, 2020

What did you do?

Query alertmanager for alerts with the label foo=~"bar|" or foo=~".*"

What did you expect to see?

I expected the alerts with the label foo set to bar and the alerts with foo unset to be returned. This is the behaviour when querying the ALERTS metric through prometheus.

What did you see instead? Under which circumstances?

The alerts with the foo label unset weren't returned for any of the regex matchers (although they were returned for a query like foo="")

This behaviour makes providing dropdown filters for alert labels in Grafana impossible as far as I can tell, as it will always filter out the alerts which don't have that label set.

Environment

  • System information: Linux 4.4.225-1.el7.elrepo.x86_64 x86_64
  • Alertmanager version: 0.16.1
  • Prometheus version: 2.14.0
  • Alertmanager configuration file:
global:
      resolve_timeout: 5m

    receivers:
    - name: 'default-receiver'
    - name: 'SNMP-Alert-Sender'
      webhook_configs:
      - send_resolved: true
        url: 'http://localhost:25443/v1/target/www.xxx.yyy.zzz/162'
      - send_resolved: true
        url: 'http://localhost:25443/v1/target/www.xxx.yyy.zzz/162'
      - send_resolved: true
        url: 'http://localhost:25443/v1/target/www.xxx.yyy.zzz/162'

    route:
      receiver: 'default-receiver'
      group_wait: 30s
      group_interval: 1m
      group_by: ['...']
      repeat_interval: 1h
      routes:
      - receiver: 'SNMP-Alert-Sender'
        repeat_interval: 1h
        continue: true
        group_by: ['...']
@simonpasquier
Copy link
Member

Indeed we need to be consistent with Prometheus which treats a missing label and a label with an empty value the same way.

vears91 added a commit to vears91/alertmanager that referenced this issue Oct 26, 2020
Filtering the alert out when the label is missing precludes a
possible match for an empty value. This change allows the
match to be evaluated.

Closes prometheus#2342

Signed-off-by: Victor Araujo <vear91@gmail.com>
@vears91
Copy link
Contributor

vears91 commented Oct 26, 2020

Hi, I'd like to attempt to fix this

simonpasquier pushed a commit that referenced this issue Nov 6, 2020
* Make filter labels consistent with Prometheus

Filtering the alert out when the label is missing precludes a
possible match for an empty value. This change allows the
match to be evaluated.

Closes #2342

Signed-off-by: Victor Araujo <vear91@gmail.com>

* Add tests for matchFilterLabels in v2 api

Signed-off-by: Victor Araujo <vear91@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants