# How to iterate and convert numbers to million/billion in Kibana watcher?

**URL:** <https://discuss.elastic.co/t/how-to-iterate-and-convert-numbers-to-million-billion-in-kibana-watcher/170548>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 1, 2019, 6:49pm UTC](https://discuss.elastic.co/t/how-to-iterate-and-convert-numbers-to-million-billion-in-kibana-watcher/170548 "2019-03-01T18:49:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrGetfit1234](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@MrGetfit1234](https://discuss.elastic.co/u/MrGetfit1234)\
**Post date:** [March 1, 2019, 6:49pm UTC](https://discuss.elastic.co/t/how-to-iterate-and-convert-numbers-to-million-billion-in-kibana-watcher/170548/1 "2019-03-01T18:49:57Z")

</div>

hi, I am writing a Kibana watcher which sends a daily email aggregating number of log events collected on a 24 hour period. In the body of the email it should give a summary of how many unique ip's contributed and how many million of logs in total for the day.

I know that I can use a transform script to count number of log events per day iteratively. How do I format it to millions and billions?

---

<div class="post-metadata">

**Author:** ![justinw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justinw/32/40277_2.png) [@justinw](https://discuss.elastic.co/u/justinw)\
**Post date:** [March 13, 2019, 12:42am UTC](https://discuss.elastic.co/t/how-to-iterate-and-convert-numbers-to-million-billion-in-kibana-watcher/170548/2 "2019-03-13T00:42:24Z")

</div>

In the transform script you can do math like any normal variable modification. For instance, I have something like this:

```auto
totalRam: _source.system.memory.total / 1024 / 1024 / 1024

```

---

<div class="post-metadata">

**Author:** ![MrGetfit1234](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@MrGetfit1234](https://discuss.elastic.co/u/MrGetfit1234)\
**Post date:** [March 15, 2019, 3:37pm UTC](https://discuss.elastic.co/t/how-to-iterate-and-convert-numbers-to-million-billion-in-kibana-watcher/170548/3 "2019-03-15T15:37:05Z")

</div>

Thank you. I ended up using something along similar lines for my code in transform:

String.format('%,d', new def {number})

---

<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 12, 2019, 3:37pm UTC](https://discuss.elastic.co/t/how-to-iterate-and-convert-numbers-to-million-billion-in-kibana-watcher/170548/4 "2019-04-12T15:37:10Z")

</div>

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