Prometheus监控redis

news/2024/5/18 23:41:20 标签: prometheus, redis, bootstrap

Redis 服务 启用

cat >docker-compose.yml<<'EOF'
version: '3'
services:
  redis:
    image: redis:5
    container_name: redis
    command: redis-server --requirepass 123456 --maxmemory 512mb
    restart: always
    volumes:
      - /data/redis/data:/data
    ports:
      - 6379:6379

Redis_exporter

  • docker直接运行
     
docker run -d --name redis_exporter -p 9121:9121 \
oliver006/redis_exporter \
--redis.addr redis://10.19.1.220:6379 \
--redis.password '123456'
  • docker-compose.yml
cd /data/redis/
```
cat >docker-compose.yaml << 'EOF'
version: '3.3'
services:
  redis_exporter:
    image: oliver006/redis_exporter
    container_name: redis_exporter
    restart: always
    environment:
      REDIS_ADDR: "10.19.1.220:6379"
      REDIS_PASSWORD: 123456
    ports:
      - '9121:9121'
EOF

prometheus/prometheus.yml 配置

cat >> prometheus/prometheus.yml << 'EOF'
  - job_name: 'redis_exporter'
    scrape_interval: 30s
    static_configs:
    - targets: ['10.19.1.220:9121']
      labels:
        instance: redis服务器 
EOF

加载配置文件

curl -X POST http://localhost:9090/-/reload

redis常用的监控指标

redis_uptime_in_seconds
rate(redis_cpu_sys_seconds_total[1m])+rate(redis_cpu_user_seconds_total[1m])
redis_memory_used_bytes
redis_memory_max_bytes
delta(redis_net_input_bytes_total[1m])
delta(redis_net_putput_bytes_total[1m])
redis_connected_clients
redis_rejected_connections_total
redis_connected_clients / redis_config_maxclients * 100

触发器设置

prometheus配置
mkdir /prometheus
```

vi prometheus/prometheus.yml
#报警(触发器)配置
rule_files:
  - "alert.yml"
  - "rules/*.yml"
```

redis触发器

cat > prometheus/rules/redis.yml << 'EOF'
groups:
- name: redis
  rules:
  - alert: RedisDown
    expr: redis_up == 0
    for: 0m
    labels:
      severity: critical
    annotations:
      summary: 'Redis Down,实例: {{ $labels.instance }}'
      description: "Redis实例 is down"
  - alert: RedisMissingBackup
    expr: time() - redis_rdb_last_save_timestamp_seconds > 60 * 60 * 24
    for: 0m
    labels:
      severity: critical
    annotations:
      summary: 'Redis 备份丢失,实例: {{ $labels.instance }}'
      description: "Redis 24 小时未备份"
  - alert: RedisOutOfConfiguredMaxmemory
    expr: redis_memory_used_bytes / redis_memory_max_bytes * 100 > 90
    for: 2m
    labels:
      severity: warning
    annotations:
      summary: 'Redis Down,实例: {{ $labels.instance }}'
      description: "Redis实例 is down"
EOF

检查

docker exec -it prometheus promtool check config /etc/prometheus/prometheus.yml
 curl -X POST http://localhost:9090/-/reload
检查
http://10.19.1.206:9090/rules
http://10.19.1.206:9090/alerts?search=)

dashboard

Redis: https://grafana.com/grafana/dashboards/11835


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

相关文章

[LeetCode][Python]389. 找不同

简单 给定两个字符串 s 和 t &#xff0c;它们只包含小写字母。 字符串 t 由字符串 s 随机重排&#xff0c;然后在随机位置添加一个字母。 请找出在 t 中被添加的字母。 示例 1&#xff1a; 输入&#xff1a;s "abcd", t "abcde" 输出&#xff1a;"…

Spring——Spring基于注解的IOC配置

基于注解的IOC配置 学习基于注解的IOC配置&#xff0c;大家脑海里首先得有一个认知&#xff0c;即注解配置和xml配置要实现的功能都是一样的&#xff0c;都是要降低程序间的耦合。只是配置的形式不一样。 1.创建工程 1.1 pom.xml <?xml version"1.0" encoding…

ISP 基础知识积累

Amber&#xff1a;现有工作必要的技术补充&#xff0c;认识需要不断深入&#xff0c;这个文档后续还会增加内容进行完善。 镜头成像资料 ——干货满满&#xff0c;看懂了这四篇文章&#xff0c;下面的问题基本都能解答 看完思考 1、ISP 是什么&#xff0c;有什么作用&#xff…

4. 返回 const 对象

// 1: three Vector objects // 2: dyslectic programming String s2, $3; s3 s2 sl; 在上述代码中,s2.operator(s2)的返回值被赋给s3。为此,返回String对象或String对象的引用都是 可行的,但与Vector范例中一样,通过使用引用,可避免该函数调用String的复制构造函数来创建一…

数据结构与算法(九)--链表与递归

一、前言 之前的文链表的学习我们学习了链表的定义&#xff0c;以及链表的CRUD操作。并且通过链表去自定义了我们的栈和队列。但是链表还有很多很重要的性质&#xff0c;例如链表本身具有天然的递归性&#xff0c;我们可以利用链表的这些性质去完成一些需求。 二、链表和递归…

python包chromadb安装失败总结

1&#xff0c;背景&#xff1a; 最近在学习langchain的课程&#xff0c;里面创建自己的知识库的Retrieval模块中&#xff0c;需要用到向量数据库。 所以按照官方的教程&#xff08;vectorstores&#xff09;&#xff0c;准备使用chroma的向量数据库。图片来源 2&#xff0c;问…

类加载机制之双亲委派模型、作用、源码、SPI打破双亲委派模型

双亲委派模型 双亲委派工作机制双亲委派的作用双亲委派的实现源码SPI打破双亲委派 应用程序是由三种类加载器相互配合&#xff0c;从而实现类加载&#xff0c;除此之外还可以加入自己定义的类的加载器。 类加载器之间的层次关系&#xff0c;称为双亲委派模型&#xff08;Parent…

chromium在中文用户名下无法编译的问题

新电脑没有太注意&#xff0c;起用户名的时候用了中文。 在编译chromium104的代码时&#xff0c;因为环境变量有中文导致编译失败&#xff1a; 因为我的电脑默认是使用gbk编码&#xff0c;而不是utf-8编码。 这个问题有三种解决办法&#xff1a; &#xff08;一&#xff09;把…