Merge pull request 'add prometheus-based monitoring service' (#66) from nhnn/selfprivacy-nixos-config:monitoring into flakes

Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config/pulls/66
This commit is contained in:
Inex Code 2024-07-15 17:10:33 +03:00
commit ea207b48d6
3 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,3 @@
[
[ "selfprivacy", "modules", "monitoring" ]
]

View file

@ -0,0 +1,9 @@
{
description = "PoC SP module for Prometheus-based monitoring";
outputs = { self }: {
nixosModules.default = import ./module.nix;
configPathsNeeded =
builtins.fromJSON (builtins.readFile ./config-paths-needed.json);
};
}

View file

@ -0,0 +1,33 @@
{config, lib, ...}: let
cfg = config.selfprivacy.modules.monitoring;
in {
options.selfprivacy.modules.monitoring = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
};
config = lib.mkIf cfg.enable {
services.prometheus = {
enable = true;
port = 9001;
listenAddress = "127.0.0.1";
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
listenAddress = "127.0.0.1";
};
};
scrapeConfigs = [
{
job_name = "node-exporter";
static_configs = [{
targets = [ "127.0.0.1:9002" ];
}];
}
];
};
};
}