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 Certification Support Alert | Pearson VUE Outage

Splunk Certification holders and candidates!  Please be advised of an upcoming system maintenance period for ...

Enterprise Security Content Update (ESCU) | New Releases

In September, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...