Splunk Search

Extract a substring and filter the results based on the extracted substring from incoming logs

nagar57
Communicator

I am pretty new to Splunk and finding a way to figure out below:
My incoming logs have a field message which contains String formatted value. e.g.

message="OVERALL_RESPONSE_TIME=43ms"
message="Correlation_id=123123hewgadkksksk"

Now I want to filter out messages which don't contain OVERALL_RESPONSE_TIME as a String and also extract OVERALL_RESPONSE_TIME as a field. I am looking for a single Eval expression to do so.

TIA

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I'm not sure one can do that with a single eval. Try this query. The regex command filters out events that don't contain OVERALL_RESPONSE_TIME and the rex command extracts OVERALL_RESPONSE_TIME as a field.

... | regex message!="OVERALL_RESPONSE_TIME=\d+ms" | rex field=message "OVERALL_RESPONSE_TIME=(?<responseTime>\d+)" | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

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

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 ...