I assume that icinga2 and icingaweb2 are already installed.
Install Graphite
You can install Graphite only limited via apt repo. This makes future updates a nightmare. That's why we don't try this way at all.
The normally easy way via Docker makes the later necessary configuration for icingaweb unnecessarily complicated.
We use the installation via Python Pip with virtual environment.To do this, we first create a Python virtual environment and install the current installation files via git.
Graphite will by default use a SQLite database, but SQLlite is only suitable for testing purposes and will be overwhelmed very quickly with Graphite. We use PostgreSQL instead:
Create a graphite user and set rights
Configure carbon cache and relay
Configure carbon.conf
Specify retention times for metrics, otherwise the hard disk will sooner or later fill up:
How to read the retention policy? 1m:6w,5m:26w,15m:55w,120m:2y bedeutet store a resolution of 1m for 6 weeks, 5 minutes for 26 weeks, etc. All resolutions must be multiples of each other. For this example: 1 times 5 = 5 * 3 = 15 * 8 = 120 What would not work: 1m:6w,7m:19w,15m:40w,159m:2y You would get consumptions and gaps in the metrics.
Since the carbon cache will not start automatically, we create a SystemD unit file in /etc/systemd/system/
Relay service
Create local setting file
Copy example local_settings file
Now edit your local_settings.py and change secret_key, time_zone, logging and database entries.
Run initial migrate:
Create a graphite web superuser:
Test if setup works:
You should see your graphite GUI on http://<your_icinga_web2_IP>:8090
At this time it should be pretty empty:
Setup Graphite Web
Create a new Service unit file graphite.service in /etc/system/system/
Enable via
systemctl enable --now graphite.service
Install Graphite Module in icinga2
Go to /usr/share/icingaweb2/modules/ and clone the repo:
Enable Graphite for icinga2
icinga2 feature enable graphite
Edit your graphite config:
Configure Graphite via icingaweb2 GUI or via CLI
Last but not least, restart icinga2:
systemctl restart icinga2
A few notes
Metrics and time series are a relatively complex field of computer science and yes, the whole thing cannot be fully understood without an introduction to numerics. What we have done in this howto is standard in monitoring tools like Prometheus. If you prefer that, you should switch to Prometheus altogether. The cached graphs can get very large very quickly. If you are using Graphite, it is important to monitor disk space usage. If you want to do more with the graphics than just displaying a history in icingaweb2. The visualization tool Grafana is able to do even more. I will write more about this in the future.
The basic idea of this tutorial comes from here. Unfortunately it is no longer up to date and does not work on Debian 11 systems.