Skip to content

Comments

Add I/O statistics on Linux#5

Open
MitchLewis930 wants to merge 1 commit intopr_015_beforefrom
pr_015_after
Open

Add I/O statistics on Linux#5
MitchLewis930 wants to merge 1 commit intopr_015_beforefrom
pr_015_after

Conversation

@MitchLewis930
Copy link

PR_015

This commit adds a variety of real disk metrics for the block devices
that back Elasticsearch data paths. A collection of statistics are read
from /proc/diskstats and are used to report the raw metrics for
operations and read/write bytes.

Relates elastic#15915
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 00:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds I/O statistics collection functionality for Linux systems by reading from /proc/diskstats. The implementation tracks device-level read/write operations and sectors transferred, exposing these metrics through the Elasticsearch nodes stats API.

Changes:

  • Added DeviceStats and IoStats classes to track I/O metrics per device and aggregated totals
  • Modified FsInfo constructor to accept an optional IoStats parameter
  • Implemented /proc/diskstats parsing in FsProbe to collect device metrics on Linux
  • Added device number tracking to NodePath and ESFileStore for mapping paths to devices

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
core/src/main/java/org/elasticsearch/monitor/fs/FsInfo.java Added DeviceStats and IoStats classes; updated FsInfo constructor to include I/O statistics
core/src/main/java/org/elasticsearch/monitor/fs/FsProbe.java Implemented I/O statistics collection by parsing /proc/diskstats
core/src/main/java/org/elasticsearch/monitor/fs/FsService.java Refactored to pass previous FsInfo for delta calculations
core/src/main/java/org/elasticsearch/env/NodeEnvironment.java Added major/minor device number fields to NodePath
core/src/main/java/org/elasticsearch/env/ESFileStore.java Added device number extraction from /proc/self/mountinfo
core/src/main/resources/org/elasticsearch/bootstrap/security.policy Added read permission for /proc/diskstats
docs/reference/cluster/nodes-stats.asciidoc Documented new I/O statistics fields in the API
core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java Added tests for I/O statistics parsing and aggregation
core/src/test/java/org/elasticsearch/monitor/fs/DeviceStatsTests.java Added unit tests for DeviceStats delta calculations
test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java Updated mock to include null IoStats parameter
core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java Updated test mocks to include null IoStats parameter
core/src/main/java/org/elasticsearch/monitor/MonitorService.java Removed empty Javadoc comments

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +220 to +223
currentSectorsWritten,
previousDeviceStats != null ? previousDeviceStats.currentSectorsWritten : -1,
currentSectorsRead,
previousDeviceStats != null ? previousDeviceStats.currentSectorsRead : -1,
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

The parameter order is incorrect in the constructor call. currentSectorsWritten and currentSectorsRead are swapped. Line 220 should pass currentSectorsRead and line 222 should pass currentSectorsWritten to match the private constructor's parameter order (lines 234-236).

Copilot uses AI. Check for mistakes.
builder.endObject();
}
builder.endArray();
builder.startObject("total");
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Missing builder.endObject() call to close the "total" object started on this line. This will produce malformed JSON output.

Copilot uses AI. Check for mistakes.
used by Elasticsearch completed since starting Elasticsearch.

`fs.io_stats.read_operations` (Linux only)::
The total number of read operations for across all devices used by
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

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

Corrected grammar by removing extra 'for' - should be 'The total number of read operations across all devices'.

Suggested change
The total number of read operations for across all devices used by
The total number of read operations across all devices used by

Copilot uses AI. Check for mistakes.
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