fixed metrics to display values properly

This commit is contained in:
friendly Friend 2023-03-14 16:01:48 -07:00
parent c4af398b90
commit 4248c8f2f2

View file

@ -3,7 +3,7 @@ import os
import sys import sys
import signal import signal
import faulthandler import faulthandler
from typing import re
import requests import requests
from attrdict import AttrDict from attrdict import AttrDict
@ -45,7 +45,7 @@ class QbittorrentMetricsCollector():
def get_immich_metrics(self): def get_immich_metrics(self):
metrics = [] metrics = []
metrics.extend(self.get_immich_server_version_number()) metrics.extend(self.get_immich_server_version_number())
# metrics.extend(self.get_immich_server_info()) metrics.extend(self.get_immich_server_info())
return metrics return metrics
@ -65,22 +65,28 @@ class QbittorrentMetricsCollector():
return [ return [
{ {
"name": f"{self.config['metrics_prefix']}_dht_nodes", "name": f"{self.config['metrics_prefix']}_diskAvailable",
"value": str(response_server_info.json()["diskAvailable"]), "value": str(response_server_info.json()["diskAvailableRaw"]),
"help": "Available space on disk", "help": "Available space on disk",
}, },
{ {
"name": f"{self.config['metrics_prefix']}_dl_info_data", "name": f"{self.config['metrics_prefix']}_totalDiskSize",
"value": str(response_server_info.json()["diskSize"]), "value": str(response_server_info.json()["diskSizeRaw"]),
"help": "Disk size", "help": "tota disk size",
#"type": "counter" #"type": "counter"
}, },
{ {
"name": f"{self.config['metrics_prefix']}_up_info_data", "name": f"{self.config['metrics_prefix']}_diskUse",
"value": str(response_server_info.json()["diskUse"]), "value": str(response_server_info.json()["diskUseRaw"]),
"help": "disk space in use", "help": "disk space in use",
#"type": "counter" #"type": "counter"
}, },
{
"name": f"{self.config['metrics_prefix']}_diskUsagePercentage",
"value": str(response_server_info.json()["diskUsagePercentage"]),
"help": "disk usage in percent",
# "type": "counter"
}
] ]
def get_immich_server_version_number(self): def get_immich_server_version_number(self):
@ -97,18 +103,18 @@ class QbittorrentMetricsCollector():
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}")
server_version_number = ( str(response_server_version.json()["major"]) + "_" + server_version_number = ( str(response_server_version.json()["major"]) + "." +
str(response_server_version.json()["minor"]) + "_" + str(response_server_version.json()["minor"]) + "." +
str(response_server_version.json()["patch"]) str(response_server_version.json()["patch"])
) )
return [ return [
{ {
"name": f"{self.config['metrics_prefix']}_up_info_data", "name": f"{self.config['metrics_prefix']}_version_number",
"value": server_version_number, "value": bool(server_version_number),
"help": "server version number", "help": "server version number",
"labels": {"version": server_version_number}
} }
] ]