Skip to content

Commit cb720d1

Browse files
added information about opensearch-filesystem-status
1 parent 1e99ca4 commit cb720d1

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

src/server/extension/monitoring-endpoint.js

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,48 @@ process.stdin.on('end', () => {
364364
});
365365
}
366366

367+
function getOpenSearchWatermarkConfig() {
368+
return new Promise((resolve, reject) => {
369+
var url = 'http://opensearch:9200/_cluster/settings?include_defaults=true&filter_path=defaults.cluster.routing.allocation.disk.watermark';
370+
fetch(url, {
371+
headers: {
372+
'Accept': 'application/json'
373+
},
374+
})
375+
.then(response => {
376+
if (response.ok) {
377+
resolve(response.json());
378+
} else {
379+
throwError("Fehler bei der Anfrage an " + url + " :" + response, '');
380+
}
381+
})
382+
.catch(error => {
383+
throwError("Fehler bei der Anfrage an " + url + " :" + error, '');
384+
});
385+
});
386+
}
387+
388+
function getOpenSearchStats() {
389+
return new Promise((resolve, reject) => {
390+
var url = 'http://opensearch:9200/_cluster/stats?pretty&filter_path=nodes.fs'
391+
fetch(url, {
392+
headers: {
393+
'Accept': 'application/json'
394+
},
395+
})
396+
.then(response => {
397+
if (response.ok) {
398+
resolve(response.json());
399+
} else {
400+
throwError("Fehler bei der Anfrage an " + url + " :" + response, '');
401+
}
402+
})
403+
.catch(error => {
404+
throwError("Fehler bei der Anfrage an" + url + " :" + error, '');
405+
});
406+
});
407+
}
408+
367409
async function fetchData() {
368410
const infoData = await Promise.all([
369411
getStatsInfoFromAPI(),
@@ -377,7 +419,9 @@ process.stdin.on('end', () => {
377419
getPoolStatsFromAPI(),
378420
getDiskUsageFromAPI(),
379421
getObjectTypeStatsFromAPI(),
380-
checkSqlBackups()
422+
checkSqlBackups(),
423+
getOpenSearchWatermarkConfig(),
424+
getOpenSearchStats()
381425
]);
382426

383427
let configinfo = infoData[6];
@@ -856,7 +900,32 @@ process.stdin.on('end', () => {
856900
}
857901
}
858902

859-
//result.statusResults = statusResults;
903+
// check opensearch diskstatus
904+
const openSearchWatermarkConfig = infoData[12].defaults.cluster.routing.allocation.disk.watermark;
905+
const openSearchDiskStat = infoData[13].nodes.fs;
906+
907+
// used disk in %
908+
const usedDiskInPercent = Math.ceil(100 - (openSearchDiskStat.available_in_bytes / openSearchDiskStat.total_in_bytes * 100))
909+
910+
let openSearchWatermarkStatus = 'low';
911+
912+
const highStatus = openSearchWatermarkConfig.high.replace('%', '') * 1;
913+
const floodStatus = openSearchWatermarkConfig.flood_stage.replace('%', '') * 1;
914+
915+
if(usedDiskInPercent >= highStatus) {
916+
openSearchWatermarkStatus = 'high';
917+
statusMessages.push('openSearchWatermarkStatus: high');
918+
}
919+
if(usedDiskInPercent >= floodStatus) {
920+
openSearchWatermarkStatus = 'flood_stage';
921+
statusMessages.push('openSearchWatermarkStatus: flood_stage');
922+
}
923+
924+
result.opensearch = {};
925+
result.opensearch.status = {};
926+
result.opensearch.status.fs = {};
927+
result.opensearch.status.fs.status = openSearchWatermarkStatus;
928+
result.opensearch.status.fs.percent = usedDiskInPercent;
860929

861930
if (statusMessages.length > 0) {
862931
result.statusmessage = 'Problems: ' + statusMessages.join(', ');

0 commit comments

Comments
 (0)