Kibana 4.1 metric visualization round decimal value


(rajesh) #1

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


(Tanya Bragin) #2

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.


(Phani Nadiminti) #3

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


(Tanya Bragin) #4

"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.


(Phani Nadiminti) #5

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


(Tanya Bragin) #6

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


(Phani Nadiminti) #7

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


(Chris Blackwell) #8

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.


(Tanya Bragin) #9

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


(Kalabakas) #10

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?


(Tanya Bragin) #11

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


(Kalabakas) #12

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".


(Juan Ignacio Carniglia) #13

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

Thanks!


#14

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


#15

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


(Vinay.t) #16

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

Regards
Vinay


(Jorge Cardone) #17

Hi,

I have the same issue, someone solved this?,

Thanks!!


(Gabriel Moskovicz) #18

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


(Vaish) #19

Thank you, it worked for me