Elasticsearch query for time the value has not changed

Hi All,

I am kind of new to elasticsearch queries and I would like to get the information about the time since the last value change, in the following example the time the value is 1 = 5 seconds. Is there a way to do it, if no, can someone think of a way to achieve this?

@timestamp: May 11th 2015, 14:35:43.708 Key: service1 values: 1
@timestamp: May 11th 2015, 14:34:43.708 Key: service1 values: 1
@timestamp: May 11th 2015, 14:33:43.708 Key: service1 values: 1
@timestamp: May 11th 2015, 14:32:43.708 Key: service1 values: 1
@timestamp: May 11th 2015, 14:31:43.708 Key: service1 values: 1
@timestamp: May 11th 2015, 14:30:43.708 Key: service1 values: 0

I am basically trying to figure out my application uptime from this data that we already have.

Thanks & Regards,
Aravind Chennuru