Deploy `promtail` config for `snmp_exporter`.

This commit is contained in:
Kazuhiro MUSASHI 2020-10-25 00:16:11 +09:00
parent a5b6dbd529
commit 5a32a4bcec
2 changed files with 51 additions and 0 deletions

View File

@ -25,3 +25,14 @@ end
service 'supervisor' do service 'supervisor' do
action :nothing action :nothing
end end
# Deploy /etc/hosts file:
template '/etc/promtail/snmp_exporter.yaml' do
owner 'root'
group 'root'
mode '644'
variables(HOSTNAME: node[:hostname], LOKIENDPOINT: node['promtail']['lokiendpoint'])
notifies :restart, 'service[promtail-prometheus]'
end

View File

@ -0,0 +1,40 @@
server:
disable: true
positions:
filename: /var/opt/promtail/promtail_snmp_exporter_position.yaml
clients:
- url: http://<%= @LOKIENDPOINT %>/loki/api/v1/push
scrape_configs:
- job_name: snmp_exporter
static_configs:
- targets:
- localhost
labels:
job: snmp_exporter
hostname: <%= @HOSTNAME %>
__path__: /var/log/supervisor/snmp_exporter.log
pipeline_stages:
- match:
selector: '{job="snmp_exporter"}'
stages:
- regex:
expression: '^level=(?P<level>[^ ]+) ts=(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z) (?P<message>.+)$'
- timestamp:
source: timestamp
format: 2006-01-02T15:04:05.000Z
location: Etc/GMT
- template:
source: level
template: '{{ regexReplaceAllLiteral "warn" .Value "warning" }}'
- labels:
level:
- output:
source: message