Recomended migtration to grafana-alloy (https://grafana.com/docs/alloy/latest/set-up/migrate/from-promtail/) or fluent-bit (https://docs.fluentbit.io/manual/data-pipeline/outputs/loki) I chose alloy because of the compatability. This needs to be reworked to a native implementation later
63 lines
1.5 KiB
Nix
63 lines
1.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
let
|
|
cfg = config.malobeo.metrics;
|
|
hosts = import ../../hosts.nix {};
|
|
in
|
|
{
|
|
options.malobeo.metrics = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Enable sharing metrics";
|
|
};
|
|
enablePromtail = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Enable sharing logs";
|
|
};
|
|
logNginx = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Share nginx logs";
|
|
};
|
|
lokiHost = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = hosts.malobeo.hosts.overwatch.network.address;
|
|
description = "Address of loki host";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf (cfg.enable) {
|
|
|
|
networking.firewall.allowedTCPPorts = [ 9002 ];
|
|
|
|
services.prometheus = {
|
|
exporters = {
|
|
node = {
|
|
enable = true;
|
|
enabledCollectors = [ "systemd" "processes" ];
|
|
port = 9002;
|
|
};
|
|
};
|
|
};
|
|
|
|
services.alloy = {
|
|
enable = cfg.enablePromtail;
|
|
extraFlags = ["--config.format=promtail"]; #TODO please change this to native alloy config later
|
|
configPath = import ./promtail_config.nix {
|
|
lokiAddress = cfg.lokiHost;
|
|
logNginx = cfg.logNginx;
|
|
config = config;
|
|
pkgs = pkgs;
|
|
};
|
|
};
|
|
users.groups.promtail = {};
|
|
users.users.promtail = {
|
|
isNormalUser = true;
|
|
group = "promtail";
|
|
extraGroups = [ "systemd-journal" ] ++ (lib.optionals cfg.logNginx [ "nginx" ]) ;
|
|
};
|
|
|
|
};
|
|
}
|