Skip to content

Fix Data Node byte metrics reported in GiB instead of bytes#26732

Open
patrickmann wants to merge 2 commits into
masterfrom
fix/datanode-metrics-in-bytes-unit
Open

Fix Data Node byte metrics reported in GiB instead of bytes#26732
patrickmann wants to merge 2 commits into
masterfrom
fix/datanode-metrics-in-bytes-unit

Conversation

@patrickmann

@patrickmann patrickmann commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Closes #25532

Description

The Data Node metrics served by POST /api/datanodes/<host>/rest/metrics/multiple reported memory, heap, and disk values in GiB even though the metric names end in _in_bytes.

Root cause: one NodeStatMetrics enum feeds two consumers. The byte metrics carry a bytesToGb/bytesToMb conversion intended for the gl-datanode-metrics index and its dashboards. MetricsCollector reused those already converted values to populate the metric-registry gauges behind the endpoint, so byte gauges returned GiB.

Fix: split the two paths. NodeMetricsCollector now returns the raw OpenSearch values. The GiB/MiB conversion is applied only when building the metrics index document, so the dashboards are unchanged. The registry gauges expose the raw byte values.

How Tested

  • Unit tests
  • Manual: start a Data Node, POST /api/datanodes/<host>/rest/metrics/multiple with {"metrics":["opensearch.os.mem.total_in_bytes","opensearch.jvm.mem.heap_max_in_bytes","opensearch.fs.total.total_in_bytes"]} and confirm the values are byte scale (billions), then open the cluster configuration page and verify Memory, JVM, and Storage columns show correct GB/MiB figures.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

patrickmann and others added 2 commits July 22, 2026 14:53
The metric-registry gauges served by /rest/metrics/multiple (e.g.
opensearch.os.mem.total_in_bytes) were populated from values already
converted to GiB/MiB for the metrics index dashboards, so byte metrics
were reported in GiB while their names still said "_in_bytes". The
cluster configuration page then rendered those values as bytes, showing
wrong figures.

Split the two data paths: the collector now returns raw OpenSearch
values, the unit conversion is applied only when building the metrics
index document (dashboards unchanged), and the registry gauges expose
the raw byte values so their "_in_bytes" names stay accurate.

Closes #25532

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@patrickmann
patrickmann marked this pull request as ready for review July 22, 2026 13:43
@patrickmann
patrickmann requested review from a team and Copilot July 22, 2026 13:43

This comment was marked as low quality.

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.

OpenSearch metrics _in_bytes appear to be returning values in GiB instead of bytes

2 participants