added info about errors in Prometheus' metrics
@@ -44,7 +44,13 @@ func GenerateMetrics(state health.State) string {
if d.OK {
checkStatus = "1"
}
- metricName := fmt.Sprintf("kuberhealthy_check{check=\"%s\",namespace=\"%s\",status=\"%s\"}", c, d.Namespace, checkStatus)
+ errors := ""
+ if len(d.Errors) > 0 {
+ for _, error := range d.Errors {
+ errors += fmt.Sprintf("%s|", error)
+ }
+ }
+ metricName := fmt.Sprintf("kuberhealthy_check{check=\"%s\",namespace=\"%s\",status=\"%s\",error=\"%s\"}", c, d.Namespace, checkStatus, errors)
metricDurationName := fmt.Sprintf("kuberhealthy_check_duration_seconds{check=\"%s\",namespace=\"%s\"}", c, d.Namespace)
checkMetricState[metricName] = checkStatus
runDuration, err := time.ParseDuration(d.RunDuration)
