maxim-mityutko / borgmatic-exporter

Prometheus exporter for Borgmatic seamlessly integrated into official Borgmatic docker image
MIT License
2 stars 2 forks source link

KeyError: 'archives' #5

Closed flandweber closed 6 months ago

flandweber commented 6 months ago

The output of borgmatic info does not seem to contain an attribute archives:

borgmatic info --json
[{"cache": {"path": "/root/.cache/borg/5c05bd47897dbfd72354990e2b4de05595dc35651e31fb234a9f84fdd2e23761", "stats": {"total_chunks": 3, "total_csize": 74, "total_size": 78, "total_unique_chunks": 3, "unique_csize": 1210, "unique_size": 2309}}, "encryption": {"mode": "none"}, "repository": {"id": "5c05bd47897dbfd72354990e2b4de05595dc35651e31fb234a9f84fdd2e23761", "last_modified": "2024-02-23T14:16:30.000000", "location": "/var/backup"}, "security_dir": "/root/.config/borg/security/5c05bd47897dbfd72354990e2b4de05595dc35651e31fb234a9f84fdd2e23761"}]

which leads to

borgmatic # [  805.743419] borgmatic-exporter[845]: [2024-02-23 14:16:35,716] ERROR in app: Exception on /metrics [GET]
borgmatic # [  805.744133] borgmatic-exporter[845]: Traceback (most recent call last):
borgmatic # [  805.744719] borgmatic-exporter[845]:   File "/nix/store/iw1fhz8bbvg6kw6bi7vw3q7p43b8kq7d-python3.11-flask-3.0.1/lib/python3.11/site-packages/flask/app.py", line 1463, in wsgi_app
borgmatic # [  805.745785] borgmatic-exporter[845]:     response = self.full_dispatch_request()
borgmatic # [  805.746275] borgmatic-exporter[845]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
borgmatic # [  805.746759] borgmatic-exporter[845]:   File "/nix/store/iw1fhz8bbvg6kw6bi7vw3q7p43b8kq7d-python3.11-flask-3.0.1/lib/python3.11/site-packages/flask/app.py", line 872, in full_dispatch_request
borgmatic # [  805.749703] borgmatic-exporter[845]:     rv = self.handle_user_exception(e)
borgmatic # [  805.750272] borgmatic-exporter[845]:          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
borgmatic # [  805.751035] borgmatic-exporter[845]:   File "/nix/store/iw1fhz8bbvg6kw6bi7vw3q7p43b8kq7d-python3.11-flask-3.0.1/lib/python3.11/site-packages/flask/app.py", line 870, in full_dispatch_request
borgmatic # [  805.752186] borgmatic-exporter[845]:     rv = self.dispatch_request()
borgmatic # [  805.752676] borgmatic-exporter[845]:          ^^^^^^^^^^^^^^^^^^^^^^^
borgmatic # [  805.753160] borgmatic-exporter[845]:   File "/nix/store/iw1fhz8bbvg6kw6bi7vw3q7p43b8kq7d-python3.11-flask-3.0.1/lib/python3.11/site-packages/flask/app.py", line 855, in dispatch_request
borgmatic # [  805.754051] borgmatic-exporter[845]:     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
borgmatic # [  805.754745] borgmatic-exporter[845]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
borgmatic # [  805.755338] borgmatic-exporter[845]:   File "/nix/store/gysh9spfl0jfabhixq886jg0fv4h3b9p-prometheus-borgmatic-exporter-0.2.0/lib/python3.11/site-packages/src/http_server.py", line 33, in metrics
borgmatic # [  805.756254] borgmatic-exporter[845]:     collect(borgmatic_config, registry)
borgmatic # [  805.756690] borgmatic-exporter[845]:   File "/nix/store/gysh9spfl0jfabhixq886jg0fv4h3b9p-prometheus-borgmatic-exporter-0.2.0/lib/python3.11/site-packages/src/metrics.py", line 83, in collect
borgmatic # [  805.757596] borgmatic-exporter[845]:     value=len(repos[i]["archives"]),
borgmatic # [  805.757979] borgmatic-exporter[845]:               ~~~~~~~~^^^^^^^^^^^^
borgmatic # [  805.758368] borgmatic-exporter[845]: KeyError: 'archives'

borgmatic 1.8.1

maxim-mityutko commented 6 months ago

Thanks for the interest in the project @flandweber and finding the issue. This should be fixed now in release v0.2.1

flandweber commented 6 months ago

Tanks a lot!