turning a group_left use of info-block into a range vector

431 views
Skip to first unread message

presto...@gmail.com

unread,
Sep 10, 2018, 7:13:18 PM9/10/18
to Prometheus Users
I'm still picking up PromQL, and mostly have been able to puzzle my way through most target queries, but am stumped on this one currently:

This works, and shows me the top 10 devices rebooting the most in an hour:

topk(10, changes(device_boot_time[1h]))

This shows me the gauge value for all devices matching the "device_info" info-block (aka machine role):
device_boot_time * on (instance) group_left(region, firmware) device_info{region="California", firmware="v1.0"}

Even through seems to return an instant value - I have not been able to figure out if it is possible to turn into a range vector

Any attempt to put '[5m]' anywhere in this vector matching query results in an error. For example if at the end, the error is:
`Error executing query: parse error at char 116: binary expression must contain only scalar and instant vector types`

I could put the labels on each metric directly but then lose the series-reducing value of the info-block pattern

I could probably create a reporting rule, but that means making sure I have a reporting rule for each vector match combo

Any solution to this?

Thanks,

-Preston



Matthias Rampke

unread,
Sep 11, 2018, 3:14:32 AM9/11/18
to presto...@gmail.com, Prometheus Users
At the moment, recording rules are the only way, sorry! We recognize the need for subqueries but at the moment they are not implemented.

/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/99c62289-b399-4f5d-8f95-0fcfe2cc75bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Brazil

unread,
Sep 11, 2018, 4:15:47 AM9/11/18
to presto...@gmail.com, Prometheus Users
On 11 September 2018 at 00:13, <presto...@gmail.com> wrote:
I'm still picking up PromQL, and mostly have been able to puzzle my way through most target queries, but am stumped on this one currently:

This works, and shows me the top 10 devices rebooting the most in an hour:

topk(10, changes(device_boot_time[1h]))

This shows me the gauge value for all devices matching the "device_info" info-block (aka machine role):
device_boot_time * on (instance) group_left(region, firmware) device_info{region="California", firmware="v1.0"}

Even through seems to return an instant value - I have not been able to figure out if it is possible to turn into a range vector


What you want to do is the range vector operation, and then the group_left:

topk(10, changes(device_boot_time[1h]) * on (instance) group_left(region, firmware) device_info{region="California", firmware="v1.0"})

Brian
 

Any attempt to put '[5m]' anywhere in this vector matching query results in an error. For example if at the end, the error is:
`Error executing query: parse error at char 116: binary expression must contain only scalar and instant vector types`

I could put the labels on each metric directly but then lose the series-reducing value of the info-block pattern

I could probably create a reporting rule, but that means making sure I have a reporting rule for each vector match combo

Any solution to this?

Thanks,

-Preston



--
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.



--

presto...@gmail.com

unread,
Sep 11, 2018, 6:13:55 PM9/11/18
to Prometheus Users
Perfect Brian - thanks!!

-P


On Tuesday, September 11, 2018 at 1:15:47 AM UTC-7, Brian Brazil wrote:
On 11 September 2018 at 00:13, <presto...@gmail.com> wrote:
I'm still picking up PromQL, and mostly have been able to puzzle my way through most target queries, but am stumped on this one currently:

This works, and shows me the top 10 devices rebooting the most in an hour:

topk(10, changes(device_boot_time[1h]))

This shows me the gauge value for all devices matching the "device_info" info-block (aka machine role):
device_boot_time * on (instance) group_left(region, firmware) device_info{region="California", firmware="v1.0"}

Even through seems to return an instant value - I have not been able to figure out if it is possible to turn into a range vector


What you want to do is the range vector operation, and then the group_left:

topk(10, changes(device_boot_time[1h]) * on (instance) group_left(region, firmware) device_info{region="California", firmware="v1.0"})

Brian
 

Any attempt to put '[5m]' anywhere in this vector matching query results in an error. For example if at the end, the error is:
`Error executing query: parse error at char 116: binary expression must contain only scalar and instant vector types`

I could put the labels on each metric directly but then lose the series-reducing value of the info-block pattern

I could probably create a reporting rule, but that means making sure I have a reporting rule for each vector match combo

Any solution to this?

Thanks,

-Preston



--
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.



--
Reply all
Reply to author
Forward
0 new messages