Handle k8s widget metrics call fails
This commit is contained in:
parent
2bbe5b04c7
commit
bd5c10e907
1 changed files with 19 additions and 12 deletions
|
@ -52,6 +52,7 @@ export default async function handler(req, res) {
|
|||
memTotal += mem;
|
||||
});
|
||||
|
||||
try {
|
||||
const nodeMetrics = await metricsApi.getNodeMetrics();
|
||||
nodeMetrics.items.forEach((nodeMetric) => {
|
||||
const cpu = parseCpu(nodeMetric.usage.cpu);
|
||||
|
@ -64,6 +65,12 @@ export default async function handler(req, res) {
|
|||
nodeMap[nodeMetric.metadata.name].memory.free = nodeMap[nodeMetric.metadata.name].memory.total - mem;
|
||||
nodeMap[nodeMetric.metadata.name].memory.percent = (mem / nodeMap[nodeMetric.metadata.name].memory.total) * 100;
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error("Error getting metrics, ensure you have metrics-server installed: s", JSON.stringify(error));
|
||||
return res.status(500).send({
|
||||
error: "Error getting metrics, check logs for more details"
|
||||
});
|
||||
}
|
||||
|
||||
const cluster = {
|
||||
cpu: {
|
||||
|
|
Loading…
Add table
Reference in a new issue