diff --git a/server/src/main/java/org/opensearch/node/IoUsageStats.java b/server/src/main/java/org/opensearch/node/IoUsageStats.java index 75cd93981f04d..ecb1ac1bb1de4 100644 --- a/server/src/main/java/org/opensearch/node/IoUsageStats.java +++ b/server/src/main/java/org/opensearch/node/IoUsageStats.java @@ -58,7 +58,7 @@ public void setIoUtilisationPercent(double ioUtilisationPercent) { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - builder.field("io_utilization_percent", String.format(Locale.ROOT, "%.1f", this.ioUtilisationPercent)); + builder.field("max_io_utilization_percent", String.format(Locale.ROOT, "%.1f", this.ioUtilisationPercent)); return builder.endObject(); } diff --git a/server/src/main/java/org/opensearch/node/resource/tracker/AverageIoUsageTracker.java b/server/src/main/java/org/opensearch/node/resource/tracker/AverageIoUsageTracker.java index 97df9e6511596..101f60f36c346 100644 --- a/server/src/main/java/org/opensearch/node/resource/tracker/AverageIoUsageTracker.java +++ b/server/src/main/java/org/opensearch/node/resource/tracker/AverageIoUsageTracker.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.lucene.util.Constants; import org.opensearch.common.unit.TimeValue; import org.opensearch.monitor.fs.FsInfo.DeviceStats; import org.opensearch.monitor.fs.FsService; @@ -28,14 +29,14 @@ public class AverageIoUsageTracker extends AbstractAverageUsageTracker { private final FsService fsService; private final HashMap prevIoTimeDeviceMap; private long prevTimeInMillis; - private final IoUsageStats ioUsageStats; + private IoUsageStats ioUsageStats; public AverageIoUsageTracker(FsService fsService, ThreadPool threadPool, TimeValue pollingInterval, TimeValue windowDuration) { super(threadPool, pollingInterval, windowDuration); this.fsService = fsService; this.prevIoTimeDeviceMap = new HashMap<>(); this.prevTimeInMillis = -1; - this.ioUsageStats = new IoUsageStats(-1); + this.ioUsageStats = null; } /** @@ -67,11 +68,14 @@ public long getUsage() { @Override protected void doStart() { - scheduledFuture = threadPool.scheduleWithFixedDelay(() -> { - long usage = getUsage(); - recordUsage(usage); - updateIoUsageStats(); - }, pollingInterval, ThreadPool.Names.GENERIC); + if (Constants.LINUX) { + this.ioUsageStats = new IoUsageStats(-1); + scheduledFuture = threadPool.scheduleWithFixedDelay(() -> { + long usage = getUsage(); + recordUsage(usage); + updateIoUsageStats(); + }, pollingInterval, ThreadPool.Names.GENERIC); + } } private boolean preValidateFsStats() {