-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Emit metric tracking empty responses from prometheus #7671
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
base: main
Are you sure you want to change the base?
Changes from all commits
6144e69
8accfd2
995d9a9
d80bede
cc8f1d7
728f22e
2edc55e
2825c7b
ca0a9ec
a5034f7
cab05e6
41d65ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import ( | |
| "k8s.io/metrics/pkg/apis/external_metrics" | ||
|
|
||
| kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" | ||
| "github.com/kedacore/keda/v2/pkg/metricscollector" | ||
| "github.com/kedacore/keda/v2/pkg/scalers/authentication" | ||
| "github.com/kedacore/keda/v2/pkg/scalers/aws" | ||
| "github.com/kedacore/keda/v2/pkg/scalers/azure" | ||
|
|
@@ -26,10 +27,15 @@ import ( | |
| ) | ||
|
|
||
| type prometheusScaler struct { | ||
| metricType v2.MetricTargetType | ||
| metadata *prometheusMetadata | ||
| httpClient *http.Client | ||
| logger logr.Logger | ||
| metricType v2.MetricTargetType | ||
| metadata *prometheusMetadata | ||
| httpClient *http.Client | ||
| logger logr.Logger | ||
| scalableObjectName string | ||
| scalableObjectNS string | ||
| triggerName string | ||
| metricName string | ||
| resourceType string | ||
| } | ||
|
|
||
| // IgnoreNullValues - sometimes should consider there is an error we can accept | ||
|
|
@@ -138,10 +144,15 @@ func NewPrometheusScaler(config *scalersconfig.ScalerConfig) (Scaler, error) { | |
| } | ||
|
|
||
| return &prometheusScaler{ | ||
| metricType: metricType, | ||
| metadata: meta, | ||
| httpClient: httpClient, | ||
| logger: logger, | ||
| metricType: metricType, | ||
| metadata: meta, | ||
| httpClient: httpClient, | ||
| logger: logger, | ||
| scalableObjectName: config.ScalableObjectName, | ||
| scalableObjectNS: config.ScalableObjectNamespace, | ||
| triggerName: config.TriggerName, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or metric_name?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding metric_name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trigger index is kind of useless because it's just a number and when you have 2000+ scaled objects in a cluster, it doesn't give any userful info I wonder if we should explore removing it from other metrics? |
||
| metricName: GenerateMetricNameWithIndex(meta.triggerIndex, kedautil.NormalizeString("prometheus")), | ||
| resourceType: config.ScalableObjectType, | ||
| }, nil | ||
| } | ||
|
|
||
|
|
@@ -255,6 +266,7 @@ func (s *prometheusScaler) ExecutePromQuery(ctx context.Context) (float64, error | |
|
|
||
| // allow for zero element or single element result sets | ||
| if len(result.Data.Result) == 0 { | ||
| metricscollector.RecordEmptyUpstreamResponse(s.scalableObjectNS, s.scalableObjectName, s.triggerName, s.metricName, s.resourceType, s.metadata.IgnoreNullValues) | ||
| if s.metadata.IgnoreNullValues { | ||
| return 0, nil | ||
| } | ||
|
|
@@ -265,6 +277,7 @@ func (s *prometheusScaler) ExecutePromQuery(ctx context.Context) (float64, error | |
|
|
||
| valueLen := len(result.Data.Result[0].Value) | ||
| if valueLen == 0 { | ||
| metricscollector.RecordEmptyUpstreamResponse(s.scalableObjectNS, s.scalableObjectName, s.triggerName, s.metricName, s.resourceType, s.metadata.IgnoreNullValues) | ||
| if s.metadata.IgnoreNullValues { | ||
| return 0, nil | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.