# Calculating time spent in state with Metricbeat and Kibana

**URL:** https://discuss.elastic.co/t/calculating-time-spent-in-state-with-metricbeat-and-kibana/269457
**Category:** Kibana
**Created:** [April 7, 2021, 12:01pm UTC](https://discuss.elastic.co/t/calculating-time-spent-in-state-with-metricbeat-and-kibana/269457 "2021-04-07T12:01:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![m\_x](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_x/32/86703_2.png) [@m\_x](https://discuss.elastic.co/u/m_x)
#### Post date: [April 7, 2021, 12:01pm UTC](https://discuss.elastic.co/t/calculating-time-spent-in-state-with-metricbeat-and-kibana/269457/1 "2021-04-07T12:01:57Z")

</div>

Hi,

I would like to calculate the time spent in a certain state with Metricbeat and Kibana . For example : how long have the system been up during specified period ? how long have a user spent logged in ?. I'm discovering Kibana and I can't find a way to do this.

I can plot a metric over time but I find that "time spent in state" gives more insight.

As a workaround, I can plot the number of record over states in a histogram. Assuming the period between two record is constant (normally the case with metricbeat), the number of records is a proxy to "time spent".

My use case is gathering usage statistics on endpoint computers.

Thanks

---

<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: [April 7, 2021, 2:00pm UTC](https://discuss.elastic.co/t/calculating-time-spent-in-state-with-metricbeat-and-kibana/269457/2 "2021-04-07T14:00:26Z")

</div>

This is one of the main reasons to use the [transforms](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html) feature: your data needs to be pivoted before analysis.

---

<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: [May 5, 2021, 2:00pm UTC](https://discuss.elastic.co/t/calculating-time-spent-in-state-with-metricbeat-and-kibana/269457/3 "2021-05-05T14:00:40Z")

</div>

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