diff --git a/pkg/controller/ground.go b/pkg/controller/ground.go index 6e307400d7..d9d7252e8a 100644 --- a/pkg/controller/ground.go +++ b/pkg/controller/ground.go @@ -192,6 +192,7 @@ func (op *GroundControl) handler(key string) error { if err := op.updatePhase(kluster, models.KlusterPhaseRunning, ""); err != nil { glog.Errorf("Failed to update status of kluster %s:%s", kluster.GetName(), err) } + metrics.SetMetricBootDurationSummary(kluster.GetCreationTimestamp().Time, time.Now()) glog.Infof("Kluster %s is ready!", kluster.GetName()) } case models.KlusterPhaseTerminating: diff --git a/pkg/controller/metrics/metrics.go b/pkg/controller/metrics/metrics.go index d9d900c710..4dfcdb114a 100644 --- a/pkg/controller/metrics/metrics.go +++ b/pkg/controller/metrics/metrics.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "sync" + "time" "github.com/golang/glog" "github.com/prometheus/client_golang/prometheus" @@ -22,6 +23,15 @@ var klusterPhases = []models.KlusterPhase{ models.KlusterPhaseTerminating, } +var klusterBootDurationSummary = prometheus.NewSummaryVec( + prometheus.SummaryOpts{ + Namespace: metricNamespace, + Name: "kluster_boot_duration", + Help: "Duration until kluster got from phase pending to running", + }, + []string{}, +) + var klusterInfo = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Namespace: metricNamespace, @@ -128,6 +138,10 @@ func setMetricNodePoolStatus(klusterID, nodePoolName string, status map[string]i } } +func SetMetricBootDurationSummary(creationTimestamp, now time.Time) { + klusterBootDurationSummary.With(prometheus.Labels{}).Observe(now.Sub(creationTimestamp).Seconds()) +} + func boolToFloat64(b bool) float64 { if b { return 1 @@ -155,6 +169,7 @@ func init() { prometheus.MustRegister( klusterInfo, klusterStatusPhase, + klusterBootDurationSummary, nodePoolSize, nodePoolStatus, LaunchOperationsLatency,