# Strange visualisation behaviour with floating point numbers

**URL:** <https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449>\
**Category:** Kibana\
**Created:** [September 5, 2018, 5:16pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449 "2018-09-05T17:16:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![smilin\_stan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@smilin\_stan](https://discuss.elastic.co/u/smilin_stan)\
**Post date:** [September 5, 2018, 5:16pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/1 "2018-09-05T17:16:12Z")

</div>

I am using the jolokia module in metricbeats which is capturing (amongst other things) the following system stats:

![33](https://us1.discourse-cdn.com/elastic/original/3X/1/c/1c1b1cbf6188168224cf64c4cf320bba498ec027.png)

I am trying to graph the maximum CPU idle percentage (the system.cpu.idle.pct field), which is a floating point number which averages 3.99:

 ![21](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a5ea7e99f7010b36e5c9519177722dfc222651c3.png)

However, my graph shows a consistent line of value 1:

 ![12](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74861fb8329dfa897fca05d3862898ca3e4e658a.png)

Kibana has identified the field as a number, not a string. Does anyone have any ideas what I'm doing wrong?

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 5, 2018, 5:23pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/2 "2018-09-05T17:23:41Z")

</div>

Can you open the inspector for the visualization? What do the request and response look like?

---

<div class="post-metadata">

**Author:** ![smilin\_stan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@smilin\_stan](https://discuss.elastic.co/u/smilin_stan)\
**Post date:** [September 5, 2018, 5:32pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/3 "2018-09-05T17:32:45Z")

</div>

The request is:

```
{
  "size": 0,
  "_source": {
	"excludes": []
  },
  "aggs": {
	"2": {
	  "date_histogram": {
		"field": "@timestamp",
		"interval": "1m",
		"time_zone": "Europe/London",
		"min_doc_count": 1
	  },
	  "aggs": {
		"1": {
		  "max": {
			"field": "system.cpu.idle.pct"
		  }
		}
	  }
	}
  },
  "stored_fields": [
	"*"
  ],
  "script_fields": {},
  "docvalue_fields": [
	"@timestamp",
	"system.process.cpu.start_time"
  ],
  "query": {
	"bool": {
	  "must": [
		{
		  "match_all": {}
		},
		{
		  "match_phrase": {
			"component": {
			  "query": "ui"
			}
		  }
		},
		{
		  "exists": {
			"field": "system.cpu.idle.pct"
		  }
		},
		{
		  "range": {
			"@timestamp": {
			  "gte": 1536164633286,
			  "lte": 1536168233286,
			  "format": "epoch_millis"
			}
		  }
		}
	  ],
	  "filter": [],
	  "should": [],
	  "must_not": []
	}
  }
}

```

Response:

```
{
  "took": 10,
  "timed_out": false,
  "_shards": {
	"total": 25,
	"successful": 25,
	"skipped": 0,
	"failed": 0
  },
  "hits": {
	"total": 360,
	"max_score": 0,
	"hits": []
  },
  "aggregations": {
	"2": {
	  "buckets": [
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:23:00.000+01:00",
		  "key": 1536164580000,
		  "doc_count": 1
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:24:00.000+01:00",
		  "key": 1536164640000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:25:00.000+01:00",
		  "key": 1536164700000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:26:00.000+01:00",
		  "key": 1536164760000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:27:00.000+01:00",
		  "key": 1536164820000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:28:00.000+01:00",
		  "key": 1536164880000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:29:00.000+01:00",
		  "key": 1536164940000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:30:00.000+01:00",
		  "key": 1536165000000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:31:00.000+01:00",
		  "key": 1536165060000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T17:32:00.000+01:00",
		  "key": 1536165120000,
		  "doc_count": 6
		},
		
		<.... snip ....>
		
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:14:00.000+01:00",
		  "key": 1536167640000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:15:00.000+01:00",
		  "key": 1536167700000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:16:00.000+01:00",
		  "key": 1536167760000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:17:00.000+01:00",
		  "key": 1536167820000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:18:00.000+01:00",
		  "key": 1536167880000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:19:00.000+01:00",
		  "key": 1536167940000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:20:00.000+01:00",
		  "key": 1536168000000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:21:00.000+01:00",
		  "key": 1536168060000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:22:00.000+01:00",
		  "key": 1536168120000,
		  "doc_count": 6
		},
		{
		  "1": {
			"value": 1
		  },
		  "key_as_string": "2018-09-05T18:23:00.000+01:00",
		  "key": 1536168180000,
		  "doc_count": 5
		}
	  ]
	}
  },
  "status": 200
}
```

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 5, 2018, 5:48pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/4 "2018-09-05T17:48:28Z")

</div>

Looks like the request includes the query `ui`. Maybe this is filtering out documents with higher values? Try the request in the `dev-tools` application and set `size` to 100 so you can see some of the documents that are getting used for the aggregation.

```auto
"match_phrase": {
  "component": {
    "query": "ui"
  }
 }

```

---

<div class="post-metadata">

**Author:** ![smilin\_stan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@smilin\_stan](https://discuss.elastic.co/u/smilin_stan)\
**Post date:** [September 6, 2018, 9:57am UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/5 "2018-09-06T09:57:07Z")

</div>

Thanks! I can see that many were being filtered out, my bad, the maximum is actually below:

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

So it's 1.9 instead of 3.9. How come the values being returned in the visualization are integers and not floats?

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 6, 2018, 2:15pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/6 "2018-09-06T14:15:01Z")

</div>

What is the mapping for field `system.cpu.idle.pct`? Under `Management` -\> `Index Pattern`? What field formatter is being used for that field?

---

<div class="post-metadata">

**Author:** ![smilin\_stan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@smilin\_stan](https://discuss.elastic.co/u/smilin_stan)\
**Post date:** [September 6, 2018, 4:01pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/7 "2018-09-06T16:01:38Z")

</div>

The mapping is set to number. The field format is the default (I haven't changed/customised it) and this is set to number also:

![10](https://us1.discourse-cdn.com/elastic/original/3X/8/6/86e688fb4d2a326dc25137bb70567fa8f846385a.png)

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 6, 2018, 4:16pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/8 "2018-09-06T16:16:40Z")

</div>

What is the field mapping in elasticsearch?

[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html)

---

<div class="post-metadata">

**Author:** ![smilin\_stan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@smilin\_stan](https://discuss.elastic.co/u/smilin_stan)\
**Post date:** [September 6, 2018, 4:58pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/9 "2018-09-06T16:58:35Z")

</div>

Thank you!

The mapping in ES was set to long and not float. I have created an index template:

```
      "percentages_as_float": {
        "mapping": {
          "type": "float"
        },
        "match": "pct",
        "match_mapping_type": "*"
      }

```

I created a new index and now it's working fine!

I was a bit thrown because I could see floats in Kibana; I thought ES _must_ be storing them as floats because they'd be truncated as ints otherwise. I guess not!

---

<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 4, 2018, 4:58pm UTC](https://discuss.elastic.co/t/strange-visualisation-behaviour-with-floating-point-numbers/147449/10 "2018-10-04T16:58:38Z")

</div>

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