# How to get percentile value of number field by using logstash pipeline

**URL:** https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582
**Category:** Logstash
**Created:** [October 10, 2024, 3:30am UTC](https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582 "2024-10-10T03:30:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![upreddy](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@upreddy](https://discuss.elastic.co/u/upreddy)
#### Post date: [October 10, 2024, 3:30am UTC](https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582/1 "2024-10-10T03:30:38Z")

</div>

Hi Team,  
I am trying to get percentile value of number field from Elasticsearch by using logstash pipeline filter . Could you please help me how to get percentile value of number field from logsatsh pipeline.

---

<div class="post-metadata">

### Author: ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)
#### Post date: [October 10, 2024, 8:25am UTC](https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582/2 "2024-10-10T08:25:06Z")

</div>

Hi,

I'm not sure i understand your need, can you share an example of what you would like to do ?

---

<div class="post-metadata">

### Author: ![upreddy](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@upreddy](https://discuss.elastic.co/u/upreddy)
#### Post date: [October 10, 2024, 10:37am UTC](https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582/3 "2024-10-10T10:37:02Z")

</div>

Hi grumo,  
The requirement is we have one field called **"duration"** (number type) in elasticsearch. I need to get **75percentile of this duration** field in a day and i need to send this value to another team by using logstash pipeline. I am sharing sample logstash pipeline  
input {  
elasticsearch {  
hosts =\> ["XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"]  
index =\> "abc\*"  
query =\> '{"query": {  
"bool": {  
"must": ,  
"filter": [

```
  {
      "exists": {
        "field": "duration"
      }
    },
{"range": {
  "@timestamp": {
    "gte": "now-1d/d","lt": "now/d"
  }
}}]}} }'

```

}  
}

filter {

aggregate {  
task\_id =\> "%{duration}"  
code =\> "  
" **here i have stuck**  
push\_map\_as\_event\_on\_timeout =\> true  
timeout\_task\_id\_field =\> "duration"  
timeout =\> 60  
}  
}  
output  
{  
Kafka servers  
}

---

<div class="post-metadata">

### Author: ![upreddy](https://avatars.discourse-cdn.com/v4/letter/u/f04885/32.png) [@upreddy](https://discuss.elastic.co/u/upreddy)
#### Post date: [October 14, 2024, 9:26am UTC](https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582/4 "2024-10-14T09:26:34Z")

</div>

Hi,  
Could someone please help me with this?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [October 14, 2024, 1:17pm UTC](https://discuss.elastic.co/t/how-to-get-percentile-value-of-number-field-by-using-logstash-pipeline/368582/5 "2024-10-14T13:17:02Z")

</div>

> [@upreddy](#):
>
> I need to get **75percentile of this duration** field in a day

You can probably have elasticsearch calculate that for you using a [percentiles aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html).

It's a bad match for logstash because to calculate the percentiles you need the entire data set at the same time. To calculate the 75th percentile you would create an array with all the values in it, sort it, and take the value that is entry 0.75\*array.length. (And possibly interpolate between that entry and the next one.)
