Doc bug for system.cpu.user.pct (and other pct)?

I got thrown off by the documentation here for system.cpu.user.pct.

The percentage of CPU time spent in user space. On multi-core systems, you can have percentages that are greater than 100%. For example, if 3 cores are at 60% use, then the system.cpu.user.pct will be 180%.

It seems to indicate the value is in percent. Looking at the code though, it is clear that it is a decimal value and not a percent.

If we agree this is a doc bug, I am happy to submit a PR if someone can point me to the process for that.

Hi @suryaj welcome to the forum, and thanks for the close look.

I believe both the code and the docs are correct...

A percent is a float number that is a ratio of the part divided by the total possible. When that total percent 100% is represented as a float number between 0.0 and 1.0 When the total Percent is 300% is represented as a number between 0.0 and 3.0. So 80% is equal to .80 when represented as a float. If you were to represent that value as 80.0 that would really be 8000%

You can see this if you look at the source document and then look at the same document in discover.

Example Source from Dev Tools

GET /metricbeat-7.3.1/_doc/OwZAb20BjKA62DgGHqIA

{
  "_index" : "metricbeat-7.3.1-2019.09.18-000001",
  "_type" : "_doc",
  "_id" : "OwZAb20BjKA62DgGHqIA",
  "_version" : 1,
  "_seq_no" : 258823,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "@timestamp" : "2019-09-26T20:25:34.959Z",
    "service" : {
      "type" : "system"
    },
    "system" : {
      "process" : {
        "cmdline" : "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
        "state" : "running",
        "cpu" : {
          "start_time" : "2019-09-20T15:14:53.688Z",
          "total" : {
            "pct" : 0.0852,
            "norm" : {
              "pct" : 0.0107
            },
            "value" : 1.3449285E7
          }
        },
        "memory" : {
          "rss" : {
            "bytes" : 391880704,
            "pct" : 0.0228
          },
          "share" : 0,
          "size" : 6627667968
        }
      }
    },

.......
}

In discover, the Discover tab recognizes that they data type is a percent and thus makes it easier

You can even change you that is presented in the Settings -> Advanced Settings

Hi Stephen, appreciate your quick comment.

A percent is a float number that is a ratio of the part divided by the total possible.

I am not sure where you are applying that definition from. Percent is a number that is expressed as a fraction of 100. What you are referring to above is what is generally called ratio. If the ratio is 0.5, the equivalent percent is 50%; similarly if the ratio is 0.05, the equivalent percent is 5%.

When the total Percent is 300% is represented as a number between 0.0 and 3.0.

Are you saying this is how percentage values are represented in Elastic? This is in direct contrast to how it is referred in the doc I referred in the start of the thread, specifically this part:

For example, if 3 cores are at 60% use, then the system.cpu.user.pct will be 180%.

Based on what you are saying (and what I am seeing in code), this should perhaps say

"For example, if 3 cores are at 60% use, then the system.cpu.user.pct will be 1.8."

This will make it consistent with the default experience that a user sees when they try to visualize the system.cpu.user.pct metric.

Hi @suryaj

Thanks for the reply and apologies for any confusion...

I guess what I am saying is that I see no discrepancy between the document, the data stored in elastic or how it is represented in Kibana.

1.8 and 180% represent the same value and when speaking or documenting a percent. In general people write or display 180% rather than 1.8 but when doing math or storing the data it is 1.8

If you look at the raw data in Elasticsearch as I showed about you will see the type: scaled_float 1.8 and when you look in Kibana it will recognized the format: percent and you will see 180%

So it make sense to me, but feel to write up an issue if you feel strongly about it.

Here is the default experience:

In this case the value stored and displayed are both 0.119 and I am not seeing what you are stating here:

when you look in Kibana it will recognized the format: percent and you will see 180%

What am I missing? Our Kibana version is: 6.3.1 in case that has anything to do with this.

Hi @suryaj

I stood up a 6.3.1 cluster here is what I see

Raw : Note the Float Representation 1.2058

In Discover : Note the Percent Representation 120.58%

In the Data Table: Note the Percent Format

What I think may have happened is that the the format:percent:defaultPattern is not properly set the default is 0,0.[000]% this is what is should look like under Management -> Advanced Settings.

Take a look and see what you see...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.