Monitoring Health of Components & Traits
Components and traits in KubeVela can report their operational status and health, giving you real-time visibility into your applications. This guide shows you how to configure health checks, status reporting, and custom messages for your definitions (components & traits).
Why Monitor Health and Status?
When deploying applications, you need to know:
- Are all components running correctly? And their associated traits?
- What's the current state of each resource?
- Are there any issues that need attention?
KubeVela's health and status system helps answer these questions by continuously monitoring your components and providing detailed feedback through the Application status.
Quick Start
Here's a simple example that monitors a web service deployment:
"webservice": {
attributes: {
status: {
// Check if all replicas are ready
healthPolicy: {
isHealth: context.output.status.readyReplicas == context.output.spec.replicas
}
// Show a human-readable status
customStatus: {
message: "Ready: \(context.output.status.readyReplicas)/\(context.output.spec.replicas)"
}
}
}
}
This configuration will:
- Mark the component as healthy when all replicas are ready
- Display "Ready: 3/3" (or similar) as the status message
The Three Status Mechanisms
KubeVela provides three complementary mechanisms for monitoring your components:
1. Status Details - Structured Diagnostic Information
Status details provide a map of key-value pairs with diagnostic information about your component. This is useful for exposing multiple health indicators or metrics.
Example:
attributes: status: details: {
readyReplicas: context.output.status.readyReplicas
totalReplicas: context.output.spec.replicas
readyPercentage: (context.output.status.readyReplicas / context.output.spec.replicas) * 100
deploymentMode: context.output.spec.strategy.type
}
Result in Application status:
status:
services:
- name: my-service
status:
readyReplicas: "3"
totalReplicas: "3"
readyPercentage: "100"
deploymentMode: "RollingUpdate"
2. Health Check - Overall Health Indicator
The health check provides a simple true/false indicator of whether your component is functioning correctly.
Example:
attributes: status: healthPolicy: {
isHealth: context.output.status.readyReplicas == context.output.spec.replicas
}
Result in Application status:
status:
services:
- name: my-service
healthy: true