# Marvel search latency does not match query time

**URL:** https://discuss.elastic.co/t/marvel-search-latency-does-not-match-query-time/79597
**Category:** Elasticsearch
**Tags:** elastic-stack-monitoring
**Created:** [March 22, 2017, 2:24pm UTC](https://discuss.elastic.co/t/marvel-search-latency-does-not-match-query-time/79597 "2017-03-22T14:24:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Maxwell\_Flanders](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@Maxwell\_Flanders](https://discuss.elastic.co/u/Maxwell_Flanders)
#### Post date: [March 22, 2017, 2:24pm UTC](https://discuss.elastic.co/t/marvel-search-latency-does-not-match-query-time/79597/1 "2017-03-22T14:24:17Z")

</div>

I have been testing the length of queries using the linux time command, ex.

`time curl -s "IPADDRESS:9200/INDEX/_search?pretty" -d{ES_QUERY}`

Some queries appear on the command line end to take anywhere from 1 to 10 seconds. However, when looking at the marvel stats, there has never been a search latency of over 1000ms, and they typically stay under 500ms, even when queries on my end appear to be taking a long time.

What might account for this discrepancy?? I'd at least expect some of the long queries to show up as spikes on the search latency chart.

Thank you!

---

<div class="post-metadata">

### Author: ![pickypg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pickypg/32/62409_2.png) [@pickypg](https://discuss.elastic.co/u/pickypg)
#### Post date: [March 22, 2017, 2:42pm UTC](https://discuss.elastic.co/t/marvel-search-latency-does-not-match-query-time/79597/2 "2017-03-22T14:42:10Z")

</div>

Hi @Maxwell_Flanders,

Query latency is calculated on a _per shard_ basis. This means that, while the overall search may be slow, it may be relatively fast at the per shard level.

Can you show the header of the response that you're looking at? Particularly:

```auto
{
  "took": 12345,
  "_shards": { ... }

```

---

<div class="post-metadata">

### Author: ![Maxwell\_Flanders](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@Maxwell\_Flanders](https://discuss.elastic.co/u/Maxwell_Flanders)
#### Post date: [March 22, 2017, 2:46pm UTC](https://discuss.elastic.co/t/marvel-search-latency-does-not-match-query-time/79597/3 "2017-03-22T14:46:36Z")

</div>

@pickypg  
Sure, here is the header for a query that took ~16s

```
  "took" : 16928,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "failed" : 0
  },

```

Similarly, I have my es\_slowlog settings set to report any query that takes over 1 ms. when I run these queries that appear to take a long time, I still never see the slowlogs reporting a time higher than 1000ms.

---

<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 19, 2017, 2:46pm UTC](https://discuss.elastic.co/t/marvel-search-latency-does-not-match-query-time/79597/4 "2017-04-19T14:46:59Z")

</div>

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