62 lines
2.4 KiB
Nix
62 lines
2.4 KiB
Nix
{pkgs, lib, config, ...}:
|
|
with lib;
|
|
{
|
|
options.services = {
|
|
victoria-logs = {
|
|
enable = mkEnableOption "Enable the VictoriaLogs service";
|
|
dataPath = mkOption {
|
|
description = "Logging directory path for victoria-logs service";
|
|
default = "/Users/Zaphar/opt/victoria-logs";
|
|
};
|
|
maxStorageSize = mkOption {
|
|
description = "Maximum storage size on disk [KB, MB, GB]";
|
|
default = "200GiB";
|
|
};
|
|
retentionTime = mkOption {
|
|
description = "Timespan of logs to retain, Logs older than this will be dropped.";
|
|
default = "5d";
|
|
};
|
|
listenAddr = mkOption {
|
|
description = "Socket Address to listen on";
|
|
default = "127.0.0.1:9428";
|
|
};
|
|
stdoutPath = mkOption {
|
|
default = "${config.services.victoria-logs.dataPath}/victoria-logs.out.log";
|
|
};
|
|
stderrPath = mkOption {
|
|
default = "${config.services.victoria-logs.dataPath}/victoria-logs.err.log";
|
|
};
|
|
pidPath = mkOption {
|
|
default = "${config.services.victoria-logs.dataPath}/victoria-logs.pid";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = let
|
|
victoria-logsOutPath = "${config.services.victoria-logs.stdoutPath}";
|
|
victoria-logsErrPath = "${config.services.victoria-logs.stderrPath}";
|
|
victoria-logsPidPath = "${config.services.victoria-logs.pidPath}";
|
|
in {
|
|
launchd.user.agents.victoria-logs = mkIf config.services.victoria-logs.enable {
|
|
serviceConfig = {
|
|
ProgramArguments = [
|
|
"${pkgs.clio}/bin/clio"
|
|
"--out-path=${victoria-logsOutPath}"
|
|
"--err-path=${victoria-logsErrPath}"
|
|
"--pid-file=${victoria-logsPidPath}"
|
|
"--paranoid"
|
|
"--"
|
|
"${pkgs.victoria-logs}/bin/victoria-logs"
|
|
"-logNewStreams"
|
|
"-storageDataPath=${config.services.victoria-logs.dataPath}/data"
|
|
"-retention.maxDiskSpaceUsageBytes=${config.services.victoria-logs.maxStorageSize}"
|
|
"-retentionPeriod=${config.services.victoria-logs.retentionTime}"
|
|
"-httpListenAddr=${config.services.victoria-logs.listenAddr}"
|
|
];
|
|
KeepAlive = true;
|
|
RunAtLoad = true;
|
|
};
|
|
};
|
|
};
|
|
}
|