Skip to content

Commit

Permalink
支持external指标 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
puzhihao authored Nov 21, 2024
1 parent abc8760 commit 1194c4c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/controller/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ func parseMetricSpecForPrometheus(target string, metricType string, metricValue
}

metricSpec := autoscalingv2.MetricSpec{
Type: autoscalingv2.PodsMetricSourceType,
Pods: &autoscalingv2.PodsMetricSource{
Type: autoscalingv2.ExternalMetricSourceType,
External: &autoscalingv2.ExternalMetricSource{
Metric: autoscalingv2.MetricIdentifier{
Name: name,
},
Expand All @@ -271,9 +271,9 @@ func parseMetricSpecForPrometheus(target string, metricType string, metricValue

switch target {
case targetAverageUtilization:
metricSpec.Pods.Target.Type = autoscalingv2.UtilizationMetricType
metricSpec.External.Target.Type = autoscalingv2.UtilizationMetricType
case targetAverageValue:
metricSpec.Pods.Target.Type = autoscalingv2.AverageValueMetricType
metricSpec.External.Target.Type = autoscalingv2.AverageValueMetricType
}

return metricSpec, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
memoryAverageUtilization = "memory." + PixiuRootPrefix + PixiuSeparator + targetAverageUtilization
prometheusAverageUtilization = "prometheus." + PixiuRootPrefix + PixiuSeparator + targetAverageUtilization

// 指标来着 prometheus 时,需要指定指标名称
// 指标来自 prometheus 时,需要指定指标名称
prometheusCustomMetric = PixiuRootPrefix + PixiuSeparator + "targetCustomMetric"

// CPU, in cores. (500m = .5 cores)
Expand Down

0 comments on commit 1194c4c

Please sign in to comment.