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

Graph message: "No data points" with subquery #127

Closed
dmitrysdm opened this issue May 16, 2019 · 4 comments · Fixed by #226, #250 or grafana/grafana-plugin-repository#690
Closed

Graph message: "No data points" with subquery #127

dmitrysdm opened this issue May 16, 2019 · 4 comments · Fixed by #226, #250 or grafana/grafana-plugin-repository#690

Comments

@dmitrysdm
Copy link

dmitrysdm commented May 16, 2019

grafana v6.1.6 clickhouse-datasource 1.8.1
Working Query: as result i see graph

SELECT
    $timeSeries as t,
    count() as c
FROM $table
WHERE $timeFilter
GROUP BY t
ORDER BY t

result in query inspector:

{
  "xhrStatus": "complete",
  "request": {
    "method": "GET",
    "url": "api/datasources/proxy/8/?query=SELECT%20%20%20%20%20(intDiv(toUInt32(EventTime)%2C%201)%20*%201)%20*%201000%20as%20t%2C%20%20%20%20%20count()%20as%20c%20FROM%20em.users%20WHERE%20EventDate%20%3E%3D%20toDate(1558019528)%20AND%20EventTime%20%3E%3D%20toDateTime(1558019528)%20GROUP%20BY%20t%20ORDER%20BY%20t%20FORMAT%20JSON"
  },
  "response": {
    "meta": [
      {
        "name": "t",
        "type": "UInt64"
      },
      {
        "name": "c",
        "type": "UInt64"
      }
    ],
    "data": [
      {
        "t": "1558019633000",
        "c": "91"
      },
      {
        "t": "1558019634000",
        "c": "216"
      }
    ],
    "rows": 2,
    "statistics": {
      "elapsed": 0.003194378,
      "rows_read": 9777,
      "bytes_read": 58662
    }
  }
}

But if i try to do subquery:

SELECT * FROM (
  SELECT
      $timeSeries as t,
      count() as c
  FROM $table
  WHERE $timeFilter
  GROUP BY t
  ORDER BY t
)
GROUP BY c, t

i see same result in query inspector as previously:

{
  "xhrStatus": "complete",
  "request": {
    "method": "GET",
    "url": "api/datasources/proxy/8/?query=SELECT%20*%20FROM%20(%20SELECT%20%20%20%20%20(intDiv(toUInt32(EventTime)%2C%201)%20*%201)%20*%201000%20as%20t%2C%20%20%20%20%20count()%20as%20c%20FROM%20em.users%20WHERE%20EventDate%20%3E%3D%20toDate(1558019589)%20AND%20EventTime%20%3E%3D%20toDateTime(1558019589)%20GROUP%20BY%20t%20ORDER%20BY%20t%20)%20GROUP%20BY%20c%2C%20t%20FORMAT%20JSON"
  },
  "response": {
    "meta": [
      {
        "name": "t",
        "type": "UInt64"
      },
      {
        "name": "c",
        "type": "UInt64"
      }
    ],
    "data": [
      {
        "t": "1558019634000",
        "c": "216"
      },
      {
        "t": "1558019633000",
        "c": "91"
      }
    ],
    "rows": 2,
    "statistics": {
      "elapsed": 0.003641224,
      "rows_read": 9777,
      "bytes_read": 58662
    }
  }
}

but instead graph, i see message:
"No data points"
without any messages about errors.

@dmitrysdm dmitrysdm changed the title problem with subquery Graph message: "No data points" with subquery May 16, 2019
@dmitrysdm
Copy link
Author

With grafana-6.2.0-beta2 i have the same result :(

@juris
Copy link

juris commented Mar 24, 2020

Same here with 6.7.1.

Moreover, it shows "No data" if I specify fixed time range. Presets like "Last X days" work fine. Defined ranges, like "From now-30 to now-1" produce "No data".

@juris
Copy link

juris commented Mar 30, 2020

Same here with 6.7.1.

Moreover, it shows "No data" if I specify fixed time range. Presets like "Last X days" work fine. Defined ranges, like "From now-30 to now-1" produce "No data".

Figured out why I'm seeing it. We have a DateTime column named "t". So I was able to overcome my issue by changing :

SELECT
    $timeSeries as t

to

SELECT
    $timeSeries as time

@Slach
Copy link
Collaborator

Slach commented Jul 7, 2020

@dmitrysdm
if you change your query
from

SELECT * FROM (
  SELECT
      $timeSeries as t,
      count() as c
  FROM $table
  WHERE $timeFilter
  GROUP BY t
  ORDER BY t
)
GROUP BY c, t

to

SELECT * FROM (
  SELECT
      $timeSeries as t,
      count() as total
  FROM $table
  WHERE $timeFilter
  GROUP BY t
)
ORDER BY t

you will see results without "no data"

"no data" which you see related to behavior how to clickhouse-grafana plugin detect which columns should be represented as "groups" or "labels" and which columns should be represented as "value"
please look to:

when SQL query contains GROUP BY
all columns used in GROUP BY should be combined to "label values" or name of time series depends on how much columns not used in GROUP BY

so, when you use GROUP BY c, t you automatically exclude "c" from list of columns which should represent as "value"

@Slach Slach mentioned this issue Jul 7, 2020
@Slach Slach closed this as completed Jul 7, 2020
Slach added a commit that referenced this issue Jul 7, 2020
Slach added a commit that referenced this issue Jul 24, 2020
# 2.0.3 (2020-07-24)

## Enhancements:
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, #186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see #237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see #230
* properly parsing POST queries in golang part of plugin, #228, thanks @it1804


## Fixes:
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix #244
  * fix #243
* add multiple dashboard examples for github issues:
  * fix #240 
  * fix #135 
  * fix #245 
  * fix #238   
  * fix #232
  * fix #127
  * fix #141
Slach added a commit to Altinity/grafana-plugin-repository that referenced this issue Jul 24, 2020
## Enhancements:
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, Altinity/clickhouse-grafana#186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see Altinity/clickhouse-grafana#237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see Altinity/clickhouse-grafana#230
* properly parsing POST queries in golang part of plugin, Altinity/clickhouse-grafana#228, thanks @it1804

## Fixes:
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix Altinity/clickhouse-grafana#244
  * fix Altinity/clickhouse-grafana#243
* add multiple dashboard examples for github issues:
  * fix Altinity/clickhouse-grafana#240
  * fix Altinity/clickhouse-grafana#135
  * fix Altinity/clickhouse-grafana#245
  * fix Altinity/clickhouse-grafana#238
  * fix Altinity/clickhouse-grafana#232
  * fix Altinity/clickhouse-grafana#127
  * fix Altinity/clickhouse-grafana#141

Signed-off-by: Eugene Klimov <eklimov@altinity.com>
Slach added a commit to Altinity/grafana-plugin-repository that referenced this issue Aug 13, 2020
# 2.1.0 (2020-08-13)

## Enhancement:
* add "Skip comments" checkbox to query editor to pass SQL comments to server, fix Altinity/clickhouse-grafana#265
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, Altinity/clickhouse-grafana#186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see Altinity/clickhouse-grafana#237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see Altinity/clickhouse-grafana#230
* properly parsing POST queries in golang part of plugin, Altinity/clickhouse-grafana#228, thanks @it1804

## Fixes:
* fix corner cases for $macro + subquery, see Altinity/clickhouse-grafana#276 and Altinity/clickhouse-grafana#277
* fix parallel query execution, see Altinity/clickhouse-grafana#273
* fix identifiers quotes, see Altinity/clickhouse-grafana#276, Altinity/clickhouse-grafana#277
* fix plugin.json for pass `grafana-plugin-repository` plugin validator
* fix multi-value variables behavior - Altinity/clickhouse-grafana#252
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix Altinity/clickhouse-grafana#244
  * fix Altinity/clickhouse-grafana#243
* add multiple dashboard examples for github issues:
  * fix Altinity/clickhouse-grafana#240
  * fix Altinity/clickhouse-grafana#135
  * fix Altinity/clickhouse-grafana#245
  * fix Altinity/clickhouse-grafana#238
  * fix Altinity/clickhouse-grafana#232
  * fix Altinity/clickhouse-grafana#127
  * fix Altinity/clickhouse-grafana#141

Signed-off-by: Eugene Klimov <eklimov@altinity.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants