• Prometheus&Grafana + clickhouse监控配置


    一、Prometheus安装

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

    1.1 上传&解压 安装包

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

    1.2 修改配置文件

    1. [root@ggl203 prometheus-2.36.2]# vim prometheus.yml
    2. scrape_configs:
    3. # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
    4. - job_name: "prometheus"
    5. # metrics_path defaults to '/metrics'
    6. # scheme defaults to 'http'.
    7. static_configs:
    8. - targets: ["ggl203:9090"]
    9. # clickhouse 跟下面的clickhouse配置相对应
    10. - job_name: clickhouse
    11. static_configs:
    12. - 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 修改配置文件

    1. [root@ggl203 ~]# vim /etc/clickhouse-server/config.xml
    2. <prometheus>
    3. <endpoint>/metrics</endpoint>
    4. <port>9363</port>
    5. <metrics>true</metrics>
    6. <events>true</events>
    7. <asynchronous_metrics>true</asynchronous_metrics>
    8. <status_info>true</status_info>
    9. </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

    添加步骤如下:

     

     

     

  • 相关阅读:
    java-net-php-python-springboot办公自动化系统计算机毕业设计程序
    基于文本提示的图像目标检测与分割实践
    无重复字符的最长子串
    LeetCode每日一题——Single Number
    页面滚动组件
    Spark-3.2.4 高可用集群安装部署详细图文教程
    实现目录数据的上移(up)、下移(down)、置顶(top)、置底(bottom)的操作
    Go复合类型之数组类型
    健康防猝指南1:体重和减肥的秘密
    multisim仿真 74LS148D芯片
  • 原文地址:https://blog.csdn.net/qq_37056683/article/details/125597174