Getting Data In

How to filter relevant data from a noisy application log and only index them?

mahars01
Explorer

I have a very noisy app log. I want to use Splunk's indexer to filter only relevant data and index them. Basically I need to match a string 'Error', only forward the matched line and the line preceding that one for indexing. In other words, I need to do a grep and a grep -B1 for the string Error. Then, I only want to index those events using Splunk's indexer filtering. How do I do that?

 

Example: I have this log data

INFO: Task1

INFO: OK

INFO: Task 2

ERROR: exception xyz

 

Here, I only want to capture and index this:

INFO: Task 2

ERROR: exception xyz

Labels (1)
Tags (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mahars01,

are you speaking of events filtering at Index Time (before indexing) or at Search Time (you index all and display only the needed events)?

Anyway, it's easy to take only some events (both at Index or Search Time) filtering and discarding the others, it's more difficoult to take one event and also the previous oneand I'm not sure that's possible at Index Time and maybe also at Search Time.

The only way, at Index Time is pre-parse the log using a script.

Ciao.

Giuseppe

0 Karma

mahars01
Explorer

I am talking about filtering the data before it gets indexed. I donot want to index irrelevant data. I know you can use sed in props.conf and sed does have that kind of feature that gives u the matched event and the one before that. Just not sure how to use that to only index the ones i need and discard the rest.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @mahars01,

my hint is to find the regexes to identify not relevant events in your logs and discard them using the props and trasforms method.

For more infos see at https://docs.splunk.com/Documentation/Splunk/latest/Forwarding/Routeandfilterdatad#Discard_specific_...

Ciao.

Giuseppe

0 Karma

mahars01
Explorer

I had already thought of that. Unfortunately that's not going to work on my scenario.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...

Index This | How many sevens are there between 1 and 100?

August 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...