Merge pull request 'DockerのログファイルをLokiに送信する' (#71) from output-docker-logs-and-capture into master
Reviewed-on: #71
This commit is contained in:
commit
380b464d42
|
@ -0,0 +1,8 @@
|
|||
# -------------------------------------------
|
||||
# Specifying the default settings:
|
||||
# -------------------------------------------
|
||||
node.reverse_merge!({
|
||||
'docker' => {
|
||||
'loki' => '192.168.10.101'
|
||||
}
|
||||
})
|
|
@ -1,3 +1,5 @@
|
|||
include_recipe './attributes.rb'
|
||||
|
||||
include_recipe './install.rb'
|
||||
|
||||
include_recipe './setup.rb'
|
||||
|
|
|
@ -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/docker.toml
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=always
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=vector
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -37,3 +37,32 @@ 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
|
||||
|
||||
# Deploy `systemd` configuration for `prometheus`:
|
||||
remote_file '/etc/systemd/system/vector-docker.service' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '644'
|
||||
|
||||
notifies :restart, 'service[vector-docker]'
|
||||
end
|
||||
|
||||
# Service setting:
|
||||
service 'vector-docker' do
|
||||
action [ :enable, :restart ]
|
||||
end
|
||||
|
|
|
@ -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 %>"
|
|
@ -3,4 +3,5 @@ include_recipe './attributes.rb'
|
|||
|
||||
# Install loki here:
|
||||
include_recipe './install.rb'
|
||||
include_recipe './setup.rb'
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# Create `/var/log/vector`:
|
||||
%w( /var/log/vector ).each do |d|
|
||||
directory d do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
end
|
||||
end
|
|
@ -1,12 +1,3 @@
|
|||
# Create `/var/log/vector`:
|
||||
%w( /var/log/vector ).each do |d|
|
||||
directory d do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
end
|
||||
end
|
||||
|
||||
# Deploy `vector` configuration for `syslog`:
|
||||
remote_file '/etc/vector/syslog.toml' do
|
||||
owner 'root'
|
||||
|
|
Loading…
Reference in New Issue