dashboards_backup script does not work with grafana version >= 8

Bug #1983814 reported by Mustafa Kemal Gilor
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Grafana Charm
Fix Released
Undecided
Mustafa Kemal Gilor

Bug Description

dashboards_backup script is using a deprecated API to retrieve the dashboard JSON information from Grafana. The used API[1] is deprecated in version 5.4 in favor of using dashboard UID's[2] and removed in version 8.0.

To reproduce the issue, deploy the Grafana charm with APT[3] as follows:

1) Install Grafana charm with APT install method:
juju deploy grafana grafanasnap --series bionic --config install_method=apt

2) Login to Grafana web UI & create a dashboard

3) Schedule automatic dashboard backup job:
juju config grafanasnap dashboards_backup_schedule='*/5 * * * *'

4) Retrieve the backup command from the scheduled job:
sudo cat /etc/cron.d/juju-dashboards-backup

5) Run the backup command by hand:
/usr/local/bin/dashboards_backup -d /srv/backups -p 3000 -s http <redacted>

6) Check dashboard backup files in the backup folder:
/srv/backups/Main_Org_# cat grafana-metrics.json.20220804_132501
{"message": "Not found"}

The backup files are supposed to have the dashboard contents. Instead, they have `{"message": "Not found"}` since the API is not present in the deployed Grafana version.

Remedy:
The backup script should use the UID API for Grafana version >= 8.

[1]: https://grafana.com/docs/grafana/v5.4/http_api/dashboard/#get-dashboard-by-slug
[2]: https://grafana.com/docs/grafana/v5.4/http_api/dashboard/#get-dashboard-by-uid
[3]: APT package's grafana version is 9.0.6, whereas snap package's grafana version is 7.4.1

Related branches

tags: added: seg sts sts-sponsor
Changed in charm-grafana:
assignee: nobody → Mustafa Kemal Gilor (mustafakemalgilor)
status: New → In Progress
Changed in charm-grafana:
status: In Progress → Fix Committed
Changed in charm-grafana:
milestone: none → 22.10
Changed in charm-grafana:
status: Fix Committed → Fix Released
Changed in charm-grafana:
status: Fix Released → Fix Committed
Changed in charm-grafana:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.