Most recent value or last seen value

后端 未结 4 1271
太阳男子
太阳男子 2021-01-04 03:19

Prometheus is built around returning a time series representation of metrics. In many cases, however, I only care about what the state of a metric is right now<

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 04:01

    Given this:

    namespace_metricname_count_sum{id="1",status="to-do"}
    namespace_metricname_count_sum{id="1",status="in-progress"}
    

    If you want to get the most recent value you need to use the value that has in common in this case is id=~".*" by grouping the logs you will be able to get the last value in a time range

    count ( max_over_time ( namespace_metricname_count_sum{id=~".*"}[12h])) by (status)
    

提交回复
热议问题