feat: vector sending logs to victoria-logs
This commit is contained in:
parent
d99ab26cf5
commit
40a74fc8a7
@ -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.
|
||||
|
@ -349,6 +349,7 @@ EOF";
|
||||
(vimModule system)
|
||||
./modules/darwin-monitor.nix
|
||||
./modules/victoria-logs.nix
|
||||
./modules/vector.nix
|
||||
./darwin-configuration.nix
|
||||
];
|
||||
};
|
||||
|
34
nix/base-system/modules/vector.nix
Normal file
34
nix/base-system/modules/vector.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
@ -10,7 +10,7 @@ with lib;
|
||||
};
|
||||
listenAddr = mkOption {
|
||||
description = "Socket Address to listen on";
|
||||
default = ":9428";
|
||||
default = "127.0.0.1:9428";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user