# Calculating MTTR(Mean Time to Recovery)

**URL:** https://discuss.elastic.co/t/calculating-mttr-mean-time-to-recovery/255741
**Category:** Kibana
**Created:** [November 17, 2020, 5:43pm UTC](https://discuss.elastic.co/t/calculating-mttr-mean-time-to-recovery/255741 "2020-11-17T17:43:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sam7](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@sam7](https://discuss.elastic.co/u/sam7)
#### Post date: [November 17, 2020, 5:43pm UTC](https://discuss.elastic.co/t/calculating-mttr-mean-time-to-recovery/255741/1 "2020-11-17T17:43:03Z")

</div>

I have an Index having build failed and succeeded status with respective time stamp. I want to calculate MTTR(Mean Time to Recovery) using scripted field or any other option available. Any suggestions?

---

<div class="post-metadata">

### Author: ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)
#### Post date: [November 19, 2020, 7:13pm UTC](https://discuss.elastic.co/t/calculating-mttr-mean-time-to-recovery/255741/2 "2020-11-19T19:13:06Z")

</div>

If this information is stored in a single document, you can create a Painless scripted field to calculate it.

If the information is stored across multiple documents, you will probably have some kind of ID field? If so, you can run a [transform operation](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html) which can be set up like this:

1. Group by Terms of ID
2. For each ID, group by Terms of status
3. You can add two calculated fields, one to indicate the final status, and another to indicate the time to recover

---

<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: [December 17, 2020, 7:13pm UTC](https://discuss.elastic.co/t/calculating-mttr-mean-time-to-recovery/255741/3 "2020-12-17T19:13:15Z")

</div>

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