How show gap when no new data in mysql


I created mysql database with data about CPU, RAM, disk usage , etc… I created graph but I noticed that when there is no new data, the last value is displayed. That means that if I used 50% of CPU and than turn server down, it will still displaying 50% of usage.

This is my querry in grafana:

  UNIX_TIMESTAMP(date) as time_sec,
  cpu as value,
  'server' as metric
FROM server

This is how my querry in my looks like:
INSERT INTO database values ('$datetime', $cpu_percentage, $mem, $swap, $load1, $load5, $load15, $disk)

With value example
INSERT INTO database values ('2018-03-25 14:05:41', 9.69, 56.65, 0.00, 1.52, 1.72, 1.82, 20)

I would like to have a gap when no new value appears, because e.g. the server is down.

I am using Grafana v5.0.3.


Starting from Grafana v5.1 you can use the new fill argument in the $__timeGroup macro. See v5.1 documentation.

V5.1 is not released yet, but you can try the nightly build right now to use this new feature.



$__timeGroup is also in v 5.0 but it does not create the gap. I am not sure, if I explained It in right way.

I have this graph. At the beggining i turned off the device(approx at 3:35). Then I start it (approx at 12:20). On graph, there is still the last value measured at 3:35. There is no null or zero values between this two ( 3:35 and 12:20) values.

Please note that $__timeGroup in 5.0 only accepts two arguments where’s in 5.1 it will accept a third fill argument.

Please refer to issue for further details.


Thank you for your help.