首页 > 数据库 >Alertmanager redis告警规则

Alertmanager redis告警规则

时间:2023-10-25 18:24:43浏览次数:34  
标签:Alertmanager expr labels redis alert instance host 告警

groups:
- name: redis集群预警
  rules:
  - alert: "redis节点下线"
    expr: up{instance=~".*:59121"} == 0
    for: 20s
    labels:
      severity: ERROR
      alert_type: "节点下线通知"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }} redis 监控主节点下线,请及时处理 命令: systemctl restart|status redis-exporter"
  - alert: "redis节点下线"
    expr: redis_up{instance=~"redis:.*"} == 0
    for: 20s
    labels:
      severity: WARN
      alert_type: "节点下线通知"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "{{ $labels.instance }} 节点下线,请及时处理"
  - alert: "redis集群节点丢失"
    expr: time() - redis_rdb_last_save_timestamp_seconds > 60 * 60 * 24
    for: 5m
    labels:
      severity: ERROR
    annotations:
      summary: "Missing back (instance {{ $labels.instance }})"
      description: "redis 集群节点:{{ $labels.instance }} 已下线12小时,请立即处理"
  - alert: "内存使用大于95%"
    expr: redis_memory_used_bytes / redis_total_system_memory_bytes * 100 > 95
    for: 5m
    labels:
      severity: WARN
    annotations:
      description: "Redis 当前节点 {{ $labels.instance }} 内存已使用 {{ $value }}%"
  - alert: "内存异常"
    expr: redis_mem_fragmentation_ratio < 1
    for: 5m
    labels:
      severity: WARN
    annotations:
      description: "Redis 当前节点 {{ $labels.instance }} redis可用内存不足,请减少key或增加内存"
  - alert: "内存异常"
    expr: redis_mem_fragmentation_ratio > 18
    for: 5m
    labels:
      severity: ERROR
    annotations:
      description: "Redis 当前节点 {{ $labels.instance }} 内存碎片过大,当前 {{ $value }},处理"
  - alert: "redis连接被拒绝"
    expr: increase(redis_rejected_connections_total[1m]) > 0
    for: 5m
    labels:
      severity: WARN
      alert_type: "连接被拒绝"
    annotations:
      description: "Redis 一些服务连接 {{ $labels.instance }} 被拒绝:查看文档"
  - alert: "redis主节点缺失"
    expr: count(redis_instance_info{role="master"}) == 0
    for: 5m
    labels:
      severity: WARN
      alert_type: "redis主节点缺失"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      summary: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }} redis主节点缺失"
      description: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }} 主节点丢失5分钟"
  - alert: "redis副本下线"
    expr: delta(redis_connected_slaves[1m]) < 0
    for: 5m
    labels:
      severity: WARN
      alert_type: "数据不同步"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "redis {{ $labels.instance }} 集群副本下线,请立即处理"
  - alert: "redis连接数过多"
    expr: redis_connected_clients{instance=~"redis://.*"} > redis_config_maxclients{instance=~"redis://.*"} * 0.85
    for: 5m
    labels:
      severity: WARN
      alert_type: "连接数过多"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "主机:{{ $labels.instance }} 当前连接数:{{ $value }},连接总数达到总量的85%,请立即检查"
  - alert: "redis连接数过多"
    expr: redis_connected_clients{instance=~"redis://.*"} > redis_config_maxclients{instance=~"redis://.*"} * 0.95
    for: 5m
    labels:
      severity: ERROR
      alert_type: "连接数过多"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "主机:{{ $labels.instance }} 当前连接数:{{ $value }},连接总数达到总量的95%,请立即检查"
  - alert: "redis连接数过低"
    expr: redis_connected_clients == 0
    for: 5m
    labels:
      severity: WARN
      alert_type: "连接数过低"
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "当前:{{ $labels.instance }} 无连接,请检查服务是否下线"
  - alert: "redis连接故障"
    expr: irate(redis_blocked_clients{job="redis_exporter_targets"}[5m]) > 3
    for: 5m
    labels:
      severity: WARN
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "当前:{{ $labels.alert_host }} 5分钟内阻塞进程大于3,请检查服务是否异常"
  - alert: "redis低命中效率低下"
    expr: redis_keyspace_hits_total / (redis_keyspace_hits_total + redis_keyspace_misses_total) > 0.95
    for: 5m
    labels:
      severity: ERROR
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "当前:{{ $labels.alert_host }} 命中率低下原因:数据到期和分配给redis内存不足,请及时检查内存、数据"
  - alert: "redis异常同步"
    expr: irate(redis_rdb_changes_since_last_save[60m])
    for: 60m
    labels:
      severity: ERROR
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "当前:{{ $labels.alert_host }} redis 某一台服务异常断开,同步异常"
  - alert: "redis集群连接异常"
    expr: redis_master_link_up{master_host=~".*"} == 0
    for: 5m
    labels:
      severity: WARN
      alert_host: "{{ reReplaceAll \":(.*)\" \"\" $labels.instance }}"
    annotations:
      description: "当前:{{ $labels.alert_host }} redis 复制连接当前断开"

标签:Alertmanager,expr,labels,redis,alert,instance,host,告警
From: https://www.cnblogs.com/zmh520/p/15629327.html

相关文章

  • Alertmanager Rabbitmq告警规则
    下载rabbitmq_exporter-0.29.0.linux-amd64.tar.gz这个包,下载地址:https://github.com/kbudde/rabbitmq_exporter/releasestarxfrabbitmq_exporter-0.29.0.linux-amd64.tar.gz-C/opt/cd/opt/rabbitmq_exporter-0.29.0.linux-amd64启动命令就1行:RABBIT_USER=guest......
  • redis面试提问
    redis面试提问转载:https://blog.csdn.net/uuqaz/article/details/127088333Redis是面试中绕不过的槛,只要在简历中写了用过Redis,肯定逃不过。今天我们就来模拟一下面试官在Redis这个话题上是如何一步一步深入,全面考察候选人对于Redis的掌握情况。小二:面试官,你好。我是来......
  • 浅谈关于羚通智能分析平台通道管理和告警查询的使用功能
    ​上期我们知道了如何使用羚通智能分析平台,今天我们来详细了解一下羚通智能分析平台的通道管理和告警查询的使用功能。因为羚通智能分析平台主要是做视频算法分析的,所以我们今天来看一看羚通智能分析平台的通道管理和告警查询两个部分的使用情况如何。上一期,我们了解了一下......
  • [粘贴]github-redis-rdb-cli
    redis-rdb-cliAtoolthatcanparse,filter,split,mergerdbandanalyzememoryusageoffline.Itcanalsosync2redisdataandallowuserdefinethereownsinkservicetomigrateredisdatatosomewhere.  ChatwithauthorContracttheauthorBinaryreleas......
  • 基于redis实现防重提交
    自定义防重提交1.自定义注解importjava.lang.annotation.*;/***自定义防重提交*@author*@date2023年9月6日11:19:13*/@Documented@Target(ElementType.METHOD)@Retention(RetentionPolicy.RUNTIME)public@interfaceRepeatSubmit{/***默认防......
  • redis实现短信登录流程
    (redis实现短信登录)最近在学习使用redis,实现一个简单的短信登录功能(没使用第三方api发送短信),使用的是黑马点评项目<aname="pf8N1"></a>先用session实现,再用redis代替session一、基于session实现短信登录的流程<aname="N2YCq"></a>发送短信验证码根据上边的流程图写@Post......
  • 分布式锁优化(基于redisson实现)
    基于setnx实现的分布式锁存在下面的问题:1.不可重入同一个线程无法多次获取同一把锁2.不可重试获取锁只尝试一次就返回false,没有重试机制3.超时释放锁超时释放虽然可以避免死锁,但如果是业务执行耗时较长,也会导致锁释放,存在安全隐患4.主从一致性(主写从读)如果Redis提供了主从集群,主......
  • Redis 6 学习笔记 4 —— 通过秒杀案例,学习并发相关和apache bench的使用,记录遇到的问
    背景这是某硅谷的redis案例,主要问题是解决计数器和人员记录的事务操作按照某硅谷的视频敲完之后出现这样乱码加报错的问题 乱码的问题要去tomcat根目录的conf文件夹下修改logging.properties,把下面两个encoding参数都改成GBK就行。其实错误也很明显(ClassNotFoundExceptio......
  • docker安装redis
    docker安装Redis拉取镜像dockerpullredis创建目录mkdir/tool/redis镜像里不包含配置文件,需要拉取redis最新的配置文件,查看下载完成直接通过ftp传到/tool/reids目录下就行因为是官方配置,需要我们手动改下配置:#常用配置bind127.0.0.1 #注释掉这部分,使redis可以......
  • 为什么单线程Redis能那么快
    单线程澄清Redis的单线程,指的是Redis的键值对读写由一个线程来完成。Redis的多线程:持久化异步删除集群数据同步网络IO(Redis6.0引入,5.0及之前都是单线程)......