Splunk Search

Splunk Search help!

kc_prane
Communicator

I Have ServiceNames (A, B ,C ,D, E,  F, G, H)  but want  (C ,D, E,  F, G, H ) ServiceNames combined results and renamed as "Other_Services" 

My base search

| rex "^[^=\n]*=(?P<ServiceName>[^,]+)"
| rex "TimeMS\s\=\s(?<Trans_Time>\d+)"

 

Required Results

ServiceName        Trans_TimeCount
A601111
B401234
Other_Services( C , D, E, F,G,H)251234567
Labels (1)
Tags (1)
0 Karma
1 Solution

KendallW
Contributor

Hi @kc_prane , try this - create a new eval field (ServiceGroup) to check whether ServiceName is A or B, else assign it to "Other_Services" :

| rex "^[^=\n]*=(?P<ServiceName>[^,]+)" 
| rex "TimeMS\s\=\s(?<Trans_Time>\d+)" 
| eval ServiceGroup = case(
    ServiceName == "A", "A",
    ServiceName == "B", "B",
    1==1, "Other_Services"
    ) 
| stats 
    avg(Trans_Time) as Avg_Trans_Time,
    count as Count
    by ServiceGroup 
| rename ServiceGroup as ServiceName 
| sort ServiceName

 

View solution in original post

kc_prane
Communicator

Thanks @KendalW for the help!

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @kc_prane ,

what's the difference with your previous question?

Anyway, the solution hinted by @KendallW is similar with my previous one.

Ciao.

Giuseppe

0 Karma

kc_prane
Communicator

Hello, @gcusello. Thank you for your response. I had an issue with Rex. I corrected that now, and your earlier query works for me.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @kc_prane ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

KendallW
Contributor

Hi @kc_prane , try this - create a new eval field (ServiceGroup) to check whether ServiceName is A or B, else assign it to "Other_Services" :

| rex "^[^=\n]*=(?P<ServiceName>[^,]+)" 
| rex "TimeMS\s\=\s(?<Trans_Time>\d+)" 
| eval ServiceGroup = case(
    ServiceName == "A", "A",
    ServiceName == "B", "B",
    1==1, "Other_Services"
    ) 
| stats 
    avg(Trans_Time) as Avg_Trans_Time,
    count as Count
    by ServiceGroup 
| rename ServiceGroup as ServiceName 
| sort ServiceName

 

Get Updates on the Splunk Community!

Splunk is Nurturing Tomorrow’s Cybersecurity Leaders Today

Meet Carol Wright. She leads the Splunk Academic Alliance program at Splunk. The Splunk Academic Alliance ...

Part 2: A Guide to Maximizing Splunk IT Service Intelligence

Welcome to the second segment of our guide. In Part 1, we covered the essentials of getting started with ITSI ...

Part 1: A Guide to Maximizing Splunk IT Service Intelligence

As modern IT environments continue to grow in complexity and speed, the ability to efficiently manage and ...