Deploy `/etc/systemd/system/vector-alertmanager.service`.

This commit is contained in:
Kazuhiro MUSASHI 2023-02-16 21:45:10 +09:00
parent 6788676faa
commit 75b9a74059
2 changed files with 68 additions and 0 deletions

View File

@ -70,6 +70,14 @@ remote_file '/etc/vector/alertmanager.toml' do
notifies :restart, 'service[vector-alertmanager]' notifies :restart, 'service[vector-alertmanager]'
end end
remote_file '/etc/systemd/system/vector-alertmanager.service' do
owner 'root'
group 'root'
mode '644'
notifies :restart, 'service[vector-alertmanager]'
end
service 'vector-alertmanager' do service 'vector-alertmanager' do
action [:enable, :start] action [:enable, :start]
end end

View File

@ -0,0 +1,60 @@
data_dir = "/var/lib/vector/"
[sources.alertmanager]
type = "file"
include = [ "/var/log/alertmanager.log" ]
ignore_older_secs = 600
read_from = "beginning"
[transforms.alertmanager_transform]
type = "remap"
inputs = ["alertmanager"]
source = '''
. |= parse_syslog!(.message)
del(.host)
errmsg = parse_regex(.message, r'err=(?P<err>.+)$') ?? {}
. = merge(., errmsg)
.message = replace(.message, r'err=.+$', "")
. |= parse_logfmt!(.message)
del(.message)
.message = .msg
del(.msg)
.timestamp = .ts
del(.ts)
'''
[sinks.alertmanager_output]
type = "file"
inputs = [ "alertmanager_transform" ]
compression = "none"
path = "/tmp/alertmanager-%Y-%m-%d.log"
[sinks.alertmanager_output.encoding]
codec = "json"
[sinks.alertmanager_output.buffer]
max_size = 268435488
type = "disk"
[sinks.alertmanager_loki]
type = "loki"
inputs = [ "alertmanager_transform" ]
endpoint = "http://loki.service.consul:3100"
compression = "snappy"
[sinks.alertmanager_loki.labels]
level = "{{ level }}"
hostname = "{{ hostname }}"
job = "alertmanager"
filename = "/var/log/alertmanager.log"
[sinks.alertmanager_loki.encoding]
codec = "json"
[sinks.alertmanager_loki.buffer]
max_size = 268435488
type = "disk"