You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Prometheus按标签统计占比:查询失败率返回‘无数据点’问题

Troubleshooting "No datapoints found" for Prometheus Failure Rate Query

Hey there! Let's break down why your query function_counter_total{status="fail"} / function_counter_total{status="emit"} is returning "No datapoints found" and how to fix it. Here are the key things to check:

1. Verify the underlying time series exist

First, test each part of your query separately in Prometheus's UI:

  • Run function_counter_total{status="fail"} — do you see any data points?
  • Run function_counter_total{status="emit"} — same question here.

If either query returns no data, that's the root cause. Common issues here include:

  • A typo in the metric name (e.g., function_counter instead of function_counter_total)
  • Incorrect label values (maybe it's status="failed" or status="emitted" instead of what you used)
  • The metric isn't being exported by your service at all (double-check your service's metrics endpoint)

2. Check for overlapping time ranges with data

Prometheus only returns datapoints that exist within the time window you've selected for the query. If:

  • Your service hasn't had any fail or emit events in the selected time range
  • The metrics were only reported outside of the window you're viewing

Try expanding the time range (e.g., switch from "Last 5 minutes" to "Last 1 hour") or trigger a test event that would increment both counters.

3. Fix label mismatches between the two series

Prometheus requires that the time series on both sides of the / operator have identical label sets (except for any labels you've filtered out). If your function_counter_total has additional labels like function_name, instance, or namespace, the two series might not line up.

To fix this, use aggregation functions to group by shared labels (or remove unneeded labels):

  • Calculate an overall failure rate:
    sum(function_counter_total{status="fail"}) / sum(function_counter_total{status="emit"})
    
  • Calculate failure rate per function:
    sum by (function_name) (function_counter_total{status="fail"}) / sum by (function_name) (function_counter_total{status="emit"})
    

The sum() or sum by() will align the series by the specified dimensions, allowing the division to work as expected.

4. Confirm counters have been incremented

Prometheus counters don't store 0 values by default — a counter time series is only created when it's first incremented. If your service hasn't had any fail events yet, or hasn't emitted any emit events, those series won't exist, leading to "No datapoints found".

Trigger test events to increment both counters, then re-run your query.


内容的提问来源于stack exchange,提问作者user2637015

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:11:22