-
-
Save jmarbach/5f3e5ed1040cabfae2c497b124b02bcb to your computer and use it in GitHub Desktop.
Sending Prometheus metrics to Grafana Cloud using the Influx Line Protocol and Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'node-fetch'; | |
const USER_ID = '123456'; | |
const API_KEY = 'your-api-key-123-!!!'; | |
const body = 'test,bar_label=abc,source=grafana_cloud_docs metric=35.2'; | |
// Endpoint is on the same page as the userid / API Key | |
const response = await fetch('https://influx[...].grafana.net/api/v1/push/influx/write', { | |
method: 'post', | |
body, | |
headers: { | |
'Authorization': `Bearer ${USER_ID}:${API_KEY}`, | |
'Content-Type': 'text/plain', | |
}, | |
}); | |
const data = await response.status; | |
console.log(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment