# Displaying time lag data as an average over time using TSVB

**URL:** <https://discuss.elastic.co/t/displaying-time-lag-data-as-an-average-over-time-using-tsvb/286536>\
**Category:** Kibana\
**Created:** [October 12, 2021, 6:31pm UTC](https://discuss.elastic.co/t/displaying-time-lag-data-as-an-average-over-time-using-tsvb/286536 "2021-10-12T18:31:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IceKing](https://avatars.discourse-cdn.com/v4/letter/i/76d3ee/32.png) [@IceKing](https://discuss.elastic.co/u/IceKing)\
**Post date:** [October 12, 2021, 6:31pm UTC](https://discuss.elastic.co/t/displaying-time-lag-data-as-an-average-over-time-using-tsvb/286536/1 "2021-10-12T18:31:49Z")

</div>

Hi,

I would like some assistance please.

I'm using Amazon OpenSearch Service (successor to Amazon Elasticsearch Service).

Currently I have set of documents in my index that have following date/time fields

- "CreatedDateTime"
- "ProcessedDateTime"

The CreatedDateTime in the represents when the document was created.  
The ProcessedDateTime represents when my application had successfully processed the document.

For each of the documents I would like to calculate and then display the difference as a single unit / display that as an average over a given period. Essentially I would to display the "lag" over a given period.

I've setup a "script field" on my index pattern. I used this in my script:

`doc['CreatedDateTime'].date.millis - doc['ProcessedDateTime'].date.millis`

I then went to create a TSVB visualisation but I don't know how to use the script field within here.

How could I use TSVB to display what I'm trying to do?  
Is TSVB the correct visualisation to use?

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [October 13, 2021, 2:18pm UTC](https://discuss.elastic.co/t/displaying-time-lag-data-as-an-average-over-time-using-tsvb/286536/2 "2021-10-13T14:18:24Z")

</div>

Unfortunately we are not able to help on this as opensearch is an aws run fork of Elasticsearch and Kibana.

---

<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:** [November 10, 2021, 2:18pm UTC](https://discuss.elastic.co/t/displaying-time-lag-data-as-an-average-over-time-using-tsvb/286536/3 "2021-11-10T14:18:46Z")

</div>

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