Prometheus&Grafana + clickhouse监控配置

一、Prometheus安装

Prometheus 基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖。只需要
下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prometheus Server。
Prometheus 下载地址:https://prometheus.io/download/ 

1.1 上传&解压 安装包

[root@ggl203 ~]# tar -zxf prometheus-2.36.2.linux-amd64.tar.gz -C /data/
[root@ggl203 data]# mv prometheus-2.36.2.linux-amd64/ prometheus-2.36.2

1.2 修改配置文件

[root@ggl203 prometheus-2.36.2]# vim prometheus.yml

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: ["ggl203:9090"]

  # clickhouse 跟下面的clickhouse配置相对应
  - job_name: clickhouse
    static_configs:
      - targets: ["ggl203: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://ggl203:9090/metrics 上拉取数据。

1.3 启动

[root@ggl203 prometheus-2.36.2]# nohup ./prometheus  --config.file=prometheus.yml > ./prometheus.log 2>&1 &

 浏览器访问:http://ggl203:9090/

 

二、clickhouse配置

2.1 修改配置文件

[root@ggl203 ~]# vim /etc/clickhouse-server/config.xml

    <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.2 重启clickhouse

service clickhouse-server restart

2.3 浏览器访问

http://ggl203:9363/metrics

三、Grafana 安装

下载链接:https://grafana.com/grafana/download

3.1 上传&解压

[root@ggl203 ~]# tar -zxf grafana-enterprise-9.0.0.linux-amd64.tar.gz -C /data/

3.2 启动

[root@ggl203 grafana-9.0.0]# nohup ./bin/grafana-server web > ./grafana.log 2>&1 &

  打开浏览器 http://ggl203:3000,默认用户名和密码:admin

 

3.3 添加 Prometheus源

四、添加监控

        手动一个个添加 Dashboard 比较繁琐, Grafana 社区鼓励用户分享 Dashboard,通过 https://grafana.com/dashboards 网站,可以找到大量可直接使用的 Dashboard 模板。
        Grafana 中所有的 Dashboard 通过 JSON 进行共享,下载并且导入这些 JSON 文件,就可 以直接使用这些已经定义好的 Dashboard

添加步骤如下:

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值