grafana: test
All checks were successful
Build and Deploy / deploy (push) Successful in 2m40s

This commit is contained in:
2026-03-31 15:18:51 -04:00
parent 0027489052
commit b9cd380a22
7 changed files with 650 additions and 7 deletions

View File

@@ -38,6 +38,17 @@ let
'';
};
intelGpuCollector = pkgs.writeShellApplication {
name = "intel-gpu-collector";
runtimeInputs = with pkgs; [
python3
intel-gpu-tools
];
text = ''
exec python3 ${./intel-gpu-collector.py}
'';
};
dashboard = {
editable = true;
graphTooltip = 1;
@@ -54,6 +65,21 @@ let
title = "System Overview";
uid = "system-overview";
annotations.list = [
{
name = "Jellyfin Streams";
datasource = {
type = "grafana";
uid = "-- Grafana --";
};
enable = true;
iconColor = "green";
showIn = 0;
type = "tags";
tags = [ "jellyfin" ];
}
];
panels = [
# -- Row 1: UPS --
{
@@ -415,6 +441,134 @@ let
graphMode = "area";
};
}
# -- Row 3: Intel GPU --
{
id = 8;
type = "timeseries";
title = "Intel GPU Utilization";
gridPos = {
h = 8;
w = 18;
x = 0;
y = 16;
};
datasource = promDs;
targets = [
{
datasource = promDs;
expr = "intel_gpu_engine_busy_percent";
legendFormat = "{{engine}}";
refId = "A";
}
];
fieldConfig = {
defaults = {
unit = "percent";
min = 0;
max = 100;
color.mode = "palette-classic";
custom = {
lineWidth = 2;
fillOpacity = 10;
spanNulls = true;
};
};
overrides = [ ];
};
}
{
id = 9;
type = "stat";
title = "GPU Frequency";
gridPos = {
h = 4;
w = 6;
x = 18;
y = 16;
};
datasource = promDs;
targets = [
{
datasource = promDs;
expr = "intel_gpu_frequency_mhz";
refId = "A";
}
];
fieldConfig = {
defaults = {
unit = "megahertz";
thresholds = {
mode = "absolute";
steps = [
{
color = "green";
value = null;
}
];
};
};
overrides = [ ];
};
options = {
reduceOptions = {
calcs = [ "lastNotNull" ];
fields = "";
values = false;
};
colorMode = "value";
graphMode = "area";
};
}
{
id = 10;
type = "stat";
title = "GPU RC6 (idle)";
gridPos = {
h = 4;
w = 6;
x = 18;
y = 20;
};
datasource = promDs;
targets = [
{
datasource = promDs;
expr = "intel_gpu_rc6_percent";
refId = "A";
}
];
fieldConfig = {
defaults = {
unit = "percent";
min = 0;
max = 100;
thresholds = {
mode = "absolute";
steps = [
{
color = "blue";
value = null;
}
{
color = "green";
value = 50;
}
];
};
};
overrides = [ ];
};
options = {
reduceOptions = {
calcs = [ "lastNotNull" ];
fields = "";
values = false;
};
colorMode = "value";
graphMode = "none";
};
}
];
};
in
@@ -500,7 +654,6 @@ in
root_url = "https://${service_configs.grafana.domain}";
};
# Caddy handles auth -- disable Grafana login entirely
"auth.anonymous" = {
enabled = true;
org_role = "Admin";
@@ -539,21 +692,17 @@ in
};
};
# Provision dashboard JSON
environment.etc."grafana-dashboards/system-overview.json" = {
text = builtins.toJSON dashboard;
mode = "0444";
};
# Caddy reverse proxy with auth
services.caddy.virtualHosts."${service_configs.grafana.domain}".extraConfig = ''
import ${config.age.secrets.caddy_auth.path}
reverse_proxy :${builtins.toString service_configs.ports.private.grafana.port}
'';
# -- Jellyfin metrics collector --
# Queries the Jellyfin API for active streams and writes a .prom file
# for the node_exporter textfile collector.
# -- Jellyfin active-stream prometheus textfile collector --
systemd.services.jellyfin-metrics-collector = {
description = "Collect Jellyfin metrics for Prometheus";
after = [ "network.target" ];
@@ -572,7 +721,24 @@ in
};
};
# Ensure textfile collector directory exists (tmpfs root -- recreated on boot)
# -- Intel GPU textfile collector --
systemd.services.intel-gpu-collector = {
description = "Collect Intel GPU metrics for Prometheus";
serviceConfig = {
Type = "oneshot";
ExecStart = lib.getExe intelGpuCollector;
};
environment.TEXTFILE = "${textfileDir}/intel-gpu.prom";
};
systemd.timers.intel-gpu-collector = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*:*:0/30";
RandomizedDelaySec = "10s";
};
};
systemd.tmpfiles.rules = [
"d ${textfileDir} 0755 root root -"
];