HTTP API - Send historic data

I’m trying to push data through HTTP API directly to Grafana Cloud from a custom script which takes care on collecting and pre-aggregating relevant data.

To send the data I use the approach documented here:

Example request (I added a timestamp at the end)
curl -X POST -H “Authorization: Bearer $API_KEY” -H “Content-Type: text/plain” “” -d “test,bar_label=abc metric=35.3 1702670700000000000”

This works fine to send fresh data but unfortunately does not work if I send data with an old timestamp. In this case I get:

{“code”:“invalid”,“message”:“bad metrics write request”}

How could I send historic data? Is this possible through the /api/v1/push/influx/write endpoint? Or do I need to take a different approach? E.g. setting up a Prometheus DB and import data there.

That is only a InfluxDB protocol/gateway, which writes data into Prometheus (Mimir). And Prometheus is picky about older timestamps or out of order timestamps (it depends on the Prometheus configuration what is accepted or rejected).

I would use proper InfluxDB for this use case (or another TSDB, which you are familiar with), which works fine with historic data.

Thank you!
I’m using InfluxDB Cloud to store timeseries data now. The Grafana Cloud connector allows to run Flux queries against it. So this seems to be a good combination which also allows to ingest historic data.
Thanks for your recommendation!

1 Like