Grafana+Prometheus的安装请参考Grafana+Prometheus+Pushgateway三剑客安装_那些乐趣的博客-CSDN博客博文
1:修改clickhouse的配置文件/etc/clickhouse-server/config.xml,打开config.xml,修改如下配置,这个配置应该是被注释掉了,打开即可,是clickhouse对外暴露接口的配置,
<prometheus>
<endpoint>/metrics</endpoint>
<port>9363</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
<status_info>true</status_info>
</prometheus>
2:重启clickhouse
sudo systemctl start clickhouse-server
3:打开浏览器访问http://xx.xx.xx.xx:9363/metrics,查看是否可以访问成功,(xx.xx.xx.xx为安装clickhouse服务器的ip)
4:Prometheus添加clickhouse配置,job_nam随便填写,不重复即可,targets为clickhouse暴露接口给Prometheus的地址
- job_name: 'clickhouse-xx.xx.xx.xx'
static_configs:
- targets: ['xx.xx.xx.xx:9363']
5:Grafana添加数据模板,访问dashbord地址:Dashboards | Grafana Labs;搜索clickhouse查找数据模板,找到符合自己的下载json文件导入Grafana或者直接通过id加载导入。