mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git
synced 2024-11-29 06:01:28 +00:00
feat: add prometheus monitoring service
This commit is contained in:
parent
affce115f1
commit
26c9fd5f6e
3
sp-modules/monitoring/config-paths-needed.json
Normal file
3
sp-modules/monitoring/config-paths-needed.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[
|
||||||
|
[ "selfprivacy", "modules", "monitoring" ]
|
||||||
|
]
|
9
sp-modules/monitoring/flake.nix
Normal file
9
sp-modules/monitoring/flake.nix
Normal 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);
|
||||||
|
};
|
||||||
|
}
|
31
sp-modules/monitoring/module.nix
Normal file
31
sp-modules/monitoring/module.nix
Normal 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" ];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue