Refactor Intel Stats (#22674)

* Improve Intel stats collection

* Update handling of stats to be simpler

* Simplify handling

* More accurately label Intel stats

* Cleanup

* Remove
This commit is contained in:
Nicolas Mowen
2026-03-29 12:09:02 -05:00
committed by GitHub
parent 29ca18c24c
commit 831cfc2444
8 changed files with 180 additions and 81 deletions
+21
View File
@@ -355,16 +355,37 @@ class CustomCollector(object):
gpu_mem_usages = GaugeMetricFamily(
"frigate_gpu_mem_usage_percent", "GPU memory usage %", labels=["gpu_name"]
)
gpu_enc_usages = GaugeMetricFamily(
"frigate_gpu_encoder_usage_percent",
"GPU encoder utilisation %",
labels=["gpu_name"],
)
gpu_compute_usages = GaugeMetricFamily(
"frigate_gpu_compute_usage_percent",
"GPU compute / encode utilisation %",
labels=["gpu_name"],
)
gpu_dec_usages = GaugeMetricFamily(
"frigate_gpu_decoder_usage_percent",
"GPU decoder utilisation %",
labels=["gpu_name"],
)
try:
for gpu_name, gpu_stats in stats["gpu_usages"].items():
self.add_metric(gpu_usages, [gpu_name], gpu_stats, "gpu")
self.add_metric(gpu_mem_usages, [gpu_name], gpu_stats, "mem")
self.add_metric(gpu_enc_usages, [gpu_name], gpu_stats, "enc")
self.add_metric(gpu_compute_usages, [gpu_name], gpu_stats, "compute")
self.add_metric(gpu_dec_usages, [gpu_name], gpu_stats, "dec")
except KeyError:
pass
yield gpu_usages
yield gpu_mem_usages
yield gpu_enc_usages
yield gpu_compute_usages
yield gpu_dec_usages
# service stats
uptime_seconds = GaugeMetricFamily(
+17 -29
View File
@@ -261,45 +261,33 @@ async def set_gpu_stats(
else:
stats["jetson-gpu"] = {"gpu": "", "mem": ""}
hwaccel_errors.append(args)
elif "qsv" in args:
elif "qsv" in args or ("vaapi" in args and not is_vaapi_amd_driver()):
if not config.telemetry.stats.intel_gpu_stats:
continue
# intel QSV GPU
intel_usage = get_intel_gpu_stats(config.telemetry.stats.intel_gpu_device)
if intel_usage is not None:
stats["intel-qsv"] = intel_usage or {"gpu": "", "mem": ""}
else:
stats["intel-qsv"] = {"gpu": "", "mem": ""}
hwaccel_errors.append(args)
elif "vaapi" in args:
if is_vaapi_amd_driver():
if not config.telemetry.stats.amd_gpu_stats:
continue
# AMD VAAPI GPU
amd_usage = get_amd_gpu_stats()
if amd_usage:
stats["amd-vaapi"] = amd_usage
else:
stats["amd-vaapi"] = {"gpu": "", "mem": ""}
hwaccel_errors.append(args)
else:
if not config.telemetry.stats.intel_gpu_stats:
continue
# intel VAAPI GPU
if "intel-gpu" not in stats:
# intel GPU (QSV or VAAPI both use the same physical GPU)
intel_usage = get_intel_gpu_stats(
config.telemetry.stats.intel_gpu_device
)
if intel_usage is not None:
stats["intel-vaapi"] = intel_usage or {"gpu": "", "mem": ""}
stats["intel-gpu"] = intel_usage or {"gpu": "", "mem": ""}
else:
stats["intel-vaapi"] = {"gpu": "", "mem": ""}
stats["intel-gpu"] = {"gpu": "", "mem": ""}
hwaccel_errors.append(args)
elif "vaapi" in args:
if not config.telemetry.stats.amd_gpu_stats:
continue
# AMD VAAPI GPU
amd_usage = get_amd_gpu_stats()
if amd_usage:
stats["amd-vaapi"] = amd_usage
else:
stats["amd-vaapi"] = {"gpu": "", "mem": ""}
hwaccel_errors.append(args)
elif "preset-rk" in args:
rga_usage = get_rockchip_gpu_stats()