From e9a148035118b7e0e31e2bd36f49a635a33f0597 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Wed, 22 Feb 2023 23:52:02 +0900 Subject: [PATCH] Delete `promtail` config for `snmp_exporter`. --- cookbooks/prometheus/default.rb | 25 ------------ .../system/promtail-prometheus.service | 12 ------ .../system/promtail-snmp_exporter.service | 12 ------ cookbooks/prometheus/snmp_exporter_setup.rb | 23 ----------- .../templates/etc/promtail/snmp_exporter.yaml | 40 ------------------- 5 files changed, 112 deletions(-) delete mode 100644 cookbooks/prometheus/files/lib/systemd/system/promtail-prometheus.service delete mode 100644 cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service delete mode 100644 cookbooks/prometheus/templates/etc/promtail/snmp_exporter.yaml diff --git a/cookbooks/prometheus/default.rb b/cookbooks/prometheus/default.rb index 3ee9c9d..bb000c9 100644 --- a/cookbooks/prometheus/default.rb +++ b/cookbooks/prometheus/default.rb @@ -12,28 +12,3 @@ include_recipe './alertmanager_webhook_setup.rb' include_recipe './snmp_exporter_install.rb' include_recipe './snmp_exporter_setup.rb' - -# Deploy /etc/hosts file: -HOSTNAME = run_command('uname -n').stdout.chomp - -template '/etc/promtail/prometheus.yaml' do - owner 'root' - group 'root' - mode '644' - - variables(HOSTNAME: HOSTNAME, LOKIENDPOINT: node['promtail']['lokiendpoint']) - - notifies :restart, 'service[promtail-prometheus]' -end - -# Deploy the `systemd` configuration: -remote_file '/lib/systemd/system/promtail-prometheus.service' do - owner 'root' - group 'root' - mode '644' -end - -# Service setting: -service 'promtail-prometheus' do - action [ :enable, :restart ] -end diff --git a/cookbooks/prometheus/files/lib/systemd/system/promtail-prometheus.service b/cookbooks/prometheus/files/lib/systemd/system/promtail-prometheus.service deleted file mode 100644 index a52887f..0000000 --- a/cookbooks/prometheus/files/lib/systemd/system/promtail-prometheus.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Grafana Promtail for Prometheus -Documentation=https://github.com/grafana/loki -After=network-online.target - -[Service] -User=root -Restart=always -ExecStart=/usr/local/bin/promtail --config.file=/etc/promtail/prometheus.yaml - -[Install] -WantedBy=multi-user.target diff --git a/cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service b/cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service deleted file mode 100644 index 0fbf1ab..0000000 --- a/cookbooks/prometheus/files/lib/systemd/system/promtail-snmp_exporter.service +++ /dev/null @@ -1,12 +0,0 @@ -[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 11bb23e..8b01796 100644 --- a/cookbooks/prometheus/snmp_exporter_setup.rb +++ b/cookbooks/prometheus/snmp_exporter_setup.rb @@ -64,26 +64,3 @@ end service 'consul' do action :nothing 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-snmp_exporter]' -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 diff --git a/cookbooks/prometheus/templates/etc/promtail/snmp_exporter.yaml b/cookbooks/prometheus/templates/etc/promtail/snmp_exporter.yaml deleted file mode 100644 index 6009a02..0000000 --- a/cookbooks/prometheus/templates/etc/promtail/snmp_exporter.yaml +++ /dev/null @@ -1,40 +0,0 @@ -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[^ ]+) ts=(?P\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z) (?P.+)$' - - - 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