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

"<no value>" after templating #4012

Closed
Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk opened this issue Mar 25, 2023 · 4 comments
Closed

"<no value>" after templating #4012

Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk opened this issue Mar 25, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request vmalert

Comments

@Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk

Is your feature request related to a problem? Please describe

When I use label name that does not exist in the expression result I get <no value> label value in alert.

Test alerting rule

groups:
  - name: test
    rules:
      - alert: qqq
        expr: 1
        labels:
          alert: problem_only
          host: '{{ $labels.host }}'
#          host_display: '{{ if ne $labels.host "" }}{{ $labels.host }}{{ else }}label host is empty{{ end }}'
          host_display: '{{ if and (ne $labels.host "") (ne $labels.host nil) }}{{ $labels.host }}{{ else }}label host is empty{{ end }}'
        annotations:
          problem: 'just a test'

image

Prometheus was converting nil to an empty string, so I could use if ne $labels.host "", but now I need to add an extra nil check to all affected alerting rules. It is not so convenient. And what's more, it's not so obvious to check label value against nil (first I tried to check if ne $labels.host "<no value>").

Describe the solution you'd like

Propose to convert non-existent label values to an empty string.
What do you think ?

Describe alternatives you've considered

No response

Additional information

Version: victoria-metrics-20221126-045002-tags-v1.84.0-0-gad105147d
Type: single node

@Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk added the enhancement New feature or request label Mar 25, 2023
@zekker6
Copy link
Contributor

zekker6 commented Mar 30, 2023

@hagen1778 What do you think about this?
Maybe adding something like empty filter might make it easier to check values for similar cases?

hagen1778 added a commit that referenced this issue Mar 30, 2023
Replace empty labels with "" instead of "<no value>"
during templating, as Prometheus does.

See #4012

Signed-off-by: hagen1778 <roman@victoriametrics.com>
zekker6 pushed a commit that referenced this issue Mar 30, 2023
Replace empty labels with "" instead of "<no value>"
during templating, as Prometheus does.

See #4012

Signed-off-by: hagen1778 <roman@victoriametrics.com>
@zekker6
Copy link
Contributor

zekker6 commented Mar 30, 2023

@Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk Starting from 4a49577 vmalert should convert nil to an empty string similar to Prometheus.
This commit will be a part of the next release.

In the meantime, could you please try the following image and check if it helps?

docker.io/victoriametrics/vmalert:heads-oss-master-0-g4a4957702

If you don't use docker for deployment you can build a binary by using this doc and check if that works for you.

@zekker6 zekker6 self-assigned this Mar 30, 2023
@Z9n2JktHlZDmlhSvqc9X2MmL3BwQG7tk
Copy link
Author

Thanks ! I will wait for the next release.

valyala pushed a commit that referenced this issue Apr 1, 2023
Replace empty labels with "" instead of "<no value>"
during templating, as Prometheus does.

See #4012

Signed-off-by: hagen1778 <roman@victoriametrics.com>
@valyala
Copy link
Collaborator

valyala commented Apr 7, 2023

FYI, the issues should be fixed in vmalert v1.90.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vmalert
Projects
None yet
Development

No branches or pull requests

3 participants