update packages + patches that come w/ it

This commit is contained in:
Reid 2026-04-17 19:16:39 -07:00
parent 4304b5c887
commit 2621308fc0
7 changed files with 56 additions and 69 deletions

View file

@ -5,7 +5,7 @@ let
cfg = config.modules.services.metrics;
in {
options.modules.services.metrics = {
enable = mkEnableOption "enable grafana with loki, prometheus, and promtail";
enable = mkEnableOption "enable grafana with prometheus, alloy, and loki";
domain = mkOption {
type = types.str;
default = "grafana.reidlab.pink";
@ -16,15 +16,15 @@ in {
};
grafanaPort = mkOption {
type = types.int;
default = 2000;
default = 3000;
};
promtailPort = mkOption {
alloyPort = mkOption {
type = types.int;
default = 2001;
default = 12345;
};
lokiPort = mkOption {
type = types.int;
default = 2002;
default = 3100;
};
prometheusPort = mkOption {
type = types.int;
@ -46,6 +46,10 @@ in {
http_port = cfg.grafanaPort;
http_addr = "127.0.0.1";
};
database.type = "sqlite3"; # TODO: use postgres?
# use default secret key
# TODO: maybe don't do that idk
security.secret_key = "SW2YcwTIb9zpOOhoPsMm";
};
provision.datasources.settings = {
@ -201,38 +205,40 @@ in {
};
};
services.promtail = {
services.alloy = {
enable = true;
configuration = {
server = {
http_listen_port = cfg.promtailPort;
grpc_listen_port = 0;
};
positions.filename = "/tmp/positions.yaml";
client.url = "http://127.0.0.1:${toString cfg.lokiPort}/loki/api/v1/push";
scrape_configs = [
{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
hostname = config.networking.hostName;
};
};
relabel_configs = [
{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}
];
extraFlags = [
"--server.http.listen-addr=127.0.0.1:${toString cfg.alloyPort}"
"--disable-reporting" # disable telemetry
];
configPath = pkgs.writeText "config.alloy" ''
loki.relabel "journal" {
forward_to = []
rule {
source_labels = ["__journal__systemd_unit"]
target_label = "unit"
}
];
};
rule {
source_labels = ["__journal__hostname"]
target_label = "hostname"
}
}
loki.source.journal "journal" {
forward_to = [loki.write.default.receiver]
max_age = "12h"
labels = {job = "systemd-journal"}
relabel_rules = loki.relabel.journal.rules
}
loki.write "default" {
endpoint {
url = "http://localhost:${toString cfg.lokiPort}/loki/api/v1/push"
}
}
'';
};
services.nginx.statusPage = true;