Example: Rate Statistics

A quick example: I want to gather some message rate statistics. Here is an API call to do that for a queue named hello (from my “Hello World” set-up):

http://localhost:15672/api/queues?name=hello&columns=name,message_stats.publish,message_stats.publish_details&msg_rates_age=100&msg_rates_incr=20

/api/queues - the type of Rabbit object I want to investigate

name=hello - the name of a specific queue

columns=name,message_stats.publish,message_stats.publish_details - the specific JSON fields I want to retrieve (out of a fairly lengthy list of possible fields!). Remove this parameter to see everything.

msg_rates_age=100 - go back over the most recent 100 seconds of history.

msg_rates_incr=20 - take data samples once every 20 seconds - so, that will be 6 samples overall (0 seconds ago, 20, 40, 60, 80, 100 seconds ago).

The JSON response:

 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
[
  {
    "message_stats": {
      "publish": 5,
      "publish_details": {
        "avg": 2.8333333333333335,
        "avg_rate": 0.03,
        "rate": 0.05,
        "samples": [
          {
            "sample": 5,
            "timestamp": 1659366740000
          },
          {
            "sample": 4,
            "timestamp": 1659366720000
          },
          {
            "sample": 2,
            "timestamp": 1659366700000
          },
          {
            "sample": 2,
            "timestamp": 1659366680000
          },
          {
            "sample": 2,
            "timestamp": 1659366660000
          },
          {
            "sample": 2,
            "timestamp": 1659366640000
          }
        ]
      }
    },
    "name": "hello"
  }
]

Each sample value shows how many published messages there have been in total from the initial creation of the queue through to the timestamp value (milliseconds since the Unix epoch).

There are three detailed statistics provided:

avg: average value (in this case, for “messages published” on this one queue) for the time period.

This is calculated as: (5+4+2+2+2+2) / 6 = 2.83333

rate: change per second in most recent sampling interval.

This is calculated as: (5-4) / 20 = 0.05

avg_rate: average rate for the time period.

This is calculated as: (5-2) / 100 = 0.03

If you wanted to know rates going back in time, you would need to parse the JSON subtract each successive sample number from the previous (more recent) sample number.

The Documentation

The main page is here:

http://raw.githack.com/rabbitmq/rabbitmq-server/v3.10.6/deps/rabbitmq_management/priv/www/api/index.html