Skip to content

Commit

Permalink
add the scheduling configuration metrics (#1406)
Browse files Browse the repository at this point in the history
Signed-off-by: rleungx <rleungx@gmail.com>
  • Loading branch information
rleungx authored and huachaohuang committed Jan 7, 2019
1 parent 38221ce commit 4bb9b96
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ var (
Help: "Bucketed histogram of time spend(s) of patrol checks region.",
Buckets: prometheus.ExponentialBuckets(1, 2, 15),
})

configStatusGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "pd",
Subsystem: "config",
Name: "status",
Help: "Status of the scheduling configurations.",
}, []string{"type", "namespace"})
)

func init() {
Expand All @@ -173,4 +181,5 @@ func init() {
prometheus.MustRegister(etcdStateGauge)
prometheus.MustRegister(patrolCheckRegionsHistogram)
prometheus.MustRegister(placementStatusGauge)
prometheus.MustRegister(configStatusGauge)
}
38 changes: 38 additions & 0 deletions server/store_statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,44 @@ func (s *storeStatistics) Collect() {
clusterStatusGauge.WithLabelValues(typ, s.namespace).Set(value)
}

// Current scheduling configurations of the cluster
configs := make(map[string]float64)
configs["leader_schedule_limit"] = float64(s.opt.GetLeaderScheduleLimit(s.namespace))
configs["region_schedule_limit"] = float64(s.opt.GetRegionScheduleLimit(s.namespace))
configs["merge_schedule_limit"] = float64(s.opt.GetMergeScheduleLimit(s.namespace))
configs["replica_schedule_limit"] = float64(s.opt.GetReplicaScheduleLimit(s.namespace))
configs["max_replicas"] = float64(s.opt.GetMaxReplicas(s.namespace))
configs["high_space_ratio"] = float64(s.opt.GetHighSpaceRatio())
configs["low_space_ratio"] = float64(s.opt.GetLowSpaceRatio())
configs["tolerant_size_ratio"] = float64(s.opt.GetTolerantSizeRatio())

var disableMakeUpReplica, disableLearner, disableRemoveDownReplica, disableRemoveExtraReplica, disableReplaceOfflineReplica float64
if !s.opt.IsMakeUpReplicaEnabled() {
disableMakeUpReplica = 1
}
if !s.opt.IsRaftLearnerEnabled() {
disableLearner = 1
}
if !s.opt.IsRemoveDownReplicaEnabled() {
disableRemoveDownReplica = 1
}
if !s.opt.IsRemoveExtraReplicaEnabled() {
disableRemoveExtraReplica = 1
}
if !s.opt.IsReplaceOfflineReplicaEnabled() {
disableReplaceOfflineReplica = 1
}

configs["disable_makeup_replica"] = disableMakeUpReplica
configs["disable_learner"] = disableLearner
configs["disable_remove_down_replica"] = disableRemoveDownReplica
configs["disable_remove_extra_replica"] = disableRemoveExtraReplica
configs["disable_replace_offline_replica"] = disableReplaceOfflineReplica

for typ, value := range configs {
configStatusGauge.WithLabelValues(typ, s.namespace).Set(value)
}

for name, value := range s.LabelCounter {
placementStatusGauge.WithLabelValues(labelType, name, s.namespace).Set(float64(value))
}
Expand Down

0 comments on commit 4bb9b96

Please sign in to comment.