blob: 8d96c88404cb4140917716f4fc2c8f7b3a92964d (
plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
<!DOCTYPE html>
<html lang=en>
<head>
<title></title>
<meta charset="utf-8"/>
<link rel="shortcut icon" href="favicon.ico"/>
<link rel='stylesheet' href='../style.css'/>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<header><h1>Integrating InfluxDB and Icinga</h1></header>
<main>
<p>Icinga2 has built-in support for writing monitoring data to InfluxDB.
This makes Icinga quite extensible as it allows for other programs to read
the gathered data from InfluxDB. For example, Icinga does not have built-in
graphing support. But monitoring data can be written to InfluxDB and then
consumed by a dedicated graphing tool like Grafana.</p>
<h2>Install Packages</h2>
<p>Let's install a few necessary packages</p>
<pre><code>apt install influxdb influxdb-client ssl-cert</code></pre>
<h2>Generate self-signed certificate</h2>
<p>Now generate a self-signed certificate for accessing InfluxDB over TLS</p>
<pre><code>make-ssl-cert generate-default-snakeoil
usermod -aG ssl-cert influxdb</code></pre>
<h2>Create Database and Users</h2>
<p>Start and enable the InfluxDB service</p>
<pre><code>systemctl enable --now influxdb</code></pre>
<p>Now we'll create our database and users. We'll be creating 3 users with
different access rights. An admin user with full control over the database, a
user with write access that Icinga will use to write data to the database, and
a read-only user to allow external programs to read data from the database.</p>
<pre><code>influx -ssl -unsafeSsl -execute "create database icinga2; create user admin with password '<em>changeme</em>'; create user icingauser with password '<em>changeme</em>'; create user readonly with password '<em>changeme</em>'; grant all to admin; grant write on icinga2 to icingauser; grant read on icinga2 to readonly;"
</code></pre>
<h2>Configuration Files</h2>
<p>Then write InfluxDB's configuration file at
<em>/etc/influxdb/influxdb.conf</em></p>
<pre><code>reporting-enabled = false
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
[coordinator]
[retention]
[shard-precreation]
[monitor]
[http]
enabled = true
bind-address = ":8086"
auth-enabled = true
https-enabled = true
https-certificate = "/etc/ssl/certs/ssl-cert-snakeoil.pem"
https-private-key = "/etc/ssl/private/ssl-cert-snakeoil.key"
[ifql]
[logging]
[subscriber]
[[graphite]]
[[collectd]]
[[opentsdb]]
[[udp]]
[continuous_queries]
[tls]
min-version = "tls1.2"</code></pre>
<p>And restart InfluxDB to pickup the changes</p>
<pre><code>systemctl restart influxdb</code></pre>
<p>Then we need to configure Icinga to write data to our database. Start by
enabling the influxdb feature in Icinga</p>
<pre><code>icinga2 feature enable influxdb</code></pre>
<p>Now we tell Icinga how to write to our database. Open the configuration
file at <em>/etc/icinga2/features-available/influxdb.conf</em> and replace
with the following</p>
<pre><code>object InfluxdbWriter \"influxdb\" {
host = "127.0.0.1"
port = 8086
username = "icingauser"
password = "<em>icinga_password</em>"
ssl_enable = true
database = "icinga2"
flush_threshold = 1024
flush_interval = 10s
host_template = {
measurement = "$host.check_command$"
tags = {
hostname = "$host.name$"
}
}
service_template = {
measurement = "$service.check_command$"
tags = {
hostname = "$host.name$"
service = "$service.name$"
}
}
}</code></pre>
<p>And finally restart Icinga to make those changes live.</p>
<pre><code>systemctl restart icinga2</code></pre>
<p>Icinga2 will now be writing the data it collects to your InfluxDB instance.</p>
</main>
<p>
<hr>
Consider <a href=../donate.html>donating</a> if this article was useful.
<a class=qr href=../images/bitcoin.png>[BTC]</a>
</p>
</main>
<footer>
<a href=../kb.html>Knowledge Base</a>
<br>
<a href=../index.html>www.chudnick.com</a>
</footer>
</body>
</html>
|