当前位置:   article > 正文

prometheus部暑redis_exporter(sentinel, cluster实战)_redis sentinel exporter

redis sentinel exporter

redis_exporter

#创建工作目录
mkdir /date/redis -p
cat > /data/redis/start.sh << 'EOF'
docker run -d \
--name redis \
-p 6379:6379 \
redis redis-server \
--appendonly yes \
--requirepass password \
--maxmemory 20M
EOF
bash /data/redis/start.sh

mkdir /data/redis_exporter/ -p

#启动脚本
cat > /data/redis_exporter/start.sh<< 'EOF'
docker run -d \
--name redis_exporter \
--restart=always \
-p 9121:9121 \
-e REDIS_ADDR=192.168.11.221:6379 \
-e REDIS_PASSWORD=password \
-e REDIS_EXPORTER_INCL_SYSTEM_METRICS=true \
-v /etc/localtime:/etc/localtime:ro \
oliver006/redis_exporter
EOF

bash /data/redis_exporter/start.sh

cat > /data/prometheus/conf/rules/redis.rules << 'EOF'	
groups:
- name: Redis-监控告警
  rules:
  - alert: 警报!Redis应用不可用
    expr: redis_up == 0
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }} Redis应用不可用"
      description: "Redis应用不可达\n  当前值 = {{ $value }}"

  - alert: 警报!丢失Master节点
    expr: (count(redis_instance_info{role="master"}) ) < 1
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }} 丢失Redis master"
      description: "Redis集群当前没有主节点\n  当前值 = {{ $value }}"

  - alert: 警报!脑裂,主节点太多
    expr: count(redis_instance_info{role="master"}) > 1
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }} Redis脑裂,主节点太多"
      description: "{{ $labels.instance }} 主节点太多\n  当前值 = {{ $value }}"

  - alert: 警报!Slave连接不可达
    expr: count without (instance, job) (redis_connected_slaves) - sum without (instance, job) (redis_connected_slaves) - 1 > 1
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }} Redis丢失slave节点"
      description: "Redis slave不可达.请确认主从同步状态\n  当前值 = {{ $value }}"

  - alert: 警报!Redis副本不一致
    expr: delta(redis_connected_slaves[1m]) < 0
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }}  Redis 副本不一致"
      description: "Redis集群丢失一个slave节点\n  当前值 = {{ $value }}"

  - alert: 警报!Redis集群抖动
    expr: changes(redis_connected_slaves[1m]) > 1
    for: 2m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }}  Redis集群抖动"
      description: "Redis集群抖动,请检查.\n  当前值 = {{ $value }}"

  - alert: 警报!持久化失败
    expr: (time() - redis_rdb_last_save_timestamp_seconds) / 3600 > 24
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }}  Redis持久化失败"
      description: "Redis持久化失败(>24小时)\n  当前值 = {{ printf \"%.1f\" $value }}小时"

  - alert: 警报!内存不足
    expr: redis_memory_used_bytes / redis_total_system_memory_bytes * 100 > 90
    for: 2m
    labels:
      severity: 一般告警
    annotations:
      summary: "{{ $labels.instance }}系统内存不足"
      description: "Redis占用系统内存(> 90%)\n  当前值 = {{ printf \"%.2f\" $value }}%"

  - alert: 警报!Maxmemory不足
    expr: redis_config_maxmemory !=0 and redis_memory_used_bytes / redis_memory_max_bytes * 100 > 80
    for: 2m
    labels:
      severity: 一般告警
    annotations:
      summary: "{{ $labels.instance }} Maxmemory设置太小"
      description: "超出设置最大内存(> 80%)\n  当前值 = {{ printf \"%.2f\" $value }}%"

  - alert: 警报!连接数太多
    expr: redis_connected_clients > 200
    for: 2m
    labels:
      severity: 一般告警
    annotations:
      summary: "{{ $labels.instance }} 实时连接数太多"
      description: "连接数太多(>200)\n  当前值 = {{ $value }}"

  - alert: 警报!连接数太少
    expr: redis_connected_clients < 1
    for: 2m
    labels:
      severity: 一般告警
    annotations:
      summary: "{{ $labels.instance }}  实时连接数太少"
      description: "连接数(<1)\n  当前值 = {{ $value }}"

  - alert: 警报!拒绝连接数
    expr: increase(redis_rejected_connections_total[1m]) > 0
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }} 拒绝连接"
      description: "Redis有拒绝连接,请检查连接数配置\n  当前值 = {{ printf \"%.0f\" $value }}"

  - alert: 警报!执行命令数大于1000
    expr: rate(redis_commands_processed_total[1m])  > 1000
    for: 0m
    labels:
      severity: 严重告警
    annotations:
      summary: "{{ $labels.instance }} 执行命令次数太多"
      description: "Redis执行命令次数太多\n  当前值 = {{ printf \"%.0f\" $value }}"
EOF

#添加自动发现脚本
cat >> /data/prometheus/conf/prometheus.yml << 'EOF'
#redis自动发现
  - job_name: 'redis'
    file_sd_configs:
      - files:
        - /etc/prometheus/sd_config/redis.yaml
        refresh_interval: 5s
    metrics_path: /scrape    
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 192.168.11.221:9121
EOF

#自动发现配置
cat >> /data/prometheus/conf/sd_config/redis.yaml << 'EOF'
#redis自动发现
- labels:
    project: 民生redis
  targets:
  - 192.168.11.221:6379
  - 192.168.11.222:6379
  - 192.168.11.223:6379
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180

grfana_id :2751
在这里插入图片描述

grfana_id: 14615 (cluster)

在这里插入图片描述

监控redis_cluster
http://t.zoukankan.com/fsckzy-p-12053604.html

-redis.password-file=/redis_passwd.json

redis_passwd.json

{
  "redis://xxxxxxxxxxx.dcs.huaweicloud.com:6379":"",
  "redis://aaaaaaaa.cn-south-1.dcs.myhuaweicloud.com:6379":"q1azw2sx"
}
  • 1
  • 2
  • 3
  • 4

https://github.com/starsliao/TenSunS/blob/main/docs/%E4%BD%BF%E7%94%A8%E4%B8%80%E4%B8%AAredis_exporter%E7%9B%91%E6%8E%A7%E6%89%80%E6%9C%89%E7%9A%84Redis%E5%AE%9E%E4%BE%8B.md

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/624741
推荐阅读
相关标签
  

闽ICP备14008679号