Skip to content

Comments

Added configuration options to disable Prometheus metrics and endpoints#15499

Open
kenliao94 wants to merge 2 commits intorabbitmq:mainfrom
kenliao94:change_prometheus
Open

Added configuration options to disable Prometheus metrics and endpoints#15499
kenliao94 wants to merge 2 commits intorabbitmq:mainfrom
kenliao94:change_prometheus

Conversation

@kenliao94
Copy link
Contributor

@kenliao94 kenliao94 commented Feb 18, 2026

Proposed Changes

This PR adds configuration options to the rabbitmq_prometheus plugin that allow operators to:

Disable specific Prometheus endpoints - New configuration flags to disable the /metrics/per-object, /metrics/detailed, and /metrics/memory-breakdown endpoints individually:

disable_per_object_endpoint (default: true)
disable_detailed_endpoint (default: false)
disable_memory_breakdown_endpoint (default: false)

Disable individual metrics - A new disabled_metrics configuration option that accepts a list of metric names to exclude from scrape responses. The implementation normalizes metric names by stripping rabbitmq_, rabbitmq_detailed_, and rabbitmq_cluster_ prefixes, allowing users to specify metrics in any format.

Why this is useful:

  • Reduces scrape payload size when certain metrics are not needed
  • Improves scrape performance by skipping unnecessary metric collection
  • Allows operators to disable expensive endpoints (like per-object) in large deployments
  • Provides fine-grained control over which metrics are exposed

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

Put an x in the boxes that apply.
You can also fill these out after creating the PR.
This is simply a reminder of what we are going to look for before merging your code.

  • Mandatory: I (or my employer/client) have have signed the CA (see https://github.com/rabbitmq/cla)
  • I have read the CONTRIBUTING.md document
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally with my changes
  • If relevant, I have added necessary documentation to https://github.com/rabbitmq/rabbitmq-website
  • If relevant, I have added this change to the first version(s) in release-notes that I expect to introduce it

Further Comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution
you did and what alternatives you considered, etc.

@lukebakken lukebakken self-assigned this Feb 18, 2026
@lukebakken lukebakken self-requested a review February 18, 2026 16:59
@kenliao94 kenliao94 force-pushed the change_prometheus branch 2 times, most recently from c361663 to 9434b59 Compare February 19, 2026 18:58
Move `normalize_disabled_metrics/1` and `normalize_metric_name/1` from
`prometheus_rabbitmq_core_metrics_collector` into a new
`rabbit_prometheus_util` module so that the functions are properly
exported and testable.

Update `rabbit_prometheus_disabled_metrics_SUITE` to call
`rabbit_prometheus_util:normalize_metric_name/1` directly instead of
duplicating the implementation locally.
Copy link
Collaborator

@lukebakken lukebakken 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 for this contribution. After reviewing the changes, I have the following feedback:

Breaking default for disable_per_object_endpoint

The schema sets {default, true} for disable_per_object_endpoint, which silently disables /metrics/per-object for all existing deployments. This endpoint is documented as always accessible regardless of return_per_object_metrics, so changing its availability by default is a breaking change that will affect users who scrape it directly. Please change the default to false so that existing behavior is preserved and operators must explicitly opt in to disabling it.

normalize_metric_name/1 was duplicated in the test suite

The test suite defined its own local copy of normalize_metric_name/1 rather than testing the production function. This has been addressed in a follow-up commit by extracting the normalization logic into a new rabbit_prometheus_util module, which is now called from both the collector and the test suite.

Performance

normalize_disabled_metrics/1 is called on every scrape, re-reading and re-normalizing the disabled metrics list from app env each time. This is minor when the list is short, but worth addressing in a follow-up.

Documentation

The website documentation needs to be updated to describe the new configuration options and their defaults. The relevant sections are in docs/prometheus/index.md in the rabbitmq-website repository:

Each endpoint section (/metrics/memory-breakdown, /metrics/per-object, /metrics/detailed) should note the corresponding disable option, and a new section should cover prometheus.disabled_metrics.

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.

2 participants