监控请求延迟和丢失的数据点

Monitor request lastency and missing datapoints

我正在尝试使用Summary类型监控请求延迟并使用 Grafana 显示百分位数。

我正在使用 prometheus_client version 0.5.0。这就是我配置指标的方式

sample_processing_summary = Summary("sample_processing_3_summary_seconds", "Sample processing latency", ["sample_type"])

这就是我的使用方式:

def message_processor(message, rat):
    with metrics.sample_processing_summary.labels(rat).time():
        do_process_message(message, rat)

现在我正在尝试显示第 99 个百分位数。在 tutorial 我读过的是 PromQl 查询

sample_app_summary_request_duration_seconds{quantile="0.99"}

但这不起作用,因为我只有 sample_processing_3_summary_seconds_countsample_processing_3_summary_seconds_sumsample_processing_3_summary_seconds_created 数据点。

如何使用 Prometheus 和 Python 在 Grafana 中显示第 99 个百分位数?

Python 客户端目前不支持 Summary 的分位数。

您要做的是使用 Histogram,然后使用 histogram_quantile(0.99, rate(histogram_name_bucket[5m]))