grafana init

This commit is contained in:
mjallen18
2025-01-22 11:55:46 -06:00
parent d243f3e8f7
commit 1eca478a7b
6 changed files with 94 additions and 70 deletions

30
flake.lock generated
View File

@@ -237,11 +237,11 @@
]
},
"locked": {
"lastModified": 1737478403,
"narHash": "sha256-e6PJI4Bd+QdpukHyd5F/fQY8fRUiNfCwvCRU8WXMSk8=",
"lastModified": 1737299337,
"narHash": "sha256-0NBrY2A7buujKmeCbieopOMSbLxTu8TFcTLqAbTnQDw=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "96dee79b178d295b716052feca3ee46abc085abe",
"rev": "f8ef4541bb8a54a8b52f19b52912119e689529b3",
"type": "github"
},
"original": {
@@ -363,11 +363,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1737423230,
"narHash": "sha256-WEOiNmkcmlaeXy2HGW1PYxYmCPiHdsI7a7SpjhBYxRg=",
"lastModified": 1737162735,
"narHash": "sha256-5T+HkouTMGaRm0rh3kgD4Z1O7ONKfgjyoPQH5rSyreU=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "46d0fa4ded0a7532f19870f9bbedaf62269fe3f7",
"rev": "87131f51f8256952d1a306b5521cedc2dc61aa08",
"type": "github"
},
"original": {
@@ -420,11 +420,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1737359802,
"narHash": "sha256-utplyRM6pqnN940gfaLFBb9oUCSzkan86IvmkhsVlN8=",
"lastModified": 1736978406,
"narHash": "sha256-oMr3PVIQ8XPDI8/x6BHxsWEPBRU98Pam6KGVwUh8MPk=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "61c79181e77ef774ab0468b28a24bc2647d498d6",
"rev": "b678606690027913f3434dea3864e712b862dde5",
"type": "github"
},
"original": {
@@ -480,11 +480,11 @@
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1737299813,
"narHash": "sha256-Qw2PwmkXDK8sPQ5YQ/y/icbQ+TYgbxfjhgnkNJyT1X8=",
"lastModified": 1737165118,
"narHash": "sha256-s40Kk/OulP3J/1JvC3VT16U4r/Xw6Qdi7SRw3LYkPWs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "107d5ef05c0b1119749e381451389eded30fb0d5",
"rev": "6a3ae7a5a12fb8cac2d59d7df7cbd95f9b2f0566",
"type": "github"
},
"original": {
@@ -664,11 +664,11 @@
]
},
"locked": {
"lastModified": 1737411508,
"narHash": "sha256-j9IdflJwRtqo9WpM0OfAZml47eBblUHGNQTe62OUqTw=",
"lastModified": 1737107480,
"narHash": "sha256-GXUE9+FgxoZU8v0p6ilBJ8NH7k8nKmZjp/7dmMrCv3o=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "015d461c16678fc02a2f405eb453abb509d4e1d4",
"rev": "4c4fb93f18b9072c6fa1986221f9a3d7bf1fe4b6",
"type": "github"
},
"original": {

View File

@@ -14,6 +14,7 @@
# Authentik
authentik-nix = {
url = "github:nix-community/authentik-nix";
# url = "github:fpletz/authentik-nix/24.11"; # for some reason this is broken in stable and unstable
inputs.nixpkgs.follows = "nixpkgs-stable";
};

View File

@@ -48,12 +48,25 @@ in
asDefault = true;
http.tls.certResolver = "letsencrypt";
};
metrics = {
address = ":8082"; # Port for metrics
};
};
log = {
level = "INFO";
};
metrics = {
prometheus = {
entryPoint = "metrics";
addEntryPointsLabels = true;
addServicesLabels = true;
buckets = [0.1 0.3 1.2 5.0]; # Response time buckets
};
};
certificatesResolvers.letsencrypt.acme = {
email = "jalle008@proton.me";
storage = "${config.services.traefik.dataDir}/acme.json";

View File

@@ -19,6 +19,7 @@ in
./filesystems.nix
./boot.nix
./apps.nix
./grafana.nix
./networking.nix
./ups.nix
./samba.nix
@@ -34,7 +35,7 @@ in
# Cockpit
services.cockpit = {
enable = true;
enable = false;
port = 9090;
settings = {
WebService = {

62
hosts/nas/grafana.nix Normal file
View File

@@ -0,0 +1,62 @@
{ config, ... }:
{
services = {
prometheus = {
enable = true;
exporters = {
node = {
enable = true;
enabledCollectors = [
"filesystem"
"diskstats"
"meminfo"
"cpu"
"systemd" # Ensures systemd collector is enabled
"processes"
];
extraFlags = [
"--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|run)($|/)"
];
};
};
scrapeConfigs = [
{
job_name = "node";
static_configs = [{
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
}];
}
{
job_name = "traefik";
static_configs = [{
targets = [ "localhost:8082" ];
}];
}
];
};
grafana = {
enable = true;
settings = {
server = {
http_port = 9999;
http_addr = "0.0.0.0";
};
};
dataDir = "/media/nas/ssd/nix-app-data/grafana";
provision = {
enable = true;
datasources.settings.datasources = [{
name = "Prometheus";
type = "prometheus";
access = "proxy";
url = "http://localhost:${toString config.services.prometheus.port}";
}];
};
};
};
# Open firewall ports for Grafana
networking.firewall.allowedTCPPorts = [ 9999 ];
}

View File

@@ -200,65 +200,12 @@ in
};
};
grafana = {
enable = false;
settings.server = {
http_port = 2342;
domain = "10.0.1.18";
serve_from_sub_path = true;
http_addr = "";
};
dataDir = "/media/nas/ssd/nix-app-data/grafana";
};
nix-serve = {
enable = false;
secretKeyFile = "/var/cache-priv-key.pem";
};
prometheus = {
enable = false;
port = 8000;
exporters = {
node = {
enable = true;
enabledCollectors = [
"diskstats"
"systemd"
];
port = 8001;
};
smartctl = {
enable = true;
group = "disk";
devices = [
"/dev/mapper/ssd1"
"/dev/mapper/ssd2"
"/dev/mapper/hdd1"
"/dev/mapper/hdd2"
"/dev/mapper/hdd3"
"/dev/mapper/hdd4"
"/dev/mapper/hdd5"
];
};
};
scrapeConfigs = [
{
job_name = "jallen-nas";
static_configs = [
{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
"127.0.0.1:${toString config.services.prometheus.exporters.smartctl.port}"
];
}
];
}
];
};
};
systemd.user.services = {
protonmail-bridge = {
description = "Protonmail Bridge";