From b16ed0980359becb92416c720b75262b47c8cc6a Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Wed, 3 Apr 2024 18:11:41 +0900 Subject: [PATCH] Deploy `vector` config for `nomad`. --- cookbooks/nomad/files/etc/vector/nomad.toml | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cookbooks/nomad/files/etc/vector/nomad.toml diff --git a/cookbooks/nomad/files/etc/vector/nomad.toml b/cookbooks/nomad/files/etc/vector/nomad.toml new file mode 100644 index 0000000..2a858b5 --- /dev/null +++ b/cookbooks/nomad/files/etc/vector/nomad.toml @@ -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\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{4}) \[(?P[^\]]+)\] +(?P.*)$') + . = 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"