rmoff's random ramblings
about talks

Simple export/import of Data Sources in Grafana

Published Aug 8, 2017 by in Curl, Grafana, Bash, Jq at https://rmoff.net/2017/08/08/simple-export/import-of-data-sources-in-grafana/

Grafana API Reference

Export all Grafana data sources to data_sources folder ðŸ”—

mkdir -p data_sources && curl -s "http://localhost:3000/api/datasources"  -u admin:admin|jq -c -M '.[]'|split -l 1 - data_sources/

This exports each data source to a separate JSON file in the data_sources folder.

Load data sources back in from folder ðŸ”—

This submits every file that exists in the data_sources folder to Grafana as a new data source definition.

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

Robin Moffatt

Robin Moffatt works on the DevRel team at Confluent. He likes writing about himself in the third person, eating good breakfasts, and drinking good beer.

Story logo

© 2025