From edcc1cedda8dd730c4c920ef0d1610f18c38ee56 Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Thu, 19 Oct 2023 22:06:40 -0700 Subject: [PATCH 1/4] Return unformatted segrep metrics in stats Signed-off-by: Poojita Raj --- .../main/java/org/opensearch/index/ReplicationStats.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/main/java/org/opensearch/index/ReplicationStats.java b/server/src/main/java/org/opensearch/index/ReplicationStats.java index 9cc6685c75f80..dc537b6683edb 100644 --- a/server/src/main/java/org/opensearch/index/ReplicationStats.java +++ b/server/src/main/java/org/opensearch/index/ReplicationStats.java @@ -79,6 +79,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(Fields.MAX_BYTES_BEHIND, new ByteSizeValue(maxBytesBehind).toString()); builder.field(Fields.TOTAL_BYTES_BEHIND, new ByteSizeValue(totalBytesBehind).toString()); builder.field(Fields.MAX_REPLICATION_LAG, new TimeValue(maxReplicationLag)); + builder.humanReadableField(Fields.MAX_DATA_LAG_BYTES, Fields.MAX_DATA_LAG, new ByteSizeValue(maxBytesBehind)); + builder.humanReadableField(Fields.TOTAL_DATA_LAG_BYTES, Fields.TOTAL_DATA_LAG, new ByteSizeValue(totalBytesBehind)); + builder.humanReadableField(Fields.MAX_TIME_LAG_MILLIS, Fields.MAX_TIME_LAG, new TimeValue(maxReplicationLag)); builder.endObject(); return builder; } @@ -93,5 +96,11 @@ static final class Fields { static final String MAX_BYTES_BEHIND = "max_bytes_behind"; static final String TOTAL_BYTES_BEHIND = "total_bytes_behind"; static final String MAX_REPLICATION_LAG = "max_replication_lag"; + static final String MAX_DATA_LAG = "max_data_lag"; + static final String TOTAL_DATA_LAG = "total_data_lag"; + static final String MAX_TIME_LAG = "max_time_lag"; + static final String MAX_DATA_LAG_BYTES = "max_data_lag_in_bytes"; + static final String TOTAL_DATA_LAG_BYTES = "total_data_lag_in_bytes"; + static final String MAX_TIME_LAG_MILLIS = "max_time_lag_in_millis"; } } From 03a775531a97ff27fd1ea3b716e7e00e94b21f90 Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Thu, 19 Oct 2023 22:11:32 -0700 Subject: [PATCH 2/4] Take upload time into account for replication time lag Signed-off-by: Poojita Raj --- server/src/main/java/org/opensearch/index/shard/IndexShard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 5ebfd3863a6cf..fa3ebfdbfa7db 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -3010,7 +3010,7 @@ public ReplicationStats getReplicationStats() { long maxBytesBehind = stats.stream().mapToLong(SegmentReplicationShardStats::getBytesBehindCount).max().orElse(0L); long totalBytesBehind = stats.stream().mapToLong(SegmentReplicationShardStats::getBytesBehindCount).sum(); long maxReplicationLag = stats.stream() - .mapToLong(SegmentReplicationShardStats::getCurrentReplicationTimeMillis) + .mapToLong(SegmentReplicationShardStats::getCurrentReplicationLagMillis) .max() .orElse(0L); return new ReplicationStats(maxBytesBehind, totalBytesBehind, maxReplicationLag); From 9bc8f3d62a5ba637e9e34422b858fbb7fa8e235d Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Fri, 20 Oct 2023 10:17:56 -0700 Subject: [PATCH 3/4] unformat segrep stats Signed-off-by: Poojita Raj --- .../java/org/opensearch/index/ReplicationStats.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/ReplicationStats.java b/server/src/main/java/org/opensearch/index/ReplicationStats.java index dc537b6683edb..9e057e21298f8 100644 --- a/server/src/main/java/org/opensearch/index/ReplicationStats.java +++ b/server/src/main/java/org/opensearch/index/ReplicationStats.java @@ -8,11 +8,9 @@ package org.opensearch.index; -import org.opensearch.common.unit.TimeValue; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; -import org.opensearch.core.common.unit.ByteSizeValue; import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; @@ -76,12 +74,9 @@ public void writeTo(StreamOutput out) throws IOException { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.SEGMENT_REPLICATION); - builder.field(Fields.MAX_BYTES_BEHIND, new ByteSizeValue(maxBytesBehind).toString()); - builder.field(Fields.TOTAL_BYTES_BEHIND, new ByteSizeValue(totalBytesBehind).toString()); - builder.field(Fields.MAX_REPLICATION_LAG, new TimeValue(maxReplicationLag)); - builder.humanReadableField(Fields.MAX_DATA_LAG_BYTES, Fields.MAX_DATA_LAG, new ByteSizeValue(maxBytesBehind)); - builder.humanReadableField(Fields.TOTAL_DATA_LAG_BYTES, Fields.TOTAL_DATA_LAG, new ByteSizeValue(totalBytesBehind)); - builder.humanReadableField(Fields.MAX_TIME_LAG_MILLIS, Fields.MAX_TIME_LAG, new TimeValue(maxReplicationLag)); + builder.field(Fields.MAX_BYTES_BEHIND, maxBytesBehind); + builder.field(Fields.TOTAL_BYTES_BEHIND, totalBytesBehind); + builder.field(Fields.MAX_REPLICATION_LAG, maxReplicationLag); builder.endObject(); return builder; } From c042c176da4e908ed0578bddc81312e20353637e Mon Sep 17 00:00:00 2001 From: Poojita Raj Date: Fri, 20 Oct 2023 12:47:03 -0700 Subject: [PATCH 4/4] remove unused field names Signed-off-by: Poojita Raj --- .../main/java/org/opensearch/index/ReplicationStats.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/ReplicationStats.java b/server/src/main/java/org/opensearch/index/ReplicationStats.java index 9e057e21298f8..0ae4526365bf1 100644 --- a/server/src/main/java/org/opensearch/index/ReplicationStats.java +++ b/server/src/main/java/org/opensearch/index/ReplicationStats.java @@ -91,11 +91,5 @@ static final class Fields { static final String MAX_BYTES_BEHIND = "max_bytes_behind"; static final String TOTAL_BYTES_BEHIND = "total_bytes_behind"; static final String MAX_REPLICATION_LAG = "max_replication_lag"; - static final String MAX_DATA_LAG = "max_data_lag"; - static final String TOTAL_DATA_LAG = "total_data_lag"; - static final String MAX_TIME_LAG = "max_time_lag"; - static final String MAX_DATA_LAG_BYTES = "max_data_lag_in_bytes"; - static final String TOTAL_DATA_LAG_BYTES = "total_data_lag_in_bytes"; - static final String MAX_TIME_LAG_MILLIS = "max_time_lag_in_millis"; } }