Writing future metrics to Grafana Cloud

I’m writing metrics to Grafana Cloud with http requests using Python. All works fine until I try to write a value that is too old or too far into the future - in the Billing/Usage dashboard I see too_far_in_future or too_far_in_past under Discarded Metric Samples.

The reason why I want this is because once a day I am receiving an hourly price list, and in my dashboard I would not only like to display real time values but also this price list for the whole day - including future hours.

Is there any way of changing the allowed timestamp range of metrics? I can’t seem to find a setting for this in the Grafana Cloud interface or find any info on how to change this.

Python code used

# Works without the timestamp
body = 'test,bar_label=abc,source=grafana_cloud_docs metric=0.0 1661369185000000000'
response = requests.post('https://prometheus-prod-24-prod-eu-west-2.grafana.net/api/prom',
                                 headers={'Content-Type': 'text/plain'},
                                 data=body,
                                 auth=(f"{secrets.USERNAME}", f"{secrets.API_TOKEN}")
                                 )

You as a Grafan Cloud user can’t configure that. You can contact your Grafana Cloud support and they may change it for you (but that must be a soft limit - I’m not sure if it is possible to change that or not).

1 Like

hey! btw, could you send a link to docs where it’s describe how to write data to Grafana Cloud storage directly from a custom Python service? without local instances of prometheus or anything

Hey, Here is a blog post that you can refer.

You could also try and instrument your application with OpenTelemetry and send metrics through it. Refer this doc.

1 Like

Thanks! In the first link, there is an example of sending data in the influx format (with changing the target endpoint). Is it possible to send data in the prometheus format to a prometheus endpoint?