Rashid
Rashid

Reputation: 73

Dividing 2 integer fields using Lucene Expression in Kibana

In Kibana, I'm trying to use Lucene Expression to divide the values of two integer fields.

doc['myval'].value / doc['myvalue'].value

However, the above particular formula doesn't seems to be producing any result. I haven tried to do some changes to this formula putting them in brackets, but still it is not working.

(doc['myval'].value) / (doc['myvalue'].value)

Alternatively, I can divide one field with a numeric value like: doc['myval'].value / 100. Also I can be able to +, - and * between the values in these two fields. But division seems to be not working.

Some of the sample values of fields can be 394,567, 800,567, etc.

How can I divide two integer fields using Lucene expression in Kibana?

Upvotes: 0

Views: 2645

Answers (1)

v_sukt
v_sukt

Reputation: 1442

I had similar problem earlier had dropped it after trying much, it was due to wrong data type of the fields. Now testing on ELK5.6 its working fine. Please make changes:

  • check in the scripted field setting the language should be expression(as this is lucene syntax)
  • in the script part follow following syntax for division

    doc['field_1'].value / doc[field_2].value

where field_1 and field_2 are actual fields in the index.

Some checks :

  • ensure the fields - field_1 and field_2 are visible in the index and have correct format. e.g. integers(numbers) or float as only they can do the division
  • check if you are able to see the field in the Discover tab of kibana (if everything works fine you'll be able to see the resultant value)
  • If the value produced in the last stage is not in expected form edit the scripted field and check the input and output formats (output should be number - if you want to do sum/avg etc on it in visualizations)

Upvotes: 1

Related Questions