如何使用类似于 beanstalkd 的 cli 将 Redis 作为队列引擎进行监控?

How to monitor Redis as a queue engine using cli similar to beanstalkd?

背景

我们在两个 ec2 实例上使用了 Laravel Queues on top of beanstalkd(在负载均衡器后面)。随着系统的扩展,我们决定使用 redis 而不是 beanstalkd,并将其托管在 AWS 弹性缓存实例(具有一个主节点和两个副本的集群)上。

使用beanstalkd,我使用beanstalk utilities来监控队列的健康状况;例如,如果队列堵塞,我可以很容易地通过 运行 这样的命令看到:

./beanstalk-queue-stats.rb localhost:11300

哪个 return 像这样

2018-01-10 11:08:38 +0000
default
 - cmd-delete = 32678 (+32678)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 5 (+5)
 - current-waiting = 0 (0)
 - current-watching = 2 (+2)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 32678 (+32678)
high
 - cmd-delete = 116005 (+116005)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 9 (+9)
 - current-jobs-ready = 1117 (+1117)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 117131 (+117131)
low
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
marketing
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (+1)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
------------------
2018-01-10 11:08:48 +0000
default
 - cmd-delete = 32678 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 5 (0)
 - current-waiting = 0 (0)
 - current-watching = 2 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 32678 (0)
high
 - cmd-delete = 116005 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 9 (0)
 - current-jobs-ready = 1117 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 117131 (0)
low
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)
marketing
 - cmd-delete = 0 (0)
 - cmd-pause-tube = 0 (0)
 - current-jobs-buried = 0 (0)
 - current-jobs-delayed = 0 (0)
 - current-jobs-ready = 0 (0)
 - current-jobs-reserved = 0 (0)
 - current-jobs-urgent = 0 (0)
 - current-using = 0 (0)
 - current-waiting = 0 (0)
 - current-watching = 1 (0)
 - pause = 0 (0)
 - pause-time-left = 0 (0)
 - total-jobs = 0 (0)

问题

我想在 Redis 上做同样的事情;我可以远程登录到 Redis 并输入 keys *,这会给我队列:

keys *
*4

queues:high:delayed

queues:high

ctr

queues:low

(注意它如何很好地映射到上面 beanstalkd 输出中的队列)。然而,如果我想查看特定队列,那么我的运气就到此为止了,然后输入:

dump queues:high    

我遇到了乱码:

71
�FC^��4
       A�{"job":"Illuminate\Queu Call`
    dHandler@c ","data":{"comm Name AApp\Jobs\Slack
 +�# O:17:\�
            &   \":7:{s:10 \u0 *�   message\"; `:lemon: Order *629* (code:
                                                                               1479-45157*) has been p �ed by *client Testing*. Deliv H@R
                                                                                                                                         2018-01-05 14 n:32�x3��    op_city_id  ihigh`�9�%suffix !N `�  connection�5 3qam@�4
@@6 ���`}"},"iAayA6noA7Dc9wtujE9XJ3CDqiqah5HNdby!�attempts":1}��"b�LRetai"2Newa�Push�   32 ��7�5!�5b1 .�oB��"
                                                                                                             !h�'�8��h0CEQenh9QNSqv9lhFa4LQQ6xcktrAlpY�hi!hC�LhAXNotificaBXs�   e2B��e�
  2!b8Ab8�ausers"gO:4B��&Contract#�D$basM#�lId#e �er W2@W@;clas@J�e`�U ] \s $\"�
a:1:{i:0cV2;}}s$�D`*3@Z@��
1:52:20.053320`X`K@Yzone_typ@:i:3 >@��`+@vUTC �i@' {@' �Bh�2
is_unregistereA*b!% )@��)DB_prior$� Ob:1@'E\�V�Q06QFyrdyNaG2S7T2OMmpoSIjGBjZ9m0�#�AGF�1b!�(3B-�h2:03"{.600349"�"�B�����sg31WFi5ZxAYyBWM2oRvLaXfSiQwhCYK�C�"/E
�29�/E�k8 �.586574`���K65twHypvaVJfpXaZiKQx4rSD9L5EUqq�f-��Z2 c�jF24.9-T28`���oArS0cNElFDTacbOstCp32Iq4dwkbXpa�
                                                                                                               B���/,2�]6+�1 5 2 3�Ul�Kk,��"�L�lQ_broke,) F��l� j#J,���HClwcMykz2ZFiM�;��LM�[SKJh0bstcXHmRwnEBph55IzX39kxK1Lbv��"A��L�L�s:warn4���32* i4�dV.dWg����7"nP��#�h�YTtg6bBN0vcU6MDzdskeShyqYRnz4jit�����%�0��q�48.6797�����WfmvHIi0AkK8tfxZscweXGuyhQniuKGC�}Fc^��� +KEkFSe4E3kmnUu4mWpsXCpxapdkt2DSd��G����hqcbX8wls5ErNwYwyxZed9p2NIGsYID5�
      A�{"job":"Illuminate\Queu Call`
    dHandler@c ","data":{"comm Name AApp\Jobs\Slack
 +�# O:17:\�
high`ge\";s:32 :warning: Order *632* is broken.`)13 )�@�G   op_city_id  i:7 N9�#suffix N `� connection�5 3qa@�4
@@6 ��!f`}"},"iAgGvVjmnQ3Ps7IYrnF83tUzDmkXKLcUfr!=attempts":1}��C�L�
                                                                    PushNotifica@�s�    �2A0���
                                                                                               2!�8A�8��users �O:4A(�lContract"6D"Wbas"zMo!KIden@�er W2@W@;clas@J�e`�U ] \s $\!Z
a:1:{i:0!�291;}}s"a��B�`*3@Z@�oBR�#"X Q@qa"�t )"ANew `)  received!`BtimB�B�Carb";#H`"�i@' {@' �B'

考虑到 dump command 只是序列化 "Redis specific format" 中的值,这是有道理的。

我做了什么

GUI 工具 ❌

一个选项是使用 gui tool but since my Redis is sitting behind a VPC, setting that up would be a pain 简单地查看 Redis,但无论如何都不适合生产(参见相同的 link 限制)。

CLI 工具 ❌

This tool relies on the rdb file format, which is more about looking at the content of your entire Redis (I feel it's more about using Redis as a long term storage 而不是一些队列,所以我不觉得合适)。

谁能告诉我怎么做?

修复方法是使用此命令在我的本地计算机上简单地打开一个 ssh 隧道

ssh -N -L 1234:amazon.elastic.cache.redis.instance:6379 forge@ip.of.remote.server -i /Users/Shared/.ssh/secret_file.pub

查看此命令的更多详细信息here

然后我安装了这个开源的 redis gui 工具:https://github.com/luin/medis

其余的工作就像一个魅力:

Redis 的另一个 GUI 是 Redis Desktop manager

它在 windows、Mac 和 linux 上可用。 它还支持SSH连接