Reputation: 21
I am trying to fetch metrics from postgresql (timeseries) database in Grafana (Ver 8) using below query .
Just wondering its throwing below exception :-
failed to convert long to wide series when converting from dataframe: long series must be sorted ascending by time to be converted
SELECT time, cpu_count,CASE WHEN step = 0 THEN 'Today' ELSE (-interval)::text END AS metric
FROM
-- sub-query to generate the intervals
( SELECT step, (step||'day')::interval AS interval FROM generate_series(0,3) g(step) order by interval asc) g_offsets
JOIN LATERAL (
SELECT
-- adding set interval to time values
time_bucket('15m',time + interval )::timestamptz AS time, avg(limit_cpu) AS cpu_count FROM cpu_model
WHERE
time BETWEEN $__timeFrom()::timestamptz - interval AND $__timeTo()::timestamptz - interval
GROUP BY 1
ORDER BY 1,2 ASC
) l ON true
Would appreciate it if some one can help me to find the error or provide solution .
Upvotes: 2
Views: 6570
Reputation: 31
In my case, for some reason sorting the data by time ASC solved the issue. Grafana 's error was correct.
SELECT
time AS "time",
pair,
price as value
FROM currency_pair_price
WHERE
time/1000 >= 1662481845 AND time/1000 <= 1662568245
AND pair = 'BTCBUSD'
ORDER BY time ASC;
Upvotes: 3