redis-shake可视化监控

目录

一.redis-shake v4

 1.镜像

2.shake.toml

3.启动redis-shake后

二.json-exporter配置

1.Dockerfile

2.config.yml

三.prometheus配置

1.prometheus.yml

2.redis-shake.json

四.grafana


一.redis-shake v4

 1.镜像

######################### Dockerfile ########################################
FROM centos:7WORKDIR /opt
COPY shake.toml /tmp/
COPY redis-shake /opt/
COPY entrypoint.sh /usr/local/bin/
RUN  chmod +x redis-shake  &&  chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 8888
ENTRYPOINT ["entrypoint.sh"]######################### entrypoint.sh ######################################
#!/bin/bash
set -eeval "cat <<EOF$(< /tmp/shake.toml)
EOF
"  > /opt/shake.toml
/opt/redis-shake /opt/shake.toml
exit 0

2.shake.toml

status_port = 8888 获取监控数据端口,部署启动时映射8888端口

function = ""########## 过滤key #########################################
#function """
#local prefix = "user:"
#local prefix_len = #prefix
#if string.sub(KEYS[1], 1, prefix_len) ~= prefix then
#  return
#end
#shake.call(DB, ARGV)
#"""[sync_reader]
cluster = ${SOURCE_IF_CLUSTER}  # set to true if source is a redis cluster
address = ${SOURCE_ADDRESS}     # when cluster is true, set address to one of the cluster node
password = ${SOURCE_PASSWORD}   # keep empty if no authentication is required
sync_rdb = ${SYNC_RDB} # set to false if you don't want to sync rdb true全量同步 false不全量同步
sync_aof = ${SYNC_AOF} # set to false if you don't want to sync aof true 增量同步 false不增量同步
prefer_replica = true # set to true if you want to sync from replica node
dbs = []           # set you want to scan dbs such as [1,5,7], if you don't want to scan all
tls = false
# username = ""              # keep empty if not using ACL
# ksn = false         # set to true to enabled Redis keyspace notifications (KSN) subscription[redis_writer]
cluster = ${TARGET_IF_CLUSTER}   # set to true if target is a redis cluster
address = ${TARGET_ADDRESS}      # when cluster is true, set address to one of the cluster node
password = ${TARGET_PASSWORD}    # keep empty if no authentication is required
tls = false
off_reply = false       # ture off the server reply
# username = ""         # keep empty if not using ACL[advanced]
dir = "data"
ncpu = 0        # runtime.GOMAXPROCS, 0 means use runtime.NumCPU() cpu cores
# pprof_port = 8856  # pprof port, 0 means disable
status_port = 8888 # status port, 0 means disable# log
log_file = "shake.log"
log_level = "info"     # debug, info or warn
log_interval = 5       # in seconds# redis-shake gets key and value from rdb file, and uses RESTORE command to
# create the key in target redis. Redis RESTORE will return a "Target key name
# is busy" error when key already exists. You can use this configuration item
# to change the default behavior of restore:
# panic:   redis-shake will stop when meet "Target key name is busy" error.
# rewrite: redis-shake will replace the key with new value.
# ignore:  redis-shake will skip restore the key when meet "Target key name is busy" error.
rdb_restore_command_behavior = ${RESTORE_BEHAVIOR} # panic, rewrite or ignore# redis-shake uses pipeline to improve sending performance.
# This item limits the maximum number of commands in a pipeline.
pipeline_count_limit = 1024# Client query buffers accumulate new commands. They are limited to a fixed
# amount by default. This amount is normally 1gb.
target_redis_client_max_querybuf_len = 1024_000_000# In the Redis protocol, bulk requests, that are, elements representing single
# strings, are normally limited to 512 mb.
target_redis_proto_max_bulk_len = 512_000_000# If the source is Elasticache or MemoryDB, you can set this item.
aws_psync = "" # example: aws_psync = "10.0.0.1:6379@nmfu2sl5osync,10.0.0.1:6379@xhma21xfkssync"# destination will delete itself entire database before fetching files
# from source during full synchronization.
# This option is similar redis replicas RDB diskless load option:
#   repl-diskless-load on-empty-db
empty_db_before_sync = false[module]
# The data format for BF.LOADCHUNK is not compatible in different versions. v2.6.3 <=> 20603
target_mbbloom_version = 20603

3.启动redis-shake后

可部署多个 redis-shake 10.111.11.12:8888  10.111.11.12:8889 10.111.11.12:8890

{"start_time":"2024-02-02 16:13:07","consistent":true,"total_entries_count":{"read_count":77403368,"read_ops":0,"write_count":77403368,"write_ops":0},"per_cmd_entries_count":{"APPEND":{"read_count":2,"read_ops":0,"write_count":2,"write_ops":0},"DEL":{"read_count":5,"read_ops":0,"write_count":5,"write_ops":0},"HMSET":{"read_count":2,"read_ops":0,"write_count":2,"write_ops":0},"PEXPIRE":{"read_count":8,"read_ops":0,"write_count":8,"write_ops":0},"RESTORE":{"read_count":77403341,"read_ops":0,"write_count":77403341,"write_ops":0},"SADD":{"read_count":1,"read_ops":0,"write_count":1,"write_ops":0},"SCRIPT-LOAD":{"read_count":7,"read_ops":0,"write_count":7,"write_ops":0},"SET":{"read_count":2,"read_ops":0,"write_count":2,"write_ops":0}},"reader":[{"name":"reader_10.127.11.11_9984","address":"10.127.11.11:9984","dir":"/opt/data/reader_10.172.48.17_9984","status":"syncing aof","rdb_file_size_bytes":867659640,"rdb_file_size_human":"828 MiB","rdb_received_bytes":867659640,"rdb_received_human":"828 MiB","rdb_sent_bytes":867659640,"rdb_sent_human":"828 MiB","aof_received_offset":567794044,"aof_sent_offset":567794044,"aof_received_bytes":6614445,"aof_received_human":"6.3 MiB"},{"name":"reader_10.127.11.12_9984","address":"10.127.11.12:9984","dir":"/opt/data/reader_10.172.48.16_9984","status":"syncing aof","rdb_file_size_bytes":867824091,"rdb_file_size_human":"828 MiB","rdb_received_bytes":867824091,"rdb_received_human":"828 MiB","rdb_sent_bytes":867824091,"rdb_sent_human":"828 MiB","aof_received_offset":564917306,"aof_sent_offset":564917306,"aof_received_bytes":6612502,"aof_received_human":"6.3 MiB"},{"name":"reader_10.127.11.13_9984","address":"10.127.11.13:9984","dir":"/opt/data/reader_10.172.48.15_9984","status":"syncing aof","rdb_file_size_bytes":867661773,"rdb_file_size_human":"828 MiB","rdb_received_bytes":867661773,"rdb_received_human":"828 MiB","rdb_sent_bytes":867661773,"rdb_sent_human":"828 MiB","aof_received_offset":562834707,"aof_sent_offset":562834707,"aof_received_bytes":6615286,"aof_received_human":"6.3 MiB"}],"writer":[{"name":"writer_10.127.12.11_9984","unanswered_bytes":0,"unanswered_entries":0},{"name":"writer_10.127.12.12_9984","unanswered_bytes":0,"unanswered_entries":0},{"name":"writer_10.127.12.13_9984","unanswered_bytes":0,"unanswered_entries":0}]}

二.json-exporter配置

1.Dockerfile

FROM prometheuscommunity/json-exporter:latestUSER root
RUN mkdir -p  /opt
WORKDIR /opt
COPY  config.yml /opt/

2.config.yml

根据上边返回的json数据,制定自己需要的监控模版,部署json-exporter 10.111.11.11:7979

modules:default:headers:X-Dummy: my-test-headermetrics:- name: shake_consistenthelp: Example of sub-level value scrapes from a jsonpath: '{.consistent}'labels:start_time: '{.start_time}'- name: shake_total_entries_counttype: objecthelp: Example of sub-level value scrapes from a jsonpath: '{.total_entries_count}'values:read_count: '{.read_count}'     # static valueread_ops: '{.read_ops}' # dynamic valuewrite_count: '{.write_count}'write_ops: '{.write_ops}'- name: shake_per_cmd_entries_count_restoretype: objecthelp: Example of sub-level value scrapes from a jsonpath: "{.per_cmd_entries_count.RESTORE}"values:read_count: '{.read_count}'read_ops: '{.read_ops}'write_count: '{.write_count}'write_ops: '{.write_ops}'- name: shake_per_cmd_entries_script_loadtype: objecthelp: Example of sub-level value scrapes from a jsonpath: "{.per_cmd_entries_count.SCRIPT-LOAD}"values:read_count: '{.read_count}'read_ops: '{.read_ops}'write_count: '{.write_count}'write_ops: '{.write_ops}'- name: shake_readertype: objecthelp: Example of sub-level value scrapes from a jsonpath: "{.reader}"labels:address: '{.address}'          # dynamic labeldir: '{.dir}'status: '{.status}'values:rdb_file_size_bytes: '{.rdb_file_size_bytes}'rdb_received_bytes: '{.rdb_received_bytes}'rdb_sent_bytes: '{.rdb_sent_bytes}'aof_received_offset: '{.aof_received_offset}'aof_sent_offset: '{.aof_sent_offset}'aof_received_bytes: '{.aof_received_bytes}'- name: shake_writertype: objecthelp: Example of sub-level value scrapes from a jsonpath: "{.writer}"labels:name: '{.name}'          # dynamic labelvalues:unanswered_bytes: '{.unanswered_bytes}'unanswered_entries: '{.unanswered_entries}'

三.prometheus配置

1.prometheus.yml

global:scrape_interval: 15s evaluation_interval: 15sscrape_configs:- job_name: json_exportermetrics_path: /probefile_sd_configs:- files:- 'redis-shake.json'relabel_configs:- source_labels: [__address__]target_label: __param_target- source_labels: [__param_target]target_label: instance- target_label: __address__replacement: 10.111.11.11:7979 # json-exporter地址

2.redis-shake.json

单独的文件配置可实现动态加载,同时可添加自定义的标签在文件中

[
# labels为自定义的标签,targets为部署各个redis-shake地址
{"labels": {"env-1":"团队1"},"targets": ["http://10.111.11.12:8888"]},
{"labels": {"env-1":"团队2"},"targets": ["http://10.111.11.12:8889"]},
{"labels": {"env-1":"团队3"},"targets": ["http://10.111.11.12:8890"]}
]

四.grafana

上边的都配置好,把自己的peometheus数据源添加到grafana中,就可以设置自己想要的监控界面了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/576219.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

StarRocks实战——多点大数据数仓构建

目录 前言 一、背景介绍 二、原有架构的痛点 2.1 技术成本 2.2 开发成本 2.2.1 离线 T1 更新的分析场景 2.2.2 实时更新分析场景 2.2.3 固定维度分析场景 2.2.4 运维成本 三、选择StarRocks的原因 3.1 引擎收敛 3.2 “大宽表”模型替换 3.3 简化Lambda架构 3.4 模…

计算机网络-RIP动态路由协议简介

一、概述 前面我们学习了动态路由协议按照工作机制及算法划分可以分为&#xff1a;距离矢量路由协议DV型和链路状态路由协议LS型。RIP就是典型的距离矢量路由协议&#xff0c;但是实际工作中用得已经比较少了。 距离矢量路由协议DV: RIP 链路状态路由协议LS: OSPF IS-IS 二、RI…

【开发篇】十二、GCeasy报告分析

文章目录 1、图一&#xff1a;正常情况2、图二&#xff1a;缓存对象过多3、图三&#xff1a;内存泄漏4、图四&#xff1a;频繁持续Full GC5、图五&#xff1a;元空间不足导致的Full GC 1、图一&#xff1a;正常情况 正常的堆内存如图&#xff1a; 锯齿状对象创建后内存占用上…

第十二章 微服务核心(一)

一、Spring Boot 1.1 SpringBoot 构建方式 1.1.1 通过官网自动生成 进入官网&#xff1a;https://spring.io/&#xff0c;点击 Projects --> Spring Framework&#xff1b; 拖动滚动条到中间位置&#xff0c;点击 Spring Initializr 或者直接通过 https://start.spring…

ffmpeg拉流并解码

流程 注意事项 版本不同导致的api差异资源安全释放

Linux安装redis(基于CentOS系统,Ubuntu也可参考)

前言&#xff1a;本文内容为实操记录&#xff0c;仅供参考&#xff01; 一、下载并解压Redis 1、执行下面的命令下载redis&#xff1a;wget https://download.redis.io/releases/redis-6.2.6.tar.gz 2、解压redis&#xff1a;tar xzf redis-6.2.6.tar.gz 3、移动redis目录&a…

Tensorflow2.0笔记 - metrics做损失和准确度信息度量

本笔记主要记录metrics相关的内容&#xff0c;详细内容请参考代码注释&#xff0c;代码本身只使用了Accuracy和Mean。本节的代码基于上篇笔记FashionMnist的代码经过简单修改而来&#xff0c;上篇笔记链接如下&#xff1a; Tensorflow2.0笔记 - FashionMnist数据集训练-CSDN博…

HTTP,Servlet

HTTP 概念&#xff1a;HyperTextTransferProtocol&#xff0c;超文本传输协议&#xff0c;规定了浏览器和服务器之间数据传输的规则 HTTP协议特点&#xff1a; 1.基于TCP协议&#xff1a;面向连接&#xff0c;安全 2.基于请求-响应模型的&#xff1a;一次请求对应一次响应 …

java数据结构与算法刷题-----LeetCode278. 第一个错误的版本

java数据结构与算法刷题目录&#xff08;剑指Offer、LeetCode、ACM&#xff09;-----主目录-----持续更新(进不去说明我没写完)&#xff1a;https://blog.csdn.net/grd_java/article/details/123063846 文章目录 二分查找 二分查找 解题思路&#xff1a;时间复杂度O( l o g 2 …

Linux文件IO(2):使用标准IO进行文件的打开、关闭、读写、流定位等相关操作

目录 前言 文件的打开和关闭的概念 文件的打开 文件的打开函数 文件打开的模式 文件的关闭 文件的关闭函数 注意事项 字符的输入&#xff08;读单个字符&#xff09; 字符输入的函数 注意事项 字符的输出&#xff08;写单个字符&#xff09; 字符输出的函数 注意…

【Web应用技术基础】CSS(6)——使用 HTML/CSS 实现 Educoder 顶部导航栏

第一题&#xff1a;使用flex布局实现Educoder顶部导航栏容器布局 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>Educoder</title><script src"https://cdn.staticfile.org/jquery/1.1…

论文笔记:分层问题-图像共注意力问答

整理了2017 Hierarchical Question-Image Co-Attention for Visual Question Answering&#xff09;论文的阅读笔记 背景模型问题定义模型结构平行共注意力交替共注意力 实验可视化 背景 视觉问答(VQA)的注意力模型在此之前已经有了很多工作&#xff0c;这种模型生成了突出显示…