在普罗米修斯中按年/月/日对数据进行分组 [英] Group data by year/month/day in prometheus
问题描述
正如标题所说,我正在寻找一种方法来获得每天重置的时间序列的最大值.完成此任务后,我想对这些值进行总和,以获得每月/每年的值.在 Prometheus 中实现这一目标的最佳方法是什么?
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?
推荐答案
如我在 prometheus-developers,这是一个可能的选项,尽管它远非可读:
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
用您需要的任何系列选择器替换 up{job="prometheus"}
的两个实例.不过,不知道这有多有效.:o)
Replace both instances of up{job="prometheus"}
with whatever series selector you need. No idea how efficient this is, though. :o)
这篇关于在普罗米修斯中按年/月/日对数据进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!