Python script to update field overrides on Grafana Dashboards via API
Before | After |
---|---|
Raw data from Meraki Dashboard, client MAC address displayed | Custom fields added, client name displayed |
- Grafana Dashboard
- Grafana API key
- List of field to overrides with the new value
- Clone or download this repo
git clone https://github.com/xaviervalette/grafana-update-field-overrides
- Install required packages
python3 -m pip install -r requirements.txt
- Add a
config.yml
file as follow:
└── meraki-network-event-log-collector/
+ ├── config.yml
├── ressources
│ └── fieldOverrideTemplate.json
└── src/
├── functions.py
└── main.py
- In the
config.yml
file, add the following variables:
#config.yml
---
api_key: "<grafanaApiKey>"
host: "<grafanaHost>"
dashboards:
- uid: "<firstDashboardUid>"
folderUid: "<firstDashboardFolderUid>"
fieldOverrides:
- field: "<firstField>"
name: "<firstFieldTargetName>"
#[...]
- field: "<lastField>"
name: "<lastFieldTargetName>"
#[...]
- uid: "<lastDashboardUid>"
folderUid: "<lastDashboardFolderUid>"
fieldOverrides:
- field: "<firstField>"
name: "<firstFieldTargetName>"
#[...]
- field: "<lastField>"
name: "<lastFieldTargetName>"
colorPalette:
- "#DFFF00"
#[...]
...
ⓘ You can add as many colors you want in the
colorPalette
list. Those colors will be use to override sequentially the field color
- Now you can run the code by using the following command:
python3 src/main.py
The output should be as followed:
Dashboard <firstDashboardUid> overrides updated successfully
[...]
Dashboard <lastDashboardUid> overrides updated successfully
Example:
Dashboard UdGt5bb4z overrides updated successfully