Deploy `systemd` config for `vector-node_exporter`.
This commit is contained in:
parent
ccf94f0174
commit
44cede10da
|
@ -0,0 +1,17 @@
|
|||
[Unit]
|
||||
Description=Vector
|
||||
Documentation=https://vector.dev
|
||||
After=network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/vector --config /etc/vector/node_exporter.toml
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=always
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=vector
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
data_dir = "/var/lib/vector/"
|
||||
|
||||
[sources.node_exporter]
|
||||
type = "file"
|
||||
include = [ "/var/log/node_exporter.log" ]
|
||||
ignore_older_secs = 600
|
||||
read_from = "beginning"
|
||||
|
||||
[transforms.node_exporter_transform]
|
||||
type = "remap"
|
||||
inputs = ["node_exporter"]
|
||||
source = '''
|
||||
. |= parse_syslog!(.message)
|
||||
|
||||
. |= parse_key_value!(.message)
|
||||
|
||||
del(.message)
|
||||
del(.host)
|
||||
|
||||
.message = .msg
|
||||
del(.msg)
|
||||
'''
|
||||
|
||||
[sinks.node_exporter_output]
|
||||
type = "file"
|
||||
inputs = [ "node_exporter_transform" ]
|
||||
compression = "none"
|
||||
path = "/tmp/node_exporter-%Y-%m-%d.log"
|
||||
|
||||
[sinks.node_exporter_output.encoding]
|
||||
codec = "json"
|
||||
|
||||
[sinks.node_exporter_output.buffer]
|
||||
max_size = 268435488
|
||||
type = "disk"
|
||||
|
||||
[sinks.node_exporter_loki]
|
||||
type = "loki"
|
||||
inputs = [ "node_exporter_transform" ]
|
||||
endpoint = "http://loki.service.consul:3100"
|
||||
compression = "snappy"
|
||||
|
||||
[sinks.node_exporter_loki.labels]
|
||||
level = "{{ level }}"
|
||||
hostname = "{{ hostname }}"
|
||||
job = "node_exporter"
|
||||
filename = "/var/log/node_exporter.log"
|
||||
|
||||
[sinks.node_exporter_loki.encoding]
|
||||
codec = "json"
|
||||
|
||||
[sinks.node_exporter_loki.buffer]
|
||||
max_size = 268435488
|
||||
type = "disk"
|
|
@ -1,4 +1,4 @@
|
|||
# Deploy the `supervisord` configuration:
|
||||
# Deploy the `systemd` configuration:
|
||||
remote_file '/etc/systemd/system/node_exporter.service' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
|
@ -35,6 +35,23 @@ remote_file '/etc/logrotate.d/node_exporter' do
|
|||
mode '0644'
|
||||
end
|
||||
|
||||
# Deploy the `systemd` config for `vector`:
|
||||
remote_file '/etc/vector/node_exporter.toml' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '644'
|
||||
end
|
||||
|
||||
remote_file '/etc/systemd/system/vector-node_exporter.service' do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '644'
|
||||
end
|
||||
|
||||
service 'vector-node_exporter' do
|
||||
action [ :enable, :start]
|
||||
end
|
||||
|
||||
# Deploy `consul` config for `node_exporter`:
|
||||
remote_file '/etc/consul.d/service-node_exporter.json' do
|
||||
owner 'consul'
|
||||
|
|
|
@ -19,3 +19,11 @@ groups:
|
|||
summary: "node_exporter is not running: {{ $labels.instance }}."
|
||||
description: "node_exporter is not running: {{ $labels.instance }}."
|
||||
|
||||
- alert: vector-node_exporter
|
||||
expr: node_systemd_unit_state{name="vector-node_exporter.service", state="active"} != 1
|
||||
for: 5m
|
||||
labels:
|
||||
severity: error
|
||||
annotations:
|
||||
summary: "vector-node_exporter is not running: {{ $labels.instance }}."
|
||||
description: "vector-node_exporter is not running: {{ $labels.instance }}."
|
||||
|
|
Loading…
Reference in New Issue