Skip to content

exporter: improve RGW sync metric path parsing for zone names with special chars - #71642

Merged
afreen23 merged 1 commit into
ceph:mainfrom
AnuragRaut08:wip-2275910-rgw-sync-zone-regex
Sep 28, 2026
Merged

afreen23 merged 1 commit into
ceph:mainfrom
AnuragRaut08:wip-2275910-rgw-sync-zone-regex

Conversation

@AnuragRaut08

@AnuragRaut08 AnuragRaut08 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Refers-to: https://tracker.ceph.com/issues/80400
Signed-off-by: Anurag Raut [email protected]

PR Description

This PR improves RGW sync metric path handling for zone names containing special characters, such as underscores.

The Prometheus module previously relied on regex-based parsing of the metric path, which could ambiguously separate the zone name from the counter name. The change explicitly separates the zone name and counter suffix when normalizing RGW sync metrics, preserving the complete zone name as the source_zone label.

Regression tests cover hyphenated and underscore-containing zone names, multiple zones, counter suffixes, and unrelated metrics.

The implementation was verified with:

  • python3 -m flake8 module.py test_module.py
  • tox -e py3 -- prometheus/test_module.py -v
  • 40 tests passed
  • Focused RGW sync tests: 9 passed

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@AnuragRaut08
AnuragRaut08 force-pushed the wip-2275910-rgw-sync-zone-regex branch from 2c424c3 to 17c3624 Compare September 9, 2026 06:42
@AnuragRaut08 AnuragRaut08 changed the title mgr/prometheus: fix RGW sync metrics for zone names with special chars exporter: fix RGW sync metrics for zone names with special chars Sep 9, 2026
@AnuragRaut08
AnuragRaut08 force-pushed the wip-2275910-rgw-sync-zone-regex branch from 17c3624 to b722285 Compare September 9, 2026 06:49
@cloudbehl
cloudbehl requested a review from afreen23 September 9, 2026 11:56
@AnuragRaut08
AnuragRaut08 marked this pull request as ready for review September 10, 2026 05:10

@avanthakkar avanthakkar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not related to the changes, but AFAIK Prometheus module doesn't scrape perf counters by default (unless you explicitly set exclude_perf_counters to false). It's mostly ceph-exporter job to do so. Please ignore comment if this is intentional

@AnuragRaut08

AnuragRaut08 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Acknowledged. This fix targets users who explicitly set exclude_perf_counters = false. The option is supported, and the issue occurs when perf counters are explicitly enabled, so the change is intentional.

@afreen23 afreen23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your test cases are passing without your changes as well:

platform linux -- Python 3.9.25, pytest-8.4.2, pluggy-1.6.0 -- /ceph/src/pybind/mgr/.tox/py3/bin/python
cachedir: .tox/py3/.pytest_cache
rootdir: /ceph/src/pybind/mgr
configfile: tox.ini
plugins: requests-mock-1.12.1, xdist-3.8.0, cov-7.1.0, pyfakefs-5.10.2
8 workers [7 items]     
scheduling tests via LoadScheduling

prometheus/test_module.py::RgwSyncMetricsTest::test_multi_hyphenated_zone_name 
prometheus/test_module.py::RgwSyncMetricsTest::test_underscore_zone_name_long 
prometheus/test_module.py::RgwSyncMetricsTest::test_longrunavg_counters_get_separate_fixed_paths 
prometheus/test_module.py::RgwSyncMetricsTest::test_hyphenated_zone_name 
prometheus/test_module.py::RgwSyncMetricsTest::test_non_sync_metric_not_affected 
[gw5] [ 14%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_non_sync_metric_not_affected 
prometheus/test_module.py::RgwSyncMetricsTest::test_multiple_zones_merged_under_fixed_path 
prometheus/test_module.py::RgwSyncMetricsTest::test_underscore_zone_name 
[gw2] [ 28%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_multi_hyphenated_zone_name 
[gw0] [ 42%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_hyphenated_zone_name 
[gw4] [ 57%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_underscore_zone_name 
[gw7] [ 71%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_underscore_zone_name_long 
[gw1] [ 85%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_longrunavg_counters_get_separate_fixed_paths 
[gw3] [100%] PASSED prometheus/test_module.py::RgwSyncMetricsTest::test_multiple_zones_merged_under_fixed_path 

=========================================== 7 passed in 2.26s ===========================================
________________________________________________ summary ________________________________________________
  py3: commands succeeded
  congratulations :)

Example: data-sync-from-my_zone.fetch_bytes

Old code:
re.search -> group(1) = "my_zone"
re.sub -> "data-sync-from-zone.fetch_bytes"
label -> "my_zone"

New code:
re.match -> group(1) = "my_zone", group(2) = "fetch_bytes"
new_path -> "data-sync-from-zone.fetch_bytes"
label -> "my_zone"

We can keep these enhancements, but this is not a bug fix , the code is working fine.

The only real improvement is replacing the fragile re.sub with a clean direct string construction.

Still we can take this PR if you can edit title,commit, description and take it as enhancement

Also we can add test cases more as now it avoid empty zone names, older used to have.

Thanks

@AnuragRaut08 AnuragRaut08 changed the title exporter: fix RGW sync metrics for zone names with special chars exporter: improve RGW sync metric path parsing for zone names with special chars Sep 24, 2026
@AnuragRaut08
AnuragRaut08 force-pushed the wip-2275910-rgw-sync-zone-regex branch from b722285 to 357b454 Compare September 24, 2026 15:30
@AnuragRaut08

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed analysis! I've added two additional tests covering an underscore-containing zone name with an underscore-containing counter suffix, and empty zone names. The updated test suite passes with 42 tests. I've also updated the commit message and PR description to reflect this as an enhancement. Please take another look.

@afreen23
afreen23 merged commit 2ebfe4e into ceph:main Sep 28, 2026
16 checks passed
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.

3 participants