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!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...