
Grafana Has a Free API — Build Dashboards and Query Metrics Programmatically
Grafana Cloud Free Tier Is Generous Grafana Cloud gives you free monitoring with 10K metrics, 50GB logs, and 50GB traces. Their API lets you manage dashboards and query data programmatically. Setup Get your API key from grafana.com/orgs/YOUR_ORG/api-keys. import requests GRAFANA_URL = " https://your-org.grafana.net " API_KEY = " your_grafana_api_key " HEADERS = { " Authorization " : f " Bearer { API_KEY } " } List Dashboards def list_dashboards (): r = requests . get ( f " { GRAFANA_URL } /api/search " , headers = HEADERS , params = { " type " : " dash-db " }) return [{ " title " : d [ " title " ], " uid " : d [ " uid " ], " url " : d [ " url " ]} for d in r . json ()] for d in list_dashboards (): print ( f " { d [ title ] } — { d [ uid ] } " ) Create a Dashboard def create_dashboard ( title , panels ): dashboard = { " dashboard " : { " title " : title , " panels " : panels , " timezone " : " browser " }, " overwrite " : False } r = requests . post ( f " { GRAFANA_URL } /api/dashboards
Continue reading on Dev.to Tutorial
Opens in a new tab




