feat: add prometheus monitoring service

This commit is contained in:
nhnn 2024-06-09 21:04:14 +03:00 committed by Inex Code
parent affce115f1
commit 26c9fd5f6e
3 changed files with 43 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,31 @@
{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;
exporters = {
node = {
enable = true;
enabledCollectors = [ "systemd" ];
port = 9002;
};
};
scrapeConfigs = [
{
job_name = "node-exporter";
static_configs = [{
targets = [ "127.0.0.1:9002" ];
}];
}
];
};
};
}