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

Explore UI - updated PromQL / LogQL statement not being resolved correctly when 'Run Query' clicked #37099

Closed
aengusrooneygrafana opened this issue Jul 22, 2021 · 6 comments
Labels
area/explore prio/low It's a good idea, but not scheduled for any release stale Issue with no recent activity type/bug

Comments

@aengusrooneygrafana
Copy link

What happened:

(Step 1) In Grafana Explore, run a PromQL or LogQL query, e.g.

Query1 - PromQL example
sum(count_over_time(container_network_transmit_errors_total{namespace="production"}[10m]))

Query2 - LogQL example
sum(count_over_time({error_level="ERROR"}[10m]))

Click 'Run Query' - the expected result is displayed.

(Step 2) Modify the query to remove the sum funciton sum( and )

Query1 modified -
count_over_time(container_network_transmit_errors_total{namespace="production"}[10m])

Query2 modified -
count_over_time({error_level="ERROR"}[10m])

Click 'Run Query' immediately after deleting the closing bracket ) - an error is returned.

Error Query 1 -
image

Error Query 2 -
Screenshot 2021-07-22 at 13 30 25

Json Query 1 - note the 'expression' still contains the closing bracket )

{
  "state": "Error",
  "series": [],
  "annotations": [],
  "error": {
    "message": "\"invalid parameter \\\"query\\\": 1:87: parse error: unexpected right parenthesis ')'\"",
    "refId": "A",
    "status": 400,
    "statusText": ""
  },
  "request": {
    "app": "explore",
    "dashboardId": 0,
    "timezone": "browser",
    "startTime": 1626953875815,
    "interval": "2s",
    "intervalMs": 2000,
    "panelId": "Q-5831a900-a26c-4e9b-8383-1e4ed1d05c37-0",
    "targets": [
      {
        "refId": "A",
        "key": "Q-5831a900-a26c-4e9b-8383-1e4ed1d05c37-0",
        "exemplar": true,
        "expr": "count_over_time(container_network_transmit_errors_total{namespace=\"production\"}[10m]))"
      }

Json Query 2 - note the 'expression' still contains the closing bracket )

{
  "state": "Error",
  "series": [],
  "request": {
    "app": "explore",
    "dashboardId": 0,
    "timezone": "browser",
    "startTime": 1626953406049,
    "interval": "2s",
    "intervalMs": 2000,
    "panelId": "Q-f912cbf1-f83e-4741-be69-c0ba1427eadf-0",
    "targets": [
      {
        "refId": "A",
        "key": "Q-f912cbf1-f83e-4741-be69-c0ba1427eadf-0",
        "expr": "count_over_time({error_level=\"ERROR\"}[10m]))"
      }

What you expected to happen:

No error returned after clicking on 'Run Query'

How to reproduce it (as minimally and precisely as possible):

Follow the steps above

Anything else we need to know?:

n/a

Environment:

  • Grafana version: Grafana Cloud Hosted Grafana 8.0.6
  • Data source type & version: Grafana Cloud Hosted Prometheus and Hosted Loki
  • OS Grafana is installed on: Grafana Cloud
  • User OS & Browser: MacOS & Chrome
  • Grafana plugins: n/a
  • Others: n/a
@aengusrooneygrafana
Copy link
Author

Additional note:

"Click 'Run Query' immediately after deleting the closing bracket ) - an error is returned"

You need to hit 'Run Query' very quickly after deleting the closing bracket to reproduce this, in under a second.

@ifrost
Copy link
Contributor

ifrost commented Jul 29, 2021

Could be related to the way we debounce running the query. One solution could be to cancel debouncing onBlur(). I had similar issues reported in the past. cc @gabor @davkal

@ifrost ifrost self-assigned this Jul 29, 2021
@ifrost ifrost added the prio/low It's a good idea, but not scheduled for any release label Jul 29, 2021
@ifrost
Copy link
Contributor

ifrost commented Jul 29, 2021

Possibly related to grafana/x-ray-datasource#24 and #33319

@ifrost ifrost removed their assignment Jul 30, 2021
@gabor
Copy link
Contributor

gabor commented Aug 2, 2021

@ifrost yes it does sound like an issue with the debounce (though i did not debug the code to verify it). i think in general what we want is:

  • the data-model is updated immediately without debounce (technically this means on every keypress)
    • (this might be technically challenging/impossible in some cases though)
  • (in panel, not explore) trigger query re-evaluation in a debounced way

your idea with not-debouncing onblur sounds reasonable, though i wonder if it could cause problems in some corner cases

@ivanahuckova any ideas?

Copy link
Contributor

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale Issue with no recent activity label Jan 28, 2024
@ivanahuckova
Copy link
Member

Since the last message, we have significantly change the code and switched query editor library. Moreover, I was not able to reproduce this anymore. So closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/explore prio/low It's a good idea, but not scheduled for any release stale Issue with no recent activity type/bug
Projects
None yet
Development

No branches or pull requests

5 participants