# Create panel to display latency time using two datetime fields

**URL:** <https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430>\
**Category:** Elasticsearch\
**Created:** [March 18, 2014, 3:16pm UTC](https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430 "2014-03-18T15:16:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![computer\_engineer](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@computer\_engineer](https://discuss.elastic.co/u/computer_engineer)\
**Post date:** [March 18, 2014, 3:16pm UTC](https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430/1 "2014-03-18T15:16:13Z")

</div>

I would like to display in a panel the lagtime between two times that come  
in a message. I have no idea how to initiate it and would appreciate some  
help:

inDate "2014-03-18 05:00:00" outDate: "2014-03-18 05:05:00"

lagtime = outdate - indate

So what I would expect is lagtime to show average lagtime coming in for all.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/90c09d4c-e138-48f1-b1c5-a8d6738255ef%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/90c09d4c-e138-48f1-b1c5-a8d6738255ef%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 18, 2014, 11:40pm UTC](https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430/2 "2014-03-18T23:40:17Z")

</div>

If you are referring to a Kibana panel, it sounds like you want something  
like the histogram panel, except you want a script to get the value instead  
of a field. The date histogram facet actually supports a value\_script  
computation, so you should be able to make a copy of Kibana histogram  
panel, and slightly modify the call to the date histogram facet to pass in  
your script into the value\_script field.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1c8f6a13-d603-403b-a8de-f5557b75b97b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1c8f6a13-d603-403b-a8de-f5557b75b97b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![computer\_engineer](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@computer\_engineer](https://discuss.elastic.co/u/computer_engineer)\
**Post date:** [March 25, 2014, 6:45pm UTC](https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430/3 "2014-03-25T18:45:12Z")

</div>

Thanks for your response but I am completely confused here: I am actually  
stuck on what the script would be. Technically I could put in a table  
format as well but the actual query is what I am unsure about; the script?

On Tuesday, March 18, 2014 7:40:17 PM UTC-4, Binh Ly wrote:

> If you are referring to a Kibana panel, it sounds like you want something  
> like the histogram panel, except you want a script to get the value instead  
> of a field. The date histogram facet actually supports a value\_script  
> computation, so you should be able to make a copy of Kibana histogram  
> panel, and slightly modify the call to the date histogram facet to pass in  
> your script into the value\_script field.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d9e3dd38-6e7d-42ff-b323-076ab42f2550%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d9e3dd38-6e7d-42ff-b323-076ab42f2550%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 26, 2014, 5:53pm UTC](https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430/4 "2014-03-26T17:53:39Z")

</div>

On this page:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-date-histogram-facet.html#search-facets-date-histogram-facet](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-date-histogram-facet.html#search-facets-date-histogram-facet)

If you scroll down to the bottom, there is an example for value\_script. In  
your case, the value\_script would be something like (the result is in  
milliseconds, btw, so just convert accordingly if needed):

doc['outDate'].value - doc['inDate'].value

Again this is not supported by the Histogram Panel out of the box, but you  
can implement it yourself using a new panel, or by hacking the Histogram  
Panel.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0ed2b6f2-e201-469f-88e1-7b147740c405%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0ed2b6f2-e201-469f-88e1-7b147740c405%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:40am UTC](https://discuss.elastic.co/t/create-panel-to-display-latency-time-using-two-datetime-fields/16430/5 "2017-07-06T01:40:27Z")

</div>

Closed on July 6, 2017, 1:40am UTC


