Clickhouse监控_使用Prometheus+Grafana来监控Clickhouse服务和性能指标

官方文档https://clickhouse.com/docs/zh/operations/monitoring

建议使用Prometheus+Grafana组合监控Clickhouse服务和性能指标

1、把prometheus的clickhouse_exporter下载到Clickhouse服务器,查找prometheus的clickhouse_exporter参见https://prometheus.io/docs/instrumenting/exporters/#databases,查看clickhouse_exporter的git信息可以登陆到https://github.com/ClickHouse/clickhouse_exporter上面查看

bash 复制代码
root@DAILACHDBUD002:~# git clone https://github.com/ClickHouse/clickhouse_exporter.git
Cloning into 'clickhouse_exporter'...
remote: Enumerating objects: 1185, done.
remote: Counting objects: 100% (306/306), done.
remote: Compressing objects: 100% (162/162), done.
remote: Total 1185 (delta 179), reused 164 (delta 138), pack-reused 879
Receiving objects: 100% (1185/1185), 1.36 MiB | 5.99 MiB/s, done.
Resolving deltas: 100% (359/359), done.

2、进入下载后的clickhouse_exporter目录,对其进行编译,由于https://github.com/ClickHouse/clickhouse_exporter上看到clickhouse_exporter相关信息是golang,所以安装是golang再编译

bash 复制代码
root@DAILACHDBUD002:~# cd clickhouse_exporter/
root@DAILACHDBUD002:~/clickhouse_exporter# ll clickhouse_exporter
ls: cannot access 'clickhouse_exporter': No such file or directory
root@DAILACHDBUD002:~/clickhouse_exporter# apt install golang-go
root@DAILACHDBUD002:~/clickhouse_exporter# go build clickhouse_exporter.go
root@DAILACHDBUD002:~/clickhouse_exporter# ll clickhouse_exporter
-rwxr-xr-x 1 root root 12591899 Dec 21 07:04 clickhouse_exporter*

3、编译好clickhouse_exporter后,配置clickhouse_exporter开机启动,其中/root/clickhouse_exporter/clickhouse_exporter -scrape_uri=http://default:W123@localhost:8123/ &此处必须加上后缀&,否则后面的systemctl start clickhouse_exporter会一直无法正常启然后systemctl status clickhouse_exporter会看到一直处于Active: activating (start)启动的状态而不是正常的Active: active (running)

bash 复制代码
root@DAILACHDBUD002:~# cat /root/script/clickhouse_exporter.sh
#/bin/sh
/root/clickhouse_exporter/clickhouse_exporter -scrape_uri=http://default:W123@localhost:8123/ &
bash 复制代码
root@DAILACHDBUD002:~# cat /usr/lib/systemd/system/clickhouse_exporter.service
[Unit]
Description=clickhouse_exporter
After=network.target

[Service]
User=root
Group=root
Type=forking
ExecStart=/bin/bash /root/script/clickhouse_exporter.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
bash 复制代码
root@DAILACHDBUD002:~# systemctl enable clickhouse_exporter
Created symlink /etc/systemd/system/multi-user.target.wants/clickhouse_exporter.service → /lib/systemd/system/clickhouse_exporter.service.

root@DAILACHDBUD002:~# systemctl start clickhouse_exporter

root@DAILACHDBUD002:~# systemctl status clickhouse_exporter
● clickhouse_exporter.service - clickhouse_exporter
     Loaded: loaded (/lib/systemd/system/clickhouse_exporter.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-12-21 07:22:30 UTC; 3s ago

4、登陆Prometheus所在服务器,打开Prometheus配置文件vim /prometheus/prometheus-2.32.1/prometheus.yml,增加如下配置

bash 复制代码
 - job_name: "clickhouse_exporter"
    scrape_timeout: 10s
    metrics_path: /metrics
    static_configs:
      - targets: ['172.22.137.132:9116']
      - targets: ['172.22.137.133:9116']
      - targets: ['172.22.137.134:9116']
      - targets: ['172.22.137.136:9116']

5、在https://grafana.com/grafana/dashboards/中查找Clickhouse的模板,在Grafana监控配置页面导入Clickhouse的模板https://grafana.com/grafana/dashboards/882-clickhouse/或https://grafana.com/grafana/dashboards/14432-clickhouse-metrics-on-settings/,然后在Grafana监控配置页面的数据源选项中选择Prometheus

相关推荐
川石课堂软件测试14 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
逻辑与&&1 天前
[Prometheus学习笔记]从架构到案例,一站式教程
笔记·学习·prometheus
Walden-20201 天前
构建基于 DCGM-Exporter, Node exporter,PROMETHEUS 和 GRAFANA 构建算力监控系统
docker·容器·grafana·prometheus
gengjianchun2 天前
clickhouse 安装配置
服务器·网络·clickhouse
东皋长歌2 天前
ClickHouse安装
clickhouse
大嘴吧Lucy2 天前
实战攻略 | ClickHouse优化之FINAL查询加速
数据库·mysql·clickhouse
东皋长歌2 天前
SpringBoot+ClickHouse集成
clickhouse·springboot
牛角上的男孩2 天前
部署Prometheus、Grafana、Zipkin、Kiali监控度量Istio
grafana·prometheus·istio
从未完美过3 天前
ClickHouse集成Mysql表引擎跨服务器读表说明
服务器·mysql·clickhouse
福大大架构师每日一题4 天前
文心一言 VS 讯飞星火 VS chatgpt (383)-- 算法导论24.5 3题
prometheus