Kibana 4.1 metric visualization round decimal value

Thanks in advance..
I am using kibana 4.1 and trying to create a metric visualization which returning me a value of 135.649
how can I round off this value 135.65

How can I do this

Indeed, documentation on field formatters in 4.1 is light (I just logged issue 4299 to improve it).

To accomplish number formatting in 4.1, you can do the following:

  • In Settings, go to the index with the field in question
  • On the right-hand side under "Controls" column click the Edit icon next to the field you want to format
  • If it's a numeric field, in the "Format" dropdown you'll see "Number" as one of the options
  • Change the default to the following numeral.js pattern 0,0.[00]
  • Click Update Field

After this, all visualizations using this field will only show two decimal points.

Hi Tanya,
yes with this procedure we can decrease precession but how to round value to the nearest integer using script field functions

I have a netamt value which is of double type now I want to round it to nearest integer value i used the following function in scripted fields in kibana 4.1.1.

Used following scripting calculation to round the value. round(doc['netamt'].value)

I am getting error like undefined method "round" so please suggest me how to apply round function or suitable function to get nearest integer value in kibana.

Thanks,
phani

"round" is not a supported function in Lucene Expressions, which is the default scripting language in Kibana scripted fields.

As mentioned above, field formatters can be combined with scripted metrics, so you should use that to customize the display. To round to the nearest integer, just use '0' or '0,0' as your numeral.js pattern.

Hi Tanya

Thank you for quick reply.I tried the logic which you have mentioned in numeral.js pattern but it is rounding only some values not all.any other function we can apply to round to nearest integer..please suggest me next procedure to achieve that one.

Thanks
phani

Interesting. Could you share some screenshots of your configuration and results of those in terms of not rounding values?

Yeah sure.please find the following value table where i am calculating netamounts.

In database I am using round function .Please find the attached configuration screen shot of netamt in kibana

please suggest me where i am going wrong here?

Thanks,
phani

Whats really needed here is format pattern thats applied only to the metric visualisation.

We have events with numeric values stored with 5 decimal places (for example 0.02340) so need to retain precision, but when we sum them over thousands of events to display as a metric I just want to display an integer value.

3 Likes

Indeed - we are tracking this as an enhancement on Github: https://github.com/elastic/kibana/issues/4957

Hi Tanya,

in our index there is a field having values 0 or 1.
All I want is to present the average in a metric visualization.
The issue is that the result is like "0.9346090399208182" and cannot find how to round that value...

Already tried to set format as Number but no change.
Is this the same case as in the issue mentioned above?

Not really. Could you post your visualization config and field formatter config in screenshots?

There is a field named "foo".
Field formatter: Type=number, Numeral.js format pattern = 0,0.[00]
Visualization: Metric, Aggregation: Average, Field: "foo".

The issue is that the average output is "0.9346090399208182" instead of "0.93".

1 Like

Hi! Ever solved this? I am battling the same foe...

Thanks!

1 Like

I have the same issue. Do you find something?
I tried to set format as Number but no change.

ps: I am using Kibana extended metric in kibana 5.
Do someone had the same issue?

Hi,
I got the same requirement,
How to achieve this on 5.5 Version, Please provide steps.

Regards
Vinay

Hi,

I have the same issue, someone solved this?,

Thanks!!

I think that Visual Builder can accomplish this easily by configuring the right formatter (with Number.js):

You can format any number as you wish.

Thanks!
--Gabriel

Thank you, it worked for me

As I am using AWS Elasticsearch, I do not have option to use any third party plugins.

I need to round off the decimal values of the values in a visualization which are generated using Average aggregation. Hence formatting the field in Settings page would not help.