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

feat(sysadvisor): emit bound type code for knob status #391

Merged
merged 1 commit into from
Dec 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ func (n *MetricSyncerNode) advisorMetric(ctx context.Context) {
Key: fmt.Sprintf("%s%s", data.CustomMetricLabelSelectorPrefixKey, "region"),
Val: fmt.Sprintf("%v", regionName),
},
{
Key: fmt.Sprintf("%s%s", data.CustomMetricLabelSelectorPrefixKey, "bound"),
Val: fmt.Sprintf("%v", regionInfo.RegionStatus.BoundType),
},
}...)
for indicator, overshot := range regionInfo.RegionStatus.OvershootStatus {
regionTag = append(regionTag, metrics.MetricTag{
Expand All @@ -66,7 +62,12 @@ func (n *MetricSyncerNode) advisorMetric(ctx context.Context) {
})
}

_ = n.dataEmitter.StoreFloat64(apimetricnode.CustomMetricNodeAdvisorKnobStatus, 1, metrics.MetricTypeNameRaw, regionTag...)
if code, ok := types.BoundTypeCodeMap[regionInfo.RegionStatus.BoundType]; ok {
_ = n.dataEmitter.StoreFloat64(apimetricnode.CustomMetricNodeAdvisorKnobStatus, float64(code), metrics.MetricTypeNameRaw, regionTag...)
} else {
general.Errorf("region %v with invalid bound type %v", regionName, regionInfo.RegionStatus.BoundType)
}

return true
})

Expand Down
7 changes: 7 additions & 0 deletions pkg/agent/sysadvisor/types/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ package types

import "time"

var BoundTypeCodeMap = map[BoundType]int{
BoundUpper: BoundUpperCode,
BoundLower: BoundLowerCode,
BoundNone: BoundNoneCode,
BoundUnknown: BoundUnknownCode,
}

const (
RegionNameSeparator = "-"
)
Expand Down
12 changes: 8 additions & 4 deletions pkg/agent/sysadvisor/types/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,20 @@ type BoundType string

const (
// BoundUpper indicates reaching resource upper bound, with highest priority
BoundUpper BoundType = "upper"
BoundUpper BoundType = "upper"
BoundUpperCode int = 0

// BoundLower indicates reaching resource lower bound
BoundLower BoundType = "lower"
BoundLower BoundType = "lower"
BoundLowerCode int = 1

// BoundNone indicates between resource upper and lower bound
BoundNone BoundType = "none"
BoundNone BoundType = "none"
BoundNoneCode int = 2

// BoundUnknown indicates unknown bound status
BoundUnknown BoundType = "unknown"
BoundUnknown BoundType = "unknown"
BoundUnknownCode int = 3
)

// RegionStatus holds stability accounting info of region
Expand Down