monitoring: add nixos-exporter to all hosts #26

Merged
torjus merged 1 commits from nixos-exporter into master 2026-02-06 22:56:05 +00:00
3 changed files with 76 additions and 127 deletions
Showing only changes of commit 97ff774d3f - Show all commits

21
flake.lock generated
View File

@@ -42,6 +42,26 @@
"url": "https://git.t-juice.club/torjus/labmon" "url": "https://git.t-juice.club/torjus/labmon"
} }
}, },
"nixos-exporter": {
"inputs": {
"nixpkgs": [
"nixpkgs-unstable"
]
},
"locked": {
"lastModified": 1770417341,
"narHash": "sha256-Js2EJZlpol6eSWVGyYy6SAhIISKHfURnD6S+NBaLfHU=",
"ref": "refs/heads/master",
"rev": "e381038537bbee314fb0326ac7d17ec4f651fe1e",
"revCount": 7,
"type": "git",
"url": "https://git.t-juice.club/torjus/nixos-exporter"
},
"original": {
"type": "git",
"url": "https://git.t-juice.club/torjus/nixos-exporter"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1770136044, "lastModified": 1770136044,
@@ -78,6 +98,7 @@
"inputs": { "inputs": {
"alerttonotify": "alerttonotify", "alerttonotify": "alerttonotify",
"labmon": "labmon", "labmon": "labmon",
"nixos-exporter": "nixos-exporter",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"sops-nix": "sops-nix" "sops-nix": "sops-nix"

151
flake.nix
View File

@@ -17,6 +17,10 @@
url = "git+https://git.t-juice.club/torjus/labmon?ref=master"; url = "git+https://git.t-juice.club/torjus/labmon?ref=master";
inputs.nixpkgs.follows = "nixpkgs-unstable"; inputs.nixpkgs.follows = "nixpkgs-unstable";
}; };
nixos-exporter = {
url = "git+https://git.t-juice.club/torjus/nixos-exporter";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
}; };
outputs = outputs =
@@ -27,6 +31,7 @@
sops-nix, sops-nix,
alerttonotify, alerttonotify,
labmon, labmon,
nixos-exporter,
... ...
}@inputs: }@inputs:
let let
@@ -42,6 +47,17 @@
alerttonotify.overlays.default alerttonotify.overlays.default
labmon.overlays.default labmon.overlays.default
]; ];
# Common modules applied to all hosts
commonModules = [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
sops-nix.nixosModules.sops
nixos-exporter.nixosModules.default
];
allSystems = [ allSystems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
@@ -58,15 +74,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/ns1 ./hosts/ns1
sops-nix.nixosModules.sops
]; ];
}; };
ns2 = nixpkgs.lib.nixosSystem { ns2 = nixpkgs.lib.nixosSystem {
@@ -74,15 +83,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/ns2 ./hosts/ns2
sops-nix.nixosModules.sops
]; ];
}; };
ha1 = nixpkgs.lib.nixosSystem { ha1 = nixpkgs.lib.nixosSystem {
@@ -90,15 +92,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/ha1 ./hosts/ha1
sops-nix.nixosModules.sops
]; ];
}; };
template1 = nixpkgs.lib.nixosSystem { template1 = nixpkgs.lib.nixosSystem {
@@ -106,15 +101,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/template ./hosts/template
sops-nix.nixosModules.sops
]; ];
}; };
template2 = nixpkgs.lib.nixosSystem { template2 = nixpkgs.lib.nixosSystem {
@@ -122,15 +110,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/template2 ./hosts/template2
sops-nix.nixosModules.sops
]; ];
}; };
http-proxy = nixpkgs.lib.nixosSystem { http-proxy = nixpkgs.lib.nixosSystem {
@@ -138,15 +119,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/http-proxy ./hosts/http-proxy
sops-nix.nixosModules.sops
]; ];
}; };
ca = nixpkgs.lib.nixosSystem { ca = nixpkgs.lib.nixosSystem {
@@ -154,15 +128,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/ca ./hosts/ca
sops-nix.nixosModules.sops
]; ];
}; };
monitoring01 = nixpkgs.lib.nixosSystem { monitoring01 = nixpkgs.lib.nixosSystem {
@@ -170,15 +137,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/monitoring01 ./hosts/monitoring01
sops-nix.nixosModules.sops
labmon.nixosModules.labmon labmon.nixosModules.labmon
]; ];
}; };
@@ -187,15 +147,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/jelly01 ./hosts/jelly01
sops-nix.nixosModules.sops
]; ];
}; };
nix-cache01 = nixpkgs.lib.nixosSystem { nix-cache01 = nixpkgs.lib.nixosSystem {
@@ -203,15 +156,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/nix-cache01 ./hosts/nix-cache01
sops-nix.nixosModules.sops
]; ];
}; };
pgdb1 = nixpkgs.lib.nixosSystem { pgdb1 = nixpkgs.lib.nixosSystem {
@@ -219,15 +165,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/pgdb1 ./hosts/pgdb1
sops-nix.nixosModules.sops
]; ];
}; };
nats1 = nixpkgs.lib.nixosSystem { nats1 = nixpkgs.lib.nixosSystem {
@@ -235,15 +174,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/nats1 ./hosts/nats1
sops-nix.nixosModules.sops
]; ];
}; };
testvm01 = nixpkgs.lib.nixosSystem { testvm01 = nixpkgs.lib.nixosSystem {
@@ -251,15 +183,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/testvm01 ./hosts/testvm01
sops-nix.nixosModules.sops
]; ];
}; };
vault01 = nixpkgs.lib.nixosSystem { vault01 = nixpkgs.lib.nixosSystem {
@@ -267,15 +192,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/vault01 ./hosts/vault01
sops-nix.nixosModules.sops
]; ];
}; };
vaulttest01 = nixpkgs.lib.nixosSystem { vaulttest01 = nixpkgs.lib.nixosSystem {
@@ -283,15 +201,8 @@
specialArgs = { specialArgs = {
inherit inputs self sops-nix; inherit inputs self sops-nix;
}; };
modules = [ modules = commonModules ++ [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/vaulttest01 ./hosts/vaulttest01
sops-nix.nixosModules.sops
]; ];
}; };
}; };

View File

@@ -18,4 +18,21 @@
"--systemd.collector.enable-ip-accounting" "--systemd.collector.enable-ip-accounting"
]; ];
}; };
services.prometheus.exporters.nixos = {
enable = true;
# Default port: 9971
flake = {
enable = true;
url = "git+https://git.t-juice.club/torjus/nixos-servers.git";
};
};
# Register nixos-exporter as a Prometheus scrape target
homelab.monitoring.scrapeTargets = [
{
job_name = "nixos-exporter";
port = 9971;
}
];
} }