# Get count of fields in Kibana

**URL:** <https://discuss.elastic.co/t/get-count-of-fields-in-kibana/98784>\
**Category:** Kibana\
**Created:** [August 30, 2017, 5:08am UTC](https://discuss.elastic.co/t/get-count-of-fields-in-kibana/98784 "2017-08-30T05:08:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kottapar](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@kottapar](https://discuss.elastic.co/u/kottapar)\
**Post date:** [August 30, 2017, 5:08am UTC](https://discuss.elastic.co/t/get-count-of-fields-in-kibana/98784/1 "2017-08-30T05:08:12Z")

</div>

Hello,

we're gathering an inventory of virtual machines from vcenters. I was just wondering if there's a way we can create a new field with a count of total VMs or with a count of the total number of ESX servers or something like the total memory of all VMs.  
However I'm not sure how to get this done. I did try creating scripted fields, but if I understood it right it can used only a doc.

For example, I was able to create a new field converting memory in mb to memory in gb. However how can I create a new field containing the sum of memory of all VMs?

I'm no expert, but I can sense that it doesn't make sense trying to add a field with the same value to all docs. But can we create a new index which contains such calculated values?

---

<div class="post-metadata">

**Author:** ![immavalls](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/immavalls/32/146501_2.png) [@immavalls](https://discuss.elastic.co/u/immavalls)\
**Post date:** [August 30, 2017, 6:44am UTC](https://discuss.elastic.co/t/get-count-of-fields-in-kibana/98784/2 "2017-08-30T06:44:26Z")

</div>

You could create a kibana metric, with a unique count of your hostnames. No need to create a field in elasticsearch.

![metric](https://us1.discourse-cdn.com/elastic/original/3X/a/c/ac1bb43f46392b93469d392754e4a379570a67c3.png)

---

<div class="post-metadata">

**Author:** ![kottapar](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@kottapar](https://discuss.elastic.co/u/kottapar)\
**Post date:** [August 30, 2017, 11:10am UTC](https://discuss.elastic.co/t/get-count-of-fields-in-kibana/98784/3 "2017-08-30T11:10:10Z")

</div>

Thanks a lot! That was a life-saver.

---

<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:** [September 27, 2017, 11:10am UTC](https://discuss.elastic.co/t/get-count-of-fields-in-kibana/98784/4 "2017-09-27T11:10:13Z")

</div>

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