美文网首页软件测试性能优化
监控平台Prometheus+Grafana

监控平台Prometheus+Grafana

作者: Fox_Nick | 来源:发表于2022-07-18 18:40 被阅读0次

    目录:

    1、Prometheus
    
    1.1、安装与配置
    
    1.2、查看监控指标
    
    1.3、监控远程主机
    
    1.4、监控数据库
    
    2、Grafana
    
    2.1、安装与配置
    
    2.2、添加数据源
    
    2.3、添加仪表板
    
    2.4、官方仪表板
    

    1、Prometheus

    简介:
    Prometheus是一个开源系统监控和警报工具包,最初是在SoundCloud上构建的。自2012年成立以来,许多公司和组织都采用了Prometheus,该项目拥有非常活跃的开发者和用户社区。它现在是一个独立的开源项目,独立于任何公司进行维护。为了强调这一点,并澄清项目的治理结构,Prometheus于2016年加入云原生计算基金会,作为继Kubernetes之后的第二个托管项目。

    Prometheus将其指标收集并存储为时间序列数据,即指标信息与记录的时间戳一起存储,以及称为标签的可选键值对。

    官网地址:

    https://prometheus.io/
    

    下载地址:

    https://prometheus.io/download/
    

    1.1、安装与配置

    1、下载

    根据服务器系统,下载指定的版本。

    例如下载prometheus-2.30.0.linux-amd64.tar.gz

    image.png

    并将已下载的文件上传到服务器上
    或者直接输入命令,在服务器上进行下载

     wget https://github.com/prometheus/prometheus/releases/download/v2.30.0/prometheus-2.30.0.linux-amd64.tar.gz
    

    2、解压

    tar xf prometheus-2.30.0.linux-amd64.tar.gz
    

    3、移动文件夹并命名为prometheus

    mv prometheus-2.30.0.linux-amd64 /usr/local/prometheus
    

    4、跳转到prometheus文件夹

    cd /usr/local/prometheus
    

    目录文件:

    image.png

    5、prometheus.yml文件详解

    # my global config
    # 全局配置
    global:
      scrape_interval: 15s # 多久收集一次数据
      evaluation_interval: 15s # 多久评估一次规则
      # scrape_timeout is set to the global default (10s). 每次收集数据的超时时间,默认10秒
     
    # 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"]
    

    6、查看版本

    ./prometheus --version
    
    image.png

    7、后台启动
    ./prometheus &

    (记住prometheus IP端口地址,后续会用到)

    1.2、查看监控指标

    1、浏览器访问
    浏览器访问 http://服务器ip地址(端口默认9090)


    image.png

    Alerts:可以看到自定义的告警规则。

    Graph:按查询条件进行数据查询,并生成指定图形。

    Status:可以查看配置信息、规则、节点目标等,其中Targets表示本地和远端的监控,可以查看各节点运行情况。

    相关文章

      网友评论

        本文标题:监控平台Prometheus+Grafana

        本文链接:https://www.haomeiwen.com/subject/qawolrtx.html