grafana / google-bigquery-datasource

Google BigQuery Datasource Plugin for Grafana.
Apache License 2.0
26 stars 13 forks source link

Alerting: Failed to evaluate queries and expressions: input data must be a wide series but got type long (input refid) #168

Open Boeller666 opened 1 year ago

Boeller666 commented 1 year ago

I tryed to create an alert from a query that already works in explore, even as table or time series:

SELECT
  a.publishTime as TIMESTAMP,
  a.entityId,
  a.status,
  a.publishTime,
  a.operation,
  TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), a.publishTime, MINUTE) as state_since
FROM `events` AS a
JOIN (
  SELECT
    entityId,
    MAX(publishTime) as maxPublishTime
  FROM `events`
  WHERE $__timeFilter(publishTime)
  GROUP BY entityId
) AS b ON a.entityId = b.entityId AND a.publishTime = b.maxPublishTime
WHERE a.status IN ("A", "B") AND a.operation = "transition"
AND $__timeFilter(a.publishTime)
order by TIMESTAMP ASC;

When using this as a table I got:

Failed to evaluate queries and expressions: input data must be a wide series but got type long (input refid)

When using this as a time series I got:

Failed to evaluate queries and expressions: no float64 value column found in frame A

Maybe related to https://github.com/grafana/grafana/issues/48072 ?

Boeller666 commented 1 year ago

Is anybody able to check if this is a bug or if I'm doing something wrong?

zoltanbedi commented 1 year ago

Hey @Boeller666, Sure thing, let's try to make this simpler. Can you provide a test database or csv I can use to test this? Can you please tell us more about the data types you are using there?

Boeller666 commented 1 year ago

These are the data types:

and a csv is attached example-data.csv

zoltanbedi commented 1 year ago

Hey @Boeller666, Thanks for providing me data to reproduce this. I was able to see the error you mentioned. I suspect you only see this when a query returns no data right?

We will fix this soon anyways. Thanks for reporting.

Boeller666 commented 1 year ago

Hmm, have to check if it only occurs if there is no data returned. Will tell you later!

Boeller666 commented 1 year ago

Yes, seems it will not fail if data is returned. Is there any other PR, branch or whatever to link here that solves this issue?

zoltanbedi commented 1 year ago

@Boeller666 nope, this is not picked up yet. We had something similar in the core sql data sources recently https://github.com/grafana/grafana/pull/67844/files#diff-fb30141c4ef5bef3c02a17014449038daac2b593e7cc4e066fb3c35243a4e7dcL317 the cause of the issue is that we return the column names with null values and alerting doesn't consider this an empty dataframe. The fix we did for the sql data sources is to remove the columns if they are empty. It looks like a proper fix would be not to return the column names from upstream. From here https://github.com/grafana/grafana-plugin-sdk-go/blob/main/data/sqlutil/sql.go

gabor commented 4 months ago

( as this relates to the no-results case, this may be similar to https://github.com/grafana/grafana/issues/82306)