-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat][monitor] PIP-447 for Customizable Prometheus Labels for Topic Metrics #24991
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
base: master
Are you sure you want to change the base?
Conversation
d8179f9 to
bc8eab2
Compare
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment about the usage of PolicyName.MAX_SUBSCRIPTIONS
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements PIP-447 to add support for customizable Prometheus labels on topic metrics, allowing operators to attach custom metadata (like SLA tier, team ownership, etc.) to topics that will be exposed as Prometheus labels.
Key changes:
- Adds
customMetricLabelsfield to TopicPolicies with clone and validation support - Implements REST APIs, admin client methods, and CLI commands for managing custom metric labels
- Integrates custom labels into Prometheus metrics generation in TopicStats
- Adds configuration options to enable/disable the feature and control allowed label keys and value lengths
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/TopicPolicies.java | Adds customMetricLabels field with proper cloning and accessor methods |
| pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/HierarchyTopicPolicies.java | Adds PolicyHierarchyValue for customMetricLabels to support policy hierarchy |
| pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/TopicPolicies.java | Adds API methods for setting, getting, and removing custom metric labels |
| pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicPoliciesImpl.java | Implements client-side REST API calls for custom metric labels operations |
| pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java | Adds CLI commands for managing custom metric labels in CmdTopics |
| pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java | Adds CLI commands for managing custom metric labels in CmdTopicPolicies |
| pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/CmdTopicPoliciesTest.java | Adds comprehensive tests for CLI command functionality |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java | Adds REST endpoints for custom metric labels operations |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java | Implements business logic for setting, getting, and removing custom metric labels with validation |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java | Updates topic policy loading to include customMetricLabels |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/TopicStats.java | Modifies metrics generation to include custom labels in Prometheus output |
| pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java | Retrieves and passes custom metric labels to TopicStats for metrics generation |
| pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java | Adds integration tests for custom metric labels feature including validation scenarios |
| pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java | Adds three configuration properties for the custom metric labels feature |
| conf/broker.conf | Documents the new configuration properties with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
...ar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicPoliciesImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
Outdated
Show resolved
Hide resolved
…s and expose them in Prometheus
…tency in topic statistics
…with CLI commands
…configuration - Add namespace-level allowed_topic_properties_for_metrics field in Policies.java - Add admin API methods for set/get/remove allowedTopicPropertiesForMetrics - Add REST endpoints in Namespaces.java (v2) - Add CLI commands: set-allowed-topic-properties-for-metrics, get-allowed-topic-properties-for-metrics, remove-allowed-topic-properties-for-metrics - Integrate with Prometheus metrics generation to merge broker-level and namespace-level configurations - Add test for namespace-level allowedTopicPropertiesForMetrics
Since PIP-447 now uses topic properties instead of topic policies, this removes: - TopicPolicies.customMetricLabels field and methods - HierarchyTopicPolicies.customMetricLabels field - TopicPolicies admin API methods (set/get/removeCustomMetricLabels) - CLI commands in CmdTopicPolicies and CmdTopics - TopicPoliciesImpl implementation - REST API endpoints in PersistentTopics.java (v2) - Internal methods in PersistentTopicsBase.java - References in AbstractTopic.java - Unit tests in CmdTopicPoliciesTest.java - Renamed test method in PrometheusMetricsLabelsTest.java
…rectly and update usage in NamespacesBase
…x config validation order
…LabelValueLength and clarify allowedTopicPropertiesForMetrics documentation
…nore hidden directories
28db9d2 to
c431957
Compare
…metrics - Move logic for fetching and filtering custom metric labels to TopicStats - Simplify NamespaceStatsAggregator by delegating label handling to TopicStats - Ensure only allowed topic properties are exposed as custom metric labels
…tats to AbstractTopic
4b7fb7b to
804b972
Compare
…_METRIC_LABELS for consistency
0c837f1 to
8c5d6f5
Compare
8c5d6f5 to
2e1cc8a
Compare
…xception with detailed error messages
PIP: https://github.com/apache/pulsar/blob/master/pip/pip-447.md
Motivation
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: