tool fails when grafana-config `hide_version` is set
Closed this issue · 0 comments
chriz-active commented
Problem
Running grafana-backup save
with the grafana-config-setting hide_version
fails:
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/grafana_backup/cli.py", line 52, in main
save(args, settings)
File "/usr/local/lib/python3.11/site-packages/grafana_backup/save.py", line 61, in main
backup_functions[backup_function](args, settings)
File "/usr/local/lib/python3.11/site-packages/grafana_backup/save_alert_rules.py", line 19, in main
grafana_version = get_grafana_version(grafana_url, verify_ssl)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/grafana_backup/dashboardApi.py", line 440, in get_grafana_version
return version.parse(r.json()['version'])
~~~~~~~~^^^^^^^^^^^
KeyError: 'version'
Error is thrown here:
grafana-backup-tool/grafana_backup/dashboardApi.py
Lines 437 to 442 in 3dd9d71
calling api/health
in our instance v9.5.2 as admin returns
api/health
{
"database": "ok"
}
That is, the version
-field is not available.
- The config we use is https://grafana.com/docs/grafana/v9.5/setup-grafana/configure-security/configure-security-hardening/#hide-the-version-number
- Although it states that hiding is only done for "unauthenticated users" that seems not the case? At least, I did a curl providing admin credentials...
https://github.com/grafana/grafana/blob/cfcea7591663053d58f0783e84a356eb258444cb/pkg/api/http_server.go#L687
https://github.com/grafana/grafana/blob/284c43c23d90d8688d21971f8bed55a09151bb3e/pkg/api/frontendsettings.go#L79
https://github.com/grafana/grafana/blob/284c43c23d90d8688d21971f8bed55a09151bb3e/pkg/services/navtree/navtreeimpl/navtree.go#L208
Possible Solution
- The version is currently needed for the
alert-rules
:
grafana-backup-tool/grafana_backup/create_alert_rule.py
Lines 17 to 21 in 3dd9d71
grafana-backup-tool/grafana_backup/save_alert_rules.py
Lines 19 to 22 in 3dd9d71
- Might it be an option to provide the version as fallback as config/environment-variable?