Skip to content

Commit

Permalink
statistics,metrics: allow stats health to have finer granularity (pin…
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Oct 9, 2024
1 parent 31d75bd commit c49fb9f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 11 additions & 5 deletions pkg/statistics/handle/cache/statscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (s *StatsCacheImpl) SetStatsCacheCapacity(c int64) {

// UpdateStatsHealthyMetrics updates stats healthy distribution metrics according to stats cache.
func (s *StatsCacheImpl) UpdateStatsHealthyMetrics() {
distribution := make([]int64, 5)
distribution := make([]int64, 9)
uneligibleAnalyze := 0
for _, tbl := range s.Values() {
distribution[4]++ // total table count
Expand All @@ -273,16 +273,22 @@ func (s *StatsCacheImpl) UpdateStatsHealthyMetrics() {
}
if healthy < 50 {
distribution[0]++
} else if healthy < 80 {
} else if healthy < 55 {
distribution[1]++
} else if healthy < 100 {
} else if healthy < 60 {
distribution[2]++
} else {
} else if healthy < 70 {
distribution[3]++
} else if healthy < 80 {
distribution[4]++
} else if healthy < 100 {
distribution[5]++
} else {
distribution[6]++
}
}
for i, val := range distribution {
handle_metrics.StatsHealthyGauges[i].Set(float64(val))
}
handle_metrics.StatsHealthyGauges[5].Set(float64(uneligibleAnalyze))
handle_metrics.StatsHealthyGauges[8].Set(float64(uneligibleAnalyze))
}
5 changes: 4 additions & 1 deletion pkg/statistics/handle/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ func init() {
func InitMetricsVars() {
StatsHealthyGauges = []prometheus.Gauge{
metrics.StatsHealthyGauge.WithLabelValues("[0,50)"),
metrics.StatsHealthyGauge.WithLabelValues("[50,80)"),
metrics.StatsHealthyGauge.WithLabelValues("[50,55)"),
metrics.StatsHealthyGauge.WithLabelValues("[55,60)"),
metrics.StatsHealthyGauge.WithLabelValues("[60,70)"),
metrics.StatsHealthyGauge.WithLabelValues("[70,80)"),
metrics.StatsHealthyGauge.WithLabelValues("[80,100)"),
metrics.StatsHealthyGauge.WithLabelValues("[100,100]"),
// [0,100] should always be the last
Expand Down

0 comments on commit c49fb9f

Please sign in to comment.