housekeep-promtail-config-for-nomad #18

Merged
kazu634 merged 6 commits from housekeep-promtail-config-for-nomad into main 2024-04-06 07:31:42 +00:00
1 changed files with 53 additions and 0 deletions
Showing only changes of commit b16ed09803 - Show all commits

View File

@ -0,0 +1,53 @@
data_dir = "/var/lib/vector/"
[sources.nomad]
type = "file"
include = [ "/var/log/nomad.log" ]
ignore_older_secs = 600
read_from = "beginning"
[transforms.nomad_transform]
type = "remap"
inputs = ["nomad"]
source = '''
. |= parse_syslog!(.message)
lv, err = parse_regex(.message, r'(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{4}) \[(?P<level>[^\]]+)\] +(?P<message>.*)$')
. = merge(., lv)
del(.host)
.level = downcase!(.level)
'''
[sinks.nomad_output]
type = "file"
inputs = [ "nomad_transform"]
compression = "none"
path = "/tmp/nomad-%Y-%m-%d.log"
[sinks.nomad_output.encoding]
codec = "json"
[sinks.nomad_output.buffer]
max_size = 268435488
type = "disk"
[sinks.nomad_loki]
type = "loki"
inputs = [ "nomad_transform" ]
endpoint = "http://loki.service.consul:3100"
compression = "snappy"
[sinks.nomad_loki.labels]
level = "{{ level }}"
hostname = "{{ hostname }}"
job = "nomad"
filename = "{{ file }}"
[sinks.nomad_loki.encoding]
codec = "json"
[sinks.nomad_loki.buffer]
max_size = 268435488
type = "disk"