From 3aa5a8bb0941564b37c6ba53c0446e804326f353 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 25 Oct 2020 00:16:55 +0900 Subject: [PATCH] Deploy the `systemd` config for monitoring `snmp_exporter` logs. --- .../systemd/system/promtail-snmp_exporter.service | 12 ++++++++++++ cookbooks/prometheus/snmp_exporter_setup.rb | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service diff --git a/cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service b/cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service new file mode 100644 index 0000000..0fbf1ab --- /dev/null +++ b/cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service @@ -0,0 +1,12 @@ +[Unit] +Description=Grafana Promtail for snmp_exporter +Documentation=https://github.com/grafana/loki +After=network-online.target + +[Service] +User=root +Restart=always +ExecStart=/usr/local/bin/promtail --config.file=/etc/promtail/snmp_exporter.yaml + +[Install] +WantedBy=multi-user.target diff --git a/cookbooks/prometheus/snmp_exporter_setup.rb b/cookbooks/prometheus/snmp_exporter_setup.rb index b35f865..f20aea8 100644 --- a/cookbooks/prometheus/snmp_exporter_setup.rb +++ b/cookbooks/prometheus/snmp_exporter_setup.rb @@ -36,3 +36,15 @@ template '/etc/promtail/snmp_exporter.yaml' do notifies :restart, 'service[promtail-prometheus]' end + +# Deploy the `systemd` configuration: +remote_file '/lib/systemd/system/promtail-snmp_exporter.service' do + owner 'root' + group 'root' + mode '644' +end + +# Service setting: +service 'promtail-snmp_exporter' do + action [ :enable, :restart ] +end