Skip to content

[Feature] Add metric category filtering support to Prometheus exporter#4084

Open
j1wonpark wants to merge 2 commits intoapache:masterfrom
j1wonpark:feature/prometheus-metric-category-filter
Open

[Feature] Add metric category filtering support to Prometheus exporter#4084
j1wonpark wants to merge 2 commits intoapache:masterfrom
j1wonpark:feature/prometheus-metric-category-filter

Conversation

@j1wonpark
Copy link
Contributor

Why are the changes needed?

Currently, the Prometheus exporter exposes all registered metrics (~61 metrics) unconditionally. As the number of tables grows, the volume of metrics increases significantly. Users need the ability to selectively enable/disable metric categories to reduce noise and focus on the metrics that matter to their use case.

Brief change log

  • Added MetricCategory enum in amoro-metrics-prometheus module to define 5 metric categories (self-optimizing, optimizer-group, orphan-files, ams-jvm, table-summary) with their corresponding metric name prefixes
  • Modified MetricsCollector to accept a set of disabled categories and filter them out in isValidMetric()
  • Modified PrometheusMetricsReporter to parse category settings from properties in open() and pass them to MetricsCollector
  • Updated metric-reporters.yaml with category filtering configuration examples
  • Updated Helm chart values.yaml and amoro-configmap_test.yaml to reflect the new configuration options

Configuration example:

metric-reporters:
  - name: prometheus-exporter
    enabled: true
    properties:
       port: 7001
       category.self-optimizing.enabled: "true"
       category.optimizer-group.enabled: "true"
       category.orphan-files.enabled: "false"
       category.ams-jvm.enabled: "true"
       category.table-summary.enabled: "false"

All categories are enabled by default for backward compatibility.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible
    • MetricCategoryTest (10 tests): category matching, properties parsing, case-insensitive values, invalid values
    • MetricsCollectorFilterTest (5 tests): no filter, single/multiple disabled categories, unknown metrics not filtered, orphan-files multi-prefix filtering
  • Add screenshots for manual tests if appropriate
  • Run test locally before making a pull request
    • ./mvnw test -pl amoro-metrics/amoro-metrics-prometheus -am — 15 tests passed
    • helm unittest charts/amoro — 74 tests passed

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? docs (metric-reporters.yaml comments and Helm values.yaml comments)

Allow users to enable/disable metric categories (self-optimizing,
optimizer-group, orphan-files, ams-jvm, table-summary) via
metric-reporters.yaml properties. All categories are enabled by
default for backward compatibility. Also update Helm chart values
and configmap tests to reflect the new configuration options.

Signed-off-by: jiwonpark <jiwonpark@example.com>
Signed-off-by: Jiwon Park <jpark92@outlook.kr>
@zhoujinsong
Copy link
Contributor

@j1wonpark Thanks a lot for the proposal.

I think it is useful to support filtering some metrics.
However, I'm wondering if we could open up a regular expression to allow users to freely configure the metrics they want to filter.

@j1wonpark
Copy link
Contributor Author

@zhoujinsong Thanks for the feedback! Regex support sounds like a great idea.
I’ll update it so users can configure their own filtering patterns. Will get it done soon!

Replace the fixed category enum approach with a flexible regex-based
metric filter. Users can now specify include/exclude patterns via
metric-filter.includes and metric-filter.excludes properties to
freely configure which metrics are exported.

Signed-off-by: Jiwon Park <jpark92@outlook.kr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants