(一) Prometheus
参考:
https://prometheus.io/docs/introduction/first_steps/
https://prometheus.io/docs/prometheus/latest/installation/
https://blog.csdn.net/luanpeng825485697/article/details/82318204
(1) 安装(下面介绍使用Docker进行安装)
Docker 拉取镜像
docker pull prom/prometheus
(2)配置文件:prometheus.yml
# 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: ['localhost:9090']
- job_name: 'clickhouse_exporter'
# 覆盖全局的 scrape_interval
scrape_interval: 5s
static_configs:
- targets: ['192.168.10.154:9116']
(3)docker 运行
sudo docker run -d -p 9090:9090 -v $PWD/prometheus-data/prometheus.yml:/etc/prometheus/prometheus.yml -v $PWD/prometheus-data:/prometheus --user "root" --name prometheus prom/prometheus
(4)测试验证
在浏览器输入下面url能访问到内容,则表明测试成功。
# localhost填写prometheus安装的服务ip地址
http://localhost:9090/
(二)ClickHouse Exporter
参考:https://github.com/f1yegor/clickhouse_exporter
推荐使用Docker进行安装:
- Docker 拉取镜像
docker pull f1yegor/clickhouse-exporter
- Docker 运行
# clickhouse.service.consul 填写clickhouse安装的服务ip地址
docker run -d -p 9116:9116 f1yegor/clickhouse-exporter -scrape_uri=http://clickhouse.service.consul:8123/
- 测试验证
在浏览器输入下面url能访问到内容,则表明测试成功。
# localhost填写clickhouse-exporter安装的服务ip地址
http://localhost:9116/
(三)Grafana
安装参考:https://grafana.com/grafana/download
- Centos (64 Bit) 安装
sudo wget https://dl.grafana.com/oss/release/grafana-6.0.2-1.x86_64.rpm
sudo yum localinstall grafana-6.0.2-1.x86_64.rpm
- 配置文件,可以根据自己需求修改
sudo vim /etc/grafana/grafana.ini
[server]
;protocol = http (默认的连接形式)
;http_addr = (这里可以限制登陆的ip,增加安装性)
;http_port = 3000 (端口)
;domain = localhost (域名)
;enforce_domain = false
;root_url = http://localhost:3000 (访问的项目地址)
- 运行
# 开启grafana
sudo systemctl start grafana-server
# 设为开机启动
sudo systemctl enable grafana-server
默认情况下,Grafana将监听 http://localhost:3000。默认登录名和密码都为"admin",第一次登录会提示修改。