Skip to content

This repository contains a Python script that reads a JSON file and makes API calls to create datasources in Grafana.

License

Notifications You must be signed in to change notification settings

GPegel/grafana-datasource-creation

Repository files navigation

Grafana Datasource Creation

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.

Prerequisites

Before running the script, make sure you have the following prerequisites:

  • Python 3.8 or later
  • Pip package manager

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/GPegel/grafana-datasource-creation.git
    
  2. Navigate to the repository directory:

    cd grafana-datasource-creation
    
  3. Install the required Python packages:

    pip install -r requirements.txt
    

Usage

  1. Edit the data.json file and add your desired datasources in the JSON format.

  2. Set the necessary environment variables:

  3. GRAFANA_TOKEN: Your Grafana authentication token.

  4. GRAFANA_DATASOURCE_URL: The URL of your Grafana datasource endpoint.

  5. Run the Python script:

    python push-datasources.py
    
  6. 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

About

This repository contains a Python script that reads a JSON file and makes API calls to create datasources in Grafana.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published