Skip to content

Conversation

@yeya24
Copy link
Contributor

@yeya24 yeya24 commented Jan 5, 2026

What this PR does:

Currently in the Cortex read path, there is the slow query and query stats log available to gain insights of query performance to see how heavy a query is. However, this doesn't cover all the usecases in order to identify a heavy query.

One common way to identify expensive queries is via CPU profiling. For example, unoptimized regex queries can be super expensive to evaluate and cause Ingester CPU to spike to 100%. There is no way to track how expensive a regex matcher as it is too granular. Since expensive queries usually show up in Ingester CPU profile, adding more visibility to the CPU profile itself can help identify the bad tenant or the query.

In this PR, we start to instrument Ingester query path APIs with pprof label user=<userID> so that when looking at the Ingester CPU profile, we can at least identify which tenant ran the expensive query.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@dosubot dosubot bot added component/ingester type/observability To help know what is going on inside Cortex labels Jan 5, 2026
Copy link
Member

@alanprot alanprot left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 5, 2026
yeya24 added 2 commits January 5, 2026 11:31
Signed-off-by: yeya24 <benye@amazon.com>
Signed-off-by: yeya24 <benye@amazon.com>
@yeya24
Copy link
Contributor Author

yeya24 commented Jan 5, 2026

Merging this now as I just updated the changelog

@yeya24 yeya24 merged commit 95adbf8 into cortexproject:master Jan 5, 2026
6 checks passed
@yeya24 yeya24 deleted the pprof-labels branch January 5, 2026 19:33
kishorekg1999 pushed a commit to kishorekg1999/cortex that referenced this pull request Jan 6, 2026
)

* instrument ingester query path with pprof user label

Signed-off-by: yeya24 <benye@amazon.com>

* update changelog

Signed-off-by: yeya24 <benye@amazon.com>

---------

Signed-off-by: yeya24 <benye@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/ingester lgtm This PR has been approved by a maintainer size/L type/observability To help know what is going on inside Cortex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants