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!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

Cisco Use Cases, ITSI Best Practices, and More New Articles from Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...