Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xsqian/5d713f6b9ed58f903aa1c9be1b84807e to your computer and use it in GitHub Desktop.
Save xsqian/5d713f6b9ed58f903aa1c9be1b84807e to your computer and use it in GitHub Desktop.
how to export and import datasource from Grafana using Grafana API
mkdir -p data_sources && curl -s "http://localhost:3000/api/datasources" -u admin:admin|jq -c -M '.[]'|split -l 1 - data_sources/
for i in data_sources/*; do \
curl -X "POST" "http://localhost:3000/api/datasources" \
-H "Content-Type: application/json" \
--user admin:admin \
--data-binary @$i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment