I am using Grafana cloud v10.0.3 and could not find any way to exports alerts json data. I tried to write a python script to access alerts json data but it is not showing any output. Below is the python script
import requests
import json
# Replace this with your actual token
token = "api token"
grafana_url = "https://domain.grafana.net"
alert_name = "NetworkDevice Down" //alert name
headers = {
"Authorization": f"Bearer {token}",
"Accept": "application/json",
"Content-Type": "application/json"
}
response = requests.get(f"{grafana_url}/api/alerts", headers=headers)
if response.status_code == 200:
alerts = response.json()
for alert in alerts:
if alert['name'] == alert_name:
print(json.dumps(alert, indent=4))
else:
print(f"Request failed with status code {response.status_code}")
Any idea what I am doing wrong? Thanks