Skip to content

Commit

Permalink
Merge pull request #471 from simonemex/extend-prometheus-metrics-info
Browse files Browse the repository at this point in the history
added info about errors in Prometheus' metrics
  • Loading branch information
Eric Greer committed May 13, 2020
2 parents 8b30197 + 7093ce5 commit c001310
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/metrics/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c001310

Please sign in to comment.