# Possible to sum counter increase within range of hours, every day?

**URL:** <https://discuss.prometheus.io/t/possible-to-sum-counter-increase-within-range-of-hours-every-day/1595>\
**Category:** PromQL\
**Created:** [April 13, 2023, 6:31pm UTC](https://discuss.prometheus.io/t/possible-to-sum-counter-increase-within-range-of-hours-every-day/1595 "2023-04-13T18:31:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrometheLost](https://avatars.discourse-cdn.com/v4/letter/p/cc9497/32.png) [@PrometheLost](https://discuss.prometheus.io/u/PrometheLost)\
**Post date:** [April 13, 2023, 6:31pm UTC](https://discuss.prometheus.io/t/possible-to-sum-counter-increase-within-range-of-hours-every-day/1595/1 "2023-04-13T18:31:07Z")

</div>

Been around the internets, tried a thousand things, suspect it isn’t possible (or I’m out of my depth here), so last ditch is to seek out guidance on the forum…

Basically we have a counter that tracks successful job runs. What I am trying to do is `sum(increase(...` within a 4h window every day over say, a 30d period.

For example, if a job ran between 9am and 12pm today, the counter would increase by 1. If it ran again today between 12pm and 4pm, the counter would increase by 1 again (2 job runs total for today).

The metrics I want are **only** the 12pm-4pm, ignoring the 9am-12pm resulting in a today’s total of 1. Ultimately I’m piping this into Grafana to show the higher-ups a nice graph per day that shows the number of jobs that are re-run in the afternoon. I can do this on the whole day no problem (i.e. 2 jobs ran today), and I have been experimenting with `and on() hour() > 12 and on() hour <= 16` but haven’t been able to get what I need.

First question should probably be: is this even possible?

Many thanks in advance!
