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

Promtool: label not found when not included in group by clause #4946

Closed
mwalters-workmarket opened this Issue Dec 3, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@mwalters-workmarket
Copy link

mwalters-workmarket commented Dec 3, 2018

Minimal example:

rules.yaml:

groups:
  - name: MyAlert
    rules:
    - alert: MyAlert
      expr: min(abc) by (service_name) == 0
      for: 1m
      annotations:
        summary: "service {{ $labels.service_name }} on instance {{ $labels.instance }} is unhealthy"

test.yaml:

rule_files:
  - rules.yaml
evaluation_interval: 1m
tests:
  - interval: 1m
    input_series:
      - series: 'abc{service_name="service_one", instance="localhost:9090"}'
        values: '0+0x1'
    alert_rule_test:
      - alertname: MyAlert
        eval_time: 1m
        exp_alerts:
          - exp_labels:
              service_name: "service_one"
            exp_annotations:
              summary: "service service_one on instance localhost:9090 is unhealthy"

when I execute promtool test rules test.yaml
I expect to see output:

Unit Testing: test.yaml
  SUCCESS

But the actual output is:

Unit Testing:  test.yaml
  FAILED:
    alertname:MyAlert, time:1m0s, 
        exp:"[Labels:{alertname=\"MyAlert\", service_name=\"service_one\"} Annotations:{summary=\"service service_one on instance localhost:9090 is unhealthy\"}]", 
        got:"[Labels:{alertname=\"MyAlert\", service_name=\"service_one\"} Annotations:{summary=\"service service_one on instance  is unhealthy\"}]"

in the annotation.summary, promtool didn't resolve {{ $labels.instance }} properly

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Dec 3, 2018

You aggregated away the instance label, this is working as expected.

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

@mwalters-workmarket

This comment has been minimized.

Copy link
Author

mwalters-workmarket commented Dec 3, 2018

Thanks, will do next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.