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