3

I use sub-queries to get hourly aggregated values for the last week for example: The number of http requests per hour over the whole last week, which will return 168 values in a range vector.

delta(http_server_requests_seconds_count[1h])[1w:1h]

Now I want to filter the value to return only the ones which are for a specific week day, lets say return only the 24 value from Monday. I found some hints about day_of_week, timestamp, bool expr, but I cannot combine them to get it working or maybe it is not possible? Something like:

delta(http_server_requests_seconds_count[1h])[1w:1h] bool day_of_week() == 1
radio
  • 897
  • 2
  • 10
  • 25

1 Answers1

8

It'd be more effficient to adjust your start/end time to only over the day, but you could do:

(increase(http_server_requests_seconds_count[1h]) and on () day_of_week() == 1)[1w:1h]
brian-brazil
  • 31,678
  • 6
  • 93
  • 86
  • Adjust start/end, how do you mean that? Maybe my whole use case will show this is not feasible: I need these filtered number of requests for let's say the last 5 Mondays to pass them to the stddev function and then use the value for Monday to spot anomalies for every recent number of requests for Monday. The same for every weekday. Btw. Is increase faster than delta when anyway the number can only increase? – radio Apr 14 '19 at 13:14
  • Currently I have that for the whole week together without the filtering: Mean number of requests for last week: `delta(http_server_requests_seconds_count[1w]) / (7*24)` Stddev for last week: `stddev_over_time(delta(http_server_requests_seconds_count[1h])[1w:1h])` Recent number of requests: `delta(http_server_requests_seconds_count[1h])` And out of the above if mean - stddev > recent number, then obviously there were too few requests recently – radio Apr 14 '19 at 13:34