# Slow log took time questions

**URL:** https://discuss.elastic.co/t/slow-log-took-time-questions/337384
**Category:** Elasticsearch
**Tags:** rally
**Created:** [July 2, 2023, 2:08am UTC](https://discuss.elastic.co/t/slow-log-took-time-questions/337384 "2023-07-02T02:08:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tengfei225](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tengfei225/32/122664_2.png) [@tengfei225](https://discuss.elastic.co/u/tengfei225)
#### Post date: [July 2, 2023, 2:08am UTC](https://discuss.elastic.co/t/slow-log-took-time-questions/337384/1 "2023-07-02T02:08:42Z")

</div>

Hi

I have some questions about the slow log took time

I want to only get the process time in elasticsearch server using esrally to do the benchmark

So I opened the slow log like below

```auto
PUT /myIndex/_settings
{
    "index.search.slowlog.threshold.fetch.trace": "0s",
    "index.search.slowlog.threshold.query.trace": "0s",
}

```

then I can find all the slow logs in the elastic-cloud-logs\* index, but if I run a query ,there will be two documents logged , one component is query and another is fetch, so which time should I use as the total processing time in es including both query and fetch phase

query phase log

```auto
{
 "slowlog": {
              "cluster": {},
              "elasticsearch.slowlog.search_type": "QUERY_THEN_FETCH",
              "elasticsearch.slowlog.took": "278.3micros",
              "elasticsearch.slowlog.message": "[5c43591a_608d_493f_94aa_5da18abecabc][0]",
              "elasticsearch.slowlog.stats": "[]",
              "elasticsearch.slowlog.source": "{}",
              "elasticsearch.slowlog.id": "null",
              "node": {},
              "elasticsearch.slowlog.total_shards": "1",
              "elasticsearch.slowlog.took_millis": "0",
              "elasticsearch.slowlog.total_hits": "10001+ hits"
            }
}

```

fetch phase log

```auto
{
"slowlog": {
              "cluster": {},
              "elasticsearch.slowlog.search_type": "QUERY_THEN_FETCH",
              "elasticsearch.slowlog.took": "1.4ms",
              "elasticsearch.slowlog.message": "[5c43591a_608d_493f_94aa_5da18abecabc][0]",
              "elasticsearch.slowlog.stats": "[]",
              "elasticsearch.slowlog.source": "{}",
              "elasticsearch.slowlog.id": "null",
              "node": {},
              "elasticsearch.slowlog.total_shards": "1",
              "elasticsearch.slowlog.took_millis": "1",
              "elasticsearch.slowlog.total_hits": "10001+ hits"
            }
}

```

Does the "elasticsearch.slowlog.took": "278.3micros" includes both the query and fetch phase time or need to add the time in fetch phase ?

Thanks

---

<div class="post-metadata">

### Author: ![Quentin\_Pradet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quentin_pradet/32/94192_2.png) [@Quentin\_Pradet](https://discuss.elastic.co/u/Quentin_Pradet)
#### Post date: [July 3, 2023, 6:24am UTC](https://discuss.elastic.co/t/slow-log-took-time-questions/337384/2 "2023-07-03T06:24:08Z")

</div>

Hello @tengfei225!

You should use the sum of both times. In that case that would be 1.4ms + 278.3micros, that is 1.4ms + 0.3ms or 1.7ms. I would expect the `took` time reported by the request result to be 2 as 1.7ms rounds to 2ms.

Many Rally operations return that result already, so if you configure metrics ([Metrics - Rally 2.8.0 documentation](https://esrally.readthedocs.io/en/stable/metrics.html)) you may not have to configure slowlog. Search for took in [Track Reference - Rally 2.8.0 documentation](https://esrally.readthedocs.io/en/stable/track.html) to see all operations that store the `took` time. (In some cases enabling `detailed-results` is needed though.)

That said, `took` is a server metric, and in most cases you will care more about the latency as seen by the client. See [Frequently Asked Questions (FAQ) - Rally 2.8.0 documentation](https://esrally.readthedocs.io/en/stable/faq.html#what-do-latency-and-service-time-mean-and-how-do-they-relate-to-the-took-field-that-elasticsearch-returns) for more details.

---

<div class="post-metadata">

### Author: ![tengfei225](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tengfei225/32/122664_2.png) [@tengfei225](https://discuss.elastic.co/u/tengfei225)
#### Post date: [July 3, 2023, 8:12am UTC](https://discuss.elastic.co/t/slow-log-took-time-questions/337384/3 "2023-07-03T08:12:13Z")

</div>

Thanks @Quentin_Pradet , your reply helps a lot .  
Is this reasonable if I separate the query and fetch phase, like I only use fetch phase took time to benchmark the \_source/doc\_value/stored since we have some test cases about which one from \_source/doc\_value/stored is better to retrieve data ? Will this way be more accurate ?

---

<div class="post-metadata">

### Author: ![Quentin\_Pradet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quentin_pradet/32/94192_2.png) [@Quentin\_Pradet](https://discuss.elastic.co/u/Quentin_Pradet)
#### Post date: [July 3, 2023, 12:25pm UTC](https://discuss.elastic.co/t/slow-log-took-time-questions/337384/4 "2023-07-03T12:25:44Z")

</div>

Well, no, using fetch phase isn't a very accurate measurement. It will exclude various things:

- Query phase
- Possibly time spent in queues inside Elasticsearch (I don't know the details enough to tell)
- Time needed to send the request to Elasticsearch
- Time needed to serialize the JSON response
- Time needed to send the response to a client

See [Search API | Elasticsearch Guide [8.8] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-api-response-body) for the last three bullets.

---

<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 31, 2023, 12:26pm UTC](https://discuss.elastic.co/t/slow-log-took-time-questions/337384/5 "2023-07-31T12:26:11Z")

</div>

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