Prometheus + ClickHouse Exporter + Grafana 实现ClickHouse监控

(一) 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进行安装:

  1. Docker 拉取镜像
docker pull f1yegor/clickhouse-exporter
  1. Docker 运行
# clickhouse.service.consul 填写clickhouse安装的服务ip地址
docker run -d -p 9116:9116 f1yegor/clickhouse-exporter -scrape_uri=http://clickhouse.service.consul:8123/
  1. 测试验证
    在浏览器输入下面url能访问到内容,则表明测试成功。
# localhost填写clickhouse-exporter安装的服务ip地址
http://localhost:9116/

(三)Grafana

安装参考:https://grafana.com/grafana/download

  1. 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 
  1. 配置文件,可以根据自己需求修改
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 (访问的项目地址)

  1. 运行
# 开启grafana
sudo systemctl start grafana-server
# 设为开机启动
sudo systemctl enable grafana-server

默认情况下,Grafana将监听 http://localhost:3000。默认登录名和密码都为"admin",第一次登录会提示修改。

(四) 通过上面步骤的安装运行完成之后,可以在浏览器通过http://localhost:3000进行对应监控数据的显示面板配置。

参考:https://grafana.com/dashboards/882

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
好的,下面是prometheus+node_exporter+grafana的详细部署流程: 1. 下载并安装Prometheus 首先,需要从Prometheus的官方网站 https://prometheus.io/download/ 下载最新版本的Prometheus。下载完成后,解压缩并将其放在合适的位置。然后,可以通过以下命令启动Prometheus: ``` ./prometheus --config.file=prometheus.yml ``` 这里的“prometheus.yml”是Prometheus的配置文件,可以根据需要进行修改。 2. 下载并安装Node Exporter Node Exporter是一个用于收集主机指标的代理程序,可以通过以下命令下载最新版本的Node Exporter: ``` wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz ``` 下载完成后,解压缩并将其放在合适的位置。然后,可以通过以下命令启动Node Exporter: ``` ./node_exporter ``` 3. 配置Prometheus监控Node Exporter监控Node Exporter,需要将其添加到Prometheus的配置文件中。打开“prometheus.yml”文件并添加以下内容: ``` scrape_configs: - job_name: 'node_exporter' scrape_interval: 5s static_configs: - targets: ['localhost:9100'] ``` 这里的“targets”是Node Exporter的地址和端口号。如果要监控多个Node Exporter,则可以添加多个目标。 4. 下载并安装Grafana Grafana是一个用于可视化监控数据的开源平台,可以通过以下命令下载最新版本的Grafana: ``` wget https://dl.grafana.com/oss/release/grafana-7.1.5.linux-amd64.tar.gz ``` 下载完成后,解压缩并将其放在合适的位置。然后,可以通过以下命令启动Grafana: ``` ./bin/grafana-server ``` 5. 配置Grafana 要将PrometheusGrafana集成,需要在Grafana中添加一个数据源。打开Grafana并导航到“Configuration”>“Data Sources”>“Add Data Source”: - 在“Name”字段中输入数据源的名称。 - 在“Type”字段中选择“Prometheus”。 - 在“HTTP”字段中输入Prometheus的地址和端口号。 - 单击“Save & Test”以保存数据源并测试连接。 接下来,可以创建一个仪表盘并添加一个面板以显示Prometheus的数据。导航到“Create”>“Dashboard”>“Add Panel”: - 选择要显示的指标。 - 选择要显示的图表类型。 - 单击“Apply”以保存面板。 6. 查看监控数据 现在,可以通过Grafana查看收集到的监控数据。导航到仪表盘,将其刷新以更新数据,并查看面板中的图表。 以上就是prometheus+node_exporter+grafana的详细部署流程。希望对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值