Splunk Search

What syntax can I use to run a search that sorts varying runtimes?

JyotiP
Path Finder

I have data for 1 day where I want to sort it with activity like following manner, total number of records took 0-3 sec , total number of records took 3-4 and goes on. Want to present it in one query.

0 Karma
1 Solution

DalJeanis
Legend

There are two basic syntaxes you can use (probably a dozen more, but these two demonstrate the top two in use)

your query here 
| eval mygroup=case(Val_value>=0 AND Val_value<=3,"0.0 to 3.0", 
    Val_value>3 AND Val_value<=4,"3.0+ to 4.0", 
    Val_value>4 AND Val_value<=5,"4.0+ to 5.0", 
    Val_value>5 AND Val_value<=6,"5.0+ to 6.0", 
    true(),"6.0+")

...then your choice of one of these two...

| stats count by mygroup
| chart count by mygroup

stats presents one record per value of mygroup, chart would present them horizontally.

... OR ...

your query here 
| stats count(eval(Val_value>=0 AND Val_value<=3)) as "0.0 to 3.0",
    count(eval(Val_value>3 AND Val_value<=4)) as "3.0+ to 4.0",
    count(eval(Val_value>4 AND Val_value<=5)) as "4.0+ to 5.0",
    count(eval(Val_value>5 AND Val_value<=6)) as "5.0+ to 6.0",
    count(eval(Val_value>6)) as "6.+"

This second version presents them horizontally. If you wanted to change them to vertically, you could do it the other way, or add this afterward...

 | eval junk=1
 | untable junk mygroup count
 | fields - junk

View solution in original post

JyotiP
Path Finder

@DalJeanis can create a pi chart or graph for the above query ??

0 Karma

DalJeanis
Legend

There are two basic syntaxes you can use (probably a dozen more, but these two demonstrate the top two in use)

your query here 
| eval mygroup=case(Val_value>=0 AND Val_value<=3,"0.0 to 3.0", 
    Val_value>3 AND Val_value<=4,"3.0+ to 4.0", 
    Val_value>4 AND Val_value<=5,"4.0+ to 5.0", 
    Val_value>5 AND Val_value<=6,"5.0+ to 6.0", 
    true(),"6.0+")

...then your choice of one of these two...

| stats count by mygroup
| chart count by mygroup

stats presents one record per value of mygroup, chart would present them horizontally.

... OR ...

your query here 
| stats count(eval(Val_value>=0 AND Val_value<=3)) as "0.0 to 3.0",
    count(eval(Val_value>3 AND Val_value<=4)) as "3.0+ to 4.0",
    count(eval(Val_value>4 AND Val_value<=5)) as "4.0+ to 5.0",
    count(eval(Val_value>5 AND Val_value<=6)) as "5.0+ to 6.0",
    count(eval(Val_value>6)) as "6.+"

This second version presents them horizontally. If you wanted to change them to vertically, you could do it the other way, or add this afterward...

 | eval junk=1
 | untable junk mygroup count
 | fields - junk

JyotiP
Path Finder

@DalJeanis, thanks for the update, let me try and will post my result

JyotiP
Path Finder

Currently I have separate query as follows :
query 1 : where Val_value>=0 AND Val_value<=3 | stats count
query 2 : where Val_value>=3.1 AND Val_value<=4 | stats count
query 3 : where Val_value>=4.1 AND Val_value<=5 | stats count
query 4 : where Val_value>=5.1 AND Val_value<=6 | stats count
So I want to merge the above request into 1 query. How to do it ?

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...