# How to display Percentiles rank values?

**URL:** <https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 11, 2019, 2:06pm UTC](https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782 "2019-03-11T14:06:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hmezoughi](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@hmezoughi](https://discuss.elastic.co/u/hmezoughi)\
**Post date:** [March 11, 2019, 2:06pm UTC](https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782/1 "2019-03-11T14:06:19Z")

</div>

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"

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 20, 2019, 8:52am UTC](https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782/2 "2019-03-20T08:52:40Z")

</div>

hey,

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

--Alex

---

<div class="post-metadata">

**Author:** ![hmezoughi](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@hmezoughi](https://discuss.elastic.co/u/hmezoughi)\
**Post date:** [March 21, 2019, 2:55pm UTC](https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782/3 "2019-03-21T14:55:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hmezoughi](https://avatars.discourse-cdn.com/v4/letter/h/e79b87/32.png) [@hmezoughi](https://discuss.elastic.co/u/hmezoughi)\
**Post date:** [March 21, 2019, 9:19pm UTC](https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782/4 "2019-03-21T21:19:07Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 18, 2019, 9:19pm UTC](https://discuss.elastic.co/t/how-to-display-percentiles-rank-values/171782/5 "2019-04-18T21:19:11Z")

</div>

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