Deploy `systemd` config for `filestat_exporter`.

This commit is contained in:
Kazuhiro MUSASHI 2023-02-07 23:39:10 +09:00
parent 080eda7535
commit f7eae0c857
3 changed files with 90 additions and 0 deletions

View File

@ -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/filestat_exporter.toml
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=vector
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,55 @@
data_dir = "/var/lib/vector/"
[sources.filestat_exporter]
type = "file"
include = [ "/var/log/filestat_exporter.log" ]
ignore_older_secs = 600
read_from = "beginning"
[transforms.filestat_exporter_transform]
type = "remap"
inputs = ["filestat_exporter"]
source = '''
. |= parse_syslog!(.message)
. |= parse_key_value!(.message)
del(.message)
del(.host)
.message = .msg
del(.msg)
'''
[sinks.filestat_exporter_output]
type = "file"
inputs = [ "filestat_exporter_transform" ]
compression = "none"
path = "/tmp/filestat_exporter-%Y-%m-%d.log"
[sinks.filestat_exporter_output.encoding]
codec = "json"
[sinks.filestat_exporter_output.buffer]
max_size = 268435488
type = "disk"
[sinks.filestat_exporter_loki]
type = "loki"
inputs = [ "filestat_exporter_transform" ]
endpoint = "http://loki.service.consul:3100"
compression = "snappy"
[sinks.filestat_exporter_loki.labels]
level = "{{ level }}"
hostname = "{{ hostname }}"
job = "filestat_exporter"
filename = "/var/log/filestat_exporter.log"
[sinks.filestat_exporter_loki.encoding]
codec = "json"
[sinks.filestat_exporter_loki.buffer]
max_size = 268435488
type = "disk"

View File

@ -38,6 +38,25 @@ remote_file '/etc/logrotate.d/filestat_exporter' do
mode '644'
end
# Deploy `vector` config:
remote_file '/etc/vector/filestat_exporter.toml' do
owner 'root'
group 'root'
mode '0644'
notifies :restart, 'service[vector-filestat_exporter]'
end
remote_file '/etc/systemd/system/vector-filestat_exporter.service' do
owner 'root'
group 'root'
mode '0644'
end
service 'vector-filestat_exporter' do
action [:enable, :start]
end
# Deploy `consul` config for `filestat_exporter`:
remote_file '/etc/consul.d/service-filestat_exporter.json' do
owner 'consul'