Skip to content

Commit

Permalink
Merge pull request #108 from sapcc/phasesum
Browse files Browse the repository at this point in the history
phase transition summary
  • Loading branch information
auhlig authored Nov 30, 2017
2 parents 10d7d4a + 9a54b65 commit 8e58f05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controller/ground.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions pkg/controller/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"sync"
"time"

"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -155,6 +169,7 @@ func init() {
prometheus.MustRegister(
klusterInfo,
klusterStatusPhase,
klusterBootDurationSummary,
nodePoolSize,
nodePoolStatus,
LaunchOperationsLatency,
Expand Down

0 comments on commit 8e58f05

Please sign in to comment.