Created
May 16, 2022 09:14
-
-
Save dansimau/fc2c4c277f510db2f76d7b48ba919fce to your computer and use it in GitHub Desktop.
Push metric to a Grafana Cloud Graphite instance
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
#!/bin/bash | |
set -euo pipefail | |
api_key="" # API key from Grafana Cloud | |
metrics_user="" # Graphite username from Grafana Cloud console | |
metrics_endpoint="" # Graphite endpoint from Grafana Cloud console | |
now=$(date +%s) | |
metric_name=$1 | |
metric_value=$2 | |
metric_interval=$3 | |
metric_body=" | |
[{ | |
\"name\": \"${metric_name}\", | |
\"value\": ${metric_value}, | |
\"time\": $now, | |
\"interval\": ${metric_interval} | |
}] | |
" | |
curl -X POST -u "$metrics_user:$api_key" -H "Content-Type: application/json" "$metrics_endpoint" -d "$metric_body" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage: