pulling labels "hidden" in "avg by"

276 views
Skip to first unread message

Yosef Yudilevich

unread,
Feb 28, 2017, 7:08:29 AM2/28/17
to Prometheus Users
hi, is it possible to pull labels from this query:

-------------------------
ALERT CpuUtilizationWarning
        IF
                floor(100 - ( avg by (instance,core) (irate(wmi_cpu_time_total{mode="idle"}[5m])) * 100)) > 90 # windows nodes
                OR
                floor(100 - ( avg by (cpu,instance) (irate(node_cpu{mode="idle", job="node"}[5m])) * 100)) > 90 # linux nodes
        LABELS { severity = "warning" }
        ANNOTATIONS {
                description = "{{ $labels.Type }} ({{ $labels.instance }}) in region {{ $labels.region }} reported over 90% CPU utilization in the past 5 minutes. Monitored by job: {{ $labels.job }}. Public IP: {{$labels.public_ip}}"
        }
---------------------------

it only shows cpu and instance...
i guess because they are in avg by (cpu,instance) because if i add say job label there then i get it in result
but i need to add data to message sent to recipient 

thank you

Matthias Rampke

unread,
Mar 1, 2017, 5:04:10 AM3/1/17
to Yosef Yudilevich, Prometheus Users
Do you want the labels in the result or not?

You can run queries within the message templating but in this case that seems like a huge overkill. If the job and public_ip labels are relevant, then preserve them in the alert, it's the right thing to do. You could even just let them be as labels and remove them from the message. If you don't like the presentation of the messages, you can adapt the templates in Alertmanager.

/MR

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/12cc8a75-c831-40b4-85c4-c035c7c2f4fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yosef Yudilevich

unread,
Mar 1, 2017, 5:10:17 AM3/1/17
to Matthias Rampke, Prometheus Users
i tried to preserve but still they get out empty

i did
LABELS { severity = "warning" , job="$labels.job }

the avg function only let what is in BY to go through somehow

thanks


On Wed, Mar 1, 2017 at 12:03 PM, Matthias Rampke <m...@soundcloud.com> wrote:
Do you want the labels in the result or not?

You can run queries within the message templating but in this case that seems like a huge overkill. If the job and public_ip labels are relevant, then preserve them in the alert, it's the right thing to do. You could even just let them be as labels and remove them from the message. If you don't like the presentation of the messages, you can adapt the templates in Alertmanager.

/MR

On Tue, Feb 28, 2017 at 12:08 PM Yosef Yudilevich <yosef.yu...@gmail.com> wrote:
hi, is it possible to pull labels from this query:

-------------------------
ALERT CpuUtilizationWarning
        IF
                floor(100 - ( avg by (instance,core) (irate(wmi_cpu_time_total{mode="idle"}[5m])) * 100)) > 90 # windows nodes
                OR
                floor(100 - ( avg by (cpu,instance) (irate(node_cpu{mode="idle", job="node"}[5m])) * 100)) > 90 # linux nodes
        LABELS { severity = "warning" }
        ANNOTATIONS {
                description = "{{ $labels.Type }} ({{ $labels.instance }}) in region {{ $labels.region }} reported over 90% CPU utilization in the past 5 minutes. Monitored by job: {{ $labels.job }}. Public IP: {{$labels.public_ip}}"
        }
---------------------------

it only shows cpu and instance...
i guess because they are in avg by (cpu,instance) because if i add say job label there then i get it in result
but i need to add data to message sent to recipient 

thank you

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.

Matthias Rampke

unread,
Mar 1, 2017, 11:18:59 AM3/1/17
to Yosef Yudilevich, Prometheus Users
Yes, that's how aggregations work. Why not `avg by (cpu,instance,job,public_ip)`?

To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages