Skip to content

Instantly share code, notes, and snippets.

@grafuls
Created December 22, 2023 16:23
Show Gist options
  • Save grafuls/e70a17ddfde98f5e446e1cc4d15aed07 to your computer and use it in GitHub Desktop.
Save grafuls/e70a17ddfde98f5e446e1cc4d15aed07 to your computer and use it in GitHub Desktop.
Python generated grafana dashboards
from grafanalib.core import (
Dashboard, Graph,
OPS_FORMAT, Row,
single_y_axis, Target
)
dashboard = Dashboard(
title="Python generated dashboard",
rows=[
Row(panels=[
Graph(
title="Prometheus http requests",
dataSource='default',
targets=[
Target(
expr='rate(prometheus_http_requests_total[5m])',
legendFormat="{{ handler }}",
refId='A',
),
],
yAxes=single_y_axis(format=OPS_FORMAT),
),
]),
],
).auto_panel_ids()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment