clickhouse-graphite-integration
Table of Contents
Introduction - what are we talking about
We'd like to monitor ClickHouse's status, preferably with some tool, which can provide nice on-the-fly graphics. Graphite is one of such tools available, so we'd use it to receive and display metrics, coming from ClickHouse.
Graphite - what is it? Graphite is an enterprise-scale monitoring tool, and as we'd like to monitor Clickhouse's health, we need to report to Graphite some kind of health metrics. We'll need to have CickHouse and Graphite installed and setup integration between them. After that, let's take a look on monitoring.
Install Clickhouse
Most likely you have it installed already, so just skip this section.
ClickHouse installation is explained in several sources, such as:
- for deb-based systems
- for rpm-based systems
Install Graphite
Graphite installation is described in details in its manual. Feel free to choose any type of installation described, we just need to have Graphite's network port open to receive monitoring data coming from ClickHouse.
Setup ClickHouse - Graphite integration
Setup ClickHouse to report metrics into Graphite. Edit /etc/clickhouse-server/config.xml and append something like the following:
<graphite>
<host>192.168.74.150</host>
<port>2003</port>
<timeout>0.1</timeout>
<interval>60</interval>
<root_path>one_min_cr_plain</root_path>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
</graphite>
<graphite>
<host>192.168.74.150</host>
<port>2003</port>
<timeout>0.1</timeout>
<interval>1</interval>
<root_path>one_sec_cr_plain</root_path>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>false</asynchronous_metrics>
</graphite>Settings description:
host– host where Graphite is running. 192.168.74.150 in our case, you need to specify yours.port– Carbon plain text receiver port (2003 is default in Graphite). In general, Graphite has multiple ports open, with the following default values:80nginx2003carbon receiver - plaintext this one should receive data from ClickHouse2004carbon receiver - pickle2023carbon aggregator - plaintext2024carbon aggregator - pickle8080Graphite internal gunicorn port (without Nginx proxying).8125statsd8126statsd admin
interval– interval for sending data from ClickHouse, in seconds.timeout– timeout for sending data, in seconds.root_path– prefix used by Graphite.metrics– should data fromsystem_tables-system.metricstable be sent.events– should data fromsystem_tables-system.eventstable be sent.asynchronous_metrics– should data fromsystem_tables-system.asynchronous_metricstable be sent.
Multiple <graphite> clauses can be configured for sending different data at different intervals.
We have two metrics streams - each second and each minute - mainly for test purposes
Monitoring
As we have ClickHouse - Graphite integration setup done, metrics data should be coming from ClickHouse into Graphite.
Let's take a look on those metrics. Navigate to Graphite web monitoring tool in browser as http://host/dashboard (where host is the host Graphite is running).
In case all is well and ClickHouse sends its data, you'll see entries with prefixes, specified in ClickHouse's configuration, which are
<root_path>one_sec_cr_plain</root_path>
...
<root_path>one_min_cr_plain</root_path>in our case. You should see metrics available and you can choose graphs to watch.
