# Creating latency graph using timelion or line graph

**URL:** <https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [March 6, 2019, 2:27pm UTC](https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132 "2019-03-06T14:27:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dheerajbtu](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dheerajbtu](https://discuss.elastic.co/u/Dheerajbtu)\
**Post date:** [March 6, 2019, 2:27pm UTC](https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132/1 "2019-03-06T14:27:07Z")

</div>

Hi,

I have some documents in elasticsearch, below is the sample document.

{  
"\_index": "mulesoft-log-mon-2019.03.05",  
"\_type": "doc",  
"\_id": "yCPzTWkBSDlUxQpoJfQf",  
"\_score": 1,  
"\_source": {  
"policyViolation": null,  
"transactionId": null,  
"applicationName": "CBS Monitoring App",  
"userAgent": "runscope-radar/2.0",  
"hostId": "mule.qa.2",  
"requestBytes": 65,  
"apiVersion": "1.0.0",  
"eventId": "2-bce585b0-2382-11e9-8b05-0242ac120002",  
"orgId": "eeb3ccb6-a2f4-4c7b-9459-7202183bce03",  
"apiVersionId": 15552430,  
"clientId": "fadce792e5124b7eb7cd8bef2026717f",  
"repliedTs": "2019-01-29T00:00:06.121-05:00",  
"instanceName": "1.0.0:15552430",  
"host": "L-156106076",  
"receivedTs": "2019-01-29T00:00:03.339-05:00",  
"@version": "1",  
"requestDisposition": "PROCESSED",  
"responseBytes": 2661,  
"apiId": 210966762,  
"path": "/hma/v1.0/mc/offers/recommended?t=e6ceaa7b-f6cb-4df9-90ae-9cf6f6428bf0&n=1000&so=asc&i=0&sb=OT",  
"@timestamp": "2019-03-05T13:02:48.780Z",  
"type": "json",  
"verb": "POST",  
"statusCode": 200,  
"clientIp": "10.129.40.136",  
"apiName": "hannafordmobile-xapi"  
}  
}

My requirement is I need to plot a graph using (receivedTs) and (repliedTs), where both are date fields.

It is more like when was request received and replied for it (which is in seconds/millisecs).

Two different lines.

Something like below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/b/7bca95aa11e8ef3a0d14d1da7b32012a9db8c65b.png)  
Can any one help me out with it.

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [March 7, 2019, 2:02pm UTC](https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132/2 "2019-03-07T14:02:43Z")

</div>

Hey,

what is on your Y axis ?  
in timelion you can plot two lines just by separating definitions with comma:  
`.es(timefield=receivedTs), .es(timefied=repliedTs)`

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [March 7, 2019, 3:13pm UTC](https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132/5 "2019-03-07T15:13:49Z")

</div>

yes, something like this should work:

`.es(*).divide(.es(*))` (one serie devided with the other)  
`.es(...), .es(....), .es(...).divide(.es(...))` to do 3

---

<div class="post-metadata">

**Author:** ![Dheerajbtu](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@Dheerajbtu](https://discuss.elastic.co/u/Dheerajbtu)\
**Post date:** [March 7, 2019, 3:41pm UTC](https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132/6 "2019-03-07T15:41:28Z")

</div>

Hi @ppisljar,

Sorry it was my bad, I have not observed the query. There was "l" missing in timefield.

with little bit of search was able to find subtraction (.es(timefield=receivedTs).subtract(.es(timefield=repliedTs)).label(timeTaken)).

I had one question:

How can I get only this graph only for "apiName": "hannafordmobile-xapi".

Current query I am using is as below.  
.es(timefield=receivedTs).label(receivedTs), .es(timefield=repliedTs).label(repliedTs), .es(timefield=receivedTs).subtract(.es(timefield=repliedTs)).

Thanks & Regards,  
Dheeraj B

---

<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:** [April 4, 2019, 3:41pm UTC](https://discuss.elastic.co/t/creating-latency-graph-using-timelion-or-line-graph/171132/7 "2019-04-04T15:41:30Z")

</div>

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