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

a question about prometheus example.rules #2456

Closed
xuxiali13 opened this Issue Mar 1, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@xuxiali13
Copy link

xuxiali13 commented Mar 1, 2017

The problems of scene description:
the prometheus collect the bandwidth from nginx, and it will send alert message to alertmanager when bandwidth reached the threshold seted, also, alertmanager send alert to nginx meanwhile.
I make http requests to nginx, and the bandwidth prometheus collected is display:
job="prometheus",servername="www.at.com"} 611005
job="prometheus",servername="www.bt.com"} 400732

If I config "example.rules" as follows:

prometheus:ngx_bandwidth:sum = sum(ngx_bandwidth) by (job,servername)
ALERT APINGXBANDWIDTH
IF prometheus:ngx_bandwidth:sum{servername="www.at.com"} > 100
FOR 2s
LABELS { service = "bandwidth" }
ANNOTATIONS {
summary = "{{ $labels.job }} {{$labels.value}}",
description = "{{ $value }}",
}
the alertmanager will receive the alert message from prometheus.

But, ,If I config "example.rules" as follows:
prometheus:ngx_bandwidth:sum = sum(ngx_bandwidth) by (job,servername)
ALERT APINGXBANDWIDTH
IF prometheus:ngx_bandwidth:sum{servername="www.at.com"} + prometheus:ngx_bandwidth:sum{servername="www.bt.com"}> 100
FOR 2s
LABELS { service = "bandwidth" }
ANNOTATIONS {
summary = "{{ $labels.job }} {{$labels.value}}",
description = "{{ $value }}",
}
the alertmanager cann't receive the alert message from prometheus .
why? help me, thanks.

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Mar 1, 2017

prometheus:ngx_bandwidth:sum{servername="www.at.com"} + prometheus:ngx_bandwidth:sum{servername="www.bt.com"}

This expression is an addition of matching vector elements. Since there are no matching vector elements, the result is empty, and the alert doesn't fire.

What you want is an aggregation:

sum(prometheus:ngx_bandwidth:sum{servername=~"www\\.(at|bt)\\.com"}) without (servername)

In different news, it makes more sense to ask quastions like this on the prometheus-users mailinglist rather than filing a GitHub issue.

@beorn7 beorn7 closed this Mar 1, 2017

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

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