prometheus: added but not enabled yet

This commit is contained in:
Tigor Hutasuhut 2024-09-10 16:34:58 +07:00
parent 26cb5919fa
commit 61bbceb2cf
4 changed files with 55 additions and 1 deletions

View file

@ -55,6 +55,10 @@ in
type = types.bool;
default = config.profile.services.telemetry.enable;
};
prometheus.enable = mkOption {
type = types.bool;
default = config.profile.services.telemetry.enable;
};
};
};
}

View file

@ -3,7 +3,6 @@ let
cfg = config.profile.services.telemetry.alloy;
webguiListenAddress = "0.0.0.0:5319";
domain = "alloy.tigor.web.id";
inherit (lib.strings) optionalString;
in
{
imports = [

View file

@ -6,5 +6,6 @@
./tempo.nix
./alloy.nix
./mimir.nix
./prometheus.nix
];
}

View file

@ -0,0 +1,50 @@
{ config, lib, ... }:
let
cfg = config.profile.services.telemetry.prometheus;
inherit (lib) mkIf;
in
{
config = mkIf cfg.enable {
services.prometheus = {
enable = false;
port = 0; # Random
enableAgentMode = true;
globalConfig = {
external_labels = {
instance = "homeserver";
};
};
remoteWrite =
let
mimirServer = config.services.mimir.configuration.server;
in
[
{
url = "http://${mimirServer.http_listen_address}:${toString mimirServer.http_listen_port}/api/v1/push";
}
];
scrapeConfigs = [
{
job_name = "systemd";
static_configs = [{
labels = {
job = "systemd";
};
targets =
let
systemdExporter = config.services.prometheus.exporters.systemd;
in
[
"${systemdExporter.listenAddress}:${toString systemdExporter.port}"
];
}];
}
];
exporters = {
systemd = {
enable = true;
};
};
};
};
}