Skip to content

Commit

Permalink
resource_manager: add metrics to show resource group configuration (#…
Browse files Browse the repository at this point in the history
…8478) (#8638)

close #8444

Signed-off-by: nolouch <[email protected]>

Co-authored-by: nolouch <[email protected]>
  • Loading branch information
ti-chi-bot and nolouch authored Sep 23, 2024
1 parent af0b9a4 commit aa1a99c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/mcs/resourcemanager/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
delete(maxPerSecTrackers, r.name)
readRequestUnitMaxPerSecCost.DeleteLabelValues(r.name)
writeRequestUnitMaxPerSecCost.DeleteLabelValues(r.name)
resourceGroupConfigGauge.DeletePartialMatch(prometheus.Labels{newResourceGroupNameLabel: r.name})
}
}
case <-availableRUTicker.C:
Expand All @@ -474,8 +475,10 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
ru = 0
}
availableRUCounter.WithLabelValues(group.Name, group.Name).Set(ru)
resourceGroupConfigGauge.WithLabelValues(group.Name, priorityLabel).Set(float64(group.Priority))
resourceGroupConfigGauge.WithLabelValues(group.Name, ruPerSecLabel).Set(float64(group.RUSettings.RU.Settings.FillRate))
resourceGroupConfigGauge.WithLabelValues(group.Name, ruCapacityLabel).Set(float64(group.RUSettings.RU.Settings.BurstLimit))
}

case <-recordMaxTicker.C:
// Record the sum of RRU and WRU every second.
m.RLock()
Expand Down
14 changes: 14 additions & 0 deletions pkg/mcs/resourcemanager/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const (
tiflashTypeLabel = "ap"
defaultTypeLabel = "tp"
newResourceGroupNameLabel = "resource_group"

// Labels for the config.
ruPerSecLabel = "ru_per_sec"
ruCapacityLabel = "ru_capacity"
priorityLabel = "priority"
)

var (
Expand Down Expand Up @@ -116,6 +121,14 @@ var (
Name: "available_ru",
Help: "Counter of the available RU for all resource groups.",
}, []string{resourceGroupNameLabel, newResourceGroupNameLabel})

resourceGroupConfigGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: serverSubsystem,
Name: "group_config",
Help: "Config of the resource group.",
}, []string{newResourceGroupNameLabel, typeLabel})
)

func init() {
Expand All @@ -130,4 +143,5 @@ func init() {
prometheus.MustRegister(availableRUCounter)
prometheus.MustRegister(readRequestUnitMaxPerSecCost)
prometheus.MustRegister(writeRequestUnitMaxPerSecCost)
prometheus.MustRegister(resourceGroupConfigGauge)
}

0 comments on commit aa1a99c

Please sign in to comment.