Skip to content

Instantly share code, notes, and snippets.

@jmarbach
Created September 1, 2022 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmarbach/82d555aeadfab9a01059b7ef898c8b97 to your computer and use it in GitHub Desktop.
Save jmarbach/82d555aeadfab9a01059b7ef898c8b97 to your computer and use it in GitHub Desktop.
Sending InfluxDB Metrics to Grafana Cloud with Python
import requests
import base64
# Go to "My Account" (grafana.com/orgs/your-organization),
# 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 = 'test,bar_label=abc,source=grafana_cloud_docs metric=35.2'
response = requests.post('https://influx[...].grafana.net/api/v1/push/influx/write',
headers = {
'Content-Type': 'text/plain',
},
data = str(body),
auth = (USER_ID, API_KEY)
)
status_code = response.status_code
print(status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment