前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >kubernetes-23:监控redis-cluster

kubernetes-23:监控redis-cluster

作者头像
千里行走
发布2022-04-28 16:01:20
8340
发布2022-04-28 16:01:20
举报
文章被收录于专栏:千里行走千里行走

目录

(1).前置阅读

(2).前置准备

(3).容器化生产规划

(4).使用redisd-exporter监控redis实例

1.镜像选择

2.容器化配置

(5).容器化步骤

(6).关键配置

1.prometheus-redis-configmap.yaml

2.datasource.yml

3.provision.yml

4.exporter-deployment-redis-cluster.yaml

(7).最终效果与dashboard详解

(8).相关文章

架构实战交流钉钉群号:23394754

(1).前置阅读

需要先行部署grafana/prometheus,以及合理拓扑,参见:

grafana&prometheus生产级容器化监控-1:生产级容器化

(2).前置准备

容器化redis-cluster实例,可以使用:

https://github.com/hepyu/k8s-app-config/tree/master/yaml/min-cluster-allinone/redis-cluster-min

参考文章:

kubernetes-20:redis-cluster容器化

注意:

即使生产上redis集群本身没有放在K8S中,本文同样适用。redis-exporter放到K8S也是很划算的。

(3).容器化生产规划

原始图片位于:

https://github.com/hepyu/k8s-app-config/blob/master/product/standard/grafana-prometheus-pro/images/grafana-prometheus%E7%94%9F%E4%BA%A7%E7%BA%A7%E5%AE%9E%E8%B7%B5.jpg

如上图所示:

容器化多个prometheus实例

由于当数据量很大(metrics很多)或者grafana选择的时间跨度很大时,prometheus的吞吐性能会很有问题,再加上会有很多人通过grafana查看各业务数据,如果生产环境只部署一个prometheus,肯定是有问题的,prometheus会经常性崩溃。

同时,这样也可以设置不同的数据保存时间,比如对于mq来说,我希望保留更长时间的数据。

(4).使用redis-exporter监控redis-cluster实例

1.镜像选择

镜像:image: oliver006/redis_exporter:v0.28.0

容器化配置位于:

https://github.com/hepyu/k8s-app-config/tree/master/product/standard/grafana-prometheus-pro/exporter-redis

2.容器化配置

建立新的prometheus实例,专门用于存放redis-cluster实例的metrics,同时dashboards导入方式选择provisioning方式。

笔者提供生产级容器化配置,位于:

https://github.com/hepyu/k8s-app-config/tree/master/product/standard/grafana-prometheus-pro

prometheus-redis容器化配置:

https://github.com/hepyu/k8s-app-config/tree/master/product/standard/grafana-prometheus-pro/prometheus-redis

dashboard位置:

https://github.com/hepyu/k8s-app-config/tree/master/product/standard/grafana-prometheus-pro/grafana/provisioning/dashboards/redis

还有一个是单实例redis的dashboard,由于redis单例用法早就淘汰,这里不赘述,有兴趣可以看看。

(5).容器化步骤

大体步骤,注意本例配置默认使用local pv(生产环境需要换成云存储),需要使用者自行创建。

1.cd https://github.com/hepyu/k8s-app-config/tree/master/product/standard/grafana-prometheus-pro

#Kubectl apply -f grafana-prometheus-image-repo-secret.yaml (生产环境使用)

Kubectl apply -f grafana-prometheus-namespace.yaml

2.cd grafana-prometheus-pro/prometheus-redis

kubectl apply -f .

3.cd grafana-prometheus-pro/grafana

kubectl apply -f .

4.cd grafana-prometheus-pro/exporter-redis

Kubectl apply -f .

(6).关键配置

1.prometheus-redis-configmap.yaml

相对路径:prometheus-redis/prometheus-redis-configmap.yaml

配置服务发现,从k8s的那些pod拉取metrics:

代码语言:javascript
复制
label_exporter=redis, namespace=monitor的pod

relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_exporter, __meta_kubernetes_namespace]
action: keep
regex: redis;monitor

2.datasource.yml

相对路径:grafana/provisioning/datasources

将数据库prometheus-redis放到grafana的数据库列表中:

代码语言:javascript
复制
- name: prometheus-redis
type: prometheus
access: proxy
orgId: 1
url: http://prometheus-redis:9090
isDefault: false
jsonData:
tlsAuth: false
tlsAuthWithCACert: false

3.provision.yml

相对路径:grafana/provisioning/dashboards

将redis-dashboards放到grafana的dashboards列表中:

代码语言:javascript
复制
- name: 'redis-cluster'
orgId: 1
folder: 'redis-cluster'
folderUid: ''
type: file
options:
path: /var/lib/grafana/k8s-app-config/product/standard/grafana-prometheus-pro/grafana/provisioning/dashboards/redis

4.exporter-deployment-redis-cluster.yaml

env要配置被监控的redis-cluster:

- name: REDIS_ADDR

value: redis-hkc-0.redis-hkc.redis-cluster-min.svc.cluster.local:9720,redis-hkc-1.redis-hkc.redis-cluster-min.svc.cluster.local:9720,redis-hkc-2.redis-hkc.redis-cluster-min.svc.cluster.local:9720,redis-hkc-3.redis-hkc.redis-cluster-min.svc.cluster.local:9720,redis-hkc-4.redis-hkc.redis-cluster-min.svc.cluster.local:9720,redis-hkc-5.redis-hkc.redis-cluster-min.svc.cluster.local:9720

(7).最终效果与dashboard详解

1.总览

可以看到dashboard分5组:

下拉框说明:

2.master cluster info bgsave

master节点信息,主要是last bgsave的持续时间和发生时间,可以看到有负数存在,这个在grafana/prometheust体系中是普遍存在的,用于占位。

生产环境要用redis集群的哨兵模式,如果成本允许;bgsave可以关闭,对峰值时段的服务影响还是比较大的,会有很多尖锐的spike。

3.master cluster info

各项很好看懂,不再赘述。

4.node master

各项很好看懂,不再赘述。

(8).相关文章

grafana&prometheus生产级容器化监控-1:生产级容器化

kubernetes-20:redis-cluster容器化

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-01-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 千里行走 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档