From fc5c85e81adbb1d42d16fcb1d7c8115aec034646 Mon Sep 17 00:00:00 2001 From: nhnn Date: Wed, 24 Jul 2024 06:01:41 +0300 Subject: [PATCH 1/4] fix: typo in PrometheusQueries._send_query --- selfprivacy_api/utils/prometheus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfprivacy_api/utils/prometheus.py b/selfprivacy_api/utils/prometheus.py index 3e25a2d..2248170 100644 --- a/selfprivacy_api/utils/prometheus.py +++ b/selfprivacy_api/utils/prometheus.py @@ -37,7 +37,7 @@ class PrometheusQueries: raise Exception("Prometheus returned unexpected HTTP status code") json = response.json() return PrometheusQueryResult( - result_type=json["result_type"], result=json["result"] + result_type=json["resultType"], result=json["result"] ) except Exception as error: raise Exception("Prometheus request failed! " + str(error)) From d0aec6cd0636e6964dd9c660a1ceb91c0ab83e4b Mon Sep 17 00:00:00 2001 From: nhnn Date: Wed, 24 Jul 2024 06:12:18 +0300 Subject: [PATCH 2/4] fix: rename prometheus to monitoring --- selfprivacy_api/migrations/__init__.py | 4 ++-- .../{add_prometheus.py => add_monitoring.py} | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) rename selfprivacy_api/migrations/{add_prometheus.py => add_monitoring.py} (56%) diff --git a/selfprivacy_api/migrations/__init__.py b/selfprivacy_api/migrations/__init__.py index 5eb3194..327bb28 100644 --- a/selfprivacy_api/migrations/__init__.py +++ b/selfprivacy_api/migrations/__init__.py @@ -15,12 +15,12 @@ from selfprivacy_api.migrations.check_for_system_rebuild_jobs import ( CheckForSystemRebuildJobs, ) from selfprivacy_api.migrations.add_roundcube import AddRoundcube -from selfprivacy_api.migrations.add_prometheus import AddPrometheus +from selfprivacy_api.migrations.add_monitoring import AddMonitoring migrations = [ WriteTokenToRedis(), CheckForSystemRebuildJobs(), - AddPrometheus(), + AddMonitoring(), AddRoundcube(), ] diff --git a/selfprivacy_api/migrations/add_prometheus.py b/selfprivacy_api/migrations/add_monitoring.py similarity index 56% rename from selfprivacy_api/migrations/add_prometheus.py rename to selfprivacy_api/migrations/add_monitoring.py index 93089ff..a6dbfde 100644 --- a/selfprivacy_api/migrations/add_prometheus.py +++ b/selfprivacy_api/migrations/add_monitoring.py @@ -4,33 +4,33 @@ from selfprivacy_api.services.flake_service_manager import FlakeServiceManager from selfprivacy_api.utils import ReadUserData, WriteUserData -class AddPrometheus(Migration): - """Adds the Prometheus if it is not present.""" +class AddMonitoring(Migration): + """Adds monitoring service if it is not present.""" def get_migration_name(self) -> str: - return "add_prometheus" + return "add_monitoring" def get_migration_description(self) -> str: - return "Adds the Prometheus if it is not present." + return "Adds the Monitoring if it is not present." def is_migration_needed(self) -> bool: with FlakeServiceManager() as manager: - if "prometheus" not in manager.services: + if "monitoring" not in manager.services: return True with ReadUserData() as data: - if "prometheus" not in data["modules"]: + if "monitoring" not in data["modules"]: return True return False def migrate(self) -> None: with FlakeServiceManager() as manager: - if "prometheus" not in manager.services: + if "monitoring" not in manager.services: manager.services[ - "prometheus" - ] = "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/prometheus" + "monitoring" + ] = "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/monitoring" with WriteUserData() as data: - if "prometheus" not in data["modules"]: - data["modules"]["prometheus"] = { + if "monitoring" not in data["modules"]: + data["modules"]["monitoring"] = { "enable": False, - "subdomain": "prometheus", + "subdomain": "monitoring", } From e9cecd6789ade097406c089dc3746a7a6344fb92 Mon Sep 17 00:00:00 2001 From: nhnn Date: Wed, 24 Jul 2024 06:18:11 +0300 Subject: [PATCH 3/4] fix: remove subdomain property on monitoring --- selfprivacy_api/migrations/add_monitoring.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/selfprivacy_api/migrations/add_monitoring.py b/selfprivacy_api/migrations/add_monitoring.py index a6dbfde..b717808 100644 --- a/selfprivacy_api/migrations/add_monitoring.py +++ b/selfprivacy_api/migrations/add_monitoring.py @@ -31,6 +31,5 @@ class AddMonitoring(Migration): with WriteUserData() as data: if "monitoring" not in data["modules"]: data["modules"]["monitoring"] = { - "enable": False, - "subdomain": "monitoring", + "enable": True } From 7fd97fe0b29ded1e89e8fb01c35bb3f121641533 Mon Sep 17 00:00:00 2001 From: nhnn Date: Wed, 24 Jul 2024 15:02:56 +0300 Subject: [PATCH 4/4] fix: add location to monitoring migration --- selfprivacy_api/migrations/add_monitoring.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selfprivacy_api/migrations/add_monitoring.py b/selfprivacy_api/migrations/add_monitoring.py index b717808..965e234 100644 --- a/selfprivacy_api/migrations/add_monitoring.py +++ b/selfprivacy_api/migrations/add_monitoring.py @@ -2,6 +2,7 @@ from selfprivacy_api.migrations.migration import Migration from selfprivacy_api.services.flake_service_manager import FlakeServiceManager from selfprivacy_api.utils import ReadUserData, WriteUserData +from selfprivacy_api.utils.block_devices import BlockDevices class AddMonitoring(Migration): @@ -31,5 +32,6 @@ class AddMonitoring(Migration): with WriteUserData() as data: if "monitoring" not in data["modules"]: data["modules"]["monitoring"] = { - "enable": True + "enable": True, + "location": BlockDevices().get_root_block_device().name }