Group data by year/month/day in prometheus

Viewed 7322

As the title says, I am looking for a way to get the maximum value of a time series, which resets daily. After this task is achieved I would like to create a sum over those values to get a value per month/year. What is the best way to achieve this in Prometheus?

1 Answers

As described in my post on prometheus-developers, here is a possible option, although it's far from readable:

up{job="prometheus"} + ignoring(year, month, day) group_right
  count_values without() ("year", year(timestamp(
    count_values without() ("month", month(timestamp(
      count_values without() ("day", day_of_month(timestamp(
        up{job="prometheus"}
      )))
    )))
  ))) * 0

Replace both instances of up{job="prometheus"} with whatever series selector you need. No idea how efficient this is, though. :o)

Related