init prometheus module
This commit is contained in:
parent
079ece082a
commit
4e9bf3ebac
2 changed files with 49 additions and 0 deletions
|
@ -3,5 +3,6 @@
|
|||
imports = [
|
||||
./restic.nix
|
||||
./vaultwarden.nix
|
||||
./prometheus.nix
|
||||
];
|
||||
}
|
48
modules/nixos/prometheus.nix
Normal file
48
modules/nixos/prometheus.nix
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.custom.prometheus;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
custom.prometheus = {
|
||||
enable = mkEnableOption "Prometheus instance";
|
||||
exporters = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable Prometheus exporter on every supported services";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
services.prometheus = mkIf cfg.enable {
|
||||
enable = true;
|
||||
port = 9091;
|
||||
exporters = {
|
||||
node = {
|
||||
enable = true;
|
||||
enabledCollectors = [ "systemd" ];
|
||||
port = 9100;
|
||||
};
|
||||
};
|
||||
scrapeConfigs = [
|
||||
{ job_name = "prometheus";
|
||||
static_configs = [
|
||||
{ targets = [ "localhost:${toString config.services.prometheus.port}" ]; }
|
||||
];
|
||||
}
|
||||
{ job_name = "node";
|
||||
static_configs = [
|
||||
{ targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ]; }
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue