Importing Alerts
Using Kloudfuse Customer Scripts
Kloudfuse provides Python scripts to manage alerts and dashboards in Grafana, to enable you to upload, download, and delete alerts and dashboards in specified folders within Grafana.
This document is your guide to efficiently manage Grafana alerts and dashboards using the alert.py and dashboard.py scripts.
Prerequisites
-
Python 3.x
-
Required Python packages:
requests,loguru,argparse(use the requirements.txt file to install all the packages:pip3 install -r requirements.txt) -
Access to a Grafana instance with API authentication
-
The Kloudfuse scripts can be found Kloudfuse Shared Customer Repo
Common Arguments
These arguments apply to both alert and dashboard scripts:
-f, --folder-name-
Grafana folder name
-a, --grafana-address-
Grafana server URL
-u, --grafana-username-
Grafana username (default:
admin)
-p, --grafana-password-
Grafana password (default:
password)
-v, --verify-ssl-
Disable SSL verification (default: enabled). Use this flag to skip SSL verification when connecting to Grafana.
|
Manage Alerts
To migrate (download and upload) or delete existing alerts, use the alert.py file, hosted for you in our customer/blob/main/scripts/assets/ directory.
Upload Alerts
Upload alerts to a specific Grafana folder.
python alert.py upload -s /path/to/alert.json \
-f "My Alert Folder" \
-a https://<grafana-instance>/grafana \
-u admin -p password
python alert.py upload -d /path/to/alerts/directory \
-f "My Alert Folder" \
-a https://<grafana-instance>/grafana \
-u admin -p password
python alert.py upload -m /path/to/root_directory \
-a https://<grafana-instance>/grafana \
-u admin -p password \
-f "placeholder"
Download Alerts
Retrieve alerts from Grafana, and save them as JSON files.
python alert.py download -s "Alert Name" -o /path/to/alert.json \
-f "My Alert Folder" \
-a https://<grafana-instance>/grafana \
-u admin -p password
python alert.py download -d -o /path/to/alerts/download/ \
-f "My Alert Folder" \
-a https://<grafana-instance>/grafana \
-u admin -p password
python alert.py download -m -o /path/to/alerts/download/ \
-a https://<grafana-instance>/grafana \
-u admin -p password \
-f "placeholder"
Delete Alerts
Remove alerts from Grafana.
python alert.py delete -s "Alert Name" \
-f "My Alert Folder" \
-a https://<grafana-instance>/grafana \
-u admin -p password
python alert.py delete -d -f "My Alert Folder" \
-a https://<grafana-instance>/grafana \
-u admin -p password