A timeline chart on my dashboard that displays the number of occurrences of an event over a selected time range in blocks of a selected time interval
I have some live data via a mysql database (via PLC) that displays system performance of a factory floor process. The data includes a TimeDate field for each event and 8 additional columns of information.
By using Variables I can filter this data in table format to show the correct information, but I would like to display this as a timeline, highlighting the number of occurrences per hr (for example)
Can someone please advise how to display this data ? This is what I have so far…
SELECT
$__timeGroup(TimeDate,'1h') as time_sec,
COUNT(Fault) as value,
Program as metric
FROM AGVfault
WHERE $__timeFilter(TimeDate)
GROUP BY 1, Program
ORDER BY 1
I am still not sure what I am doing with this, but the results below seem a little closer? the query seems to fall over when I add the 1, to the group line?
SELECT $__timeGroup(TimeDate,'1h') as time_sec, COUNT(Fault) as value
FROM AGVfault
WHERE $__timeFilter(TimeDate) AND Program <> 0 AND Fault in ($Fault)
GROUP BY TimeDate
ORDER BY 1
Hi, thanks for the reply. I don’t think this what you are after, but I’m not sure how to supply the correct data?
I am still very new to Grafana so will require support to provide information.
none filtered query below, return aprox 800 rows per hour.
SELECT * FROM AGV.dbo.AGVfault
WHERE $__timeFilter(TimeDate) AND Program <> 0
I am still stuck on this problem. unsing the internet and trying various methods the below get me the closest to a working solution, but its still not correct.
I now have a table displaying the correct number of faults per hour, filtered by my variables, in a table form, but I cant seem to mange to add a second column, to indicate the time range split.
SELECT COUNT(Fault) as value
FROM AGVfault
WHERE $__timeFilter(TimeDate) AND Program <> 0 AND Program in ($Program) AND Fault in ($Fault) and AGV in ($AGV)
GROUP BY $__timeGroup(TimeDate,1h,0)
Any help would be much apreciated, also if I am on the wrong track, please explain how I should be approaching this problem.
To close this thread, please find the solution to my question below.
Thanks for the continued support
SELECT $__timeGroup(TimeDate,6h,0) as time, COUNT(Fault) as value
FROM AGVfault
WHERE $__timeFilter(TimeDate) AND Program <> 0 AND Program in ($Program) AND Fault in ($Fault) and AGV in ($AGV)
GROUP BY $__timeGroup(TimeDate,6h,0)
ORDER BY time ASC