How to display Percentiles rank values?

I want to call values of percentiles rank 500 and/or 1000 in a variable to compare it with conditions

       "aggs": {
          "load_time_outlier": {
            "percentile_ranks": {
              "field": "TOTAL_TIME",
              "values": [
                500,
                1000
              ]
            }
          }
        }
      }
    }
  }
},

RESULT

   "aggregations": {
      "load_time_outlier": {
        "values": {
          "500.0": **99.92902987518903**,
          "1000.0": **99.9449336790884**

I want to compare the values ​​of 500 and 1000 and compare if > 95

I've got this error

},
"exception": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx.payload.aggregations.load_time_outlier.value < 95",
" ^---- HERE"
],
"script": "ctx.payload.aggregations.load_time_outlier.value < 95",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null,
"stack_trace": "java.lang.NullPointerException\n\tat org.elasticsearch.painless.DefBootstrap$MIC.checkLHS(DefBootstrap.java:381)\n\tat org.elasticsearch.painless.PainlessScript$Script.execute(ctx.payload.aggregations.load_time_outlier.value >= 70:43)\n\tat org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:105)\n\tat org.elasticsearch.xpack.watcher.condition.ScriptCondition.doExecute(ScriptCondition.java:85)\n\tat org.elasticsearch.xpack.watcher.condition.ScriptCondition.execute(ScriptCondition.java:76)\n\tat org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:471)\n\tat org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:322)\n\tat org.elasticsearch.xpack.watcher.transport.actions.execute.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:165)\n\tat org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:573)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n"

hey,

have you tried ctx.payload.aggregations.load_time_outlier.values["500.0"]?

--Alex

Genius, it works but with simple quote, like this : ctx.payload.aggregations.load_time_outlier.values['500.0'].

Last question : can i use this ctx**** to display the content in an e-mail for example ?
What is the exact syntax ? = = > {{ctx.payload.aggregations.load_time_outlier.values['500.0']}} < = = doesn't work

@spinscale : Finaly it's OK, i put it in a variable

"condition": {
"script": {
"source": "ctx.vars.pct_500 = ctx.payload.aggregations.load_time_outlier.values['500.0'] ; return ctx.vars.pct_500 < 95",
"lang": "painless"
}
},

Thx a lot, everything it's OK

1 Like

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