Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#8478
Browse files Browse the repository at this point in the history
close tikv#8444

Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
nolouch authored and ti-chi-bot committed Sep 20, 2024
1 parent 34f401d commit 6ed5e14
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/mcs/resource_manager/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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()
Expand Down
23 changes: 23 additions & 0 deletions pkg/mcs/resource_manager/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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() {
Expand All @@ -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
}

0 comments on commit 6ed5e14

Please sign in to comment.