prow/kube/metrics.go
func GatherProwJobMetrics(pjs []prowapi.ProwJob) {
	// map of job to job type to state to count
	metricMap := make(map[string]map[string]map[string]float64)

	for _, pj := range pjs {
		if metricMap[pj.Spec.Job] == nil {
			metricMap[pj.Spec.Job] = make(map[string]map[string]float64)
		}
		if metricMap[pj.Spec.Job][string(pj.Spec.Type)] == nil {
			metricMap[pj.Spec.Job][string(pj.Spec.Type)] = make(map[string]float64)
		}
		metricMap[pj.Spec.Job][string(pj.Spec.Type)][string(pj.Status.State)]++
	}

	// This may be racing with the prometheus server but we need to remove
	// stale metrics like triggered or pending jobs that are now complete.
	prowJobs.Reset()

	for job, jobMap := range metricMap {
		for jobType, typeMap := range jobMap {
			for state, count := range typeMap {
				prowJobs.WithLabelValues(job, jobType, state).Set(count)
			}
		}
	}
}
func GatherProwJobMetrics(pjs []prowapi.ProwJob) {
	// map of job to job type to state to count
	metricMap := make(map[string]map[string]map[string]float64)

	for _, pj := range pjs {
		if metricMap[pj.Spec.Job] == nil {
			metricMap[pj.Spec.Job] = make(map[string]map[string]float64)
		}
		if metricMap[pj.Spec.Job][string(pj.Spec.Type)] == nil {
			metricMap[pj.Spec.Job][string(pj.Spec.Type)] = make(map[string]float64)
		}
		metricMap[pj.Spec.Job][string(pj.Spec.Type)][string(pj.Status.State)]++
	}

	// This may be racing with the prometheus server but we need to remove
	// stale metrics like triggered or pending jobs that are now complete.
	prowJobs.Reset()

	for job, jobMap := range metricMap {
		for jobType, typeMap := range jobMap {
			for state, count := range typeMap {
				prowJobs.WithLabelValues(job, jobType, state).Set(count)
			}
		}
	}
}
// GatherProwJobMetrics gathers prometheus metrics for prowjobs.