Skip to content

1.metrics

ClickHouse 从 v20.1.2.4 开始,内置了对接 Prometheus 的功能,配置的方式也很简单,可以将其作为 Prometheus 的 Endpoint 服务,从而自动的将 metrics 、 events 和asynchronous_metrics 三张系统的表的数据发送给 Prometheus

1.1开启

编辑,/etc/clickhouse-server/config.xml

yaml
    <prometheus>
        <endpoint>/metrics</endpoint>
        <port>9363</port>

        <metrics>true</metrics>
        <events>true</events>
        <asynchronous_metrics>true</asynchronous_metrics>
        <status_info>true</status_info>
    </prometheus>
    <prometheus>
        <endpoint>/metrics</endpoint>
        <port>9363</port>

        <metrics>true</metrics>
        <events>true</events>
        <asynchronous_metrics>true</asynchronous_metrics>
        <status_info>true</status_info>
    </prometheus>
  • 重启服务

如果有多个 CH 节点,分发配置

systemctl restart clickhouse-server.service
systemctl restart clickhouse-server.service

1.2访问

浏览器打开: http://ip:9363/metrics

image-20241104223926086

2. prometheus添加

yaml
    - job_name: clickhouse
      static_configs:
      - targets:
        - 10.103.236.200:9363
      scrape_interval: 1m
      scrape_timeout: 30s
      scheme: http
      metrics_path: "/metrics"
    - job_name: clickhouse
      static_configs:
      - targets:
        - 10.103.236.200:9363
      scrape_interval: 1m
      scrape_timeout: 30s
      scheme: http
      metrics_path: "/metrics"
  • 热更新
bash
curl -XPOST  http://prometheus.ikubernetes.net/-/reload
curl -XPOST  http://prometheus.ikubernetes.net/-/reload

3. granfana添加