ysde / grafana-backup-tool

A Python-based application to backup Grafana settings by using the Grafana API
MIT License
877 stars 277 forks source link

issue with azure #142

Closed icy closed 3 years ago

icy commented 3 years ago

I don't use azure storage, and leave the configuration empty for them (azure: {}). I got an error (version 1.1.8) when working with grafana-7.0.3

Traceback (most recent call last):
  File "/usr/local/bin/grafana-backup", line 5, in <module>
    from grafana_backup.cli import main
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/cli.py", line 2, in <module>
    from grafana_backup.save import main as save
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/save.py", line 10, in <module>
    from grafana_backup.azure_storage_upload import main as azure_storage_upload
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/azure_storage_upload.py", line 1, in <module>
    from azure.storage.blob import BlobServiceClient, BlobClient
ImportError: cannot import name 'BlobServiceClient' from 'azure.storage.blob' (/root/.local/lib/python3.8/site-packages/azure/storage/blob/__init__.py)

What can I do to debug and/or to fix this problem?

Thanks

icy commented 3 years ago

I tried to remove the pip files and reinstall the package (pip install grafana-backup-tool), and now I got into another issue:


[DEBUG] resp status: 200
Traceback (most recent call last):
  File "/usr/local/bin/grafana-backup", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/cli.py", line 43, in main
    save(args, settings)
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/save.py", line 26, in main
    (status, json_resp, uid_support, paging_support) = api_checks(settings)
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/api_checks.py", line 12, in main
    (status, json_resp) = health_check(grafana_url, http_get_headers, verify_ssl, client_cert, debug)
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/dashboardApi.py", line 8, in health_check
    return send_grafana_get(url, http_get_headers, verify_ssl, client_cert, debug)
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/dashboardApi.py", line 188, in send_grafana_get
    log_response(r)
  File "/usr/local/lib/python3.8/site-packages/grafana_backup/commons.py", line 13, in log_response
    print("[DEBUG] resp body: {0}".format(resp.json()))
  File "/root/.local/lib/python3.8/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

``

It's used to work well with grafana-6.0 but looked like it can't deal with new grafana.
icy commented 3 years ago

I found it. The grafana URL doesn't accept any trailing slash. The error would be a lot more informative...