有没有办法在忽略(没有)标签的情况下获取 Prometheus 中指标的最新值?
Is there a way to get latest value of a metric in Prometheus while ignoring(without) a label?
PROMQL 查询 我试过的是 - last_over_time(METRIC_ABC{ INDICATORNAME="INDICATORNAME_1"}[6h])
Returns 指标 -
METRIC_ABC{DATE="2022-04-27", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_1", instance="i_1", job="DB"} 10
METRIC_ABC{DATE="2022-04-27", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_2", instance="i_1", job="DB"} 15
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_1", instance="i_1", job="DB"} 11
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_2", instance="i_1", job="DB"} 16
我只想获取最新的而忽略 DATE 标签。即
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_1", instance="i_1", job="DB"} 11
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_2", instance="i_1", job="DB"} 16
是否有任何方法可以忽略具有 last_over_time 功能的标签或其他方法?
我确定这是一个常见的用例,那么是否已经存在我找不到的函数?
之前需要使用像sum这样的聚合函数:
last_over_time(sum without (DATE) (METRIC_ABC{ INDICATORNAME="INDICATORNAME_1"}[6h]))
PROMQL 查询 我试过的是 - last_over_time(METRIC_ABC{ INDICATORNAME="INDICATORNAME_1"}[6h])
Returns 指标 -
METRIC_ABC{DATE="2022-04-27", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_1", instance="i_1", job="DB"} 10
METRIC_ABC{DATE="2022-04-27", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_2", instance="i_1", job="DB"} 15
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_1", instance="i_1", job="DB"} 11
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_2", instance="i_1", job="DB"} 16
我只想获取最新的而忽略 DATE 标签。即
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_1", instance="i_1", job="DB"} 11
METRIC_ABC{DATE="2022-04-28", INDICATORNAME="INDICATORNAME_1", PRODUCT_NAME="PR_2", instance="i_1", job="DB"} 16
是否有任何方法可以忽略具有 last_over_time 功能的标签或其他方法? 我确定这是一个常见的用例,那么是否已经存在我找不到的函数?
之前需要使用像sum这样的聚合函数:
last_over_time(sum without (DATE) (METRIC_ABC{ INDICATORNAME="INDICATORNAME_1"}[6h]))