aboutsummaryrefslogtreecommitdiff
path: root/personal_infra/puppet
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2023-11-13 23:32:19 +0100
committeralex <alex@pdp7.net>2023-11-13 23:32:19 +0100
commitaa7b9fd9c65de8ef30bfd63e23c7e47420aa8053 (patch)
tree1c6f54070d3c7e57a97700f4e4ad3c4b2e588a82 /personal_infra/puppet
parentebe548ab9019c6fc7902ca183e653ff22d35d531 (diff)
Parse nagios.log and send notifications to clickhouse.h1
Diffstat (limited to 'personal_infra/puppet')
-rw-r--r--personal_infra/puppet/site/nagios.h1.int.pdp7.net.pp44
1 files changed, 44 insertions, 0 deletions
diff --git a/personal_infra/puppet/site/nagios.h1.int.pdp7.net.pp b/personal_infra/puppet/site/nagios.h1.int.pdp7.net.pp
index 262b8026..4010d3c4 100644
--- a/personal_infra/puppet/site/nagios.h1.int.pdp7.net.pp
+++ b/personal_infra/puppet/site/nagios.h1.int.pdp7.net.pp
@@ -17,4 +17,48 @@ node 'nagios.h1.int.pdp7.net' {
}
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'],
+ }
}