You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "programmerahul (via GitHub)" <gi...@apache.org> on 2026/10/19 12:52:43 UTC
[I] [Enhancement] Support getting broker-stats of a specific broker by broker id [pulsar]
programmerahul opened a new issue, #27000:
URL: https://github.com/apache/pulsar/issues/27000
### Search before reporting
- [x] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Motivation
The `broker-stats` admin endpoints (`metrics`, `mbeans`, `topics`, `allocator-stats`, `bookieops`, `load-report`) only return stats of the broker that serves the HTTP request.
In a multi-broker cluster, operators usually point `pulsar-admin` (or the Java admin client) at a load balancer or at one broker. To inspect a specific broker, for example one listed by `pulsar-admin brokers list <cluster>`, they must find that broker's web service URL and create a separate admin client / pass a different `--admin-url` for it. This is inconvenient for tooling and scripts that iterate over the brokers of a cluster.
Other broker-scoped admin operations, such as `brokers healthcheck`, already accept a broker id and route the request to the right broker. `broker-stats` should do the same.
### Solution
Add an optional broker id parameter to the `broker-stats` APIs:
- **REST**: optional `broker` query param on `/admin/v2/broker-stats/{metrics,mbeans,topics,allocator-stats/{allocator},bookieops,load-report}`. After the super-user check, if `broker` names a different broker, the receiving broker replies with an HTTP 307 redirect to the target broker's web service URL. This uses the existing `PulsarWebResource#maybeRedirectToBroker`, the same mechanism used by `brokers healthcheck`. An unknown broker id returns 404. Without the param, behavior is unchanged.
- **Java admin client** (`BrokerStats`): add overloads taking a broker id, e.g. `getLoadReport(String broker)`, `getMetrics(String broker)`, `getAllocatorStats(String allocatorName, String broker)`, plus async variants. Existing methods are unchanged.
- **CLI**: add `-b/--broker <broker-id>` to `pulsar-admin broker-stats {monitoring-metrics,mbeans,topics,allocator-stats,load-report}`.
Example:
pulsar-admin brokers list <cluster>
pulsar-admin broker-stats load-report --broker <broker-id>
All changes are additive and backward compatible.
### Alternatives
1. **Use `--admin-url` per broker (status quo).** Works, but requires resolving each broker's web service URL. It also needs direct reachability and doesn't help Java admin client users who share one `PulsarAdmin` instance.
2. **CLI-only `--broker` that swaps the admin URL.** Same as the above with a different flag; no benefit for REST or Java client users.
3. **Server-side proxying (b1 fetches from b2 and returns the result).** Works when clients can't reach individual brokers, but adds load and complexity on the receiving broker and differs from how other broker-scoped admin endpoints behave. Rejected in favor of the existing redirect mechanism.
### Anything else?
With the redirect approach, the client must be able to reach the target broker's advertised web service URL. This is the same requirement as the other redirecting admin endpoints (topic ownership, `brokers healthcheck`).
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Enhancement] Support getting broker-stats of a specific broker by broker id [pulsar]
Posted by "codelipenghui (via GitHub) via commits" <co...@pulsar.apache.org>.
codelipenghui closed issue #27000: [Enhancement] Support getting broker-stats of a specific broker by broker id
URL: https://github.com/apache/pulsar/issues/27000
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org