'remote write receiver' HTTP API request in Prometheus
Asked Answered
V

1

9

I am trying to find a working example of how to use the remote write receiver in Prometheus.

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

I am able to send a request to the endpoint ( POST /api/v1/write ) and can authenticate with the server. However, I have no idea in what format I need to send the data over.

The official documentation says that the data needs to be in Protobuf format and snappy encoded. I know the libraries for them. I have a few metrics i need to send over to prometheus http:localhost:1234/api/v1/write. The metrics i am trying to export are scraped from a metrics endpoint (http://127.0.0.1:9187/metrics ) and looks like this :

# 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

As of now, i can authenticate with my server via a POST request in Golang.

Vigilant answered 3/6, 2022 at 22:13 Comment(0)
C
0

Please note that it isn't recommended to send application data to Prometheus via remote_write protocol, since Prometheus is designed to scrape metrics from the targets specified in Prometheus config. This is known as pull model, while you are trying to push metrics to Prometheus aka push model.

If you need pushing application metrics to Prometheus, then the following options exist:

  • Pushing metrics to pushgateway. Please read when to use the pushgateway before using it.

  • Pushing metrics to statsd_exporter.

  • Pushing application metrics to VictoriaMetrics (this is an alternative Prometheus-like monitoring system) via any supported text-based data ingestion protocol:

    • Prometheus text exposition format
    • Graphite
    • Influx line protocol
    • OpenTSDB
    • DataDog
    • JSON
    • CSV

    All these protocols are much easier to implement and debug comparing to Prometheus remote_write protocol, since these protocols are text-based, while Prometheus remote_write protocol is a binary protocol (basically, it is snappy-compressed protobuf messages sent over HTTP).

Casualty answered 22/12, 2022 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.