在Linux系统部署prometheus监控(2) --配置规则

简介: 在Linux系统部署prometheus监控(2) --配置规则

首先确保服务开启

vim node_rules.yml

注意:编写这个文件注意不要用tab键,只用空格来缩进

访问localhost:9090/rules

如果relod发现rules没有生效,可以重启服务

netstate -lntp |grep prom

kill -9 进程号

./prometheus &

再次访问

cpu > 80

100-(avg(irate(node_cup_seconds_total{mode='idle'}[5m]))by(instance)*100) > 80

内存

100 - (node_memory_MemFree_bytes + node_memory_Cached_bytes + node_memory_Buffers_bytes) / node_memory_MemTotal_bytes * 100

 

disk

100 - (((node_filesystem_size_bytes{fstype=~"xfs|ext4"} - node_filesystem_free_bytes{fstype=~"xfs|ext4"}) / node_filesystem_size_bytes{fstype=~"xfs|ext4"}) * 100)

节点状态

up metric

监视特定节点状态的另一个有用指标:up ,如果实例是健康的,度量就被设置为1 ,失败返回 - 或 0

用来监控节点是否健康,如果健康则为1,不健康的话说明该服务器node服务可能停了,也可能该节点down了需要立马检查

- alert: NodeDown

 expr: node_up == 0

 for: 0m

 labels:

    severity: serious

 annotations:

      summary: "NodeDown"

下面都一样的模板配置即可

MysqlDown

RedisDown

NginxDown

JavaDown

groups:

- name: Hoststate-alert()

 rules:

 - alert: RedisDown

   expr: up == 0

   for: 0m

   labels:

     status: critical

   annotations:

     summary: "Redisdown"

     description: "Redis instance is down"

 - alert: MysqlDown

   expr: up == 0

   for: 0m

   labels:

     status: critical

   annotations:

     summary: "Msqldown"

     description: "Mysql instance is down"

 - alert: NginxDown

   expr: up == 0

   for: 0m

   labels:

     status: critical

   annotations:

     summary: "Nginxdown"

     description: "Nginx instance is down"

 - alert: NodeDown

   expr: up == 0

   for: 0m

   labels:

     status: critical

   annotations:

     summary: "Nodedown"

     description: "Node instance is down"

 - alert: JavaDown

   expr: up == 0

   for: 0m

   labels:

     status: critical

   annotations:

     summary: "Javadown"

     description: "Java instance is down"

 - alert: CPUusage

   expr: 100-(avg(irate(node_cpu_seconds_total{mode='idle'}[5m]))by(instance) * 100) > 80

   for: 5m

   labels:

     status: critical

   annotations:

     summary: "{{$labels.mountpoint}} CPU usage high"

     description: "{{$labels.mountpoint}} CPU usage above 80% ( current usage:{{$value}})"

 - alert: Memoryusage

   expr: 100 - (node_memory_MemFree_bytes + node_memory_Cached_bytes + node_memory_Buffers_bytes)/ node_memory_MemTotal_bytes * 100 > 80

   for: 5m

   labels:

     status: critical

   annotations:

     summary: " Memory usage high"

     description: "Memory usage above 80%.( current usage:{{$value}})"

 - alert: Diskusage

   expr: 100 - (((node_filesystem_size_bytes{fstype=~"xfs|ext4"} - node_filesystem_free_bytes{fstype=~"xfs|ext4"}) / node_filesystem_size_bytes{fstype=~"xfs|ext4"}) * 100)  > 80

   for: 5m

   labels:

     status: critical

   annotations:

     summary: "Disk usage high"

     description: "Disk usage above 80% ( current usage:{{$value}})"



相关文章
|
2天前
|
Linux
【Linux系统编程】基础指令(二)(下)
【Linux系统编程】基础指令(二)
|
1天前
|
运维 监控 Linux
提升系统稳定性:Linux内核参数调优实战
【5月更文挑战第1天】 在运维领域,保障服务器的高效稳定运行是核心任务之一。Linux操作系统因其开源、可靠和灵活的特点被广泛应用于服务器中。本文将深入探讨通过调整Linux内核参数来优化系统性能,提升服务器的稳定性和响应能力。文章首先介绍了内核参数调优的必要性和基本原则,然后详细阐述了调优过程中的关键步骤,包括如何监控当前系统状态,确定性能瓶颈,选择合适的参数进行调优,以及调优后的测试与验证。最后,文中提供了一些常见问题的解决策略和调优的最佳实践。
12 5
|
1天前
|
Linux
Linux系统ps命令
这些是一些常见的 `ps`命令选项和用法,用于查看系统中运行的进程及其相关信息。您可以根据需要选择合适的选项以满足您的任务要求。
5 0
|
1天前
|
存储 Linux 文件存储
Linux使用Docker部署Traefik容器并实现远程访问管理界面-1
Linux使用Docker部署Traefik容器并实现远程访问管理界面
|
1天前
|
存储 负载均衡 网络协议
在Linux中优化系统性能的实用指南
【4月更文挑战第30天】本文是关于Linux系统性能优化的指南,涵盖硬件选择、系统及软件更新、调整Swap分区、内核参数优化、使用性能分析工具、文件系统优化、网络服务优化和定期维护等方面。通过这些方法,可提升系统响应速度,降低资源消耗,延长硬件寿命。注意,优化需根据具体系统和应用需求进行。
|
2天前
|
弹性计算 Shell Linux
|
2天前
|
存储 缓存 Linux
linux几种典型应用对系统资源使用的特点
【4月更文挑战第22天】几种典型应用对系统资源使用的特点
8 0
|
2天前
|
存储 关系型数据库 MySQL
linux安装MySQL8.0,密码修改权限配置等常规操作详解
linux安装MySQL8.0,密码修改权限配置等常规操作详解
|
2天前
|
Web App开发 监控 Unix
Linux 常用命令汇总(七):进程管理 & 系统权限 & 用户授权
Linux 常用命令汇总(七):进程管理 & 系统权限 & 用户授权

热门文章

最新文章