[improve][broker]PIP-333 Add monitor metrics for the number of connections to client IPs and roles
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Motivation
Currently, Pulsar does not monitor the number of connections to client IPs and roles. When there are many business teams accessing the cluster, and there are also many topics and production consumers, it is difficult for us to quickly locate which IPs or roles are accessing the cluster abnormally from a global perspective and optimize them. So, we hope to have a monitoring indicator that can statistically analyze the connection information between IP and role dimensions, making it easier to quickly locate problems in the later stage.
### Solution
Add new metircs to ServerCnx.java class:
```
private static final Gauge clientIpAndRoleConnections = Gauge.build()
.name("pulsar_broker_client_ip_role_connections")
.labelNames("ip", "role")
.help("The number of client IP and role connections")
.register();
```
### Alternatives
_No response_
### Anything else?
_No response_
### Are you willing to submit a PR?
- [X] I'm willing to submit a PR!
PR:https://github.com/apache/pulsar/pull/21935
Contributor guide
Research direction
Start with ServerCnx.java and review the proposed implementation in PR #21935. Check how connection counts are tracked across client IP and role dimensions, then verify that the new metric reports the intended values and remains correct as connections change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100