weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.87k stars 311 forks source link

Main improved dashboard links #622

Closed padraic-padraic closed 1 year ago

padraic-padraic commented 1 year ago

What does this do?

Extends the implementation of DashboardLink to support creating both direct links and lists of dashboards.

Why is it a good idea?

This enables grafanalib users to fully employ the DashboardLink feature. The previous JSON model was no longer accurate for recent grafana versions, meaning dashboard links were not properly generated. Here we add all available fields, allowing users to create dashboard links correctly from grafanalib.

Context

Dashboard Links are a way to create links along the top of a dashboard, linking either to other sets of dashboards from the same organization or arbitrary external resources. See the documentation here: https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/manage-dashboard-links/#manage-dashboard-links

Questions

I have removed a parameter from the old DashboardLink class, dashboard; this could consistute a breaking change.

This parameter was not actually consumed by Grafana, so was in effect only acting as an internal alias to the title field. The title would only be shown if the DashboardLink.type attribute is set to link, something actually not possible before this PR. so I don't consider it to be a significant change. But, if desired, we can retain that alias-like behaviour to maintain API compatability.

padraic-padraic commented 1 year ago

Thanks for approving the workflows, will work to correct the tests shortly!

padraic-padraic commented 1 year ago

Looks like the issue is with py37/38 support, will push some fixes shortly.

padraic-padraic commented 1 year ago

Running locally against Python 3.8 passes now, screenshot is provided 🙂 Screenshot 2023-09-08 at 10 50 57