Skip to content

Instantly share code, notes, and snippets.

Last active August 19, 2022 18:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Sending Graphite Metrics to Grafana Cloud with Python
import requests
import json
# Go to "My Account" (,
# then under your Grafana stack, click the "Details" button under Graphite.
# Under the section titled "Using Grafana with Grafana Cloud Graphite" you will see
# your username. You can also generate an API key here, or do so in the account
# overview side navigation.
USER_ID = '123456'
API_KEY = 'your-api-key-123-!!!'
body = [
"name": "test.metric",
"interval": 10,
"value": 12.345,
"tags": ["foo=bar", "source=grafana_cloud_docs"],
"time": 1534685580
"name": "test.metric",
"interval": 10,
"value": 12.345,
"tags": ["foo=baz", "source=grafana_cloud_docs"],
"time": 1534685590
# Endpoint is on the same page as the userid / API Key
response ='https://[...]',
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {USER_ID}:{API_KEY}'
data = str(json.dumps(body))
data = response.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment