Created
September 7, 2017 15:10
-
-
Save brancz/2bd616ef9107021a51c42fb602927fea to your computer and use it in GitHub Desktop.
failed attempt of scraping grafana dashboards off of its api, turns out the output is not compatible with what the create endpoint expects
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 | |
grafanaapi="http://localhost:8001/api/v1/proxy/namespaces/tectonic-system/services/grafana:3000/api" | |
dir="./assets/grafana/" | |
dashboards=`curl $grafanaapi/search | jq -r ".[] .uri"` | |
while read -r d; do | |
name=`echo $d | cut -c 3-` | |
curl "$grafanaapi/dashboards/$d" | jq -r ".dashboard" | jq -r '. + {"__inputs":[{"name": "DS_PROMETHEUS","label": "prometheus","description": "","type": "datasource","pluginId": "prometheus","pluginName": "Prometheus"}]}' > "./assets/grafana/$name-dashboard.json" | |
done <<< "$dashboards" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment