Skip to content

Allow disabling metrics with data-prepper-config.yaml#5627

Merged
dlvenable merged 2 commits intoopensearch-project:mainfrom
Davidding4718:allowing-disabling-metrics
May 1, 2025
Merged

Allow disabling metrics with data-prepper-config.yaml#5627
dlvenable merged 2 commits intoopensearch-project:mainfrom
Davidding4718:allowing-disabling-metrics

Conversation

@Davidding4718
Copy link
Copy Markdown
Contributor

@Davidding4718 Davidding4718 commented Apr 18, 2025

Description

This PR introduces the ability to disable specific metrics via the data-prepper-config.yaml configuration file.
To use this feature, add a new section to your configuration:

disabled_metrics:
  - "jvm.gc.max.data.size"
  - "jvm.gc.**"
  - "**.http.successRequests"

Known Limitations
Pattern matching is based on the raw Meter ID name, not what is displayed in CloudWatch (e.g., .sum, .count, .max).

  • For example, disabling jvm.gc.max.data.size.value won't work, because the base ID is only jvm.gc.max.data.size.
    Only:
disabled_metrics:
  - "jvm.gc.max.data.size"

works.

  • Disabling '**.BlockingBuffer.readLatency.count' won't work, because the base ID is 'your-pipeline-name.BlockingBuffer.readLatency'.
    Only:
disabled_metrics:
  - "**.BlockingBuffer.readLatency"

works.

Issues Resolved

Resolves #5431

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    - [ ] New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Siqi Ding <dingdd@amazon.com>
Copy link
Copy Markdown
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Davidding4718 for this contribution!

import java.util.Collections;
import java.util.List;

public class DisableMetricsFilter implements MeterFilter {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should have unit tests. This is the best place for testing different combinations of different values such as:

- "jvm.gc.max.data.size"
- "jvm.gc.**"
- "**.http.successRequests"

You can use JUnit's @ParameterizedTest to make some good test case coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created a DisableMetricsFilterTest class in test folder.

@JsonProperty("metric_tag_filters")
final List<MetricTagFilter> metricTagFilters,
@JsonProperty("disabled_metrics")
@JsonAlias("disabledMetrics")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this alias. This is a new feature, so we can just have the correct format of disabled_metrics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Have made the change.

Signed-off-by: Siqi Ding <109874435+Davidding4718@users.noreply.github.com>
Copy link
Copy Markdown
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Davidding4718 !

@dlvenable dlvenable merged commit b422250 into opensearch-project:main May 1, 2025
45 of 47 checks passed
alparish pushed a commit to alparish/data-prepper that referenced this pull request May 22, 2025
…ject#5627)

Add support for disabling metrics via data-prepper-config.yaml

Signed-off-by: Siqi Ding <dingdd@amazon.com>
Signed-off-by: Siqi Ding <109874435+Davidding4718@users.noreply.github.com>
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.

Allow disabling metrics

2 participants