mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-05 13:47:10 +02:00
No info annotation for rate/increase when type is histogram (#16915)
Signed-off-by: Carrie Edwards <edwrdscarrie@gmail.com>
This commit is contained in:
parent
3f59fe1a80
commit
44b0fbba1e
@ -1904,7 +1904,7 @@ func (ev *evaluator) eval(ctx context.Context, expr parser.Expr) (parser.Value,
|
|||||||
if ev.enableTypeAndUnitLabels {
|
if ev.enableTypeAndUnitLabels {
|
||||||
// When type-and-unit-labels feature is enabled, check __type__ label
|
// When type-and-unit-labels feature is enabled, check __type__ label
|
||||||
typeLabel := inMatrix[0].Metric.Get("__type__")
|
typeLabel := inMatrix[0].Metric.Get("__type__")
|
||||||
if typeLabel != string(model.MetricTypeCounter) {
|
if typeLabel != string(model.MetricTypeCounter) && typeLabel != string(model.MetricTypeHistogram) {
|
||||||
warnings.Add(annotations.NewPossibleNonCounterLabelInfo(metricName, typeLabel, e.Args[0].PositionRange()))
|
warnings.Add(annotations.NewPossibleNonCounterLabelInfo(metricName, typeLabel, e.Args[0].PositionRange()))
|
||||||
}
|
}
|
||||||
} else if !strings.HasSuffix(metricName, "_total") &&
|
} else if !strings.HasSuffix(metricName, "_total") &&
|
||||||
|
@ -3504,7 +3504,7 @@ func TestRateAnnotations(t *testing.T) {
|
|||||||
expr: "rate(series[1m1s])",
|
expr: "rate(series[1m1s])",
|
||||||
typeAndUnitLabelsEnabled: true,
|
typeAndUnitLabelsEnabled: true,
|
||||||
expectedInfoAnnotations: []string{
|
expectedInfoAnnotations: []string{
|
||||||
`PromQL info: metric might not be a counter, __type__ label is not set to "counter", got "": "series" (1:6)`,
|
`PromQL info: metric might not be a counter, __type__ label is not set to "counter" or "histogram", got "": "series" (1:6)`,
|
||||||
},
|
},
|
||||||
expectedWarningAnnotations: []string{},
|
expectedWarningAnnotations: []string{},
|
||||||
},
|
},
|
||||||
@ -3515,7 +3515,7 @@ func TestRateAnnotations(t *testing.T) {
|
|||||||
expr: "increase(series[1m1s])",
|
expr: "increase(series[1m1s])",
|
||||||
typeAndUnitLabelsEnabled: true,
|
typeAndUnitLabelsEnabled: true,
|
||||||
expectedInfoAnnotations: []string{
|
expectedInfoAnnotations: []string{
|
||||||
`PromQL info: metric might not be a counter, __type__ label is not set to "counter", got "": "series" (1:10)`,
|
`PromQL info: metric might not be a counter, __type__ label is not set to "counter" or "histogram", got "": "series" (1:10)`,
|
||||||
},
|
},
|
||||||
expectedWarningAnnotations: []string{},
|
expectedWarningAnnotations: []string{},
|
||||||
},
|
},
|
||||||
@ -3528,6 +3528,15 @@ func TestRateAnnotations(t *testing.T) {
|
|||||||
expectedWarningAnnotations: []string{},
|
expectedWarningAnnotations: []string{},
|
||||||
expectedInfoAnnotations: []string{},
|
expectedInfoAnnotations: []string{},
|
||||||
},
|
},
|
||||||
|
"no info annotation when rate() over series with __type__=histogram label": {
|
||||||
|
data: `
|
||||||
|
series{label="a", __type__="histogram"} 1 2 3
|
||||||
|
`,
|
||||||
|
expr: "rate(series[1m1s])",
|
||||||
|
typeAndUnitLabelsEnabled: true,
|
||||||
|
expectedWarningAnnotations: []string{},
|
||||||
|
expectedInfoAnnotations: []string{},
|
||||||
|
},
|
||||||
"no info annotation when increase() over series with __type__=counter label": {
|
"no info annotation when increase() over series with __type__=counter label": {
|
||||||
data: `
|
data: `
|
||||||
series{label="a", __type__="counter"} 1 2 3
|
series{label="a", __type__="counter"} 1 2 3
|
||||||
@ -3537,6 +3546,15 @@ func TestRateAnnotations(t *testing.T) {
|
|||||||
expectedWarningAnnotations: []string{},
|
expectedWarningAnnotations: []string{},
|
||||||
expectedInfoAnnotations: []string{},
|
expectedInfoAnnotations: []string{},
|
||||||
},
|
},
|
||||||
|
"no info annotation when increase() over series with __type__=histogram label": {
|
||||||
|
data: `
|
||||||
|
series{label="a", __type__="histogram"} 1 2 3
|
||||||
|
`,
|
||||||
|
expr: "increase(series[1m1s])",
|
||||||
|
typeAndUnitLabelsEnabled: true,
|
||||||
|
expectedWarningAnnotations: []string{},
|
||||||
|
expectedInfoAnnotations: []string{},
|
||||||
|
},
|
||||||
"no info annotation when rate() over series with _total suffix": {
|
"no info annotation when rate() over series with _total suffix": {
|
||||||
data: `
|
data: `
|
||||||
series_total{label="a"} 1 2 3
|
series_total{label="a"} 1 2 3
|
||||||
|
@ -147,7 +147,7 @@ var (
|
|||||||
IncompatibleBucketLayoutInBinOpWarning = fmt.Errorf("%w: incompatible bucket layout encountered for binary operator", PromQLWarning)
|
IncompatibleBucketLayoutInBinOpWarning = fmt.Errorf("%w: incompatible bucket layout encountered for binary operator", PromQLWarning)
|
||||||
|
|
||||||
PossibleNonCounterInfo = fmt.Errorf("%w: metric might not be a counter, name does not end in _total/_sum/_count/_bucket:", PromQLInfo)
|
PossibleNonCounterInfo = fmt.Errorf("%w: metric might not be a counter, name does not end in _total/_sum/_count/_bucket:", PromQLInfo)
|
||||||
PossibleNonCounterLabelInfo = fmt.Errorf("%w: metric might not be a counter, __type__ label is not set to %q", PromQLInfo, model.MetricTypeCounter)
|
PossibleNonCounterLabelInfo = fmt.Errorf("%w: metric might not be a counter, __type__ label is not set to %q or %q", PromQLInfo, model.MetricTypeCounter, model.MetricTypeHistogram)
|
||||||
HistogramQuantileForcedMonotonicityInfo = fmt.Errorf("%w: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) for metric name", PromQLInfo)
|
HistogramQuantileForcedMonotonicityInfo = fmt.Errorf("%w: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) for metric name", PromQLInfo)
|
||||||
IncompatibleTypesInBinOpInfo = fmt.Errorf("%w: incompatible sample types encountered for binary operator", PromQLInfo)
|
IncompatibleTypesInBinOpInfo = fmt.Errorf("%w: incompatible sample types encountered for binary operator", PromQLInfo)
|
||||||
HistogramIgnoredInAggregationInfo = fmt.Errorf("%w: ignored histogram in", PromQLInfo)
|
HistogramIgnoredInAggregationInfo = fmt.Errorf("%w: ignored histogram in", PromQLInfo)
|
||||||
|
Loading…
Reference in New Issue
Block a user