Author: LemonNan

The original address: mp.weixin.qq.com/s/fb63XndhU…

Note: the author and original address should be indicated

introduce

Clickhouse monitors clickhouse system metrics by storing clickhouse system metrics in its own system.events and System. metrics tables, so you only need to expose these tables through the interface.

This article describes how to easily set up Clickhouse + Prometheus + Grafana monitoring

Reminder: This component is deployed using Docker

Let’s start with a few images:

Operation process

Modify the Clickhouse configuration

Copy the clickhouse configuration itself from the /etc/clickhouse-server container and search for Prometheus in config.xml, removing the comments.

Configuration instructions

Metrics here is the record of Clickhouse’s System. metrics table

Events is the Clickhouse system. Events table record

Start the Clickhouse container

{localConfig} is the path to your Clickhouse configuration file

Docker run -d --name clickhouse -p 9363:9363 -v {localConfig}:/etc/clickhouse-server --ulimit docker run -d --name clickhouse -p 9363:9363 -v {localConfig}:/etc/clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-serverCopy the code

Verify the Prometheus port of Clickhouse

Curl localhost:9363 curl localhost:9363 curl localhost:9363 curl localhost:9363

Added Prometheus configuration

Create Prometheus. Yml

global: scrape_interval: 15s evaluation_interval: 15s alerting: alertmanagers: - static_configs: - targets: rule_files: - "test.yml" scrape_configs: -scrape_configs: -target: ['172.16.16.4:9363']Copy the code

Start the Prometheus

{localConfig}prometheus.ymlThe path

{localData} is the data storage path

Note: The root user must be used here, otherwise the startup will fail without permission

Prometheus docker run -d --name mypro -p 9090:9090 -v {localConfig}:/etc/prometheud.yml -v {localData}:/ Prometheus docker run -d --name mypro -p 9090:9090 -v {localConfig}:/etc --user "root" prom/prometheusCopy the code

Verify the Prometheus

Visit address:{ip}:9090/targetsIf the following dialog box is displayed, the installation is correct

Install Grafana

{localData} is where grafana data is stored locally

Note: The root user is still used here

Since port 3000 has other applications, Docker run -d --name mygra -p 3999:3000 -v {localData}:/var/lib/grafana --user "root" grafana/grafana docker run -d --name mygra -p 3999:3000 -v {localData}:/var/lib/grafana --user "root" grafana/grafanaCopy the code

Access: {IP}:3999. If the following interface is displayed, the installation is normal. The default account and password are admin

Prometheus Grafana configuration

After entering Grafana, add Data Source, select Prometheus, and configure as follows

172.16.16.4 is the local Intranet address

Add metrics and test

The indicator set here is the number of selectQuery-select times, with a time span of 1 minute

After several queries are executed, the number of times changes on the screen

After changing the indicator to InsertBytes, observe the difference between before and after data is inserted

Insert before

After inserting

You can see that the number of bytes inserted has skyrocketed because of the file import.

The plug-in

One index search and page layout, will make a very large head, fortunately, there are plug-ins.

Install a Clickhouse plug-in in Grafana

A search for Clickhouse in Plugin will bring up two plugins, the Vertamedia one used in this article. After installing the Plugin, set the Clickhouse address to create the data source, and then enter ID 13606 by “+” Import. It will have the same effect as the beginning.

conclusion

At this point Clickhouse monitoring based on Prometheus and Grafana is basically set up, allowing you to monitor different metrics according to your needs.

The last

Welcome to LemonCode, the official account, to exchange and learn together!