简体   繁体   English

普罗米修斯直方图的 Grafana 表达式

[英]Grafana expression for prometheus histogram

Can anyone help me with visualising a prometheus histogram as both a chart and apdex please?任何人都可以帮助我将普罗米修斯直方图可视化为图表和 apdex 吗?

Ignoring any secondary labelling (for now) I'd just like to be able to visualise them as a histogram on Grafana (stacked bar chart is fine) and it would be really useful to also show the apdex in grafana.忽略任何二级标签(现在)我只是希望能够将它们可视化为 Grafana 上的直方图(堆叠条形图很好),并且在 grafana 中显示 apdex 也非常有用。

Examples of the buckets from the prometheus web console prometheus Web 控制台中的存储桶示例

someoperation_duration_seconds_bucket{
    labelOne="some_consistent_label",
    exported_instance="foo",
    exported_job="my_job",
    instance="10.0.0.0:9091",
    job="kubernetes-service-endpoints",
    kubernetes_name="prometheus-push-gateway",
    kubernetes_namespace="monitoring",
    le="+Inf",
    labelTwo="some_label_that_changes1"
}

someoperation_duration_seconds_bucket{
    labelOne="some_consistent_label",
    exported_instance="foo",
    exported_job="my_job",
    instance="10.0.0.0:9091",
    job="kubernetes-service-endpoints",
    kubernetes_name="prometheus-push-gateway",
    kubernetes_namespace="monitoring",
    le="120",
    labelTwo="some_label_that_changes1"
} etc etc

I've viewed this post how can I visualize a histogram with promdash or grafana and got the chart showing as a stacked bar with the series being the 'le' (bucket) values however the value for the Y axis for each bucket has exactly the same value.我已经查看了这篇文章,如何使用 promdash 或 grafana 可视化直方图,并将图表显示为堆积条形图,其中系列为“le”(桶)值,但是每个桶的 Y 轴值恰好具有相同的值。

Because of the nature of the operation the metrics are collected via a PushGateway.由于操作的性质,指标是通过 PushGateway 收集的。 Not sure if that has an impact.不确定这是否有影响。

Many thanks all非常感谢大家

Equally sized buckets are best for the panel type histogram.相同大小的桶最适合面板类型的直方图。 Three carefully chosen buckets are perfect for apdex calculation.三个精心挑选的桶非常适合 apdex 计算。

Histogram直方图

Select Histogram as panel type and use the following query:选择直方图作为面板类型并使用以下查询:

someoperation_duration_seconds_bucket{
    labelOne="some_consistent_label",
    exported_instance="foo",
    exported_job="my_job",
    instance="10.0.0.0:9091",
    job="kubernetes-service-endpoints",
    kubernetes_name="prometheus-push-gateway",
    kubernetes_namespace="monitoring",
    labelTwo="some_label_that_changes1"
}

Note that I just copied your own query but ommitted the label le.请注意,我只是复制了您自己的查询,但省略了标签 le。

I suppose, that you are interested in the change of the values over time, so it might be useful to visualize the following query instead:我想,您对值随时间的变化感兴趣,因此可视化以下查询可能会很有用:

increase(someoperation_duration_seconds_bucket{ ... }[TIME])

TIME could be 10m, 1h or 1d, depending on your requirements. TIME 可以是 10m、1h 或 1d,具体取决于您的要求。

The X-axis will not use the same bucket sizes as you defined them in your application. X 轴不会使用与您在应用程序中定义的相同的存储桶大小。 You can set a bucket size as a panel option, but this might not be what you are searching for.您可以将存储桶大小设置为面板选项,但这可能不是您要搜索的内容。

Apdex顶点索引

You can only calculate an apdex, if you know, which performance is acceptable by your customer.如果您知道客户可以接受哪种性能,您只能计算一个 apdex。 Let us assume 80 to 120 Seconds are tolerated, everything faster is fine, everything slower is not acceptable.让我们假设 80 到 120 秒是可以容忍的,快的一切都很好,慢的一切都是不可接受的。 Let's now assume that you defined only three buckets b1=[0,80], b2=[0,120], b3=[0,+Inf].现在假设您只定义了三个桶 b1=[0,80], b2=[0,120], b3=[0,+Inf]。 The apdex will be calculated as follows: apdex将按如下方式计算:

((count(b1) + (count(b2)-count(b1)) * 0.5)) / count(b3)

You've allready given the formula to calculate the count of a bucket:您已经给出了计算存储桶计数的公式:

someoperation_duration_seconds_bucket{
    ...,
    le="BUCKET",
    ...
}

For my example, BUCKET will be 80 and 120. Bucket +Inf gives you the total count.在我的示例中,BUCKET 将为 80 和 120。 Bucket +Inf 为您提供总数。 It might again be useful to calcuate the increase over time:计算随时间的增加可能再次有用:

increase(someoperation_duration_seconds_bucket{
    ...,
    le="BUCKET",
    ...
}[TIME])

The only problem here is, that you need to know the bucket sizes defined by your application.这里唯一的问题是,您需要知道应用程序定义的存储桶大小。 And those sizes must match the tolerated performance boundaries of your customer.并且这些尺寸必须与您的客户所容忍的性能界限相匹配。 We could not calcuate the apdex in the example above, if 80 and 120 where no bucket boundaries.我们无法计算上面示例中的 apdex,如果 80 和 120 没有桶边界。 More than three buckets would be fine, but you'll need at least those three buckets that match the tolerated performance boundaries.三个以上的存储桶就可以了,但您至少需要与可容忍的性能边界相匹配的三个存储桶。

I found this answer quite interesting as it calculates an apdex threshold that corresponds to some SLA agreement but takes a different approach than I did.我发现这个答案非常有趣,因为它计算了一个与某些 SLA 协议相对应的 apdex 阈值,但采用了与我不同的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM