Skip to content

Add consumer count to stream queue metrics #4727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

acogoluegnes
Copy link
Contributor

This commit adds the "consumers" metrics to stream queues (consumer count).
It is computed by counting the element of the consumer_created ETS table
for the given stream queue and for each member of the Osiris cluster.

Fixes #4622

This commit adds the "consumers" metrics to stream queues (consumer count).
It is computed by counting the element of the consumer_created ETS table
for the given stream queue and for each member of the Osiris cluster.

Fixes #4622
It handles common RPC errors.

References #4622
Otherwise needs to enable stream feature flag.

References #4622
@acogoluegnes
Copy link
Contributor Author

acogoluegnes commented May 4, 2022

A/C:

Get the code and start a cluster:

cd /tmp
git clone [email protected]:rabbitmq/rabbitmq-server.git rabbitmq-server-4622
cd rabbitmq-server-4622
git checkout rabbitmq-server-4622-stream-queue-consumer-count
make start-cluster NODES=3 PLUGINS='rabbitmq_stream rabbitmq_management'

Download the performance tool and start it:

wget https://github.com/rabbitmq/rabbitmq-java-tools-binaries-dev/releases/download/v-stream-perf-test-latest/stream-perf-test-latest.jar
java -jar stream-perf-test-latest.jar --rate 100 --producers 2 --consumers 9 --stream-count 2

The performance tool creates 2 streams, publishes to them, and balances 9 consumers across them.

Go to the queue list page and make sure the Consumers column shows up (+/- characters on the right of the table, check Consumer count). The 2 streams should be listed, with 5 consumers for the first one, and 4 consumers for the second one.

image

List the queues with the REST API, the consumer count should be the same as for the management UI:

curl -u guest:guest http://localhost:15672/api/queues | jq .
[
  {
    "arguments": {
      "x-max-length-bytes": 20000000000,
      "x-queue-leader-locator": "least-leaders",
      "x-queue-type": "stream",
      "x-stream-max-segment-size-bytes": 500000000
    },
    "auto_delete": false,
    "consumers": 5,
    "durable": true,
    "effective_policy_definition": {},
    "exclusive": false,
    "members": [
      "rabbit-1@acogoluegnes-nuc",
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-2@acogoluegnes-nuc"
    ],
    "memory": 9248,
    "messages": 56879,
    "messages_details": {
      "rate": 100.4
    },
    "messages_ready": 56879,
    "messages_ready_details": {
      "rate": 100.4
    },
    "messages_unacknowledged": 0,
    "messages_unacknowledged_details": {
      "rate": 0
    },
    "name": "stream-1",
    "node": "rabbit-1@acogoluegnes-nuc",
    "online": [
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-2@acogoluegnes-nuc",
      "rabbit-1@acogoluegnes-nuc"
    ],
    "operator_policy": null,
    "policy": null,
    "readers": {
      "rabbit-1@acogoluegnes-nuc": 2,
      "rabbit-2@acogoluegnes-nuc": 3,
      "rabbit-3@acogoluegnes-nuc": 2
    },
    "reductions": 0,
    "reductions_details": {
      "rate": 0
    },
    "state": "running",
    "type": "stream",
    "vhost": "/"
  },
  {
    "arguments": {
      "x-max-length-bytes": 20000000000,
      "x-queue-leader-locator": "least-leaders",
      "x-queue-type": "stream",
      "x-stream-max-segment-size-bytes": 500000000
    },
    "auto_delete": false,
    "consumers": 4,
    "durable": true,
    "effective_policy_definition": {},
    "exclusive": false,
    "members": [
      "rabbit-2@acogoluegnes-nuc",
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-1@acogoluegnes-nuc"
    ],
    "memory": 9280,
    "messages": 56787,
    "messages_details": {
      "rate": 100.4
    },
    "messages_ready": 56787,
    "messages_ready_details": {
      "rate": 100.4
    },
    "messages_unacknowledged": 0,
    "messages_unacknowledged_details": {
      "rate": 0
    },
    "name": "stream-2",
    "node": "rabbit-2@acogoluegnes-nuc",
    "online": [
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-2@acogoluegnes-nuc",
      "rabbit-1@acogoluegnes-nuc"
    ],
    "operator_policy": null,
    "policy": null,
    "readers": {
      "rabbit-1@acogoluegnes-nuc": 2,
      "rabbit-2@acogoluegnes-nuc": 2,
      "rabbit-3@acogoluegnes-nuc": 2
    },
    "reductions": 0,
    "reductions_details": {
      "rate": 0
    },
    "state": "running",
    "type": "stream",
    "vhost": "/"
  }
]

Or just extract the consumers field values:

curl -u guest:guest http://localhost:15672/api/queues | jq '.[].consumers'
5
4

Stop the performance tool (Ctrl+C). Refresh the queue list page, the number of consumers should be 0 for both streams.

image

Check the REST API:

curl -u guest:guest http://localhost:15672/api/queues | jq .
[
  {
    "arguments": {
      "x-max-length-bytes": 20000000000,
      "x-queue-leader-locator": "least-leaders",
      "x-queue-type": "stream",
      "x-stream-max-segment-size-bytes": 500000000
    },
    "auto_delete": false,
    "consumers": 0,
    "durable": true,
    "effective_policy_definition": {},
    "exclusive": false,
    "members": [
      "rabbit-1@acogoluegnes-nuc",
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-2@acogoluegnes-nuc"
    ],
    "memory": 9184,
    "messages": 96958,
    "messages_details": {
      "rate": 0
    },
    "messages_ready": 96958,
    "messages_ready_details": {
      "rate": 0
    },
    "messages_unacknowledged": 0,
    "messages_unacknowledged_details": {
      "rate": 0
    },
    "name": "stream-1",
    "node": "rabbit-1@acogoluegnes-nuc",
    "online": [
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-2@acogoluegnes-nuc",
      "rabbit-1@acogoluegnes-nuc"
    ],
    "operator_policy": null,
    "policy": null,
    "readers": {
      "rabbit-1@acogoluegnes-nuc": 2,
      "rabbit-2@acogoluegnes-nuc": 3,
      "rabbit-3@acogoluegnes-nuc": 2
    },
    "reductions": 0,
    "reductions_details": {
      "rate": 0
    },
    "state": "running",
    "type": "stream",
    "vhost": "/"
  },
  {
    "arguments": {
      "x-max-length-bytes": 20000000000,
      "x-queue-leader-locator": "least-leaders",
      "x-queue-type": "stream",
      "x-stream-max-segment-size-bytes": 500000000
    },
    "auto_delete": false,
    "consumers": 0,
    "durable": true,
    "effective_policy_definition": {},
    "exclusive": false,
    "members": [
      "rabbit-2@acogoluegnes-nuc",
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-1@acogoluegnes-nuc"
    ],
    "memory": 9216,
    "messages": 96957,
    "messages_details": {
      "rate": 0
    },
    "messages_ready": 96957,
    "messages_ready_details": {
      "rate": 0
    },
    "messages_unacknowledged": 0,
    "messages_unacknowledged_details": {
      "rate": 0
    },
    "name": "stream-2",
    "node": "rabbit-2@acogoluegnes-nuc",
    "online": [
      "rabbit-3@acogoluegnes-nuc",
      "rabbit-2@acogoluegnes-nuc",
      "rabbit-1@acogoluegnes-nuc"
    ],
    "operator_policy": null,
    "policy": null,
    "readers": {
      "rabbit-1@acogoluegnes-nuc": 2,
      "rabbit-2@acogoluegnes-nuc": 2,
      "rabbit-3@acogoluegnes-nuc": 2
    },
    "reductions": 0,
    "reductions_details": {
      "rate": 0
    },
    "state": "running",
    "type": "stream",
    "vhost": "/"
  }
]
curl -u guest:guest http://localhost:15672/api/queues | jq '.[].consumers'
0
0

Stop the cluster:

make stop-cluster NODES=3

Delete the sources for the branch:

cd /tmp
rm -rf /tmp/rabbitmq-server-4622

@acogoluegnes acogoluegnes marked this pull request as ready for review May 5, 2022 07:39
@michaelklishin michaelklishin merged commit e0e2397 into master May 5, 2022
@michaelklishin michaelklishin deleted the rabbitmq-server-4622-stream-queue-consumer-count branch May 5, 2022 11:04
acogoluegnes added a commit that referenced this pull request May 5, 2022
Add consumer count to stream queue metrics (backport #4727) (backport #4731)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consumer count does not show up in queues page for streams
2 participants