grafana / grafonnet

Jsonnet library for generating Grafana dashboards.
https://grafana.github.io/grafonnet/
Apache License 2.0
320 stars 18 forks source link

Question: ability to set panel ids in order to preserve manually added annotations #197

Closed Antiarchitect closed 2 months ago

Antiarchitect commented 2 months ago

Hi, We use generated boards with manual annotations (stored in Grafana). According to the Annotations API this kind of annotation is bound to the panel via panelId. As far as I've searched through Grafonnet - there is no ability to explicitly set panelId for panels in order to make ids consistent. It would be nice if anyone who faced such issues shares experience in order to mitigate this if it's at all possible.

Duologic commented 2 months ago

The withPanels function on the dashboard generates the IDs, but these change if you add/remove/reorder panels. It has a boolean to disable that behavior: https://grafana.github.io/grafonnet/API/dashboard/index.html#fn-withpanels

This would mean you have to manage panel IDs on your own, the util package has some useful functions that can help with that: https://grafana.github.io/grafonnet/API/util.html

Antiarchitect commented 2 months ago

Thank you @Duologic. As for now we decided to reassign panel IDs after Grafana Dashboard JSON object is generated by Grafonnet.