Back to articles
Grafana Has a Free API — Here's How to Create Dashboards and Query Data Programmatically
How-ToDevOps

Grafana Has a Free API — Here's How to Create Dashboards and Query Data Programmatically

via Dev.to DevOpsAlex Spinov

Grafana is an open-source observability platform with a powerful HTTP API. You can create dashboards, manage data sources, set up alerts, and query metrics — all programmatically. Getting Started docker run -d -p 3000:3000 grafana/grafana-oss Default credentials: admin/admin. Create an API key in Settings → API Keys. Create a Dashboard const response = await fetch ( " http://localhost:3000/api/dashboards/db " , { method : " POST " , headers : { " Authorization " : " Bearer your-api-key " , " Content-Type " : " application/json " }, body : JSON . stringify ({ dashboard : { title : " API Performance " , panels : [{ type : " timeseries " , title : " Request Latency " , gridPos : { h : 8 , w : 12 , x : 0 , y : 0 }, targets : [{ expr : " histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) " , legendFormat : " p95 latency " }] }, { type : " stat " , title : " Total Requests " , gridPos : { h : 4 , w : 6 , x : 12 , y : 0 }, targets : [{ expr : " sum(rate(http_requests_tot

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
5 views

Related Articles