Skip to content

Instantly share code, notes, and snippets.

@brancz
Created September 7, 2017 15:10
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 brancz/2bd616ef9107021a51c42fb602927fea to your computer and use it in GitHub Desktop.
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
#!/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