From fc0561b29364107ef003e6850ce100cc47f59f84 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 12 Dec 2023 12:21:31 -0700 Subject: [PATCH] Use dataset size instead of on-disk size for data stream stats (#103342) Previously we were using the size of the shard that was on local disk, however, in some cases (for object storage) this would return 0b, which is very confusing. This commit changes it to use the dataset size, which should be calculated correctly regardless of where the data resides. --- docs/changelog/103342.yaml | 5 +++++ .../datastreams/action/DataStreamsStatsTransportAction.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 docs/changelog/103342.yaml diff --git a/docs/changelog/103342.yaml b/docs/changelog/103342.yaml new file mode 100644 index 0000000000000..32711d7a6b390 --- /dev/null +++ b/docs/changelog/103342.yaml @@ -0,0 +1,5 @@ +pr: 103342 +summary: Use dataset size instead of on-disk size for data stream stats +area: Data streams +type: bug +issues: [] diff --git a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DataStreamsStatsTransportAction.java b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DataStreamsStatsTransportAction.java index 029fd88abd9c6..2aa5c07ad6be5 100644 --- a/modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DataStreamsStatsTransportAction.java +++ b/modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/DataStreamsStatsTransportAction.java @@ -229,11 +229,11 @@ public DataStreamsStatsAction.Response newResponse( assert dataStream != null; // Aggregate global stats - totalStoreSizeBytes += shardStat.getStoreStats().sizeInBytes(); + totalStoreSizeBytes += shardStat.getStoreStats().totalDataSetSizeInBytes(); // Aggregate data stream stats AggregatedStats stats = aggregatedDataStreamsStats.computeIfAbsent(dataStream.getName(), s -> new AggregatedStats()); - stats.storageBytes += shardStat.getStoreStats().sizeInBytes(); + stats.storageBytes += shardStat.getStoreStats().totalDataSetSizeInBytes(); stats.maxTimestamp = Math.max(stats.maxTimestamp, shardStat.getMaxTimestamp()); }