zoukankan      html  css  js  c++  java
  • 【开源监控】Prometheus+Node Exporter+Grafana监控linux服务器

    Prometheus

    Prometheus介绍

    Prometheus新一代开源监控解决方案。github地址

    Prometheus主要功能

    • 多维 数据模型(时序由 metric 名字和 k/v 的 labels 构成)。
    • 灵活的查询语句(PromQL)。
    • 无依赖存储,支持 local 和 remote 不同模型。
    • 采用 http 协议,使用 pull 模式,拉取数据,简单易懂。
    • 监控目标,可以采用服务发现或静态配置的方式。
    • 支持多种统计数据模型,图形化友好。

    Prometheus核心组件

    • Prometheus Server, 主要用于抓取数据和存储时序数据,另外还提供查询和 Alert Rule 配置管理。
    • client libraries,用于对接 Prometheus Server, 可以查询和上报数据。
    • push gateway ,用于批量,短期的监控数据的汇总节点,主要用于业务数据汇报等。
    • 各种汇报数据的 exporters ,例如汇报机器数据的 node_exporter, 汇报 MongoDB 信息的 MongoDB exporter 等等。
    • 用于告警通知管理的 alertmanager

    Prometheus安装

    二进制安装

    cd /opt
    wget https://github.com/prometheus/prometheus/releases/download/v2.13.0/prometheus-2.13.0.linux-amd64.tar.gz
    tar zxvf prometheus-2.13.0.linux-amd64.tar.gz 
    cd prometheus-2.13.0.linux-amd64
    

    查看版本

    [root@localhost prometheus-2.13.0.linux-amd64]# ./prometheus --version
    prometheus, version 2.13.0 (branch: HEAD, revision: 6ea4252299f542669aca11860abc2192bdc7bede)
      build user:       root@f30bdad2c3fd
      build date:       20191004-11:25:34
      go version:       go1.13.1
    

    启动

    ./prometheus
    

    或者

    cd /opt/prometheus-2.13.0.linux-amd64
    nohup ./prometheus &
    

    可以通过浏览器来访问 http://IP:9090,可以看到prometheus管理页面。

    Node Exporter安装

    cd /opt/
    wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
    tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz 
    

    Node Exporter启动

    ./node_exporter 
    

    可以通过浏览器访问http://IP:9100/metrics,访问度量指标。

    Prometheus端配置

    /opt/prometheus-2.13.0.linux-amd64/prometheus.yml修改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: ['localhost:9090']
      ## 以下是node_exporter的添加内容
      - job_name: 'node_exporter'
        static_configs:
        - targets:
          - '172.31.1.203:9100'
    

    Prometheus端效果查询

    检验Node Exporter的效果

    node-04.png

    Grafana端配置

    1.配置Prometheus数据源

    node_02.png

    2.添加dashboards的模板

    这里使用的是9276模板,连接地址:https://grafana.com/grafana/dashboards/9276

    node-03.png

    3.展示效果,如下:

    node05.png

  • 相关阅读:
    java lambda表达式学习笔记
    一个奇妙的java坑:Long 类型的比较
    要不要冗余字段
    mysql找回密码
    mysql创建触发器
    【转】Java 8十个lambda表达式案例
    ThreadLocal类学习笔记
    mybatis generator使用总结
    【转】Java 项目UML反向工程转化工具
    PostMan做接口自动化测试
  • 原文地址:https://www.cnblogs.com/zhangshengdong/p/11724888.html
Copyright © 2011-2022 走看看