@@ -47,7 +47,7 @@ bazel_dep(name = "rules_grafana", version = "2.0.0")
4747git_override(
4848 module_name = " rules_grafana" ,
4949 remote = " https://github.com/etsy/rules_grafana.git" ,
50- branch = " grafana-foundation-sdk " ,
50+ branch = " main " ,
5151)
5252
5353# For plugins and container setup
@@ -92,36 +92,23 @@ to ensure it has a [consistent URL in Grafana](http://docs.grafana.org/administr
9292
9393### Python dashboards
9494
95- Dashboards can also be generated with Python using the
96- [ ` grafana-foundation-sdk ` ] ( https://github.com/grafana/grafana-foundation-sdk ) library.
97- The SDK provides type-safe builders for creating Grafana dashboards programmatically.
95+ Dashboards can also be generated with Python,
96+ using the [ ` grafanalib ` ] ( https://github.com/weaveworks/grafanalib ) library.
97+ ` grafanalib ` is automatically imported,
98+ and you can also add other ` deps ` to help build your dashboard.
9899
99100Each Python dashboard file should print the complete JSON of a Grafana dashboard.
100- Here's a template to get started :
101+ An easy way to do that is to follow a template like this :
101102
102103``` python
103- import json
104- from grafana_foundation_sdk.builders import dashboard as dashboard_builder
105- from grafana_foundation_sdk.builders import text, timeseries
106- from grafana_foundation_sdk.cog.encoder import JSONEncoder
107- from grafana_foundation_sdk.models.dashboard import GridPos
108-
109- dashboard = (
110- dashboard_builder.Dashboard(" My Dashboard" )
111- .with_panel(
112- text.Panel()
113- .title(" Welcome" )
114- .grid_pos(GridPos(h = 4 , w = 24 , x = 0 , y = 0 ))
115- )
116- .with_panel(
117- timeseries.Panel()
118- .title(" Metrics" )
119- .grid_pos(GridPos(h = 8 , w = 12 , x = 0 , y = 4 ))
120- )
121- .build()
104+ from grafanalib.core import *
105+ from grafanalib._gen import print_dashboard
106+
107+ dashboard = Dashboard(
108+ # Fill in your dashboard!
122109)
123110
124- print (json.dumps(dashboard, cls = JSONEncoder, indent = 2 ))
111+ print_dashboard(dashboard.auto_panel_ids()) # `auto_panel_ids()` call is required!
125112```
126113
127114Use ` py_dashboards ` to add Python files that generate dashboards to your build.
@@ -199,7 +186,7 @@ Then pass the plugin to the image rule's `plugins` list as `@grafana_plotly_plug
199186
200187### Custom Grafana image
201188
202- The default version of Grafana (12.0 ) may not suit your needs.
189+ The default version of Grafana (11.6.9 ) may not suit your needs.
203190You can override the container by modifying the grafana extension in your MODULE.bazel.
204191
205192## API Reference
0 commit comments