summaryrefslogtreecommitdiffstats
path: root/hosts/poweredge/metrics.nix
blob: edf3da98ce7072d2b1b9ab63c0e26bca5ace755d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ config, inputs, ... }: {
	imports = [ inputs.telemetry.nixosModules.collectors ];

	services.telemetry.collectors = {
		enable = true;
		logs.lokiUrl = "http://metrics:3100";  # The container
	};

	containers.metrics = {
		autoStart = true;
		privateNetwork = true;
		hostBridge = "br-lan0";
		localMacAddress = "02:00:00:00:00:06";
		ephemeral = true;

		# The module reads whatever path you point secretKeyFile at.
		bindMounts = {
			"/var/lib/prometheus2" = { hostPath = "/nix/persist/metrics/prometheus2"; isReadOnly = false; };
			"/var/lib/loki"        = { hostPath = "/nix/persist/metrics/loki"; isReadOnly = false; };
			"/var/lib/grafana"     = { hostPath = "/nix/persist/metrics/grafana"; isReadOnly = false; };
		};

		config = { ... }: {
			imports = [ inputs.telemetry.nixosModules.server ];

			networking.enableIPv6 = false;
			networking.interfaces.eth0.useDHCP = true;

			services.telemetry.server = {
				enable = true;
				collectorHosts = [ "poweredge" ];
				grafana.generateSecretKey = true;
				proxy.enable = true;
			};

			# Pin loki uid+gid
			users.users.loki = { uid = 3100; group = "loki"; isSystemUser = true; };
			users.groups.loki.gid = 3100;

			system.stateVersion = "26.05";
		};
	};
}