Splunk Search

Count elements from every percentile

kp_pl
Path Finder

My target is not only show proper percentiles but also count elements in every precentile . So the first step I did is:

index="oap"
| stats perc25(tt) as P25,
             perc50(tt) as P50,
             perc75(tt) as P75 by oper


It gives me expected values for each percentile - the first part is ready.
Then I figured out something like

| where tt>P75
| stats values(P75) count by oper


It adds additional column but only with data from one (75th) percentile. But how to prepare a query which returns count for each Percentil ?

 

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Instead of stats, use eventstats.

index="oap"
| eventstats perc25(tt) as P25,
             perc50(tt) as P50,
             perc75(tt) as P75 by oper
| foreach P25 P50 P75
  [eval <<FIELD>>count = if(tt><<FIELD>>, 1, 0)]
| stats values(P*count) as P*count by oper P25 P50 P75
Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @kp_pl ,

sorry but I don't understand your request:

perc75(tt) is one of the calculated values, so why do you want to add a new column?

Could you share how you are waiting for results?

Ciao.

Giuseppe

0 Karma

kp_pl
Path Finder

Ok, will try to expain it ....

 

there are thousand of digits, of course values can repeat.

So first I want to  divide them ( in that case) into quartile. In my case : 0-25, 25-50, 50-75,75-100. Then , and this is my problem, count how many values has every section/quartile. In my case I need 4 pairs : value<>quantity. 

Is it more clear ... 

 

 

 

0 Karma
Get Updates on the Splunk Community!

Splunk Search APIを使えば調査過程が残せます

   このゲストブログは、JCOM株式会社の情報セキュリティ本部・専任部長である渡辺慎太郎氏によって執筆されました。 Note: This article is published in both Japanese ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...