Deploy `vector` config for `Docker` logs.

This commit is contained in:
Kazuhiro MUSASHI 2020-12-13 14:03:24 +09:00
parent 2b451d6db8
commit cc9ce1806e
4 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# -------------------------------------------
# Specifying the default settings:
# -------------------------------------------
node.reverse_merge!({
'docker' => {
'loki' => '192.168.10.101'
}
})

View File

@ -1,3 +1,5 @@
include_recipe './attributes.rb'
include_recipe './install.rb'
include_recipe './setup.rb'

View File

@ -37,3 +37,18 @@ remote_file '/etc/cron.d/docker-housekeep' do
group 'root'
mode '644'
end
# Deploy config file for `vector`:
template '/etc/vector/docker.toml' do
owner 'root'
group 'root'
mode '644'
variables(LOKI: node['docker']['loki'],
HOSTNAME: node[:hostname]
)
source 'templates/etc/vector/docker.toml.erb'
notifies :restart, 'service[vector-docker]'
end

View File

@ -0,0 +1,22 @@
data_dir = "/var/lib/vector"
[sources.docker]
type = "docker"
[transforms.docker-transform]
type = "remove_fields"
inputs = ["docker"]
fields = ["container_created_at", "container_id", "container_name"]
[sinks.docker-logs]
type = "loki"
inputs = ["docker-transform"]
endpoint = "http://<%= @LOKI %>:3100"
healthcheck = true
remove_timestamp = true
encoding.codec = "text"
labels.level = "info"
labels.job = "docker"
labels.hostname = "<%= @HOSTNAME %>"