Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mcs/resourcemanager: add metric for TiFlash RU consumption #7115

Merged
merged 8 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/mcs/resourcemanager/server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,16 @@ func (s *Service) AcquireTokenBuckets(stream rmpb.ResourceManager_AcquireTokenBu
}
// Send the consumption to update the metrics.
isBackground := req.GetIsBackground()
isTiFlash := req.GetIsTiflash()
if isBackground && isTiFlash {
return errors.New("background and tiflash cannot be true at the same time")
}
s.manager.consumptionDispatcher <- struct {
resourceGroupName string
*rmpb.Consumption
isBackground bool
}{resourceGroupName, req.GetConsumptionSinceLastRequest(), isBackground}
isTiFlash bool
}{resourceGroupName, req.GetConsumptionSinceLastRequest(), isBackground, isTiFlash}
if isBackground {
continue
}
Expand Down
21 changes: 13 additions & 8 deletions pkg/mcs/resourcemanager/server/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Manager struct {
resourceGroupName string
*rmpb.Consumption
isBackground bool
isTiFlash bool
}
// record update time of each resource group
consumptionRecord map[string]time.Time
Expand All @@ -81,6 +82,7 @@ func NewManager[T ConfigProvider](srv bs.Server) *Manager {
resourceGroupName string
*rmpb.Consumption
isBackground bool
isTiFlash bool
}, defaultConsumptionChanSize),
consumptionRecord: make(map[string]time.Time),
}
Expand Down Expand Up @@ -361,20 +363,23 @@ func (m *Manager) backgroundMetricsFlush(ctx context.Context) {
if consumption == nil {
continue
}
backgroundType := ""
ruLabelType := tidbTypeLabel
if consumptionInfo.isBackground {
backgroundType = backgroundTypeLabel
ruLabelType = backgroundTypeLabel
}
if consumptionInfo.isTiFlash {
ruLabelType = tiflashTypeLabel
}

var (
name = consumptionInfo.resourceGroupName
rruMetrics = readRequestUnitCost.WithLabelValues(name, backgroundType)
wruMetrics = writeRequestUnitCost.WithLabelValues(name, backgroundType)
rruMetrics = readRequestUnitCost.WithLabelValues(name, ruLabelType)
wruMetrics = writeRequestUnitCost.WithLabelValues(name, ruLabelType)
sqlLayerRuMetrics = sqlLayerRequestUnitCost.WithLabelValues(name)
readByteMetrics = readByteCost.WithLabelValues(name, backgroundType)
writeByteMetrics = writeByteCost.WithLabelValues(name, backgroundType)
kvCPUMetrics = kvCPUCost.WithLabelValues(name, backgroundType)
sqlCPUMetrics = sqlCPUCost.WithLabelValues(name, backgroundType)
readByteMetrics = readByteCost.WithLabelValues(name, ruLabelType)
writeByteMetrics = writeByteCost.WithLabelValues(name, ruLabelType)
kvCPUMetrics = kvCPUCost.WithLabelValues(name, ruLabelType)
sqlCPUMetrics = sqlCPUCost.WithLabelValues(name, ruLabelType)
readRequestCountMetrics = requestCount.WithLabelValues(name, readTypeLabel)
writeRequestCountMetrics = requestCount.WithLabelValues(name, writeTypeLabel)
)
Expand Down
2 changes: 2 additions & 0 deletions pkg/mcs/resourcemanager/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const (
readTypeLabel = "read"
writeTypeLabel = "write"
backgroundTypeLabel = "background"
tiflashTypeLabel = "tiflash"
tidbTypeLabel = "tidb"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this label may be confusing to the users. /cc @HuSharp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users may wonder how much RU TiKV consumes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to tp/ap #7135

)

var (
Expand Down
Loading