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

Feature request: GMP query API works with "pint" tool (support the ?stats=1 query parameter) #1054

Open
faevourite opened this issue Jul 3, 2024 · 1 comment
Assignees

Comments

@faevourite
Copy link

faevourite commented Jul 3, 2024

Prometheus supports stats=1 as part of the /api/v1/query and api/v1/query_range endpoints. It returns an additional json field called "stats" with some execution timings. For /query:

{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": ["..."],
    "stats": {
      "timings": {
        "evalTotalTime": 0.0000875,
        "resultSortTime": 0,
        "queryPreparationTime": 0.000051542,
        "innerEvalTime": 0.000029166,
        "execQueueTime": 0.00004725,
        "execTotalTime": 0.000141459
      },
      "samples": {
        "totalQueryableSamples": 1,
        "peakSamples": 1
      }
    }
  }
}

Right now this parameter causes gmp-frontend to return an error:

{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"stats\": Cannot bind query parameter. Field 'stats' could not be found in request message.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "description": "Invalid JSON payload received. Unknown name \"stats\": Cannot bind query parameter. Field 'stats' could not be found in request message."
          }
        ]
      }
    ]
  }
}

This means we can't make use of some excellent Prometheus tooling out there like pint to lint for expensive queries, because it relies on the stats=1 parameter (and not just for that one check, but all that call Prometheus APIs). Is it possible to increase compatibility with Prometheus and start supporting this param?

@bwplotka
Copy link
Collaborator

bwplotka commented Jul 8, 2024

Thanks! Great request. 💪🏽

The main challenge is to map internal workings of Google Cloud Monitoring PromQL engine to those stats which assumes Prometheus' TSDB PromQL engine.

We could make it work, at the minimum level, so tools like [pint](https://cloudflare.github.io/pint/checks/query/cost.html could work OR we could contribute to pint to make sure it's more generic. Anyway, the acceptance criteria here:

Acceptance Criteria

  • Make GMP work with pint

@bwplotka bwplotka changed the title Feature request: support the ?stats=1 query parameter Feature request: GMP query API works with "pint" tool (support the ?stats=1 query parameter) Jul 8, 2024
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

No branches or pull requests

2 participants