# Visualize a Counter from MicroMeter with ElasticAPM

**URL:** <https://discuss.elastic.co/t/visualize-a-counter-from-micrometer-with-elasticapm/285404>\
**Category:** APM\
**Tags:** java\
**Created:** [September 28, 2021, 8:12pm UTC](https://discuss.elastic.co/t/visualize-a-counter-from-micrometer-with-elasticapm/285404 "2021-09-28T20:12:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milanvdm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/milanvdm/32/82732_2.png) [@milanvdm](https://discuss.elastic.co/u/milanvdm)\
**Post date:** [September 28, 2021, 8:12pm UTC](https://discuss.elastic.co/t/visualize-a-counter-from-micrometer-with-elasticapm/285404/1 "2021-09-28T20:12:41Z")

</div>

Im trying out a simple counter with MicroMeter. I have 4 instances of the same application running on k8s and each of them has a counter "counter-example" which they increment.

From what I understand, each increment creates a new document with the new incremented value. This is done for each pod.

Now I want to sum all 4 "counter-example" last values into 1 total value across all instances in a dashboard.

I keep failing as I can't seem to figure out how to do a group-by on last-value and then sum the result.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 29, 2021, 11:16am UTC](https://discuss.elastic.co/t/visualize-a-counter-from-micrometer-with-elasticapm/285404/2 "2021-09-29T11:16:35Z")

</div>

> From what I understand, each increment creates a new document with the new incremented value. This is done for each pod.

We do not capture counter increments, rather we report counter values periodically based on the `metrics_interval` config - see more in the [Micrometer documentation](https://www.elastic.co/guide/en/apm/agent/java/current/metrics.html#metrics-micrometer).

> I keep failing as I can't seem to figure out how to do a group-by on last-value and then sum the result.

Metric docs should contain a `service.node.name` filed, which should be set with the container ID in the case of k8s. So, combining your search for both `service.name` and `service.node.name` should address your needs.

---

<div class="post-metadata">

**Author:** ![milanvdm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/milanvdm/32/82732_2.png) [@milanvdm](https://discuss.elastic.co/u/milanvdm)\
**Post date:** [September 30, 2021, 2:26pm UTC](https://discuss.elastic.co/t/visualize-a-counter-from-micrometer-with-elasticapm/285404/3 "2021-09-30T14:26:39Z")

</div>

> [@Eyal\_Koren](#):
>
> Metric docs should contain a `service.node.name` filed, which should be set with the container ID in the case of k8s. So, combining your search for both `service.name` and `service.node.name` should address your needs.

Combining the search on both `service.name` and `service.node.node` will give me 4 distinct values right? Each showing the last value of each of the corresponding counters.

In Kibina, I select a TSVB visualization, pick a Table. Here I seem to be able to select the aggregation `max` for my counter `example-counter`. This will only show 1 out of the 4 counters I have and there doesnt seem to be a way to sum all 4 counters grouping them by each pod.

---

<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:** [October 21, 2021, 10:27am UTC](https://discuss.elastic.co/t/visualize-a-counter-from-micrometer-with-elasticapm/285404/4 "2021-10-21T10:27:18Z")

</div>

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