Getting Data In

How to filter or extract fields before indexing time

crazyeva
Contributor

I have got very large orginal data, with events strictly formatted as "f1,f2,f3,..."
most of the fields are meaningless: "0,f2,0,0,0,0,f7,0,f9,..." i only want f2,f7,f9
Can I filter fields before indexing, drop unnecessary data, avoid reach license limit?

0 Karma
2 Solutions

Ayn
Legend

Yes, as long as you can formulate a regular expression that defines how Splunk should include or exclude data. You can either to nullQueue routing (= drop events altogether) or

Docs on how to use each: nullQueue routing - http://docs.splunk.com/Documentation/Splunk/6.0/Forwarding/Routeandfilterdatad
SEDCMD - http://docs.splunk.com/Documentation/Splunk/latest/admin/Propsconf - see specification on SEDCMD at the middle of the page.

View solution in original post

kristian_kolb
Ultra Champion

source file

2013-11-01 11:11:11 f1 f2 f3 f4 f5 f6
2013-11-02 13:15:11 d1 d2 d3 d4 d5 d6
2013-11-02 14:23:22 e1 e2 e3 e4 e5 e6
2013-11-03 12:23:21 g1 g2 g3 g4 g5 g6

props.conf

[your_sourcetype]
TRANSFORMS-blah = keep235

transforms.conf

[keep235]
DEST_KEY = _raw
REGEX = ^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)
FORMAT = $1 $2 $4 $5 $7

Result:

03/11/2013 12:23:21.000  2013-11-03 12:23:21 g2 g3 g5
02/11/2013 14:23:22.000  2013-11-02 14:23:22 e2 e3 e5

^Splunk parsed timestamp  ^event timestamp     ^less columns/fields

Hope this helps,

/K

View solution in original post

kristian_kolb
Ultra Champion

source file

2013-11-01 11:11:11 f1 f2 f3 f4 f5 f6
2013-11-02 13:15:11 d1 d2 d3 d4 d5 d6
2013-11-02 14:23:22 e1 e2 e3 e4 e5 e6
2013-11-03 12:23:21 g1 g2 g3 g4 g5 g6

props.conf

[your_sourcetype]
TRANSFORMS-blah = keep235

transforms.conf

[keep235]
DEST_KEY = _raw
REGEX = ^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)
FORMAT = $1 $2 $4 $5 $7

Result:

03/11/2013 12:23:21.000  2013-11-03 12:23:21 g2 g3 g5
02/11/2013 14:23:22.000  2013-11-02 14:23:22 e2 e3 e5

^Splunk parsed timestamp  ^event timestamp     ^less columns/fields

Hope this helps,

/K

crazyeva
Contributor

Thank you, that's sweet!

0 Karma

Ayn
Legend

Yes, as long as you can formulate a regular expression that defines how Splunk should include or exclude data. You can either to nullQueue routing (= drop events altogether) or

Docs on how to use each: nullQueue routing - http://docs.splunk.com/Documentation/Splunk/6.0/Forwarding/Routeandfilterdatad
SEDCMD - http://docs.splunk.com/Documentation/Splunk/latest/admin/Propsconf - see specification on SEDCMD at the middle of the page.

crazyeva
Contributor

THANK YOU!
I have read some of related answers, and thought SEDCMD was just able to drop the content after a tag, nullQueue was "at event level"
Than i have to dig into "sed" tool. is there a awkcmd?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...