summaryrefslogtreecommitdiff
path: root/articles/icinga-influx.html
diff options
context:
space:
mode:
Diffstat (limited to 'articles/icinga-influx.html')
-rw-r--r--articles/icinga-influx.html133
1 files changed, 133 insertions, 0 deletions
diff --git a/articles/icinga-influx.html b/articles/icinga-influx.html
new file mode 100644
index 0000000..8d96c88
--- /dev/null
+++ b/articles/icinga-influx.html
@@ -0,0 +1,133 @@
1<!DOCTYPE html>
2<html lang=en>
3 <head>
4 <title></title>
5 <meta charset="utf-8"/>
6 <link rel="shortcut icon" href="favicon.ico"/>
7 <link rel='stylesheet' href='../style.css'/>
8 <meta name="viewport" content="width=device-width, initial-scale=1">
9 </head>
10<body>
11 <header><h1>Integrating InfluxDB and Icinga</h1></header>
12 <main>
13 <p>Icinga2 has built-in support for writing monitoring data to InfluxDB.
14 This makes Icinga quite extensible as it allows for other programs to read
15 the gathered data from InfluxDB. For example, Icinga does not have built-in
16 graphing support. But monitoring data can be written to InfluxDB and then
17 consumed by a dedicated graphing tool like Grafana.</p>
18
19 <h2>Install Packages</h2>
20 <p>Let's install a few necessary packages</p>
21
22 <pre><code>apt install influxdb influxdb-client ssl-cert</code></pre>
23
24 <h2>Generate self-signed certificate</h2>
25 <p>Now generate a self-signed certificate for accessing InfluxDB over TLS</p>
26
27 <pre><code>make-ssl-cert generate-default-snakeoil
28usermod -aG ssl-cert influxdb</code></pre>
29
30 <h2>Create Database and Users</h2>
31 <p>Start and enable the InfluxDB service</p>
32
33 <pre><code>systemctl enable --now influxdb</code></pre>
34
35 <p>Now we'll create our database and users. We'll be creating 3 users with
36 different access rights. An admin user with full control over the database, a
37 user with write access that Icinga will use to write data to the database, and
38 a read-only user to allow external programs to read data from the database.</p>
39
40 <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;"
41</code></pre>
42
43<h2>Configuration Files</h2>
44
45 <p>Then write InfluxDB's configuration file at
46 <em>/etc/influxdb/influxdb.conf</em></p>
47
48 <pre><code>reporting-enabled = false
49[meta]
50 dir = "/var/lib/influxdb/meta"
51[data]
52 dir = "/var/lib/influxdb/data"
53 wal-dir = "/var/lib/influxdb/wal"
54[coordinator]
55[retention]
56[shard-precreation]
57[monitor]
58[http]
59 enabled = true
60 bind-address = ":8086"
61 auth-enabled = true
62 https-enabled = true
63 https-certificate = "/etc/ssl/certs/ssl-cert-snakeoil.pem"
64 https-private-key = "/etc/ssl/private/ssl-cert-snakeoil.key"
65[ifql]
66[logging]
67[subscriber]
68[[graphite]]
69[[collectd]]
70[[opentsdb]]
71[[udp]]
72[continuous_queries]
73[tls]
74 min-version = "tls1.2"</code></pre>
75
76 <p>And restart InfluxDB to pickup the changes</p>
77
78 <pre><code>systemctl restart influxdb</code></pre>
79
80 <p>Then we need to configure Icinga to write data to our database. Start by
81 enabling the influxdb feature in Icinga</p>
82
83 <pre><code>icinga2 feature enable influxdb</code></pre>
84
85 <p>Now we tell Icinga how to write to our database. Open the configuration
86 file at <em>/etc/icinga2/features-available/influxdb.conf</em> and replace
87 with the following</p>
88
89 <pre><code>object InfluxdbWriter \"influxdb\" {
90 host = "127.0.0.1"
91 port = 8086
92 username = "icingauser"
93 password = "<em>icinga_password</em>"
94 ssl_enable = true
95 database = "icinga2"
96 flush_threshold = 1024
97 flush_interval = 10s
98 host_template = {
99 measurement = "$host.check_command$"
100 tags = {
101 hostname = "$host.name$"
102 }
103 }
104 service_template = {
105 measurement = "$service.check_command$"
106 tags = {
107 hostname = "$host.name$"
108 service = "$service.name$"
109 }
110 }
111}</code></pre>
112
113 <p>And finally restart Icinga to make those changes live.</p>
114
115 <pre><code>systemctl restart icinga2</code></pre>
116
117 <p>Icinga2 will now be writing the data it collects to your InfluxDB instance.</p>
118
119 </main>
120<p>
121<hr>
122Consider <a href=../donate.html>donating</a> if this article was useful.
123<a class=qr href=../images/bitcoin.png>[BTC]</a>
124</p>
125 </main>
126 <footer>
127 <a href=../kb.html>Knowledge Base</a>
128 <br>
129 <a href=../index.html>www.chudnick.com</a>
130 </footer>
131</body>
132</html>
133