Prometheus中的'remote write receiver' HTTP API请求

9

我正在尝试查找使用Prometheus中的远程写入接收器的工作示例。

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

我可以向终端发送请求(POST / api / v1 / write)并且可以验证服务器。但是,我不知道需要以什么格式发送数据。

官方文档说数据需要采用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 请求来进行与我的服务器的认证。

1个回答

1
请注意,不建议通过remote_write协议将应用程序数据发送到Prometheus,因为Prometheus旨在从Prometheus配置中指定的目标中抓取指标。这被称为拉模型,而您正在尝试将指标推送到Prometheus,也就是推模型
如果您需要将应用指标推送到Prometheus,则存在以下选项:
- 将指标推送到pushgateway。在使用之前,请阅读何时使用pushgateway。 - 将指标推送到statsd_exporter。 - 通过任何支持的基于文本的数据摄入协议将应用指标推送到VictoriaMetrics(这是一种替代的类似Prometheus的监控系统): - Prometheus文本格式 - Graphite - Influx线协议 - OpenTSDB - DataDog - JSON - CSV
所有这些协议比Prometheus remote_write协议更容易实现和调试,因为这些协议是基于文本的,而Prometheus remote_write协议是一个二进制协议(基本上是通过HTTP发送的protobuf消息,经过了snappy压缩)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接