Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bytes field format uses binary units while showing decimal unit labels #7543

Closed
leeway23 opened this issue Jun 24, 2016 · 13 comments
Closed
Labels
enhancement New value added to drive a business result Feature:FieldFormatters

Comments

@leeway23
Copy link

leeway23 commented Jun 24, 2016

Kibana 4.5 is given file sizes in bytes, and the functionality should conveniently translate this number of many digits into the common KB, MB, GB nomenclature using decimal units. The problem is, Kibana uses binary units while showing decimal unit labels KB, MB, GB, TB, PB. This results in misleading and confusing information (see this graphic)

There are two options how to fix this issue (both could be implemented):

  1. use decimal units assigning decimal labels (KB, MB, GB)
  2. use binary units as now while fixing the labels to KiB, MiB, GiB, TiB, PiB etc.

Currently 719373000 bytes gets translated into "685.7MB" instead of "685.7MiB" or "719.4MB".

@Bargs Bargs changed the title KIBANA DISPLAYS WRONG UNIT LABELS ! ! ! Bytes field format uses binary units while showing decimal unit labels Jun 24, 2016
@Bargs
Copy link
Contributor

Bargs commented Jun 24, 2016

Agreed, however this isn't a quick fix since it's an issue in the upstream library we use for number formatting: adamwdraper/Numeral-js#312

@Bargs Bargs added bug Fixes for quality problems that affect the customer experience P2 labels Jun 24, 2016
@leeway23
Copy link
Author

leeway23 commented Aug 17, 2016

Hi All,

For your parameter e.g. number of bytes of memory used called ‘avgRSS’ one can create a scripted field in Kibana with the following formula:

name of the scripted field: avgRSS_main_reco
Type : Bytes
Script: doc[‘avgRSS'].value * pow(1.024, floor(ln(doc['avgRSS'].value)/ln(1000)))

This corrects for the wrong binary conversion factor finally using decimal one in line with the decimal unit labels.

It carries with it the inconvenience, that one has to be alert in case Kibana fixes the issue in the future. but as far as I have heard, this is not going to happen anytime soon (problem located in one of the upstream libraries).

Cheers,
J.

PS: for general n-core jobs e.g.: (doc[‘avgRSS'].value/doc['ncores'].value) * pow(1.024, ln(doc['avgRSS'].value/doc['ncores'].value)/ln(1000))

@Prazzy
Copy link

Prazzy commented Jan 12, 2017

This has been fixed in upstream library.

"Breaking change / Feature: Bytes are now formatted as: b (base 1000) and ib (base 1024)"

So this needs to be upgraded in Kibana. I tried myself to upgrade and it's working as expected.

--- a/package.json
+++ b/package.json
@@ -68,7 +68,7 @@
     "@spalger/filesaver": "1.1.2",
     "@spalger/leaflet-draw": "0.2.3",
     "@spalger/leaflet-heat": "0.1.3",
-    "@spalger/numeral": "^2.0.0",
+    "numeral": "^2.0.4",
     "@spalger/test-subj-selector": "0.2.1",
     "@spalger/ui-ace": "0.2.3",
     "angular": "1.4.7",
diff --git a/webpackShims/numeral.js b/webpackShims/numeral.js
index 71326a8..5a6f996 100644
--- a/webpackShims/numeral.js
+++ b/webpackShims/numeral.js
@@ -1 +1,4 @@


-module.exports = require('@spalger/numeral');
+//module.exports = require('@spalger/numeral');
+
+module.exports = require('../node_modules/numeral/min/numeral.min.js');

ib (base 1024)
screen shot 2017-01-11 at 11 59 40 pm

b (base 1000)
screen shot 2017-01-12 at 12 00 49 am

@w33ble w33ble added the good first issue low hanging fruit label Jan 12, 2017
@leeway23
Copy link
Author

leeway23 commented Mar 8, 2017

Would anyone know the Kibana version number from which this fix has been included ?

@jimgoodwin
Copy link

@spalger Did we pull in this fix to our fork of numeral.js ?

@spalger
Copy link
Contributor

spalger commented Mar 22, 2017

@jimgoodwin nope, this is not fixed in our fork.

I spent a little time upgrading to the latest version of numeral so we could get support for differentiating between ib and b but unfortunately numeral 2.0 has too many breaking changes that would break existing field formats... This means it's probably time for us to face the reality that we should have never exposed raw numeral patterns in the UI...

@epixa epixa removed the P2 label Apr 25, 2017
@shaharmor
Copy link
Contributor

Hey, I think that 6.X is a good chance for the upgrade of the numeral.js library. (We're looking for the b/ib change as well).

Any chance to get this implemented?

@leeway23
Copy link
Author

Hi is this currently fixed in Kibana 6.2.X ???

@timroes timroes added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure :Management DO NOT USE labels Nov 27, 2018
@timroes timroes removed the good first issue low hanging fruit label Mar 1, 2019
@wylieconlon
Copy link
Contributor

I think the second option (use binary units as now while fixing the labels to KiB, MiB, GiB, TiB, PiB etc.) is the smallest change, and doesn't sound like a breaking change to me.

@wylieconlon
Copy link
Contributor

I'm working on a fix to this in our numeral fork: #7543

As described there, this changes the b format to use KiB and introduces the bd (bytes decimal) format which would use kB, MB etc for base 1000 numbers.

If we decide to merge that change and upgrade our version of @elastic/numeral-js in a minor version, we may also want to introduce a separate Field Formatter for "bytes decimal."

@wylieconlon wylieconlon removed the Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages label Jan 31, 2020
@wylieconlon
Copy link
Contributor

After some more discussion and investigation, it seems like there are many entities that use the decimal units labels for binary bytes, so 1024 bytes = 1 KB (not kB) and 1024*1024 bytes = 1 MB in many of these. We use this notation for Elasticsearch. https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#byte-units

We should support all the inconsistencies in the real world, which means that I think we need to support three options and clarify this to our users:

  • Binary bytes with decimal labels
  • Binary bytes with kibi/mebi labels
  • Decimal bytes with decimal labels

@wylieconlon wylieconlon removed the bug Fixes for quality problems that affect the customer experience label Jan 31, 2020
@timroes timroes added Team:AppArch and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Mar 27, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@lukeelmers lukeelmers added the enhancement New value added to drive a business result label Jul 2, 2020
@wylieconlon
Copy link
Contributor

Closing this issue because it's now supported to use different Kibana numeral formatting patterns for all options discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:FieldFormatters
Projects
None yet
Development

No branches or pull requests