diff --git a/grafana/dashboard-immich.json b/grafana/dashboard-immich.json index f43d21f..5527ad4 100644 --- a/grafana/dashboard-immich.json +++ b/grafana/dashboard-immich.json @@ -1,47 +1,4 @@ { - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "Prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "9.4.3" - }, - { - "type": "panel", - "id": "piechart", - "name": "Pie chart", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], "annotations": { "list": [ { @@ -67,14 +24,14 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": null, + "id": 11, "links": [], "liveNow": false, "panels": [ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -123,7 +80,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "exemplar": false, @@ -140,7 +97,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -190,7 +147,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_stats_user_count", @@ -205,7 +162,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -252,7 +209,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "sum(immich_server_stats_usage_by_users)", @@ -267,7 +224,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -314,7 +271,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_info_totalDiskSize", @@ -329,7 +286,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -376,7 +333,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_info_diskUse", @@ -391,7 +348,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -405,14 +362,6 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 10 - }, - { - "color": "#EAB839", - "value": 20 } ] }, @@ -446,7 +395,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "exemplar": false, @@ -465,7 +414,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -513,7 +462,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "exemplar": false, @@ -531,7 +480,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -579,10 +528,10 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", - "expr": "increase(immich_server_stats_usage_growth[7d])", + "expr": "increase(immich_server_stats_useage_growth[7d])", "legendFormat": "__auto", "range": true, "refId": "A" @@ -595,7 +544,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -647,7 +596,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_stats_usage_by_users", @@ -662,7 +611,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -710,7 +659,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_usage_growth[30h])", @@ -726,7 +675,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -774,10 +723,10 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", - "expr": "increase(immich_server_stats_usage_growth[365d])", + "expr": "increase(immich_server_stats_useage_growth[365d])", "legendFormat": "__auto", "range": true, "refId": "A" @@ -790,7 +739,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -835,7 +784,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_photos_growth[24h])", @@ -851,7 +800,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -896,7 +845,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_photos_growth[7d])", @@ -912,7 +861,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -964,7 +913,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "exemplar": false, @@ -981,7 +930,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1028,7 +977,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_photos_growth[4w])", @@ -1044,7 +993,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1091,7 +1040,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_photos_growth[52w])", @@ -1107,7 +1056,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "description": "amount of photos over time", "fieldConfig": { @@ -1118,14 +1067,13 @@ "custom": { "axisCenteredZero": false, "axisColorMode": "text", - "axisGridShow": true, "axisLabel": "", "axisPlacement": "right", "axisSoftMin": 9000, "barAlignment": 0, "drawStyle": "line", "fillOpacity": 30, - "gradientMode": "none", + "gradientMode": "opacity", "hideFrom": { "legend": false, "tooltip": false, @@ -1141,10 +1089,10 @@ "type": "linear" }, "showPoints": "never", - "spanNulls": false, + "spanNulls": true, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { "mode": "off" @@ -1187,7 +1135,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_stats_photos_by_users", @@ -1203,7 +1151,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1250,7 +1198,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_videos_growth[1d])", @@ -1266,7 +1214,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1293,7 +1241,7 @@ "y": 26 }, "hideTimeOverride": true, - "id": 44, + "id": 40, "options": { "colorMode": "value", "graphMode": "area", @@ -1313,23 +1261,23 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", - "expr": "increase(immich_server_stats_videos_growth[4w])\r\n", + "expr": "increase(immich_server_stats_videos_growth[1w])", "legendFormat": "__auto", "range": true, "refId": "A" } ], - "timeFrom": "now/M", - "title": "Monthly videos growth", + "timeFrom": "now/w", + "title": "weekly videos growth", "type": "stat" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1381,7 +1329,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_stats_videos_by_users", @@ -1396,7 +1344,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1423,7 +1371,7 @@ "y": 30 }, "hideTimeOverride": true, - "id": 40, + "id": 44, "options": { "colorMode": "value", "graphMode": "area", @@ -1443,23 +1391,23 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", - "expr": "increase(immich_server_stats_videos_growth[1w])", + "expr": "increase(immich_server_stats_videos_growth[4w])\r\n", "legendFormat": "__auto", "range": true, "refId": "A" } ], - "timeFrom": "now/w", - "title": "weekly videos growth", + "timeFrom": "now/M", + "title": "Monthly videos growth", "type": "stat" }, { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "fieldConfig": { "defaults": { @@ -1506,7 +1454,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "increase(immich_server_stats_videos_growth[52w])\r\n", @@ -1522,7 +1470,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "description": "amount of videos over time", "fieldConfig": { @@ -1538,7 +1486,7 @@ "barAlignment": 0, "drawStyle": "line", "fillOpacity": 30, - "gradientMode": "none", + "gradientMode": "opacity", "hideFrom": { "legend": false, "tooltip": false, @@ -1554,10 +1502,10 @@ "type": "linear" }, "showPoints": "never", - "spanNulls": false, + "spanNulls": true, "stacking": { "group": "A", - "mode": "none" + "mode": "normal" }, "thresholdsStyle": { "mode": "off" @@ -1599,7 +1547,7 @@ { "datasource": { "type": "prometheus", - "uid": "${DS_PROMETHEUS}" + "uid": "o-nLTb0Vz" }, "editorMode": "code", "expr": "immich_server_stats_videos_by_users", @@ -1629,6 +1577,6 @@ "timezone": "", "title": "immich", "uid": "ZWWp3aa4k", - "version": 7, + "version": 9, "weekStart": "" } \ No newline at end of file diff --git a/immich_exporter/exporter.py b/immich_exporter/exporter.py index e158007..ca0f0b5 100644 --- a/immich_exporter/exporter.py +++ b/immich_exporter/exporter.py @@ -215,15 +215,19 @@ class ImmichMetricsCollector: server_version_endpoint = "/api/server-info/version" response_server_version = "" - try: + for i in range(0, 360): + while True: + try: - response_server_version = requests.request( - "GET", - self.combine_url(server_version_endpoint), - headers={'Accept': 'application/json'} - ) - except requests.exceptions.RequestException as e: - logger.error(f"Couldn't get server version: {e}") + response_server_version = requests.request( + "GET", + self.combine_url(server_version_endpoint), + headers={'Accept': 'application/json'} + ) + except requests.exceptions.RequestException as e: + logger.error(f"Couldn't get server version: {e}") + continue + break server_version_number = (str(response_server_version.json()["major"]) + "." + str(response_server_version.json()["minor"]) + "." +