美文网首页
grafana快速搭建

grafana快速搭建

作者: 木火应 | 来源:发表于2022-05-12 23:25 被阅读0次
    • 安装Grafana

      1. docker pull grafana/grafana
      2. docker run -d --name=grafana -p 3000:3000 grafana/grafana
      3. 自此,grafana搭建完成,通过http://ip:3000访问,初始账号密码:admin/admin
    • 接下来就是收集服务节点的数据了,在需要监控的节点上操作:

      1. 安装Node Exporter,用于采集 UNIX 内核主机的数据,如cpu、内存、io、网络流量等信息,选择对应的内核版本(本地centos7)(github各个历史版本参见),解压运行,监听在9100端口
      wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
      tar xvf node_exporter-1.3.1.linux-amd64.tar.gz
      cd node_exporter-1.3.1.linux-amd64
      nohup ./node_exporter &> /dev/null &
      

      测试curl http://localhost:9100/metrics

      [root@mhy ~]# curl http://localhost:9100/metrics
      ...
      # HELP promhttp_metric_handler_requests_total Total number of     scrapes by HTTP status code.
      # TYPE promhttp_metric_handler_requests_total counter
      promhttp_metric_handler_requests_total{code="200"} 5
      promhttp_metric_handler_requests_total{code="500"} 0
      promhttp_metric_handler_requests_total{code="503"} 0
      

      关闭防火墙,systemctl stop firewalld;systemctl disable firewalld,或使用iptables放行9100端口iptables -I INPUT -p tcp --dport 9100

      1. 安装DCGM Exporter,用于采集 NVIDIA GPU 的数据,以Docker 镜像运行:
        docker run -d --restart=always --gpus all -p 9400:9400 nvidia/dcgm-exporter
      2. ...
    • 安装Prometheus(无需安装在节点上,本地测试与grafana在同一主机):

      1. 编写配置~/prometheus.yml,测试只加了Node Exporter监控:
      global:
        scrape_interval: 15s
      scrape_configs:
      # Node Exporter
      - job_name: node
        static_configs:
        - targets: ['192.168.244.132:9100','192.168.244.129:9100'] # 这里可以加入多个节点
      # DCGM Exporter
      ......... # 相关服务继续加
      
      1. 运行docker,暴露端口:9090
      [root@mhy ~]# docker pull prom/prometheus
      [root@mhy ~]# docker run -d --restart=always -p 9090:9090 -v ~/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
      
    • 最后就是在grafana中配置了

      1. 配置data sources


        image.png
        image.png
        image.png
        image.png
        image.png
      2. 导入仪表盘(ID获取)

        image.png
        image.png
        image.png
        image.png

    成功!

    参见Prometheus + Grafana 快速上手

    相关文章

      网友评论

          本文标题:grafana快速搭建

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