diff --git a/pkg/mcs/resource_manager/server/manager.go b/pkg/mcs/resource_manager/server/manager.go index fee844e6e96..20e33cdda0e 100644 --- a/pkg/mcs/resource_manager/server/manager.go +++ b/pkg/mcs/resource_manager/server/manager.go @@ -422,6 +422,7 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) { // Clean up the metrics that have not been updated for a long time. for name, lastTime := range m.consumptionRecord { if time.Since(lastTime) > metricsCleanupTimeout { +<<<<<<< HEAD:pkg/mcs/resource_manager/server/manager.go readRequestUnitCost.DeleteLabelValues(name) writeRequestUnitCost.DeleteLabelValues(name) sqlLayerRequestUnitCost.DeleteLabelValues(name) @@ -436,6 +437,23 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) { delete(maxPerSecTrackers, name) readRequestUnitMaxPerSecCost.DeleteLabelValues(name) writeRequestUnitMaxPerSecCost.DeleteLabelValues(name) +======= + readRequestUnitCost.DeleteLabelValues(r.name, r.name, r.ruType) + writeRequestUnitCost.DeleteLabelValues(r.name, r.name, r.ruType) + sqlLayerRequestUnitCost.DeleteLabelValues(r.name, r.name, r.ruType) + readByteCost.DeleteLabelValues(r.name, r.name, r.ruType) + writeByteCost.DeleteLabelValues(r.name, r.name, r.ruType) + kvCPUCost.DeleteLabelValues(r.name, r.name, r.ruType) + sqlCPUCost.DeleteLabelValues(r.name, r.name, r.ruType) + requestCount.DeleteLabelValues(r.name, r.name, readTypeLabel) + requestCount.DeleteLabelValues(r.name, r.name, writeTypeLabel) + availableRUCounter.DeleteLabelValues(r.name, r.name, r.ruType) + delete(m.consumptionRecord, r) + delete(maxPerSecTrackers, r.name) + readRequestUnitMaxPerSecCost.DeleteLabelValues(r.name) + writeRequestUnitMaxPerSecCost.DeleteLabelValues(r.name) + resourceGroupConfigGauge.DeletePartialMatch(prometheus.Labels{newResourceGroupNameLabel: r.name}) +>>>>>>> 56f082db6 (resource_manager: add metrics to show resource group configuration (#8478)):pkg/mcs/resourcemanager/server/manager.go } } case <-availableRUTicker.C: @@ -454,9 +472,15 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) { if ru < 0 { ru = 0 } +<<<<<<< HEAD:pkg/mcs/resource_manager/server/manager.go availableRUCounter.WithLabelValues(group.Name).Set(ru) +======= + 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)) +>>>>>>> 56f082db6 (resource_manager: add metrics to show resource group configuration (#8478)):pkg/mcs/resourcemanager/server/manager.go } - case <-recordMaxTicker.C: // Record the sum of RRU and WRU every second. m.RLock() diff --git a/pkg/mcs/resource_manager/server/metrics.go b/pkg/mcs/resource_manager/server/metrics.go index dec877d8c86..e50b3aece9f 100644 --- a/pkg/mcs/resource_manager/server/metrics.go +++ b/pkg/mcs/resource_manager/server/metrics.go @@ -28,6 +28,11 @@ const ( readTypeLabel = "read" writeTypeLabel = "write" newResourceGroupNameLabel = "resource_group" + + // Labels for the config. + ruPerSecLabel = "ru_per_sec" + ruCapacityLabel = "ru_capacity" + priorityLabel = "priority" ) var ( @@ -126,7 +131,19 @@ var ( Subsystem: ruSubsystem, Name: "available_ru", Help: "Counter of the available RU for all resource groups.", +<<<<<<< HEAD:pkg/mcs/resource_manager/server/metrics.go }, []string{resourceGroupNameLabel}) +======= + }, []string{resourceGroupNameLabel, newResourceGroupNameLabel}) + + resourceGroupConfigGauge = prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Namespace: namespace, + Subsystem: serverSubsystem, + Name: "group_config", + Help: "Config of the resource group.", + }, []string{newResourceGroupNameLabel, typeLabel}) +>>>>>>> 56f082db6 (resource_manager: add metrics to show resource group configuration (#8478)):pkg/mcs/resourcemanager/server/metrics.go ) func init() { @@ -140,4 +157,10 @@ func init() { prometheus.MustRegister(sqlCPUCost) prometheus.MustRegister(requestCount) prometheus.MustRegister(availableRUCounter) +<<<<<<< HEAD:pkg/mcs/resource_manager/server/metrics.go +======= + prometheus.MustRegister(readRequestUnitMaxPerSecCost) + prometheus.MustRegister(writeRequestUnitMaxPerSecCost) + prometheus.MustRegister(resourceGroupConfigGauge) +>>>>>>> 56f082db6 (resource_manager: add metrics to show resource group configuration (#8478)):pkg/mcs/resourcemanager/server/metrics.go }