Splunk Search

How to filter an word from a string using SPL?

ABHAYA
Path Finder

e.g. input : CustomerService API call compeled in 105 ms Expected output : Customerservice  105 (in some graphical reprentation)

Labels (4)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Did you include the '+' after the '\d'?

View solution in original post

ABHAYA
Path Finder

@ITWhisperer  How can we remove specific  service from the result of splunk query. Our splunk query gives below result but we dont want ExampleService in our response . How can we remove using SPL.

We tried Servicename !=ExampleService. it is not working .Please suggest what need to be done here?

e.g. Input : customerservice  56 ms.

                     ExampleService   12  ms

 

Expected output  customerservice  56.

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Exactly what did you try - please share your SPL search

0 Karma

ABHAYA
Path Finder

@ITWhisperer  I  got expected result by ServiceName != <value_to_be_added> in the last of SPL query. Thank you for your response.

0 Karma

ABHAYA
Path Finder

@ITWhisperer  Thanks. The solution provided by you worked for me.How can we  find the average time for each service call.

e.g. Input : customerservice it2-customer.com completed in 10 ms.

                    customerservice it2-customer.com   completed in 8 ms

Expected output:  customerservice   9.

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| stats avg(completion_time) as avg_completion_time by API

ABHAYA
Path Finder

It is returning only the 1st digit of the number not the whole number. for e.g. returning 1 for 105.is there  any  way to improve  above  query.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Did you include the '+' after the '\d'?

ITWhisperer
SplunkTrust
SplunkTrust
| rex "(?<API>\w+) API call completed in (?<completion_time>\d+) ms"
0 Karma

ABHAYA
Path Finder

@ITWhisperer  Thanks. The solution provided by you worked for me. but if the host name contains ip which contains number e.g.it2 or uat2 so it returns first number which is wrong. is it  better way to find a  number which is present in  before specific word like ms.

e.g. Input : customerservice it2-customer.com completed in 56 ms.

Expected output  customerservice  56.

Current output  customerservice 2.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults 
| eval _raw="customerservice it2-customer.com completed in 56 ms."
| rex "(?<API>\S+) completed in (?<completion_time>\d+) ms"
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...