Prometheus监控Linux

news/2024/5/19 0:21:57 标签: prometheus, linux, 运维

Linux 客户端安装docker 

export DOWNLOAD_URL="http://mirrors.163.com/docker-ce"
curl -fsSl https://get.docker.com/ |sh
apt install docker-compose -y

创建node-exporter

mkdir -p /data/docker-compose
cd /data/docker-compose

cat >docker-compose.yaml <<'EOF'
version: '3.3'
networks:
  monitoring:
    driver: bridge

services:
  node_exporter:
    image: prom/node-exporter:v1.5.0
    container_name: node-exporter
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command: 
      - '--path.procfs=/host/proc' 
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc|rootfs/var/lib/docker)($$|/)'
    networks:
      - monitoring
    ports:
      - '9100:9100'
EOF

启动docker

docker-compose up -d

浏览器验证


http://ip:9100/metrics


 prometheus节点操作


 配置prometheeus/prometheus.yaml

  - job_name: 'node-exporter'
    scrape_interval: 15s
    static_configs:
    - targets: ['node_exporter:9100']
      labels:
        instance: Prometheus服务器 
    - targets: ['10.19.1.206:9100']
      labels:
        instance: 10.19.1.206服务器 
    - targets: ['10.19.1.220:9100']
      labels:
        instance: 10.19.1.220服务器

配置加载
curl -X POST http://localhost:9090/-/reload
检查容器状态
docker ps -a
docker logs -f node-exporter

CPU采集
node_cpu_seconds_total
node_cpu_seconds_total{ instance="10.19.1.220服务器"}
node_load1
node_load5
node_load15


内存采集
node_memory_MemTotal_bytes
node_memory_MemAvailable_bytes (free+buffer+cache)
node_memory_MemFree_bytes
node_memory_SwapFree_bytes
node_memory_SwapTotal_bytes


磁盘采集
node_disk_


文件系统采集
node_filesystem_

网络采集
node_network_
node_network_transmit_drop_total

增加触发器配置

cat >> prometheus/alert.yml <<'EOF'
- name: node-exporter
  rules:
  - alerts: HostOutOfMemory
    expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10
	for: 2m
	labels:
	  severity: warning
	annotations:
	  summary: "主机内存不足,实例:{{ $labels.instance }}"
	  description: "内存可用率<10%,当前值:{{ $value }}"	  
  - alerts: HostMemoryUnderMemoryPressure
    expr: rate(node_vmstat_pgmajfault[1m]) > 1000
	for: 2m
	labels:
	  severity: warning
	annotations:
	  summary: "主机压力不足,实例:{{ $labels.instance }}"
	  description: "节点内存压力大,重大页面错误率高,当前值:{{ $value }}"   
  - alerts: HostUnusualNetworkThroughputIn
    expr: sum by (instance) (rate(node_network_receive_bytes_total[2m])) / 1024 / 1024 > 100
	for: 5m
	labels: 
	  severiry: warning
	annotations: 
	  summary: "异常流出网络吞吐量,实例: {{ $labels.instance }}"
	  description: "网络流入量 > 100 MB/s,当前值: {{ $value }}"  
  - alerts: HostUnusualDiskReadRate
    expr: sum by (instance) (rate(node_disk_read_bytes_total[2m])) / 1024 /1024 > 50
	for: 5m
	labels:
	  severity: warning
	annotations:
	  summary: "异常流出网络吞吐量,实例:{{ $labels.instance }}"
	  description: "网络流出流量 > 100 MB/s,当前值: {{ $value }}"
EOF
检查配置

docker exec -it prometheus promtool check config /etc/prometheus/prometheus.yml

grafana展示node-exporter的数据


http://www.niftyadmin.cn/n/5295654.html

相关文章

个人博客主题 vuepress-hope

文章目录 1. 简介2. 配置2.1 todo 非常推荐vuepress-hope 1. 简介 下面的我的博客文章的截图 通过md写博客并且可以同步到github-page上 2. 配置 2.1 todo

轻松调整视频时长,创意与技术的新篇章

传统的视频剪辑工具往往难以精确控制时间&#xff0c;而【媒体梦工厂】凭借其先进的算法和界面设计&#xff0c;让视频时长的调整变得简单而精确&#xff0c;助你释放无限的创意&#xff0c;用技术为你的创意插上翅膀&#xff0c;让每一秒都有意义。 所需工具&#xff1a; 一…

RuntimeError: The NVIDIA driver on your system is too old.

【报错】使用 AutoDL 复现实验时遇到 RuntimeError: The NVIDIA driver on your system is too old (found version 11070). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternativ…

数字图像处理——亚像素边缘的轮廓提取

像素 像素是图像处理中的基本单位&#xff0c;一个像素是图像中最小的离散化单位&#xff0c;具有特定的位置和颜色信息。在数字图像中&#xff0c;每个像素都有一个特定的坐标&#xff0c;通常以行和列的形式表示。每个像素的颜色信息可以通过不同的表示方式&#xff0c;如灰…

python dash call_back 多output 7

效果 代码 # 导入Dash库及其相关组件&#xff0c;用于构建交互式Web应用 from dash import Dash, dcc, html, Input, Output, callback# 定义一个外部样式表&#xff0c;用于美化应用界面 external_stylesheets [https://codepen.io/chriddyp/pen/bWLwgP.css]# 创建一个D…

十三:爬虫-Scrapy框架(下)

一&#xff1a;各文件的使用回顾 1.items的使用 items 文件主要用于定义储存爬取到的数据的数据结构&#xff0c;方便在爬虫和 Item Pipeline 之间传递数据。 items.pyimport scrapyclass TencentItem(scrapy.Item):# define the fields for your item here like:title scr…

Baumer工业相机堡盟工业相机如何通过NEOAPI SDK设置相机的固定帧率(C++)

Baumer工业相机堡盟工业相机如何通过NEOAPI SDK设置相机的固定帧率&#xff08;C&#xff09; Baumer工业相机Baumer工业相机的固定帧率功能的技术背景CameraExplorer如何查看相机固定帧率功能在NEOAPI SDK里通过函数设置相机固定帧率 Baumer工业相机通过NEOAPI SDK设置相机固定…

【MySQL】事务Transaction

1. 事务的概念 事务是什么 在业务逻辑中使用sql&#xff0c;面对一些较复杂的场景&#xff0c;是需要多个sql语句组合起来实现的。如&#xff1a;银行的转账业务&#xff0c;若客户A要转账100元给客户B&#xff0c;就要两条sql&#xff1a;A余额减100&#xff0c;B余额加100&a…