Script field - decimal multiplication is not working

(Britto) #1

Using Kibana UI, I created a new script field named "cpu_util_percnt". Value of this field will be calculated based on the following expression:

Here, "metric value number" is an existing field with long data type.

In the "Discover" tab, I could find the new field "cpu_util_percnt" and then selected it for performing a search. When I validated the search results, I noticed the following things as shown in the below table:

metric_value_number cpu_util_percnt
1020 102000
0.12 0
2345 234500
0.230 0

Here, we could find that the whole number multiplication works correctly and provides expected result. For example, 1020 * 100 = 1020000. But, the decimal multiplication yields wrong results, i.e., 0.12* 100 should results 12. But, it yields 0.

Kindly check and tell me how to correct the above things to achieve the expected result.

(Lukas Olson) #2

I just tried to replicate this issue and can't seem to. It seems to be working fine for me. Would you mind telling me what version of Kibana and Elasticsearch you're using?

(Britto) #3

I am using the following things:

Elastic search 2.1.1
Logstash 2.1.1
Kibana 4.3.1

(Christian Dahlqvist) #4

If the field is mapped as long, why are you storing values with decimal points in it?

(Britto) #5

Hi Sorry. In Kibana field settings, it shows that the field "metric value number" has the data type of "number". I incorrectly specified as Long. The other field "cpu_util_percnt" where we are trying to store the expression result also a number data type field.

(Christian Dahlqvist) #6

What does the mapping in Elasticsearch say about the mapping for the field?

(Britto) #7

I like to convey one thing. In Elastic search, the field type is "long". The type of the same field in Kibana is Number.

(system) #8