How to push metrics to Grafana Cloud instance?

I’m a first-time user of Grafana and Grafana Cloud.

My goal is to set up a dashboard in Grafana Cloud with data comes from our local Python app. For that I want to push the data via the the Prometheus URL, doing something like this:

def send_grafana_metrics():
    """
    Send metrics to Grafana
    """
    url = "https://<domain>.grafana.net/api/prom/push"
    response = requests.post(
        url=url,
        headers={"Content-Type": "text/plain"},
        data="test,bar_label=abc,source=grafana_cloud_docs metric=35.2",
        auth=(USERNAME, API_KEY),
    )

I have the Prometheus URL, username and API key.

When I run the above, I get the error:

'decompress snappy: snappy: corrupt input\n'

What might I be doing wrong?

Welcome @kenny0de9

I push metrics to Prometheus hosted by Grafana Cloud using this URL:

https://influx-prod-10-prod-us-central-0.grafana.net/api/v1/push/influx/write

with basis authentication (username, i.e. a 6-digit number and pwd)

More info here.

1 Like

You’re a life-saver! Just saw my first metric incoming!

Thanks

1 Like

@grant2 how can I push string values to InfluxDB?

I’m sending the following payload to InfluxDB:

'conversation_created,conversation_uuid=7d4de639-0350-458d-bcae-262bdede2f0a,arranger_uuid=c9b00fd5-b8b0-45cb-b959-48c995672d55,traveler_uuid=None,company_name=Skylink conversation_uuid="7d4de639-0350-458d-bcae-262bdede2f0a"'

and I get back a 204, however the metric never shows up.