Skip to content

Commit b2cb397

Browse files
committed
round size and add unit to return value
1 parent 9eba302 commit b2cb397

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/server/extension/monitoring-endpoint.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,14 +1097,17 @@ process.stdin.on('end', () => {
10971097
}
10981098

10991099
// Indices Size from KB to GB
1100-
const openSearchIndicesSize = infoData[14].reduce((sum, openSearchIndex) => sum + (openSearchIndex["store.size"] - 0), 0) / 1000 / 1000;
1100+
let openSearchIndicesSize = infoData[14].reduce((sum, openSearchIndex) => sum + (openSearchIndex["store.size"] - 0), 0) / 1000 / 1000;
1101+
// Math.round only rounds to the nearest integer, so we multiply by 100 before rounding to get 2 decimal places
1102+
// Number.EPSILON is here so numbers like 1.005 get rounded correctly.
1103+
openSearchIndicesSize = Math.round((openSearchIndicesSize + Number.EPSILON) * 100) / 100
11011104

11021105
result.opensearch = {};
11031106
result.opensearch.status = {};
11041107
result.opensearch.status.fs = {};
11051108
result.opensearch.status.fs.status = openSearchWatermarkStatus;
11061109
result.opensearch.status.fs.percent = usedDiskInPercent;
1107-
result.opensearch.status.fs.size = openSearchIndicesSize;
1110+
result.opensearch.status.fs.size = openSearchIndicesSize + 'GB';
11081111
result.opensearch.status.health = openSearchClusterHealth;
11091112

11101113
if (statusMessages.length > 0) {

0 commit comments

Comments
 (0)