This repository contains a Python script that reads a JSON file and makes API calls to create datasources in Grafana. The script is designed to handle datasources one by one, with a delay between each API call to avoid overwhelming Grafana.
Before running the script, make sure you have the following prerequisites:
- Python 3.8 or later
- Pip package manager
-
Clone this repository to your local machine:
git clone https://github.com/GPegel/grafana-datasource-creation.git
-
Navigate to the repository directory:
cd grafana-datasource-creation
-
Install the required Python packages:
pip install -r requirements.txt
-
Edit the data.json file and add your desired datasources in the JSON format.
-
Set the necessary environment variables:
-
GRAFANA_TOKEN: Your Grafana authentication token.
-
GRAFANA_DATASOURCE_URL: The URL of your Grafana datasource endpoint.
-
Run the Python script:
python push-datasources.py
-
Or if you want to run this script in a docker container, you can use the following command:
docker run -it --rm -e GRAFANA_TOKEN=your-token -e GRAFANA_DATASOURCE_URL=your-url -v $(pwd)/data.json:/app/data.json ghcr.io/your-username/grafana-datasource-creation:latest