# Time since last response

**URL:** https://discuss.elastic.co/t/time-since-last-response/337440
**Category:** Kibana
**Tags:** dashboard
**Created:** [July 3, 2023, 10:32am UTC](https://discuss.elastic.co/t/time-since-last-response/337440 "2023-07-03T10:32:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tomwood](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@tomwood](https://discuss.elastic.co/u/tomwood)
#### Post date: [July 3, 2023, 10:32am UTC](https://discuss.elastic.co/t/time-since-last-response/337440/1 "2023-07-03T10:32:28Z")

</div>

I'm trying to create a visualisation in Kibana dashboard that shows the UP Time of some API's and also shows when they last logged a response into Elastic. I want to colour each api's info green, amber or red, depending on when they last logged a response to elastic. How would I go about doing this?

I can only seem to get it to show the up time or last response time but not colour it or group it by time since the last response

---

<div class="post-metadata">

### Author: ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)
#### Post date: [July 3, 2023, 8:39pm UTC](https://discuss.elastic.co/t/time-since-last-response/337440/2 "2023-07-03T20:39:23Z")

</div>

Hi Thomas. I think you would need a formula in Lens like `last_value(timestamp, kql='timestamp: *')` and use the Color by value option. Here's an example screenshot.

 ![Lens-last_value](https://us1.discourse-cdn.com/elastic/original/3X/0/0/00c0d0e955283690eade3079937040f595c421cd.jpeg)

---

<div class="post-metadata">

### Author: ![tomwood](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@tomwood](https://discuss.elastic.co/u/tomwood)
#### Post date: [July 4, 2023, 8:19am UTC](https://discuss.elastic.co/t/time-since-last-response/337440/3 "2023-07-04T08:19:09Z")

</div>

Hi, I've tried that and it doesn't seem to work?  
It doesn't like the type of the timestamp field?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/4/3462a7e634a53883201301bab71b09bbef7f4853.png)

---

<div class="post-metadata">

### Author: ![tomwood](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@tomwood](https://discuss.elastic.co/u/tomwood)
#### Post date: [July 4, 2023, 8:32am UTC](https://discuss.elastic.co/t/time-since-last-response/337440/4 "2023-07-04T08:32:37Z")

</div>

Just thought it might be helpful info. I'm on Elastic 7.17.9 and can't update

---

<div class="post-metadata">

### Author: ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)
#### Post date: [July 5, 2023, 8:35pm UTC](https://discuss.elastic.co/t/time-since-last-response/337440/5 "2023-07-05T20:35:46Z")

</div>

Hi Thomas. Sadly, `last_value` does not work with Datetime fields in v7.17. I was testing on v8.8.2.

You could create a runtime field on your index pattern to convert the timestamp to a double of epoch milliseconds. Then use that field in your formula.

This is the script I used for a runtime field called `timestamp_epoch`.

```auto
ZonedDateTime input = doc['timestamp'].value;
long milliSinceEpoch = input.toInstant().toEpochMilli();
emit(milliSinceEpoch)

```

Then I can use the formula `last_value(timestamp_epoch)` in my Lens visualization.

 ![Screenshot 2023-07-05 at 16-35-14 Lens - Elastic](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2cecc1d3e79de536531af68534de9be42ea7b94a.jpeg)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 2, 2023, 8:36pm UTC](https://discuss.elastic.co/t/time-since-last-response/337440/6 "2023-08-02T20:36:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
