1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
node 'nagios.h1.int.pdp7.net' {
class {'nagios':
otel_host => 'clickhouse.h1.int.pdp7.net',
}
class {'nagios::k8s':}
$k8s_hosts = lookup("groups.k8s")
$k8s_hosts.each |String $k8s_host| {
nagios_host {$k8s_host:
use => 'generic-host',
max_check_attempts => 5,
contact_groups => 'admins',
hostgroups => 'k8s',
check_command => 'check-host-alive',
}
}
nagios_host {"shellyplusplugs-b0b21c1329b4.mad.int.pdp7.net":
use => 'generic-host',
max_check_attempts => 5,
contact_groups => 'admins',
check_command => 'check-host-alive',
}
nagios_host {"shellyhtg3-54320453c804.mad.int.pdp7.net":
use => 'generic-host',
max_check_attempts => 5,
contact_groups => 'admins',
check_command => 'check-host-alive',
}
nagios_service {'alex.corcoles.net-gemini-cert':
use => 'generic-service',
service_description => 'alex.corcoles.net-gemini-cert',
host_name => 'k8s-prod.h1.int.pdp7.net',
check_command => 'check_alex.corcoles.net-gemini-cert',
require => Package['nagios'],
notify => Service['nagios'],
owner => 'nagios',
}
nagios_command {'check_alex.corcoles.net-gemini-cert':
command_name => 'check_alex.corcoles.net-gemini-cert',
command_line => '/usr/lib64/nagios/plugins/check_http -H alex.corcoles.net -C 10,5 -p 1965',
require => Package['nagios'],
notify => Service['nagios'],
owner => 'nagios',
}
package {'nagios-plugins-pgsql':}
class {'otel':
version => '0.88.0',
}
# TODO: add otelcol-contrib user to nagios group
file {'/etc/otelcol-contrib/config.yaml':
content => @("EOT")
exporters:
otlp:
endpoint: clickhouse.h1.int.pdp7.net:4317
tls:
insecure: true
receivers:
filelog:
include: [ /var/log/nagios/nagios.log ]
operators:
- type: regex_parser
regex: '^\[(?P<time>\d+)\] (?P<log>.*)$'
timestamp:
parse_from: attributes.time
layout_type: epoch
layout: s
processors:
transform:
log_statements:
- context: log
statements:
- merge_maps(attributes, ExtractPatterns(attributes["log"], "^(?P<type>SERVICE NOTIFICATION):[ ](?P<contact>[^;]*);(?P<host>[^;]*);(?P<service>[^;]*);(?P<status>[^;]*);(?P<command>[^;]*);(?P<check_status_line>.*)$"), "insert") where IsMatch(attributes["log"], "^SERVICE NOTIFICATION:")
- merge_maps(attributes, ExtractPatterns(attributes["log"], "^(?P<type>HOST NOTIFICATION):[ ](?P<contact>[^;]*);(?P<host>[^;]*);(?P<status>[^;]*);(?P<command>[^;]*);(?P<check_status_line>.*)$"), "insert") where IsMatch(attributes["log"], "^HOST NOTIFICATION:")
service:
pipelines:
logs:
receivers: [filelog]
processors: [transform]
exporters: [otlp]
| EOT
,
require => Package['otelcol-contrib'],
notify => Service['otelcol-contrib'],
}
}
|