prometheus官网:https://prometheus.io/
下载地址:https://prometheus.io/download/
prometheus历史github地址:https://github.com/prometheus/prometheus/releases
此处选用:
prometheus-2.26.0.linux-amd64.tar.gz
安装步骤
1.clickhouse的config.xml配置文件打开promethmus注释,重启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>
--重启
clickhouse restart
添加端口,其他服务器节点类似;
firewall-cmd --zone=public --add-port=9363/tcp --permanent
firewall-cmd --reload
ClickHouse 开启 Metrics 服务成功:
http://192.168.189.9:9363/metrics
2.上传解压prometheus-2.26.0.linux-amd64.tar.gz文件并重命名
tar -zxvf prometheus-2.26.0.linux-amd64.tar.gz
mv prometheus-2.26.0.linux-amd64 promethemus-2.26
3.修改 promethmus.yml文件,#添加 ClickHouse 监控配置,
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['master:9090']
#添加 ClickHouse 监控配置
- job_name: clickhouse-master
static_configs:
- targets: ['master:9363','slave1:9363','slave2:9363']
备注:
配置说明:
1、global 配置块:控制 Prometheus 服务器的全局配置
➢ scrape_interval:配置拉取数据的时间间隔,默认为 1 分钟。
➢ evaluation_interval:规则验证(生成 alert)的时间间隔,默认为 1 分钟。
2、rule_files 配置块:规则配置文件
3、scrape_configs 配置块:配置采集目标相关, prometheus 监视的目标。Prometheus 自身
的运行信息可以通过 HTTP 访问,所以 Prometheus 可以监控自己的运行数据。
➢ job_name:监控作业的名称
➢ static_configs:表示静态目标配置,就是固定从某个 target 拉取数据
➢ targets : 指 定 监 控 的 目 标 , 其 实 就 是 从 哪 儿 拉 取 数 据 。 Prometheus 会 从
http://master:9090/metrics 上拉取数据。
Prometheus 是可以在运行时自动加载配置的。启动时需要添加:–web.enable-lifecycle
4.启动
cd promethemus-2.26/
nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &
5.访问页面
http://192.168.189.9:9090/
如下状态则成功: