运维监控grafana+prometheus+node_exporter(&or mysqld_exporter)

grafana+prometheus+node_exporter

前言

node_exporter在各个工作节点用程序本地运行,grafana和prometheus只需一个非工作节点通过网络访问这些node_exporter,所以grafana和prometheus可以用容器部署,方便。

参考文章

grafana+Prometheus(普罗米修斯)实现监控功能

保姆级教程--容器化部署prometheusd监控系统(yaml文件、docker命令均有详细解释、大白话描述服务作用、适合小白)_prometheus容器化部署-CSDN博客

Node Exporter 简介

下载

Prometheus:

bash 复制代码
exe:
https://github.com/prometheus/prometheus/releases
docker:
https://hub.docker.com/r/prom/prometheus/

node_exporter

bash 复制代码
https://github.com/prometheus/node_exporter/releases/

grafana

bash 复制代码
https://grafana.com/grafana/download?platform=docker

xx_exporter负责信息抓取(保存本地),Prometheus负责搜集(通过网络),grafana负责可视化

这个expoter最好直接运行在节点上,不要用容器运行。

node_expoter下载地址:Releases · prometheus/node_exporter · GitHub

启动

node_expoter

推荐直接运行可执行程序:

bash 复制代码
tar -xf node_exporter-1.8.2.linux-amd64.tar.gz
cd node_exporter-1.8.2.linux-amd64/
mkdir ../node_metrics
pwd
./node_exporter --web.listen-address=":9096" --web.telemetry-path="/home/xxx/tmp/node_metrics" &
ps aux | grep node_exporter

也可以容器运行(未测试其中存储映射):

bash 复制代码
docker run -d -p 9100:9100 --restart=always --name node-exporter -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter:latest

浏览器测试:

prometheus

推荐容器运行:

bash 复制代码
docker run -d --name prometheus --privileged=true -u root --restart=always -p 9090:9090 -v D:\rd\yw\prometheus\config:/etc/prometheus -v D:\rd\yw\prometheus\data:/prometheus -v D:\rd\yw\prometheus\rules:/usr/local/prometheus/rules prom/prometheus:latest --storage.tsdb.retention.time=100d --config.file=/etc/prometheus/prometheus.yml

prometheus.yml示例:

bash 复制代码
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
alerting:
  alertmanagers:
    - static_configs:
        - targets: ['15.66.11.13:9093']

rule_files:
  - "/usr/local/prometheus/rules/*.yml"

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "soc"
    static_configs:
      - targets: ["15.66.6.180:9096"]
    metrics_path: "/node_metrics"
  - job_name: "compile server"
    static_configs:
      - targets: ["15.66.2.101:9096","15.66.2.102:9096"]
    metrics_path: "/home/xiaojun.zhang/tmp/node_metrics"
  - job_name: "work test"
    static_configs:
      - targets: ["15.66.11.13:9100"]
    
    

浏览器测试:

grafana

推荐容器安装:

Linux:

bash 复制代码
docker run -d -p 3000:3000 --name grafana --restart=always -v /opt/grafana/data:/var/lib/grafana -v /etc/localtime:/etc/localtime grafana/grafana:latest

Windows(Windows上docker容器默认就与Window时间一致):

bash 复制代码
docker run -d -p 3000:3000 --name grafana -v D:\rd\yw\grafana\data:/var/lib/grafana grafana/grafana:latest

也可以用这个镜像(暂时不知区别)

bash 复制代码
grafana/grafana-enterprise:latest

注意:

如果是容器启动grafana,则配置Prometheus地址时不能用localhost,因为会从容器内尝试连接,要用主机分配的IP地址比如192.168.xx.xx

否则出现如下报错:

浏览器测试:

拉到最下面:

输入仪表盘ID,点击load

点击import

画面立即出现在眼前:

查找仪表盘:

访问Grafana: The open observability platform | Grafana Labs

搜索dashboard

比如再倒入一个1860

相关推荐
李少兄39 分钟前
CentOS系统下前后端项目部署攻略
linux·运维·centos
Two_brushes.3 小时前
【Linux】线程机制深度实践:创建、等待、互斥与同步
linux·运维·服务器·多线程
设计师小聂!5 小时前
Linux系统中部署Redis详解
linux·运维·数据库·redis
努力做小白6 小时前
Linux驱动11 --- buildroot&杂项驱动开发方法
linux·运维·驱动开发·单片机·嵌入式硬件
Sally璐璐7 小时前
Memcache核心技术解析与实战应用
运维·wpf·memcached
哈哈浩丶7 小时前
Linux驱动开发1:设备驱动模块加载与卸载
linux·运维·驱动开发
诗人不说梦^10 小时前
[BUUCTF 2018]Online Tool
linux·运维·服务器
晚风_END11 小时前
Linux|服务器|二进制部署nacos(不是集群,单实例)(2025了,不允许还有人不会部署nacos)
linux·运维·服务器·数据库·编辑器·个人开发
阿沁QWQ12 小时前
应用层协议和JSON的使用
运维·服务器·网络
运维开发王义杰12 小时前
不止于监控:深入剖析OpenTelemetry的可观察性生态体系
运维