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

Inconsistent behavior $__timeFilter #766

Closed
enginecan opened this issue Mar 20, 2024 · 2 comments
Closed

Inconsistent behavior $__timeFilter #766

enginecan opened this issue Mar 20, 2024 · 2 comments
Assignees
Labels
datasource/ClickHouse type/bug Something isn't working

Comments

@enginecan
Copy link

enginecan commented Mar 20, 2024

I've encountered an issue where Grafana exhibits inconsistent behavior when generating queries for ClickHouse using the $__timeFilter macro. The same panel occasionally produces different underlying queries for ClickHouse, which I will refer to as Result 1 and Result 2. This is a problem because Result 1 doesn't return any records, while Result 2 does. Am I missing something or is this a bug?

Query

select count(visit_result) as "Total Visits", count(distinct person_name) as "Total Persons"
from visits
where $__timeFilter(visit_timestamp)

Result 1

select count(visit_result) as "Total Visits", count(distinct person_name) as "Total Persons"
from visits
where visit_timestamp >= toDateTime64(1701417600000/1000, 3) AND visit_timestamp <= toDateTime64(1704095999000/1000, 3)

Result 2

select count(visit_result) as "Total Visits", count(distinct person_name) as "Total Persons"
from visits
where visit_timestamp >= '1701417600' AND visit_timestamp <= '1704095999'

Environment:

  • Grafana version: Grafana v10.1.1 (0cfa76b22d)
  • ClickHouse Plugin version: 3.3.0
  • ClickHouse DB version: 20.3.11.97
@SpencerTorres
Copy link
Collaborator

Result 1 looks like a query that would've been generated from version 4.0.0, but result 2 looks like it's from 3.3.0. Could you provide more details on the setup?

For example, is this a query from 3.x that you're opening in 4.x? Are there different datasources being used on this dashboard? How did you update the plugin (if at all)? Did you edit an existing panel, or copy the query into a new one?

Version 4.0.3 is available, and fixes how $__timeFilter works. Now there's 2 separate macros, $__timeFilter and $__timeFilter_ms. The first one will cast the dashboard time range to a DateTime while the latter casts to DateTime64.

@aangelisc aangelisc moved this from Incoming to Waiting in Partner Datasources Mar 20, 2024
@SpencerTorres SpencerTorres self-assigned this Mar 20, 2024
@enginecan
Copy link
Author

enginecan commented Mar 20, 2024

We just upgraded Grafana to v10.4.0 and it seems to have solved this problem. Thanks!

@github-project-automation github-project-automation bot moved this from Waiting to Done in Partner Datasources Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasource/ClickHouse type/bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants