Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ public class VolumeInfoMetrics implements MetricsSource {
Interns.info("OzoneUsed", "Ozone used space");
private static final MetricsInfo RESERVED =
Interns.info("Reserved", "Reserved Space");
private static final MetricsInfo TOTAL_CAPACITY =
Interns.info("TotalCapacity", "Ozone capacity + reserved space");
private static final MetricsInfo FS_CAPACITY =
Interns.info("FilesystemCapacity", "Filesystem capacity as reported by the local filesystem");
private static final MetricsInfo FS_AVAILABLE =
Interns.info("FilesystemAvailable", "Filesystem available space as reported by the local filesystem");
private static final MetricsInfo FS_USED =
Interns.info("FilesystemUsed", "Filesystem used space (FilesystemCapacity - FilesystemAvailable)");
private static final MetricsInfo MIN_FREE_SPACE =
Interns.info("MinFreeSpace",
"Minimum free space threshold (soft limit) reported to SCM, " +
"derived from hdds.datanode.volume.min.free.space.percent / hdds.datanode.volume.min.free.space");
private static final MetricsInfo NON_OZONE_USED =
Interns.info("NonOzoneUsed",
"Space on the filesystem consumed by non-Ozone workloads " +
"(FilesystemUsed - OzoneUsed)");

private final MetricsRegistry registry;
private final String metricsSourceName;
Expand Down Expand Up @@ -238,15 +244,17 @@ public void getMetrics(MetricsCollector collector, boolean all) {
SpaceUsageSource.Fixed fsUsage = volumeUsage.realUsage();
SpaceUsageSource usage = volumeUsage.getCurrentUsage(fsUsage);
long reserved = volumeUsage.getReservedInBytes();
long ozoneCapacity = usage.getCapacity();
builder
.addGauge(CAPACITY, usage.getCapacity())
.addGauge(CAPACITY, ozoneCapacity)
.addGauge(AVAILABLE, usage.getAvailable())
.addGauge(USED, usage.getUsedSpace())
.addGauge(RESERVED, reserved)
.addGauge(TOTAL_CAPACITY, usage.getCapacity() + reserved)
.addGauge(FS_CAPACITY, fsUsage.getCapacity())
.addGauge(FS_AVAILABLE, fsUsage.getAvailable())
.addGauge(FS_USED, fsUsage.getUsedSpace());
.addGauge(FS_USED, fsUsage.getCapacity() - fsUsage.getAvailable())
.addGauge(MIN_FREE_SPACE, volume.getReportedFreeSpaceToSpare(ozoneCapacity))
.addGauge(NON_OZONE_USED, VolumeUsage.getOtherUsed(fsUsage));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -43,6 +44,7 @@ void testVolumeInfoMetricsExposeOzoneAndFilesystemGauges() {
when(volume.getType()).thenReturn(HddsVolume.VolumeType.DATA_VOLUME);
when(volume.getCommittedBytes()).thenReturn(10L);
when(volume.getContainers()).thenReturn(3L);
when(volume.getReportedFreeSpaceToSpare(anyLong())).thenReturn(20L);

VolumeUsage volumeUsage = mock(VolumeUsage.class);
when(volume.getVolumeUsage()).thenReturn(volumeUsage);
Expand All @@ -56,7 +58,7 @@ void testVolumeInfoMetricsExposeOzoneAndFilesystemGauges() {
when(volumeUsage.getReservedInBytes()).thenReturn(50L);

// Raw filesystem stats
when(volumeUsage.realUsage()).thenReturn(new SpaceUsageSource.Fixed(2000L, 1500L, 500L));
when(volumeUsage.realUsage()).thenReturn(new SpaceUsageSource.Fixed(2000L, 1100L, 500L));

VolumeInfoMetrics metrics = new VolumeInfoMetrics("test-vol-1", volume);
try {
Expand All @@ -72,8 +74,11 @@ void testVolumeInfoMetricsExposeOzoneAndFilesystemGauges() {
assertThat(findMetric(all, "OzoneUsed")).isEqualTo(100L);

assertThat(findMetric(all, "FilesystemCapacity")).isEqualTo(2000L);
assertThat(findMetric(all, "FilesystemAvailable")).isEqualTo(1500L);
assertThat(findMetric(all, "FilesystemUsed")).isEqualTo(500L);
assertThat(findMetric(all, "FilesystemAvailable")).isEqualTo(1100L);
assertThat(findMetric(all, "FilesystemUsed")).isEqualTo(900L); // FilesystemCapacity - FilesystemAvailable

assertThat(findMetric(all, "MinFreeSpace")).isEqualTo(20L);
assertThat(findMetric(all, "NonOzoneUsed")).isEqualTo(400L);
} finally {
metrics.unregister();
}
Expand Down