【问题标题】:Add Exemplars to Metrics向指标添加示例
【发布时间】:2021-11-20 21:27:56
【问题描述】:

我无法弄清楚如何将示例附加到我的指标中。 我的代码在 python 中,我正在使用 prometheus-client 库。我的代码已针对指标进行了检测,但我仍然无法将数据作为示例集成到其中。

我的最终目标是将我的跟踪数据可视化为 grafana 仪表板中我的指标面板上的示例。

在我的应用程序中,我创建了一个简单的计数器来跟踪 http 请求的数量。我在那个柜台上加了几个标签。 我可以看到 prometheus 从应用程序中提取的指标,我也可以在 grafana 上将它们可视化,但我找不到将跟踪数据附加为示例并对其进行可视化的方法(是的,我使用的是 grafana 8,它支持示例)

这是我使用计数器进行检测的代码

tasks_counter = Counter(
    name='outgoing_x_http_requests',
    documentation='counter for http requests from server x',
    labelnames=['status_code', 'method', 'path']
)

def send_X():
    // send request to server ...
    // response_object = returned values from server

    // my counter .. also adding labels to it
    tasks_counter.labels(
        status_code="some integer",
        method="some method",
        path="some path",
    ).inc(1)

我尝试将跟踪 ID 和跨度 ID 作为标签添加到计数器,但它不起作用。这不是您创建示例的方式,因为它们没有出现在我的指标图表上……我做错了什么?

【问题讨论】:

    标签: prometheus grafana metrics


    【解决方案1】:

    这里有一个例子(使用计数器):

    https://github.com/prometheus/client_python/pull/669/commits/fb35c5fdc0312cad8c9313a625e4f00a91d77fbd

    但是 PR 还没有合并。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 1970-01-01
      • 1970-01-01
      • 2022-06-23
      相关资源
      最近更新 更多