feat: vector sending logs to victoria-logs

This commit is contained in:
Jeremy Wall 2024-06-01 13:02:27 -04:00
parent d99ab26cf5
commit 40a74fc8a7
4 changed files with 93 additions and 1 deletions

View File

@ -162,6 +162,63 @@
];
services.victoria-logs.enable = true;
services.vector.enable = true;
services.vector.settings = {
data_dir = "/var/lib/vector";
sources = {
prometheus = {
type = "file";
include = [
"${config.launchd.user.agents.prometheus.serviceConfig.StandardOutPath}"
"${config.launchd.user.agents.prometheus.serviceConfig.StandardErrorPath}"
];
};
heracles = {
type = "file";
include = [
"${config.launchd.user.agents.heracles.serviceConfig.StandardOutPath}"
"${config.launchd.user.agents.heracles.serviceConfig.StandardErrorPath}"
];
};
# TODO(zaphar): We should remap durnitisp output to get strip the tty control characters.
durnitisp = {
type = "file";
include = [
"${config.launchd.daemons.durnitisp.serviceConfig.StandardOutPath}"
"${config.launchd.daemons.durnitisp.serviceConfig.StandardErrorPath}"
];
};
vector = {
type = "file";
include = [
"${config.launchd.daemons.vector.serviceConfig.StandardOutPath}"
"${config.launchd.daemons.vector.serviceConfig.StandardErrorPath}"
];
};
};
sinks = {
victoria = {
type = "elasticsearch";
mode = "bulk";
endpoints = [
"http://${config.services.victoria-logs.listenAddr}/insert/elasticsearch/"
];
inputs = [
"prometheus"
"heracles"
"durnitisp"
"vector"
];
api_version = "v8";
healthcheck.enabled = false;
query = {
_msg_field = "message";
_time_field = "timestamp";
_stream_fields = "host,file";
};
};
};
};
# TODO launchd.user.agents.prometheus;
# Use a custom configuration.nix location.

View File

@ -349,6 +349,7 @@ EOF";
(vimModule system)
./modules/darwin-monitor.nix
./modules/victoria-logs.nix
./modules/vector.nix
./darwin-configuration.nix
];
};

View File

@ -0,0 +1,34 @@
{pkgs, lib, config, ...}:
with lib;
{
options.services.vector = {
enable = mkEnableOption "Enable the vector agent";
settings = mkOption {
description = "Settings for the vector agent";
default = {
data_dir = "/var/lib/vector";
};
defaultText = "{}";
};
};
config = {
environment.etc."vector.yaml" = mkIf config.services.vector.enable {
text = (generators.toYAML {} config.services.vector.settings);
};
launchd.daemons.vector = mkIf config.services.vector.enable {
serviceConfig = {
ProgramArguments = [
"${pkgs.vector}/bin/vector"
"--watch-config"
"--config=/etc/${config.environment.etc."vector.yaml".target}"
];
KeepAlive = true;
RunAtLoad = true;
StandardOutPath = "/var/log/vector.out.log";
StandardErrorPath = "/var/log/vector.err.log";
};
};
};
}

View File

@ -10,7 +10,7 @@ with lib;
};
listenAddr = mkOption {
description = "Socket Address to listen on";
default = ":9428";
default = "127.0.0.1:9428";
};
};
};