[prometheus-users] Re: number of occurrences in a day

2023-03-23 Thread Brian Candler
(foo==1)[24h:1m] creates a range vector, which you then need to process further. If you run a function over it to count the values in the range you will get an instant vector, which as I showed in my original post makes this: *count_over_time((foo==1)[24h:1m])* That is valid (I've tested it with

[prometheus-users] Re: number of occurrences in a day

2023-03-22 Thread BHARATH KUMAR
(foo==1)[24h:1m]. I tried this query. But I am getting an error message " *bad_data: invalid expression type "range vector" for range query, must be Scalar or instant Vector* ". foo[24h] == 1. Error message: "* bad_data: 1:1: parse error: binary expression must contain only scalar and instant

[prometheus-users] Re: number of occurrences in a day

2023-03-22 Thread Brian Candler
I also note that you're only sampling periodically whether something is in state 0, 1 or 2: you don't really know what happened in between those samples, so you're never going to get a truly accurate value for how long it was in each state. For example, it could flip from 1 to 2 and back to 1

[prometheus-users] Re: number of occurrences in a day

2023-03-22 Thread Brian Candler
It's not easy to do exactly. To get a rough answer, you can do a subquery : (foo == 1)[24h:1m] will resample the timeseries at 1 minute intervals, then you can wrap that with count_over_time, giving: