Skip to content

Support query analyze for thanos engine #6790

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Jun 4, 2025

What this PR does:

Support query analyze parameter in InstantQuery/RangeQuery API. Query analysis will be returned if analyze is set to true in the parameter and thanos engine is used. This feature is almost the same as Thanos' query analyze feature.

Mark as WIP as we still need to put this behind FF and add tests.

Example output.

curl --location 'http://localhost:8005/prometheus/api/v1/query?query=sum(up)&analyze=true'  | jq . 
{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {},
        "value": [
          1749023219,
          "2"
        ]
      }
    ],
    "analysis": {
      "name": "[duplicateLabelCheck]",
      "executionTime": "1.753624ms",
      "peakSamples": 1,
      "totalSamples": 2,
      "children": [
        {
          "name": "[concurrent(buff=2)]",
          "executionTime": "1.750166ms",
          "peakSamples": 1,
          "totalSamples": 2,
          "children": [
            {
              "name": "[aggregate] sum by ([])",
              "executionTime": "1.710457ms",
              "peakSamples": 1,
              "totalSamples": 2,
              "children": [
                {
                  "name": "[coalesce]",
                  "executionTime": "1.701584ms",
                  "peakSamples": 1,
                  "totalSamples": 2,
                  "children": [
                    {
                      "name": "[concurrent(buff=2)]",
                      "executionTime": "1.602583ms",
                      "children": [
                        {
                          "name": "[vectorSelector] {[__name__=\"up\"]} 0 mod 5",
                          "executionTime": "1.573957ms"
                        }
                      ]
                    },
                    {
                      "name": "[concurrent(buff=2)]",
                      "executionTime": "1.630917ms",
                      "children": [
                        {
                          "name": "[vectorSelector] {[__name__=\"up\"]} 1 mod 5",
                          "executionTime": "1.583667ms"
                        }
                      ]
                    },
                    {
                      "name": "[concurrent(buff=2)]",
                      "executionTime": "1.484707ms",
                      "peakSamples": 1,
                      "totalSamples": 1,
                      "children": [
                        {
                          "name": "[vectorSelector] {[__name__=\"up\"]} 2 mod 5",
                          "executionTime": "1.45725ms",
                          "peakSamples": 1,
                          "totalSamples": 1
                        }
                      ]
                    },
                    {
                      "name": "[concurrent(buff=2)]",
                      "executionTime": "1.485916ms",
                      "children": [
                        {
                          "name": "[vectorSelector] {[__name__=\"up\"]} 3 mod 5",
                          "executionTime": "1.461126ms"
                        }
                      ]
                    },
                    {
                      "name": "[concurrent(buff=2)]",
                      "executionTime": "1.619791ms",
                      "peakSamples": 1,
                      "totalSamples": 1,
                      "children": [
                        {
                          "name": "[vectorSelector] {[__name__=\"up\"]} 4 mod 5",
                          "executionTime": "1.608416ms",
                          "peakSamples": 1,
                          "totalSamples": 1
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

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]

@yeya24 yeya24 marked this pull request as draft June 4, 2025 07:52
yeya24 added 2 commits June 6, 2025 05:38
Signed-off-by: yeya24 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant