如何获取嵌入式Redis指标?

问题描述

我在 springboot 应用程序中使用了嵌入式 Redis 进行缓存。 redis 在 localhost 上运行,应用程序启动时认为 port "6379"

有没有办法从应用程序外部获取嵌入式 redis 的指标(内存使用、keyspace_hits、keyspace_misses 等),可能是命令行或任何 API

PS:我使用Redisson作为客户端,用redis来执行缓存操作。

谢谢。

解决方法

Redis 提供了一个命令行界面:struct ContentView: View { // added this space let sections = ["Exclusives","Apple","Android","Videos","Got a leak ?",""].reversed() var body: some View { HStack { // Menu using HStack ScrollView(.horizontal) { HStack(spacing: 32) { ForEach(sections,id: \.self) { section in Text(section) .padding().border(.red) } } }.rotationEffect(.degrees(-90),anchor: .center) VStack(spacing: 0) { // Header Rectangle() .fill(Color(UIColor.quaternaryLabel)) .frame(height: UIScreen.main.bounds.width * 0.2) // Vertical Content HStack(spacing: 0) { // Content Placeholder Rectangle() .fill(Color(UIColor.tertiarySystemFill)) .frame(maxWidth: .infinity,maxHeight: .infinity) } } }.ignoresSafeArea(.all,edges: .bottom) } } 来与之交互并获取指标。 redis-cli 也可以用于嵌入式 redis。

  1. 安装命令行界面
    npm install -g redis-cli
  2. 连接到本地运行的redis(cmd: rdcli -h host -p port -a password )
    rdcli -h 本地主机
  3. 使用任何redis命令
    本地主机:6379> 信息内存
    #内存
    used_memory:4384744 used_memory_human:4.18M
    used_memory_rss:4351856
    used_memory_peak:4385608
    used_memory_peak_human:4.18M
    used_memory_lua:35840
    mem_fragmentation_ratio:0.99
    mem_allocator:dlmalloc-2.8

参考:本文的“安装和运行 Node.js redis-cli” 部分 https://redislabs.com/blog/get-redis-cli-without-installing-redis-server