From 3e7c2a0f4c4f92eb628a69760e05e00c8bd0530d Mon Sep 17 00:00:00 2001 From: friendlyFriend Date: Sat, 25 Nov 2023 19:25:23 +0100 Subject: [PATCH] changed deprecreated entry points api/stats to /api/statistics --- .idea/misc.xml | 2 +- .idea/prometheus-immich-exporter.iml | 6 ++++-- immich_exporter/exporter.py | 24 +++++++++++++----------- setup.py | 3 ++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index ab530bf..e82613a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/prometheus-immich-exporter.iml b/.idea/prometheus-immich-exporter.iml index d870a4a..0e580b8 100644 --- a/.idea/prometheus-immich-exporter.iml +++ b/.idea/prometheus-immich-exporter.iml @@ -1,8 +1,10 @@ - - + + + + \ No newline at end of file diff --git a/immich_exporter/exporter.py b/immich_exporter/exporter.py index a36d390..e7cce81 100644 --- a/immich_exporter/exporter.py +++ b/immich_exporter/exporter.py @@ -52,7 +52,7 @@ def get_immich_metrics(self): def get_immich_users_stat_growth(self): try: - endpoint_user_stats = "/api/server-info/stats" + endpoint_user_stats = "/api/server-info/statistics" response_user_stats = requests.request( "GET", self.combine_url(endpoint_user_stats), @@ -105,7 +105,7 @@ def get_immich_users_stat(self): global response_user_stats try: - endpoint_user_stats = "/api/server-info/stats" + endpoint_user_stats = "/api/server-info/statistics" response_user_stats = requests.request( "GET", self.combine_url(endpoint_user_stats), @@ -113,7 +113,9 @@ def get_immich_users_stat(self): "x-api-key": self.config["token"]} ) except requests.exceptions.RequestException as e: - logger.error(f"Couldn't get server version: {e}") + logger.error(f"API ERROR: can't get server statistic: {e}") + logger.info(f"API TOKEN CORRECT?") + logger.info(f"API ENDPOINT CHANGED?") metrics = [] # To get the user count an api-endpoint exists but this works too. As a result one less api call is being made @@ -133,10 +135,10 @@ def get_immich_users_stat(self): "name": f"{self.config['metrics_prefix']}_server_stats_photos_by_users", "value": userData[x]['photos'], "labels": { - "firstName": userData[x]["userFirstName"], + "firstName": userData[x]["userName"], }, - "help": f"Number of photos by user {userData[x]['userFirstName']} " + "help": f"Number of photos by user {userData[x]['userName']} " } ) @@ -148,10 +150,10 @@ def get_immich_users_stat(self): "name": f"{self.config['metrics_prefix']}_server_stats_videos_by_users", "value": userData[x]['videos'], "labels": { - "firstName": userData[x]["userFirstName"], + "firstName": userData[x]["userName"], }, - "help": f"Number of photos by user {userData[x]['userFirstName']} " + "help": f"Number of photos by user {userData[x]['userName']} " } ) @@ -162,10 +164,10 @@ def get_immich_users_stat(self): "name": f"{self.config['metrics_prefix']}_server_stats_usage_by_users", "value": (userData[x]['usage']), "labels": { - "firstName": userData[x]["userFirstName"], + "firstName": userData[x]["userName"], }, - "help": f"Number of photos by user {userData[x]['userFirstName']} " + "help": f"Number of photos by user {userData[x]['userName']} " } ) @@ -317,7 +319,7 @@ def check_server_up(immichHost, immichPort): continue break logger.info(f"Found immich up and running at " + immichHost + ":" + immichPort + ".") - logger.info(f"Attempting to connect") + logger.info(f"Attempting to connect to immich") time.sleep(1) logger.info("Exporter v1.0.6") @@ -338,7 +340,7 @@ def check_immich_api_key(immichHost, immichPort, immichApiKey): logger.error({e}) time.sleep(3) continue - logger.info(f"Connected to immich successfully") + logger.info(f"Success.") break diff --git a/setup.py b/setup.py index c86a61f..dff7667 100644 --- a/setup.py +++ b/setup.py @@ -6,10 +6,11 @@ setup( name='prometheus-immich-exporter', packages=['immich_exporter'], - version='1.0.6', + version='1.0.7', long_description=long_description, long_description_content_type="text/markdown", description='Prometheus exporter for immich', + # forked from: # author='Esteban Sanchez', # author_email='esteban.sanchez@gmail.com', # url='https://github.com/esanchezm/prometheus-qbittorrent-exporter',