diff --git a/app/classes/web/metrics_handler.py b/app/classes/web/metrics_handler.py index c0e424de..869a6931 100644 --- a/app/classes/web/metrics_handler.py +++ b/app/classes/web/metrics_handler.py @@ -1,13 +1,7 @@ import logging import typing as t -from prometheus_client import ( - REGISTRY, - CollectorRegistry, - GC_COLLECTOR, - PLATFORM_COLLECTOR, - PROCESS_COLLECTOR, -) +from prometheus_client import REGISTRY, CollectorRegistry from prometheus_client.exposition import _bake_output from prometheus_client.exposition import parse_qs, urlparse diff --git a/app/classes/web/routes/metrics/index.py b/app/classes/web/routes/metrics/index.py index c08011a7..60315265 100644 --- a/app/classes/web/routes/metrics/index.py +++ b/app/classes/web/routes/metrics/index.py @@ -11,7 +11,9 @@ class ApiOpenMetricsIndexHandler(BaseMetricsHandler): if not auth_data: return - version = f"{self.helper.get_version().get('major')}.{self.helper.get_version().get('minor')}.{self.helper.get_version().get('sub')}" + version = f"{self.helper.get_version().get('major')} \ + .{self.helper.get_version().get('minor')} \ + .{self.helper.get_version().get('sub')}" CRAFTY_INFO.info( {"version": version, "docker": f"{self.helper.is_env_docker()}"} ) diff --git a/app/classes/web/routes/metrics/servers.py b/app/classes/web/routes/metrics/servers.py index 63fbb605..7f374ec1 100644 --- a/app/classes/web/routes/metrics/servers.py +++ b/app/classes/web/routes/metrics/servers.py @@ -1,4 +1,3 @@ -from prometheus_client import Gauge from prometheus_client.exposition import _bake_output from prometheus_client.exposition import parse_qs, urlparse @@ -19,7 +18,10 @@ class ApiOpenMetricsServersHandler(BaseMetricsHandler): self.get_registry(server_id) - def get_registry(self, server_id) -> None: + def get_registry(self, server_id=None) -> None: + if server_id is None: + return self.finish_json(500, {"status": "error", "error": "UNKNOWN_SERVER"}) + # Prepare parameters registry = ( ServersController().get_server_instance_by_id(server_id).server_registry