JSFiddle - React, Tailwind, and code Playground
by AndreaLigios
JavaScript
const healthStatus = {
"status": "UP",
"components": {
"db": {
"status": "UP",
"details": {
"database": "PostgreSQL",
"validationQuery": "isValid()"
}
},
"discoveryComposite": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN",
"components": {
"discoveryClient": {
"description": "Discovery Client not initialized",
"status": "UNKNOWN"
}
}
},
"diskSpace": {
"status": "UP",
"details": {
"total": 107361579008,
"free": 91407364096,
"threshold": 10485760,
"exists": true
}
},
"license": {
"status": "UP"
},
"livenessState": {
"status": "UP"
},
"ping": {
"status": "UP"
},
"readinessState": {
"status": "UP"
},
"refreshScope": {
"status": "UP"
}
},
"groups": [
"liveness",
"readiness"
]
};
const nonOkStatuses =
Object
.entries(healthStatus.components)
.filter(([key,healthIndicator]) => healthIndicator.status !== "UP")
.map(([key,healthIndicator]) => "<br/>" + key + ": " + healthIndicator.status + " (" + healthIndicator.description + ")");
console.log(nonOkStatuses);