# Visualisation CPU percentage is always 0 ( or null?)

**URL:** <https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883>\
**Category:** Kibana\
**Created:** [November 30, 2015, 10:49am UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883 "2015-11-30T10:49:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian\_Martin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrian_martin/32/6167_2.png) [@Adrian\_Martin](https://discuss.elastic.co/u/Adrian_Martin)\
**Post date:** [November 30, 2015, 10:49am UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/1 "2015-11-30T10:49:48Z")

</div>

Struggling to get started here...

I've set up ELK and feeding it some logs via TopBeat.

I can see the data in Discover, (filter set to type:system) I get green bars at the top, 1 every 5 seconds, can see values per item in the table columns...

So,... save search and move to the Visualize tab...

When I change the metrics to X date Histogram @timestamp over Y AVG cpu.system\_p nothing is shown in the visualisation.

The only agg that works is count....can zoom in to 1 per five seconds...

Any Idea what I'm doing wrong?

---

<div class="post-metadata">

**Author:** ![Pieter\_Agenbag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pieter_agenbag/32/4562_2.png) [@Pieter\_Agenbag](https://discuss.elastic.co/u/Pieter_Agenbag)\
**Post date:** [November 30, 2015, 12:48pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/2 "2015-11-30T12:48:58Z")

</div>

If you D oget a visualization for "count" metric , then your timestamps are obviously working and available for the specific time period... so I cant imagine why a "AVG" metric wont work other than the cpu.system\_p values being empty.

But then again you said you Can see values for system\_p on the discover tab ?

Maybe you can post a screenshot of your discover tab , with the system\_p added to the display columns as well as your visualization configuration.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [November 30, 2015, 12:54pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/3 "2015-11-30T12:54:04Z")

</div>

What is the mapping for the field? When I have seen this behaviour in the past it has quite often been due to fields being incorrectly mapped as strings instead of integers and/or floats.

---

<div class="post-metadata">

**Author:** ![Pieter\_Agenbag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pieter_agenbag/32/4562_2.png) [@Pieter\_Agenbag](https://discuss.elastic.co/u/Pieter_Agenbag)\
**Post date:** [November 30, 2015, 12:58pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/4 "2015-11-30T12:58:04Z")

</div>

My first thought as well , but the metric configuration wont let you choose string type fields - so I'm assuming its mapped as a numeric type.  
And I believe a number type is a number - theres no strict integer casting that would round an average down to 0 (unless configured in the Kibana field formatter) ?

**Update:** Strike that , I was confused.

---

<div class="post-metadata">

**Author:** ![Adrian\_Martin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrian_martin/32/6167_2.png) [@Adrian\_Martin](https://discuss.elastic.co/u/Adrian_Martin)\
**Post date:** [November 30, 2015, 4:09pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/5 "2015-11-30T16:09:12Z")

</div>

ELK Stack is on Ubuntu

Topbeat is running on Windows 7 - pretty much the default config just addresses changed:

Discover screen

 ![](https://us1.discourse-cdn.com/elastic/original/2X/7/7dbbeb7bfd01143b55e327adaa0679c82c016a0d.png)

this is visState from settings/Objects

```
{
"type": "histogram",
"params": {
	"shareYAxis": true,
	"addTooltip": true,
	"addLegend": true,
	"scale": "linear",
	"mode": "stacked",
	"times": [],
	"addTimeMarker": false,
	"defaultYExtents": false,
	"setYExtents": false,
	"yAxis": {}
},
"aggs": [
	{
	"id": "1",
	"type": "avg",
	"schema": "metric",
	"params": {
		"field": "cpu.system_p"
	}
	},
	{
	"id": "2",
	"type": "date_histogram",
	"schema": "segment",
	"params": {
		"field": "@timestamp",
		"interval": "auto",
		"customInterval": "2h",
		"min_doc_count": 1,
		"extended_bounds": {}
	}
	}
],
"listeners": {}
}
```

---

<div class="post-metadata">

**Author:** ![Pieter\_Agenbag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pieter_agenbag/32/4562_2.png) [@Pieter\_Agenbag](https://discuss.elastic.co/u/Pieter_Agenbag)\
**Post date:** [December 2, 2015, 8:04am UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/6 "2015-12-02T08:04:56Z")

</div>

I'm sorry , I cant see any reason it should not be plotting.  
Out of curiosity .. does average on for instance mem.used\_p work ?  
Or how about sum of cpu.system\_p ?

I'll see if I can get some topbeat going at some point to simulate the situation.

---

<div class="post-metadata">

**Author:** ![Adrian\_Martin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrian_martin/32/6167_2.png) [@Adrian\_Martin](https://discuss.elastic.co/u/Adrian_Martin)\
**Post date:** [December 2, 2015, 9:25am UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/7 "2015-12-02T09:25:52Z")

</div>

...hmmm just got to work to double check your questions, added the Vis for avg CPU.system\_p and user\_p ( bar chart) ....and noticed values....strange...widened the time span to last 12hrs. I get AGGs from midnight only!

Two things I changed, 1, TopBeat is now installed as a service on the monitored machine, since about 10am yesterday, if that was the fix then then why from midnight? Is there some daily 'bucket' of data and the prior days bucket has bad data?

Logstash is running as Linux service...I was running it from the terminal before as I had it sending to STDOUT whilst I was trying to learn what was going on...but I'm wondering, if i had two copies of Logstash running, one as a service and one at the Terminal....

 ![](https://us1.discourse-cdn.com/elastic/original/2X/f/faef414d60a11a885c5cb2380c1fb97f4fed2bae.png)

---

<div class="post-metadata">

**Author:** ![Adrian\_Martin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrian_martin/32/6167_2.png) [@Adrian\_Martin](https://discuss.elastic.co/u/Adrian_Martin)\
**Post date:** [December 2, 2015, 11:18am UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/8 "2015-12-02T11:18:21Z")

</div>

More poking around, the index/mapping for the none working days are set to type long...

/logstash-2015.12.01/\_mapping/system/field/cpu.system\_p

```
{
	"logstash-2015.12.01": {
		"mappings": {
			"system": {
				"cpu.system_p": {
					"full_name": "cpu.system_p",
					"mapping": {
					"system_p": {
					"type": "long"
						}
					}
				}
			}
		}
	}
}

```

but now, today, they are set to double...

```
/logstash-2015.12.02/_mapping/system/field/cpu.system_p

{
	"logstash-2015.12.02": {
		"mappings": {
			"system": {
				"cpu.system_p": {
					"full_name": "cpu.system_p",
					"mapping": {
						"system_p": {
							"type": "double"
						}
					}
				}
			}
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![Pieter\_Agenbag](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pieter_agenbag/32/4562_2.png) [@Pieter\_Agenbag](https://discuss.elastic.co/u/Pieter_Agenbag)\
**Post date:** [December 2, 2015, 1:31pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/9 "2015-12-02T13:31:11Z")

</div>

Aw man - I should have picked that up , since I had almost exactly the same problem - but the other way around (one was double and the other long) which resulted averages in the trillions ... and I feel doubly 😉 bad as I previously stated that there is no strict integer vs double types. I was confusing myself with the types Kibana maps to the ES types.

I would definitely say the "double" would do the trick and is almost certainly why you Are seeing averages for today.  
What is strange is that you Did still see percentage values for yesterday when it was mapped as long.

Maybe I should just keep quiet before I put my foot in my mouth again.

---

<div class="post-metadata">

**Author:** ![elvarb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elvarb/32/44840_2.png) [@elvarb](https://discuss.elastic.co/u/elvarb)\
**Post date:** [February 22, 2016, 2:10pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/10 "2016-02-22T14:10:43Z")

</div>

With topbeat comes a topbeat.template.json file that you must insert as a template to your elasticsearch cluster.

[https://www.elastic.co/guide/en/beats/topbeat/current/topbeat-template.html](https://www.elastic.co/guide/en/beats/topbeat/current/topbeat-template.html)

---

<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:** [July 6, 2017, 2:01pm UTC](https://discuss.elastic.co/t/visualisation-cpu-percentage-is-always-0-or-null/35883/11 "2017-07-06T14:01:25Z")

</div>


