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

ad-hoc filter does not calculate correct target table #599

Closed
mikhno-s opened this issue Nov 16, 2023 · 4 comments · Fixed by #650
Closed

ad-hoc filter does not calculate correct target table #599

mikhno-s opened this issue Nov 16, 2023 · 4 comments · Fixed by #650
Assignees

Comments

@mikhno-s
Copy link

What happened:
We added ad hoc filter to one of our dashboards and wanted to filter data on dashboards by clicking filter on the table cell of one of the tables in that dashboards.
For example I wanted to filter data by column level with value ERROR

What you expected to happen:
Clicking on the Filter for value on the table cell where level is ERROR and now expecting that settings additional_table_filters={'app_logs' : ' level = \'ERROR\' '} will be added to all queries on this dashboard with this datasource.

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

  • Create a table app logs with some columns and column level type String in clickhouse and timestamp type DateTime64 with some test data within
  • Add this clickhouse as a datasource to grafana
  • Create a dashboard and dd a adhoc filter on this datasource
  • Create a table visualisation and put some default query into it
SELECT
*
FROM logs_db.app_logs
WHERE $__timeFilter(timestamp)
LIMIT 10 
  • Enable Standard options -> Ad-hoc filterable in grafana table settings
  • Clickhouse Filter for value with some value, ERROR for example in the table
  • Checkout the query in query inspector:
SELECT
*
FROM logs_db.app_logs
WHERE timestamp >= '1700137452' AND timestamp <= '1700141052'
LIMIT 10 settings additional_table_filters={'logs_db' : ' level = \'ERROR\' '}

The right query should be

SELECT
*
FROM logs_db.app_logs
WHERE timestamp >= '1700137452' AND timestamp <= '1700141052'
LIMIT 10 settings additional_table_filters={'logs_db.app_logs' : ' level = \'ERROR\' '}

or settings additional_table_filters={'app_logs' : ' level = \'ERROR\' '}

I can suggest that plugin incorrectly gets the table name from the query.

Environment:

  • Grafana version: 10.1.1
  • Plugin version: 3.3.0
@vbichov
Copy link

vbichov commented Nov 16, 2023

also ad hoc filters are not applied on inital dashboard load, (additional_table_filters setting is not added at all)

If it helps - I can share screen recordings in PM.

@SpencerTorres SpencerTorres self-assigned this Nov 30, 2023
@asimpson asimpson moved this from Incoming to Backlog in Partner Datasources Dec 1, 2023
@mikhno-s
Copy link
Author

Hi, @SpencerTorres
Do you have any ETA for this ?

@cwurm
Copy link
Contributor

cwurm commented Jan 8, 2024

@mikhno-s @vbichov I reproduced the problem and opened a PR that will hopefully fix it for you: #650

@vbichov
Copy link

vbichov commented Feb 19, 2024

the issue wasn't fixed:
it seems that the AST parser is not aware of grafana template variables - this causes it to fail
Screenshot 2024-02-19 at 12 28 08

in the above example the failure is not due to the comment but due to the template variables. When comment is removed the parser fails on the next template variable.

when query parsing fails the additional_table_filters setting is not added to the query

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants