From f5f3926e0f8f74436ed9652348009bef956f9c9f Mon Sep 17 00:00:00 2001 From: friendly Friend Date: Wed, 19 Jul 2023 22:05:08 -0700 Subject: [PATCH] fixed api headers requirement --- immich_exporter/exporter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/immich_exporter/exporter.py b/immich_exporter/exporter.py index ca0f0b5..f752ce8 100644 --- a/immich_exporter/exporter.py +++ b/immich_exporter/exporter.py @@ -49,7 +49,6 @@ class ImmichMetricsCollector: def get_immich_users_stat_growth(self): - try: endpoint_user_stats = "/api/server-info/stats" response_user_stats = requests.request( @@ -102,7 +101,6 @@ class ImmichMetricsCollector: @property def get_immich_users_stat(self): - global response_user_stats try: endpoint_user_stats = "/api/server-info/stats" @@ -179,7 +177,8 @@ class ImmichMetricsCollector: response_server_info = requests.request( "GET", self.combine_url(endpoint_server_info), - headers={'Accept': 'application/json'} + headers={'Accept': 'application/json', + "x-api-key": self.config["token"]} ) except requests.exceptions.RequestException as e: logger.error(f"Couldn't get server version: {e}") @@ -193,7 +192,7 @@ class ImmichMetricsCollector: { "name": f"{self.config['metrics_prefix']}_server_info_totalDiskSize", "value": (response_server_info.json()["diskSizeRaw"]), - "help": "tota disk size", + "help": "total disk size", # "type": "counter" }, { @@ -222,7 +221,8 @@ class ImmichMetricsCollector: response_server_version = requests.request( "GET", self.combine_url(server_version_endpoint), - headers={'Accept': 'application/json'} + headers={'Accept': 'application/json', + "x-api-key": self.config["token"]} ) except requests.exceptions.RequestException as e: logger.error(f"Couldn't get server version: {e}")