Skip to content

Commit

Permalink
changed deprecreated entry points api/stats to /api/statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlyFriend4000 committed Nov 25, 2023
1 parent c23ad91 commit 3e7c2a0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions .idea/prometheus-immich-exporter.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions immich_exporter/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -105,15 +105,17 @@ 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),
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}")
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
Expand All @@ -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']} "

}
)
Expand All @@ -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']} "

}
)
Expand All @@ -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']} "

}
)
Expand Down Expand Up @@ -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")

Expand All @@ -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


Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
# url='https://github.com/esanchezm/prometheus-qbittorrent-exporter',
Expand Down

0 comments on commit 3e7c2a0

Please sign in to comment.