Deploy `vector` config for `journald`.
This commit is contained in:
parent
401423d0da
commit
f0635a2e8a
|
@ -0,0 +1,16 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Vector
|
||||||
|
Documentation=https://vector.dev
|
||||||
|
After=network-online.target
|
||||||
|
Requires=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/vector --config /etc/vector/journald.toml
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
Restart=always
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
SyslogIdentifier=vector
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,62 @@
|
||||||
|
data_dir = "/var/lib/vector/"
|
||||||
|
|
||||||
|
[sources.journald]
|
||||||
|
type = "journald"
|
||||||
|
exclude_units = [
|
||||||
|
"prometheus",
|
||||||
|
"consul",
|
||||||
|
"cron",
|
||||||
|
"snmp_exporter",
|
||||||
|
]
|
||||||
|
|
||||||
|
[sources.journald.exclude_matches]
|
||||||
|
"SYSLOG_IDENTIFIER" = [ "kernel", "vector", "sudo", "vault" ]
|
||||||
|
|
||||||
|
[transforms.journald_transform]
|
||||||
|
type = "remap"
|
||||||
|
inputs = ["journald"]
|
||||||
|
source = '''
|
||||||
|
.hostname = .host
|
||||||
|
del(.host)
|
||||||
|
|
||||||
|
.SYSLOG_FACILITY = to_int!(.SYSLOG_FACILITY)
|
||||||
|
.SYSLOG_FACILITY = to_syslog_facility!(.SYSLOG_FACILITY)
|
||||||
|
|
||||||
|
.PRIORITY = to_int!(.PRIORITY)
|
||||||
|
.PRIORITY = to_syslog_level!(.PRIORITY)
|
||||||
|
|
||||||
|
.SYSLOG_IDENTIFIER = downcase!(.SYSLOG_IDENTIFIER)
|
||||||
|
|
||||||
|
.job = replace!(._SYSTEMD_UNIT, r'(\.service|\.scope)', "")
|
||||||
|
'''
|
||||||
|
|
||||||
|
[sinks.journald_output]
|
||||||
|
type = "file"
|
||||||
|
inputs = [ "journald_transform" ]
|
||||||
|
compression = "none"
|
||||||
|
path = "/tmp/journald-%Y-%m-%d.log"
|
||||||
|
|
||||||
|
[sinks.journald_output.encoding]
|
||||||
|
codec = "json"
|
||||||
|
|
||||||
|
[sinks.journald_output.buffer]
|
||||||
|
max_size = 268435488
|
||||||
|
type = "disk"
|
||||||
|
|
||||||
|
[sinks.journald_loki]
|
||||||
|
type = "loki"
|
||||||
|
inputs = [ "journald_transform" ]
|
||||||
|
endpoint = "http://loki.service.consul:3100"
|
||||||
|
compression = "snappy"
|
||||||
|
|
||||||
|
[sinks.journald_loki.labels]
|
||||||
|
level = "{{ PRIORITY }}"
|
||||||
|
hostname = "{{ hostname }}"
|
||||||
|
job = "{{ job }}"
|
||||||
|
|
||||||
|
[sinks.journald_loki.encoding]
|
||||||
|
codec = "json"
|
||||||
|
|
||||||
|
[sinks.journald_loki.buffer]
|
||||||
|
max_size = 268435488
|
||||||
|
type = "disk"
|
|
@ -70,6 +70,27 @@ service 'vector-consul' do
|
||||||
action [:enable, :start]
|
action [:enable, :start]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Deploy config for mointoring `journald`:
|
||||||
|
remote_file '/etc/vector/journald.toml' do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '0644'
|
||||||
|
|
||||||
|
notifies :restart, 'service[vector-journald]'
|
||||||
|
end
|
||||||
|
|
||||||
|
remote_file '/etc/systemd/system/vector-journald.service' do
|
||||||
|
owner 'root'
|
||||||
|
group 'root'
|
||||||
|
mode '0644'
|
||||||
|
|
||||||
|
notifies :restart, 'service[vector-journald]'
|
||||||
|
end
|
||||||
|
|
||||||
|
service 'vector-journald' do
|
||||||
|
action [:enable, :start]
|
||||||
|
end
|
||||||
|
|
||||||
# Stop vector default service:
|
# Stop vector default service:
|
||||||
service 'vector' do
|
service 'vector' do
|
||||||
action :disable
|
action :disable
|
||||||
|
|
Loading…
Reference in New Issue