Grafana machine state time monitor

Hi all,
I’m completly beginner in Grafana. Started like few days ago. Working with InfluxDB and I would like to do the next. I have a Machine State variable for an automated production line wich can be 1 = Run, 2 = Stop, 3 = Block, 4 = Starve. I would like to create a timer for each state where I can monitor how much time the machine spent in it for example from 6:00 to 14:00. I cant able to create plus variables in InfluxDB so I need to do it with Grafana variables.
Wich is the easiest way to do this?

Thank you!:v: