Skip to content

Commit

Permalink
add monitor
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Dec 12, 2022
1 parent 1f13a24 commit d3f1da6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion metrics/grafana/pd.json
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@
"intervalFactor": 2,
"legendFormat": "{{type}}",
"refId": "B"
},
}
],
"thresholds": [
{
Expand Down
5 changes: 3 additions & 2 deletions server/cluster/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const (
maxScheduleRetries = 10
maxLoadConfigRetries = 10

patrolScanRegionLimit = 128 // It takes about 14 minutes to iterate 1 million regions.
statsScanRegionLimit = 1000
patrolScanRegionLimit = 128 // It takes about 14 minutes to iterate 1 million regions.
statsScanRegionLimit = 1000 // It takes about 3.5 minutes to iterate 2 million regions.
defaultScrapInterval = 15 * time.Second
// PluginLoad means action for load plugin
PluginLoad = "PluginLoad"
Expand Down Expand Up @@ -231,6 +231,7 @@ func (c *coordinator) collectRegionStats() {
case <-timer.C:

Check warning on line 231 in server/cluster/coordinator.go

View check run for this annotation

Codecov / codecov/patch

server/cluster/coordinator.go#L231

Added line #L231 was not covered by tests
}
}
collectRegionStatsGauge.Set(time.Since(start).Seconds())
start = time.Now()
}
}
Expand Down
9 changes: 9 additions & 0 deletions server/cluster/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ var (
Help: "Time spent of patrol checks region.",
})

collectRegionStatsGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "pd",
Subsystem: "statistics",
Name: "collect_region_stats_time",
Help: "Time spent of collecting region stats.",
})

updateStoreStatsGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "pd",
Expand Down Expand Up @@ -152,4 +160,5 @@ func init() {
prometheus.MustRegister(storesETAGauge)
prometheus.MustRegister(storeSyncConfigEvent)
prometheus.MustRegister(updateStoreStatsGauge)
prometheus.MustRegister(collectRegionStatsGauge)
}

0 comments on commit d3f1da6

Please sign in to comment.