# Metric visualization with date range calculation

**URL:** <https://discuss.elastic.co/t/metric-visualization-with-date-range-calculation/267644>\
**Category:** Kibana\
**Created:** [March 18, 2021, 11:16am UTC](https://discuss.elastic.co/t/metric-visualization-with-date-range-calculation/267644 "2021-03-18T11:16:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alytkowski](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@alytkowski](https://discuss.elastic.co/u/alytkowski)\
**Post date:** [March 18, 2021, 11:16am UTC](https://discuss.elastic.co/t/metric-visualization-with-date-range-calculation/267644/1 "2021-03-18T11:16:19Z")

</div>

I have a metric type data that I get every 10s from the EMS Server and one of the properties is: inbound message count. It's a total inbound message count for the EMS server. What I'd like to achieve is to create a metric that will show me how many messages came to EMS, so for example, at 12:00 Elastic gets inMessageCount=1000 and at 13:00 it gets inMessageCount=2000. How to create a metric that will count the difference (2000-1000)? That should be based on time range set in dashboard.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [March 22, 2021, 10:15am UTC](https://discuss.elastic.co/t/metric-visualization-with-date-range-calculation/267644/2 "2021-03-22T10:15:07Z")

</div>

Hi, you can use TSVB for that and apply the `Counter Rate` aggregation. This basically applies in sequence: a max aggregation over the current date histogram (getting the last counter value), then apply a derivative to get the difference between that value and the previous bucket. If the counter resets at a specific number, the "counter rate" applies also the positive only function seeing a huge negative dip in the rate.  
The mechanism is also described here: [Visualizing observability with Kibana: Event rates and rate of change in TSVB | Elastic Blog](https://www.elastic.co/blog/visualizing-observability-with-kibana-event-rates-and-rate-of-change-in-tsvb)

---

<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, 2021, 10:15am UTC](https://discuss.elastic.co/t/metric-visualization-with-date-range-calculation/267644/3 "2021-04-19T10:15:36Z")

</div>

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