Skip to content

Commit 37be142

Browse files
changes
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
1 parent e52c988 commit 37be142

8 files changed

Lines changed: 35 additions & 72 deletions

File tree

server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public enum Metric {
214214
FILE_CACHE_STATS("file_cache"),
215215
TASK_CANCELLATION("task_cancellation"),
216216
SEARCH_PIPELINE("search_pipeline"),
217-
NODES_PERFORMANCE_STATS("nodes_performance_stats");
217+
GLOBAL_PERFORMANCE_STATS("performance_stats");
218218

219219
private String metricName;
220220

server/src/main/java/org/opensearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected NodeStats nodeOperation(NodeStatsRequest nodeStatsRequest) {
125125
NodesStatsRequest.Metric.FILE_CACHE_STATS.containedIn(metrics),
126126
NodesStatsRequest.Metric.TASK_CANCELLATION.containedIn(metrics),
127127
NodesStatsRequest.Metric.SEARCH_PIPELINE.containedIn(metrics),
128-
NodesStatsRequest.Metric.NODES_PERFORMANCE_STATS.containedIn(metrics)
128+
NodesStatsRequest.Metric.GLOBAL_PERFORMANCE_STATS.containedIn(metrics)
129129
);
130130
}
131131

server/src/main/java/org/opensearch/monitor/fs/FsHealthService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ private void monitorFSHealth() {
228228
}
229229
Files.delete(tempDataPath);
230230
final long elapsedTime = currentTimeMillisSupplier.getAsLong() - executionStartTime;
231-
logger.info("health check took {}", elapsedTime);
232231
if (elapsedTime > slowPathLoggingThreshold.millis()) {
233232
logger.warn(
234233
"health check of [{}] took [{}ms] which is above the warn threshold of [{}]",

server/src/main/java/org/opensearch/monitor/fs/FsInfo.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
226226
* @opensearch.internal]
227227
*/
228228
public static class DeviceStats implements Writeable, ToXContentFragment {
229-
private static final Logger logger = LogManager.getLogger(DeviceStats.class);
230229

231230
final int majorDeviceNumber;
232231
final int minorDeviceNumber;
@@ -367,14 +366,11 @@ public long operations() {
367366
public long readOperations() {
368367
if (previousReadsCompleted == -1) return -1;
369368

370-
//logger.info("Current reads : {} , Previous reads : {}", currentReadsCompleted, previousReadsCompleted);
371-
372369
return (currentReadsCompleted - previousReadsCompleted);
373370
}
374371

375372
public long writeOperations() {
376373
if (previousWritesCompleted == -1) return -1;
377-
//logger.info("Current writes : {} , Previous writes : {}", currentWritesCompleted, previousWritesCompleted);
378374

379375
return (currentWritesCompleted - previousWritesCompleted);
380376
}
@@ -413,28 +409,6 @@ public long ioTimeInMillis() {
413409
return (currentIOTime - previousIOTime);
414410
}
415411

416-
public double getNewWriteLatency() {
417-
//double readLatency = getReadTime() / readOperations();
418-
double writeLatency = getWriteTime() / writeOperations();
419-
return writeLatency;
420-
}
421-
422-
public double getNewReadLatency() {
423-
//double readLatency = getReadTime() / readOperations();
424-
double readLatency = getReadTime() / readOperations();
425-
return readLatency;
426-
}
427-
428-
public double getReadTime() {
429-
if(previousReadTime == -1.0) return -1.0;
430-
return currentReadTime - previousReadTime;
431-
}
432-
433-
public double getWriteTime() {
434-
if(previousWriteTime == -1.0) return -1.0;
435-
return currentWriteTime - previousWriteTime;
436-
}
437-
438412
public long getCurrentIOTime() {
439413
return this.currentIOTime;
440414
}
@@ -459,7 +433,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
459433
builder.field(IoStats.WRITE_OPERATIONS, writeOperations());
460434
builder.field(IoStats.READ_KILOBYTES, readKilobytes());
461435
builder.field(IoStats.WRITE_KILOBYTES, writeKilobytes());
462-
builder.field(IoStats.IO_TIME_MS, ioTimeInMillis());
436+
builder.field(IoStats.IO_TIME_MILLIS, ioTimeInMillis());
463437
return builder;
464438
}
465439

@@ -477,7 +451,7 @@ public static class IoStats implements Writeable, ToXContentFragment {
477451
private static final String WRITE_OPERATIONS = "write_operations";
478452
private static final String READ_KILOBYTES = "read_kilobytes";
479453
private static final String WRITE_KILOBYTES = "write_kilobytes";
480-
private static final String IO_TIME_MS = "io_time_in_millis";
454+
private static final String IO_TIME_MILLIS = "io_time_in_millis";
481455

482456
final DeviceStats[] devicesStats;
483457
final long totalOperations;
@@ -585,7 +559,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
585559
builder.field(WRITE_OPERATIONS, totalWriteOperations);
586560
builder.field(READ_KILOBYTES, totalReadKilobytes);
587561
builder.field(WRITE_KILOBYTES, totalWriteKilobytes);
588-
builder.field(IO_TIME_MS, totalIOTimeInMillis);
562+
builder.field(IO_TIME_MILLIS, totalIOTimeInMillis);
589563
builder.endObject();
590564
}
591565
return builder;

server/src/main/java/org/opensearch/monitor/fs/FsProbe.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ final FsInfo.IoStats ioStats(final Set<Tuple<Integer, Integer>> devicesNumbers,
125125
final long sectorsWritten = Long.parseLong(fields[9]);
126126
final double readTime = Double.parseDouble(fields[6]);
127127
final double writeTime = Double.parseDouble(fields[10]);
128-
final double readLatency = readTime / readsCompleted;
129-
final double writeLatency = writeTime / writesCompleted;
130128
final long ioTime = Long.parseLong(fields[12]);
131129
final FsInfo.DeviceStats deviceStats = new FsInfo.DeviceStats(
132130
majorDeviceNumber,
@@ -139,8 +137,6 @@ final FsInfo.IoStats ioStats(final Set<Tuple<Integer, Integer>> devicesNumbers,
139137
ioTime,
140138
readTime,
141139
writeTime,
142-
readLatency,
143-
writeLatency,
144140
deviceMap.get(Tuple.tuple(majorDeviceNumber, minorDeviceNumber))
145141
);
146142
devicesStats.add(deviceStats);

server/src/main/java/org/opensearch/node/NodesPerformanceStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Map<String, NodePerformanceStatistics> getNodeIdToNodePerfStatsMap() {
4848

4949
@Override
5050
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
51-
builder.startObject("nodes_performance_stats");
51+
builder.startObject("performance_stats");
5252
for (String nodeId : nodePerfStats.keySet()) {
5353
builder.startObject(nodeId);
5454
NodePerformanceStatistics perfStats = nodePerfStats.get(nodeId);

server/src/main/java/org/opensearch/throttling/tracker/AverageIOUsageTracker.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
import java.util.concurrent.atomic.AtomicReference;
2424

25+
/**
26+
* This class calculates the average of various IO stats such as IOPS, throughput and IO use percent
27+
* for a given window and polling interval
28+
*/
2529
public class AverageIOUsageTracker extends AbstractLifecycleComponent {
2630

2731
private static final Logger logger = LogManager.getLogger(AverageCpuUsageTracker.class);
@@ -42,8 +46,6 @@ public class AverageIOUsageTracker extends AbstractLifecycleComponent {
4246
private final AtomicReference<DoubleMovingAverage> readLatencyObservations = new AtomicReference<>();
4347
private final AtomicReference<DoubleMovingAverage> writeLatencyObservations = new AtomicReference<>();
4448

45-
private long runs = 1;
46-
4749
public AverageIOUsageTracker(
4850
ThreadPool threadPool,
4951
TimeValue pollingInterval,
@@ -120,15 +122,9 @@ public void setWindowDuration(TimeValue windowDuration) {
120122
}
121123

122124
private void recordUsage(IoUsageFetcher.DiskStats usage) {
123-
if(usage.getIoTime() == 0.0) {
124-
runs++;
125-
return;
126-
} else {
127-
runs = 1;
128-
}
129125
ioTimeObservations.get().record(usage.getIoTime());
130126
readIopsObservations.get().record((long)usage.getReadOps());
131-
readKbObservations.get().record(usage.getReadkb());
127+
readKbObservations.get().record(usage.getReadThroughputInKB());
132128
double readOps = usage.getReadOps() < 1 ? 1.0 : usage.getReadOps() * 1.0;
133129
double writeOps = usage.getWriteOps() < 1 ? 1.0 : usage.getWriteOps() * 1.0;
134130
double readTime = usage.getReadTime() < 1 ? 0.0 : usage.getReadTime();
@@ -137,7 +133,7 @@ private void recordUsage(IoUsageFetcher.DiskStats usage) {
137133
double writeLatency = (writeTime/ writeOps);// * runs;
138134
writeLatencyObservations.get().record(writeLatency);
139135
readLatencyObservations.get().record(readLatency);
140-
writeKbObservations.get().record(usage.getWritekb());
136+
writeKbObservations.get().record(usage.getWriteThroughputInKB());
141137
writeIopsObservations.get().record((long) usage.getWriteOps());
142138
}
143139

server/src/main/java/org/opensearch/throttling/tracker/IoUsageFetcher.java

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
import java.util.HashMap;
1717
import java.util.Map;
1818

19-
public class IoUsageFetcher {
20-
private static final Logger logger = LogManager.getLogger(AverageCpuUsageTracker.class);
19+
/**
20+
* This class calculates the delta of IO utilization data such as IOPS, throughput, IO use percent etc.
21+
* from FS stats across all data disks
22+
*/
23+
class IoUsageFetcher {
24+
private static final Logger logger = LogManager.getLogger(IoUsageFetcher.class);
2125
private Map<String, DiskStats> previousIOTimeMap;
2226
private FsService fsService;
2327
public IoUsageFetcher(FsService fsService){
@@ -30,16 +34,17 @@ class DiskStats {
3034
public double writeTime;
3135
public double readOps;
3236
public double writeOps;
33-
public long readkb;
34-
public long writekb;
35-
public DiskStats(long ioTime, double readTime, double writeTime, double readOps, double writeOps, long readkb, long writekb) {
37+
public long readThroughputInKB;
38+
public long writeThroughputInKB;
39+
public DiskStats(long ioTime, double readTime, double writeTime, double readOps, double writeOps,
40+
long readThroughputInKB, long writeThroughputInKB) {
3641
this.ioTime = ioTime;
3742
this.readTime = readTime;
3843
this.writeTime = writeTime;
3944
this.readOps = readOps;
4045
this.writeOps = writeOps;
41-
this.readkb = readkb;
42-
this.writekb = writekb;
46+
this.readThroughputInKB = readThroughputInKB;
47+
this.writeThroughputInKB = writeThroughputInKB;
4348
}
4449

4550
public long getIoTime() {
@@ -54,8 +59,8 @@ public double getReadTime() {
5459
return readTime;
5560
}
5661

57-
public long getReadkb() {
58-
return readkb;
62+
public long getReadThroughputInKB() {
63+
return readThroughputInKB;
5964
}
6065

6166
public double getWriteOps() {
@@ -66,8 +71,8 @@ public double getWriteTime() {
6671
return writeTime;
6772
}
6873

69-
public long getWritekb() {
70-
return writekb;
74+
public long getWriteThroughputInKB() {
75+
return writeThroughputInKB;
7176
}
7277
}
7378
public DiskStats getDiskUtilizationStats() {
@@ -77,42 +82,35 @@ public DiskStats getDiskUtilizationStats() {
7782
long writekb = 0;
7883
double readTime = 0;
7984
double writeTime = 0;
80-
double readLatency = 0.0;
81-
double writeLatency = 0.0;
8285
double readOps = 0.0;
8386
double writeOps = 0.0;
87+
// For non linux machines, this will be null
8488
if(this.fsService.stats().getIoStats() == null) {
8589
return null;
8690
}
91+
// Sum the stats across all data volumes
8792
for (FsInfo.DeviceStats devicesStat : this.fsService.stats().getIoStats().getDevicesStats()) {
8893
if (previousIOTimeMap != null && previousIOTimeMap.containsKey(devicesStat.getDeviceName())){
89-
//logger.info(this.fsService.stats().getTimestamp());
9094
long ioSpentTime = devicesStat.getCurrentIOTime() - previousIOTimeMap.get(devicesStat.getDeviceName()).ioTime;
91-
ioUsePercent = (ioSpentTime * 100) / (1000);
95+
ioUsePercent = ioSpentTime / 10;
9296
readOps += devicesStat.currentReadOperations() - previousIOTimeMap.get(devicesStat.getDeviceName()).readOps;
9397
writeOps += devicesStat.currentWriteOpetations() - previousIOTimeMap.get(devicesStat.getDeviceName()).writeOps;
94-
readkb += devicesStat.getCurrentReadKilobytes() - previousIOTimeMap.get(devicesStat.getDeviceName()).readkb;
95-
writekb += devicesStat.getCurrentWriteKilobytes() - previousIOTimeMap.get(devicesStat.getDeviceName()).writekb;
98+
readkb += devicesStat.getCurrentReadKilobytes() - previousIOTimeMap.get(devicesStat.getDeviceName()).readThroughputInKB;
99+
writekb += devicesStat.getCurrentWriteKilobytes() - previousIOTimeMap.get(devicesStat.getDeviceName()).writeThroughputInKB;
96100
readTime += devicesStat.getCurrentReadTime() - previousIOTimeMap.get(devicesStat.getDeviceName()).readTime;
97101
writeTime += devicesStat.getCurrentWriteTime() - previousIOTimeMap.get(devicesStat.getDeviceName()).writeTime;
102+
// Avoid dividing by fractions which will give false positives in results
98103
if(readTime < 1) readTime = 1;
99104
if(readOps < 1) readOps = 1;
100105
if(writeOps < 1) writeOps = 1;
101106
if(writeTime < 1) writeTime = 1;
102-
readLatency += (readTime / readOps);
103-
writeLatency += (writeTime / writeOps);
104107
}
105108
DiskStats ps = new DiskStats(devicesStat.getCurrentIOTime(), devicesStat.getCurrentReadTime(),
106109
devicesStat.getCurrentWriteTime(), devicesStat.currentReadOperations(), devicesStat.currentWriteOpetations(),
107110
devicesStat.getCurrentReadKilobytes(), devicesStat.getCurrentWriteKilobytes());
108111
currentIOTimeMap.put(devicesStat.getDeviceName(), ps);
109112
}
110-
// logger.info("Read in MB : {} , Write in MB : {}", readkb/1000, writekb/1000);
111-
// readLatency += (readOps / readTime) * 100;
112-
// writeLatency += (writeOps / writeTime) * 100;
113-
// logger.info("read ops : {} , writeops : {} , readtime: {} , writetime: {}", readOps, writeOps, readTime, writeTime);
114-
// logger.info("Read latency : {} write latency : {}" , readLatency, writeLatency);
115-
logger.info("IO use percent : {}", ioUsePercent);
113+
logger.debug("IO use percent : {}", ioUsePercent);
116114
previousIOTimeMap = currentIOTimeMap;
117115

118116
return new DiskStats(ioUsePercent, readTime, writeTime, readOps, writeOps, readkb, writekb);

0 commit comments

Comments
 (0)