Remote write API

Hello,

I have a several closed proprietary systems that pushes some metrics in a text format on a cloud.
The format looks like this :

<timestamp> <device> <key> <value>

Then once a day, I want to fetch those data and push them into prometheus, and then monitor them with grafana.
I want to be able to keep the timestamp informations for graphs, and apparently according to what I could find on google, the only way to do this is using the remote write API.

so I’ve enabled the feature in my docker instance of prometheus, but I can’t find any documentation on how to define the metric and push it on my prometheus instance.

So I tried with a small python snippet to push a random metric :

import requests
import snappy

prometheus_url="http://localhost:9090/api/v1/write"
query='temperature{device="HpLx360", id="12345"} 25.4 1680014429'
result = requests.post(prometheus_url, data=snappy.compress(query))
print(result.status_code)
print(result.text)

I tried also without the timestamp for a first try, but everytime I get the error

400
proto: WriteRequest: wiretype end group for non-group

I can’t find any documentation about this error, I’m not sure if it’s due to snappy or an error in the syntax I’m using, any advice ?

1 Like

I think remote_write uses protobuf to define the protocol, that should be the definition:

https://github.com/prometheus/prometheus/blob/main/prompb/remote.proto

You might use protobuf to create a python client somehow.