fixed api headers requirement

This commit is contained in:
friendly Friend 2023-07-19 22:05:08 -07:00
parent a07d53249a
commit f5f3926e0f

View file

@ -49,7 +49,6 @@ class ImmichMetricsCollector:
def get_immich_users_stat_growth(self): def get_immich_users_stat_growth(self):
try: try:
endpoint_user_stats = "/api/server-info/stats" endpoint_user_stats = "/api/server-info/stats"
response_user_stats = requests.request( response_user_stats = requests.request(
@ -102,7 +101,6 @@ class ImmichMetricsCollector:
@property @property
def get_immich_users_stat(self): def get_immich_users_stat(self):
global response_user_stats global response_user_stats
try: try:
endpoint_user_stats = "/api/server-info/stats" endpoint_user_stats = "/api/server-info/stats"
@ -179,7 +177,8 @@ class ImmichMetricsCollector:
response_server_info = requests.request( response_server_info = requests.request(
"GET", "GET",
self.combine_url(endpoint_server_info), 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: except requests.exceptions.RequestException as e:
logger.error(f"Couldn't get server version: {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", "name": f"{self.config['metrics_prefix']}_server_info_totalDiskSize",
"value": (response_server_info.json()["diskSizeRaw"]), "value": (response_server_info.json()["diskSizeRaw"]),
"help": "tota disk size", "help": "total disk size",
# "type": "counter" # "type": "counter"
}, },
{ {
@ -222,7 +221,8 @@ class ImmichMetricsCollector:
response_server_version = requests.request( response_server_version = requests.request(
"GET", "GET",
self.combine_url(server_version_endpoint), 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: except requests.exceptions.RequestException as e:
logger.error(f"Couldn't get server version: {e}") logger.error(f"Couldn't get server version: {e}")