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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...