prometheus: promql engine does not return expected results with mixed floats+histograms

What did you do?

I am testing the behavior (with promqltest) of querying a series that has both floats and histograms.

For example:

load 1m
	mixed_metric 1 2 3 {{schema:0 sum:5 count:4 buckets:[1 2 1]}} {{schema:0 sum:8 count:6 buckets:[1 4 1]}} 4 5 {{schema:0 sum:18 count:10 buckets:[3 4 3]}}

# I expect the following to work, but it Fails:
eval range from 0 to 8m step 1m mixed_metric
	{__name__="mixed_metric"} 1 2 3 {{count:4 sum:5 buckets:[1 2 1]}} {{count:6 sum:8 buckets:[1 4 1]}} 4 5 {{schema:0 sum:18 count:10 buckets:[3 4 3]}} {{schema:0 sum:18 count:10 buckets:[3 4 3]}}


# The following does pass though.
# Where we expected Histograms, we got Floats from a lookback
eval range from 0 to 8m step 1m mixed_metric
	{__name__="mixed_metric"} 1 2 3 3 3 4 5 {{schema:0 sum:18 count:10 buckets:[3 4 3]}} {{schema:0 sum:18 count:10 buckets:[3 4 3]}}


clear

# As another note, this only occurs when a float follows a histogram.
load 1m
	mixed_metric 1 2 3 {{schema:0 sum:5 count:4 buckets:[1 2 1]}} {{schema:0 sum:8 count:6 buckets:[1 4 1]}}

# Passes
eval range from 0 to 5m step 1m mixed_metric
	{__name__="mixed_metric"} 1 2 3 {{count:4 sum:5 buckets:[1 2 1]}} {{count:6 sum:8 buckets:[1 4 1]}} {{count:6 sum:8 buckets:[1 4 1]}}

# Fails
eval range from 0 to 5m step 1m mixed_metric
	{__name__="mixed_metric"} 1 2 3 3 3 {{count:6 sum:8 buckets:[1 4 1]}}

What did you expect to see?

I expected to receive the Histogram point at 3m (in the first example).

What did you see instead? Under which circumstances?

Instead, I received a Float of 3. Because another float exists later on in the series, a lookback was used instead of the Histogram that exists at that point.

System information

No response

Prometheus version

No response

Prometheus configuration file

No response

Alertmanager version

No response

Alertmanager configuration file

No response

Logs

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

Finding the exact location is probably 70% of the solution here. This should work, but somewhere in the code path, we forgot to check for this condition…

@kushalShukla-web you could see this as an opportunity to explore the (humongous) PromQL code base, with solving this issue as a byproduct. But it will be quite an investment. It’s a totally acceptable decision to unassign yourself from this issue.

@kushalShukla-web I have assigned you to this issue.

Note that I suspect you have to go quite deep into the woods to fix this. You can always pull out if this feels too tough. Just let me know.