Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add the scheduling configuration metrics #1406

Merged
merged 1 commit into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do configs["disable_makeup_replica"] = !s.opt.IsMakeUpReplicaEnabled()?

Copy link
Member Author

@rleungx rleungx Jan 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we can not convert bool to float64 here.

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