Merge branch 'promtail-gitea' of kazu634/itamae into master

This commit is contained in:
Kazuhiro MUSASHI 2020-09-07 23:08:23 +09:00 committed by Gitea
commit 8485309442
3 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,12 @@
[Unit]
Description=Grafana Promtail (Digdag)
Documentation=https://github.com/grafana/loki
After=network-online.target
[Service]
User=root
Restart=always
ExecStart=/usr/local/bin/promtail --config.file=/etc/promtail/digdag.yaml
[Install]
WantedBy=multi-user.target

View File

@ -48,3 +48,26 @@ end
service 'supervisor' do
action :nothing
end
# Deploy /etc/hosts file:
HOSTNAME = run_command('uname -n').stdout.chomp
template '/etc/promtail/digdag.yaml' do
owner 'root'
group 'root'
mode '644'
variables(HOSTNAME: HOSTNAME, LOKIENDPOINT: node['promtail']['lokiendpoint'])
end
# Deploy the `systemd` configuration:
remote_file '/lib/systemd/system/promtail-digdag.service' do
owner 'root'
group 'root'
mode '644'
end
# Service setting:
service 'promtail-digdag' do
action [ :enable, :restart ]
end

View File

@ -0,0 +1,56 @@
server:
disable: true
positions:
filename: /var/opt/promtail/promtail_digdag_position.yaml
clients:
- url: http://<%= @LOKIENDPOINT %>/loki/api/v1/push
scrape_configs:
- job_name: digdag
static_configs:
- targets:
- localhost
labels:
job: digdag
hostname: <%= @HOSTNAME %>
__path__: /var/log/supervisor/digdag.log
pipeline_stages:
- match:
selector: '{job="digdag"}'
stages:
- drop:
expression: ^[^0-9]
- drop:
expression: ^[0-9\/]+ .*$
- regex:
expression: '^(?P<timestamp>[0-9]+\-[0-9]+\-[0-9]+ [0-9]+:[0-9]+:[0-9]+ [\+\-][0-9]+)[ :]+(\[(?P<level>[^\])]+)\] (?P<message1>[^ ]+) [^ ]+ (?P<message2>.+))$'
- timestamp:
source: timestamp
format: 2006-01-02 15:04:05 -0700
- template:
source: level
template: '{{ ToLower .level }}'
- template:
source: level
template: '{{ regexReplaceAllLiteral "warn" .Value "warning" }}'
- template:
source: message
template: '{{ if .message1 }} {{ .message1 }} {{ .message2 }} {{ else }} Digdag has started {{ end }}'
- labels:
level:
- output:
source: message