Merge branch 'promtail-prometheus' of kazu634/itamae into master
This commit is contained in:
commit
21012e2d5b
|
@ -11,6 +11,31 @@ if node['prometheus']['manager']
|
|||
|
||||
include_recipe './alertmanager_webhook_install.rb'
|
||||
include_recipe './alertmanager_webhook_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
|
||||
end
|
||||
|
||||
# Install the node_exporter here:
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[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
|
|
@ -0,0 +1,110 @@
|
|||
server:
|
||||
disable: true
|
||||
|
||||
positions:
|
||||
filename: /var/opt/promtail/promtail_prometheus_position.yaml
|
||||
|
||||
clients:
|
||||
- url: http://192.168.10.118:3100/loki/api/v1/push
|
||||
|
||||
scrape_configs:
|
||||
- job_name: prometheus
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: prometheus
|
||||
hostname: <%= @HOSTNAME %>
|
||||
__path__: /var/log/supervisor/prometheus.log
|
||||
|
||||
pipeline_stages:
|
||||
- match:
|
||||
selector: '{job="prometheus"}'
|
||||
stages:
|
||||
- drop:
|
||||
expression: "^[^l]"
|
||||
|
||||
- regex:
|
||||
expression: '^level=(?P<level>[^ ]+) ts=(?P<timestamp>[^ ]+) (?P<message>.+)$'
|
||||
|
||||
- timestamp:
|
||||
source: timestamp
|
||||
format: 2006-01-02T15:04:05.999Z
|
||||
location: Etc/UTC
|
||||
|
||||
- labels:
|
||||
level:
|
||||
|
||||
- output:
|
||||
source: message
|
||||
|
||||
- job_name: alertmanager
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: prometheus
|
||||
hostname: <%= @HOSTNAME %>
|
||||
__path__: /var/log/supervisor/alertmanager.log
|
||||
|
||||
pipeline_stages:
|
||||
- match:
|
||||
selector: '{job="prometheus"}'
|
||||
stages:
|
||||
- drop:
|
||||
expression: "^[^l]"
|
||||
|
||||
- regex:
|
||||
expression: '^level=(?P<level>[^ ]+) ts=(?P<timestamp>[^ ]+) (?P<message>.+)$'
|
||||
|
||||
- timestamp:
|
||||
source: timestamp
|
||||
format: 2006-01-02T15:04:05.999Z
|
||||
location: Etc/UTC
|
||||
|
||||
- labels:
|
||||
level:
|
||||
|
||||
- output:
|
||||
source: message
|
||||
|
||||
- job_name: alertmanager-webhook-logger
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: prometheus
|
||||
hostname: <%= @HOSTNAME %>
|
||||
__path__: /var/log/supervisor/alertmanager-webhook-logger.log
|
||||
|
||||
pipeline_stages:
|
||||
- match:
|
||||
selector: '{job="prometheus"}'
|
||||
stages:
|
||||
- drop:
|
||||
expression: "^[0-9]+"
|
||||
|
||||
- json:
|
||||
expressions:
|
||||
timestamp: timestamp
|
||||
message: description
|
||||
level: status
|
||||
|
||||
- timestamp:
|
||||
source: timestamp
|
||||
format: 2006-01-02T15:04:05.999999999Z
|
||||
location: Etc/UTC
|
||||
|
||||
- template:
|
||||
source: level
|
||||
template: '{{ regexReplaceAllLiteral "firing" .Value "error" }}'
|
||||
|
||||
- template:
|
||||
source: level
|
||||
template: '{{ regexReplaceAllLiteral "resolved" .Value "notice" }}'
|
||||
|
||||
- labels:
|
||||
level:
|
||||
|
||||
- output:
|
||||
source: message
|
Loading…
Reference in New Issue