【问题标题】:'remote write receiver' HTTP API request in PrometheusPrometheus 中的 \'remote write receiver\' HTTP API 请求
【发布时间】:2022-12-22 15:07:38
【问题描述】:

我试图找到一个如何使用的工作示例远程写入普罗米修斯中的接收器。

链接:https://prometheus.io/docs/prometheus/latest/querying/api/#remote-write-receiver

我能够向端点发送请求(POST /api/v1/写入) 并且可以通过服务器进行身份验证。但是,我不知道我需要以什么格式发送数据。

官方文档说数据需要采用 Protobuf 格式并进行 snappy 编码。我知道他们的图书馆。我有一些指标需要发送给 prometheus http:localhost:1234/api/v1/write。 我尝试导出的指标是从指标端点 (http://127.0.0.1:9187/metrics) 抓取的,看起来像这样:

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 1.11e-05
go_gc_duration_seconds{quantile="0.25"} 2.4039e-05
go_gc_duration_seconds{quantile="0.5"} 3.4507e-05
go_gc_duration_seconds{quantile="0.75"} 5.7043e-05
go_gc_duration_seconds{quantile="1"} 0.002476999
go_gc_duration_seconds_sum 0.104596342
go_gc_duration_seconds_count 1629

截至目前,我可以通过 Golang 中的 POST 请求对我的服务器进行身份验证。

【问题讨论】:

    标签: go protocol-buffers prometheus snappy kubernetes-metrics


    【解决方案1】:

    请注意,不建议通过 remote_write 协议将应用程序数据发送到 Prometheus,因为 Prometheus 旨在从 Prometheus config 中指定的目标中抓取指标。这被称为 pull model,而您正试图将指标推送到普罗米修斯又名 push model

    如果您需要将应用程序指标推送到 Prometheus,则存在以下选项:

    • 将指标推送到pushgateway。使用前请阅读when to use the pushgateway

    • 将指标推送到statsd_exporter

    • 通过任何 supported text-based data ingestion protocol 将应用程序指标推送到 VictoriaMetrics(这是一个类似 Prometheus 的替代监控系统):

      • Prometheus 文本阐述格式
      • 石墨
      • 流入线协议
      • OpenTSDB
      • 数据狗
      • JSON
      • CSV

      与 Prometheus remote_write 协议相比,所有这些协议都更容易实现和调试,因为这些协议是基于文本的,而 Prometheus remote_write 协议是二进制协议(基本上,它是通过 HTTP 发送的 snappy-compressed protobuf messages)。

    【讨论】:

      猜你喜欢
      • 2022-12-16
      • 2022-01-07
      • 2018-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-03
      • 2017-08-04
      • 2015-01-09
      相关资源
      最近更新 更多