fix(cloudwatch): return storedBytes on DescribeLogGroups (#4202)

* fix(cloudwatch): return storedBytes on DescribeLogGroups

AWS reports log-group storedBytes as the sum of stream sizes. Floci
always returned 0, which breaks SDK clients that read the field.

* style(cloudwatch): import collection test helpers
This commit is contained in:
c3m2r4 authored and GitHub committed 2026-09-24 07:30:14 -04:00
1 parent 35605937c8
commit babb43ac3d
5 files changed
+119 -29

No files matched your search

@@ -136,7 +136,7 @@ public class CloudWatchLogsHandler {
if (g.getKmsKeyId() != null) {
node.put("kmsKeyId", g.getKmsKeyId());
}
node.put("storedBytes", 0);
node.put("storedBytes", logsService.getStoredBytesForLogGroup(g.getLogGroupName(), region));
node.put("metricFilterCount", metricFilterHandler.metricFilterCount(g.getLogGroupName(), region));
groupsArray.add(node);
}
@@ -337,6 +337,13 @@ public class CloudWatchLogsService implements ResourceProvider {
return result;
}
public long getStoredBytesForLogGroup(String groupName, String region) {
String storagePrefix = streamKeyPrefix(region, groupName);
return streamStore.scan(k -> k.startsWith(storagePrefix)).stream()
.mapToLong(LogStream::getStoredBytes)
.sum();
}
public void putLogGroupDeletionProtection(String groupName, boolean enabled, String region) {
String key = groupKey(region, groupName);
LogGroup group = groupStore.get(key)