运维监控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

相关推荐
回忆2012初秋4 分钟前
【Nginx】原理、配置与运维实战(2)
运维·nginx·策略模式
IT WorryFree44 分钟前
Zabbix7.4 + Grafana 天蝎(Zabbix 官方插件数据源)完整配置 + 解决 412 报错
zabbix·grafana
Urbano1 小时前
工装外套全制作流程、工序痛点及自动化设备升级方案
运维·自动化
映翰通朱工1 小时前
工业4G网关无公网IP远程运维实战(内网终端异地访问方案)
运维·服务器·网络·安全·智能路由器
洪晓露1 小时前
将 rke2 集群证书延长至 10 年
运维·服务器·数据库
谢平康2 小时前
解决用 rm 报bash: /usr/bin/rm: Argument list too long错
linux·运维·运维开发
IP老炮不瞎唠2 小时前
Python 价格监控如何实现?思路与实用方法分享
运维·服务器·网络
GIS数据转换器2 小时前
城市排水生命线安全运行监测平台深度解析
java·运维·人工智能·python·安全·数据挖掘·无人机
Tokai_Teio_13 小时前
第四届黄河流域 misc
运维·服务器
hj2862513 小时前
Linux 网络服务综合笔记(概念 + 命令 + 实操案例)2
linux·运维·网络