Beam-Connectivity / grafana-dashboard-manager

Import and export Grafana dashboards for backup and dynamic provisioning
MIT License
59 stars 13 forks source link

error downloading dashboard #3

Closed clement94310 closed 11 months ago

clement94310 commented 2 years ago

I get this error when i try to download dashboards :

Found Zeus - Kubernetes App Metrics dashboard in folder API Management dashboard_download.py:80 Traceback (most recent call last): File "", line 1, in File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/typer/main.py", line 214, in call return get_command(self)(*args, kwargs) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(args, kwargs) File "/home/clement/.cache/pypoetry/virtualenvs/grafana-dashboard-manager-GvvO0-hQ-py3.8/lib/python3.8/site-packages/typer/main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "/home/clement/grafana-dashboard-manager/grafana_dashboard_manager/dashboard_download.py", line 52, in all _write_dashboards_to_local_folder_from_grafana_folder(folder, destination_dir) File "/home/clement/grafana-dashboard-manager/grafana_dashboard_manager/dashboard_download.py", line 86, in _write_dashboards_to_local_folder_from_grafana_folder dashboard_definition = update_dashlist_folder_ids(dashboard_definition) File "/home/clement/grafana-dashboard-manager/grafana_dashboard_manager/dashboard.py", line 58, in update_dashlist_folder_ids for panel in dashboard_definition["dashboard"]["panels"]: KeyError: 'panels'

chan-vince commented 2 years ago

Hi, thanks for giving this a go.

Do you happen to have dashboards with no panels in them? i.e. empty dashboards

vitosans commented 2 years ago

I have run into the same issue:

INFO Found Alertmanager / Overview dashboard in folder Kubernetes-Metrics dashboard_download.py:80 Traceback (most recent call last): File "/usr/local/bin/grafana-dashboard-manager", line 8, in <module> sys.exit(app()) File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 214, in __call__ return get_command(self)(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/typer/main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "/usr/local/lib/python3.9/site-packages/grafana_dashboard_manager/dashboard_download.py", line 52, in all _write_dashboards_to_local_folder_from_grafana_folder(folder, destination_dir) File "/usr/local/lib/python3.9/site-packages/grafana_dashboard_manager/dashboard_download.py", line 86, in _write_dashboards_to_local_folder_from_grafana_folder dashboard_definition = update_dashlist_folder_ids(dashboard_definition) File "/usr/local/lib/python3.9/site-packages/grafana_dashboard_manager/dashboard.py", line 58, in update_dashlist_folder_ids for panel in dashboard_definition["dashboard"]["panels"]: KeyError: 'panels' Any help I can provide to debug?

Also the dashboard it's attempting to get is not empty.

vitosans commented 2 years ago

@clement94310 - I pushed a PR that will skip any dashboards that have this issue. I am getting familiar with the code and will attempt a fix if it's possible, for me the issue is with a dashboard that comes pre-populated from kube-stack operator so in my case it's safe to skip.

LawrenceWarren commented 2 years ago

This should be fixed by #9, run pip install grafana-dashboard-manager --upgrade to get the newest version and let me know how it works @clement94310 & @vitosans.

anarcat commented 1 year ago

can this issue be closed then?