【问题标题】:prometheus percentage by labelprometheus 按标签的百分比
【发布时间】:2018-03-04 16:37:04
【问题描述】:

我正在尝试从低于指标中获取失败百分比

function_counter_total{name="getCar", status="fail"}
function_counter_total{name="getCar", status="emit"}

使用 prometheus 查询 function_counter_total{status="fail"} / function_counter_total{status="emit"} buy return 'No datapoints found'。

【问题讨论】:

    标签: prometheus micrometer


    【解决方案1】:

    这不是导出指标的推荐方法,因为 a)在 PromQL 中更难使用,b)标签应该是空间上的分区(假设 emit 是失败的超集,如果不是,那么你的计算'要求执行可能不是您想要的)。单独的 function_totalfunction_failed_total 计数器会更好。

    如果您必须使用这种形式的指标,您可以这样做

         function_counter_total{status="fail"} 
       / ignoring(status)
         function_counter_total{status="emit"}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-01
      • 1970-01-01
      • 2021-11-01
      • 2020-08-10
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 2020-11-28
      相关资源
      最近更新 更多