# Trouble visualizing CPU utilization

**URL:** <https://discuss.elastic.co/t/trouble-visualizing-cpu-utilization/99856>\
**Category:** Kibana\
**Created:** [September 8, 2017, 1:46pm UTC](https://discuss.elastic.co/t/trouble-visualizing-cpu-utilization/99856 "2017-09-08T13:46:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matty](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@Matty](https://discuss.elastic.co/u/Matty)\
**Post date:** [September 8, 2017, 1:46pm UTC](https://discuss.elastic.co/t/trouble-visualizing-cpu-utilization/99856/1 "2017-09-08T13:46:16Z")

</div>

I am using metricbeat to visualize system and network performance across my fleet. It works great! One thing I' having a hard time with is getting CPU used vs. CPU idle. I would like to be able to subtract system.cpu.idle.pct  
from 100 to get the current utilization. The following forum post suggested using scripted fields:

> [@Metricbeat CPU usage total](https://discuss.elastic.co/t/metricbeat-cpu-usage-total/84260):
>
> Hiya, Metricbeat is working nicely for me but what I want to see for my servers are how busy they are. I get the CPU usage in parts (user, system, steal etc) and the idle %, what I want is the total usage as a percentage; the opposite of the idle percent value. I expect the answer might be a TimeLion based one but I can't get that to work. Is there a really good TimeLion tutorial out there? My solution in the end was to use logstash and a bit of ruby in the filter section like this: if [@me…

I created a scripted field with the following attributes:

Index -\> metricbeat-\*  
Name -\> cpuutilization  
Language -\> expression  
Type: number  
Format -\> default  
Script -\> 100 - doc['system.cpu.idle.pct'].value

And used the following video as a starting point:

> **[Using Painless in Kibana scripted fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields)**

My field isn't showing up under discover and refreshing the fields doesn't appear to help. First off, is this the ideal way to get actual utilization? Second, any idea why the cpuutilization field isn't showing up?

---

<div class="post-metadata">

**Author:** ![Matty](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@Matty](https://discuss.elastic.co/u/Matty)\
**Post date:** [September 8, 2017, 2:59pm UTC](https://discuss.elastic.co/t/trouble-visualizing-cpu-utilization/99856/2 "2017-09-08T14:59:15Z")

</div>

I solved by own problem. The system.cpu.\* values returned by metricbeat are percentages so I needed to set format to a percentage. Now my graphs are rendering correctly.

---

<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 6, 2017, 2:59pm UTC](https://discuss.elastic.co/t/trouble-visualizing-cpu-utilization/99856/3 "2017-10-06T14:59:27Z")

</div>

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