clickhouse-监控配置

一、概述

监控是运维的一大利器,要想运维好clickhouse,首先就要对其进行监控,clickhouse有几种监控数据的方式,一种是系统本身监控,一种是通过exporter来监控,下面分别描述一下

二、系统自带监控

我下面会对监控做一些介绍,详细可查看官网

1.配置数据采集

修改配置文件/etc/clickhouse-server/config.xml使其可以往prometheus写数据

bash 复制代码
<clickhouse>
    <listen_host>0.0.0.0</listen_host>
    <http_port>8123</http_port>
    <tcp_port>9000</tcp_port>
    <prometheus>
        <endpoint>/metrics</endpoint>
        <port>9363</port>
        <metrics>true</metrics>
        <events>true</events>
        <asynchronous_metrics>true</asynchronous_metrics>
    </prometheus>
</clickhouse>

查看metrics数据

bash 复制代码
curl 127.0.0.1:9363/metrics

2.配置prometheus和grafana

2.1安装prometheus和grafana

prometheus和grafana的启动可查看这个文章

2.2修改prometheus配置文件

bash 复制代码
# 控制 Prometheus 服务器的全局配置
global:
  scrape_interval: 15s # 将抓取间隔设置为每 15 秒一次。 默认为每 1 分钟一次。
  evaluation_interval: 15s # 每 15 秒评估一次规则。 默认为每 1 分钟一次
  # scrape_timeout 设置为全局默认值(10 秒)。

# 警报配置
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# 规则配置文件
# 加载规则并根据全局 "evaluation_interval" 定期评估
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# 配置采集目标相关, prometheus 监视的目标。
# Prometheus 自身的运行信息可以通过 HTTP 访问,所以 Prometheus 可以监控自己的运行数据。
scrape_configs:
  # 监控作业的名称 
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # 表示静态目标配置,就是固定从某个 target 拉取数据
    # 默认方案为 HTTP
    static_configs:
      - targets: ["localhost:9090"]

  # 添加如下 clickhouse 监控
  - job_name: "clickhouse"
    static_configs:
      - targets: ['127.0.0.1:9363']
      - targets: ['192.168.1.2:9363']
      - targets: ['192.168.1.3:9363']

2.3 导入grafana模版

导入grafana面板,可以从官网中找合适的面板,亲测如果只使用clickhouse的内部监控,不基于exporter,14192的面板比较合适

  • 添加文件夹
  • 添加面板
  • 选择面板号或直接导入json文件

这样一套基于clickhouse的监控就处理好了

三、基于exporter的监控

clickhouse_exporter详情可以通过github来进行查看,exporter只能用于旧的ClickHouse版本,现代版本嵌入了Prometheus端点,安装go的方式可以看这篇文章

bash 复制代码
# 安装go环境,使用如下安装方式安装的是go1.6版本,编译会报错,需要安装高版本的go(应该大于1.13版本即可),我使用的是1.21的版本
apt-get install golang

# 下载代码
git clone  https://github.com/ClickHouse/clickhouse_exporter.git
# 进入到目录
cd clickhouse_exporter
# 编译
go build clickhouse_exporter.go
# 启动exporter
nohup ./clickhouse_exporter &

只下来就可以按照上面的步骤来配置了,可以应用882模版,也可以在已有的dashboard中配置一些我们需要的查询

加上对应的query后apply即可

告警指标可以参考腾讯云的指标

相关推荐
R_AirMan1 小时前
深入浅出Redis:一文掌握Redis底层数据结构与实现原理
java·数据结构·数据库·redis
Hello.Reader1 小时前
RedisJSON 内存占用剖析与调优
数据库·redis·缓存
wkj0012 小时前
php 如何通过mysqli操作数据库?
android·数据库·php
九皇叔叔4 小时前
【9】PostgreSQL 之 vacuum 死元组清理
数据库·postgresql
风雅的远行者4 小时前
mysql互为主从失效,重新同步
数据库·mysql
宇钶宇夕5 小时前
S7-1200 系列 PLC 中 SCL 语言的 PEEK 和 POKE 指令使用详解
运维·服务器·数据库·程序人生·自动化
绿蚁新亭5 小时前
Spring的事务控制——学习历程
数据库·学习·spring
scilwb6 小时前
占用栅格地图数据集
数据库
时序数据说7 小时前
时序数据库的存储之道:从数据特性看技术要点
大数据·数据库·物联网·开源·时序数据库·iotdb
鸥梨菌Honevid7 小时前
QT解析文本框数据——概述
数据库·qt·mysql