feat: Added grafana

This commit is contained in:
2026-02-01 19:51:51 +05:30
parent 56f1ba896c
commit 2f901052f1
9 changed files with 682 additions and 12 deletions

View File

@@ -14,6 +14,11 @@
services = {
caddy = {
enable = true;
globalConfig = ''
servers {
metrics
}
'';
extraConfig = ''
(cloudflare) {
tls {

View File

@@ -1,11 +1,28 @@
{...}: {
{pkgs, ...}: let
# Port configurations
ports = {
# System exporters
node = 9100;
systemd = 9558;
process = 9256;
nvidiagpu = 9835;
# Infrastructure exporters
cadvisor = 8080;
caddy = 2019;
};
in {
services = {
prometheus = {
exporters = {
systemd = {
enable = true;
port = ports.systemd;
};
nvidia-gpu = {
enable = true;
port = ports.nvidiagpu;
};
nvidia-gpu.enable = true;
node = {
enable = true;
enabledCollectors = [
@@ -19,7 +36,10 @@
"time"
"uname"
"vmstat"
"diskstats"
"cpu"
];
port = ports.node;
};
process = {
enable = true;
@@ -33,4 +53,34 @@
};
};
};
# Docker cAdvisor for container metrics
virtualisation.oci-containers.containers.cadvisor = {
image = "gcr.io/cadvisor/cadvisor:v0.49.1";
ports = ["${toString ports.cadvisor}:8080"];
volumes = [
"/:/rootfs:ro"
"/var/run:/var/run:ro"
"/sys:/sys:ro"
"/var/lib/docker/:/var/lib/docker:ro"
"/dev/disk/:/dev/disk:ro"
];
extraOptions = [
"--privileged"
"--device=/dev/kmsg"
];
};
# Open firewall ports for Prometheus exporters
networking.firewall = {
# Allow from Tailscale network
interfaces."tailscale0".allowedTCPPorts = [
ports.node
ports.systemd
ports.process
ports.nvidiagpu
ports.cadvisor
ports.caddy
];
};
}