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

MQE: fix functions that could return multiple series with the same labels #10533

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

charleskorn
Copy link
Contributor

What this PR does

This PR fixes an issue with the clamp, clamp_min, clamp_max, round and histogram_fraction functions in MQE: they could return multiple series with the same labels if multiple series with the same labels but different metric names were passed to the function.

This PR also adds a test to ensure we catch issues like these when new functions are added in the future.

Which issue(s) this PR fixes or relates to

#10067

Checklist

  • Tests updated.
  • [n/a] Documentation added.
  • [covered by Mimir Query Engine #10067] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [n/a] about-versioning.md updated with experimental features.

@charleskorn charleskorn force-pushed the charleskorn/mqe-ensure-deduplicate-and-merge branch from 2312545 to 526732d Compare January 29, 2025 06:11
@charleskorn charleskorn marked this pull request as ready for review January 29, 2025 06:11
@charleskorn charleskorn requested a review from a team as a code owner January 29, 2025 06:11
@charleskorn charleskorn enabled auto-merge (squash) January 29, 2025 06:13
// This test ensures that all functions correctly merge series after dropping the metric name.
func TestFunctionDeduplicateAndMerge(t *testing.T) {
data := `
load 30s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use spaces here as tabs don't ensure alignment for all

image

"clamp_min": "-Inf",
"clamp_max": "Inf",
"label_replace": `"__name__", "$1", "env", "(.*)"`,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) I feel like it would be simpler to just define a query string for each function, and then assert that the number of functions checked is equal to len(instantVectorFunctionOperatorFactories)

Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to merge this so we get it into next weeks release. However I think it's worth coming back to these nits.

require.NoError(t, err)
defer q.Close()

mimirResult := q.Exec(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider passing this into Prometheus too so that we can verify we merge in the same way (as I think we've found a case previous where we don't).

Additionally, I think we should consider seeing if we can make this part of the gauntlet. ie make sure we have cases represented in there along with the selectors that would cause this to happen.

@charleskorn charleskorn merged commit 656dfb1 into main Jan 30, 2025
28 checks passed
@charleskorn charleskorn deleted the charleskorn/mqe-ensure-deduplicate-and-merge branch January 30, 2025 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants