Getting Data In

How to override source from raw data while indexing in splunk?

mitali
Explorer

For example below is my raw data in sample.log file.

This is a |AWS| test log testing. 

The source of this file is opt/sample.log but I want to change my source from source= /opt/sample.log to source=AWS which will be extracted from raw data  while indexing in splunk.

props.conf

[log]
TRANSFORMS-sourcechange=replacedefaultsource

 

Transforms.conf

[replacedefaultsource]
WRITE_META = true
SOURCE_KEY = _raw
REGEX = \|(.*)\|
DEST_KEY = MetaData:Source
FORMAT= source::$1

Thank you in advance please help me.

 

 

Labels (2)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

At first glance everything seems relatively OK.

Quick sanity check:

1) Are you ingesting this file with the "log" sourcetype?

2) On which component do you have those settings?

0 Karma

mitali
Explorer

1).we are using random sourcetype and not a specific sourcetype does it matter?

2) We have to forward data from UF and props.conf and transforms.conf are on indexer.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

1. Yes. Your excerpt from props.conf had stanza named [log] which means it would only be applied to the events with sourcetype of "log". See the documentation for the props.conf file.

2. OK. That's good. UF doesn't have any advanced processing capabilities so all the funky stuff happens on the first "heavy" component in event's path - indexer or heavy forwarder, whichever is first.

0 Karma

mitali
Explorer

We have lot of logs coming from different sources which are going to a specific directory which is than getting monitored by splunk. These log source changes everyday (everyday a new log file is created).Out of these log some of them contain AWS logs so I  need to change the source for those particular logs which has AWS logs in it.

The only way to differentiate AWS logs from other logs is that AWS contains field which has "AWS" and that was my trying to do using props and transforms.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Well... fiddling with metadata is tricky and it might cause results unexpected at this point. Especially if you're ingesting well-known data format. Especially overwriting the source field globally with a static value does mean that you're losing some level of information (in case of file-based ingestion you're forgetting which file the data was read from). So it might not be the best possible idea. You could use another means of selecting the data from AWS by - for example - defining an eventtype. But if you really want to overwrite the source, you have to point your props.conf to apply the transform defined in transforms.conf to the appropriate sourcetypes/sources/hosts. Read  the https://docs.splunk.com/Documentation/Splunk/9.0.0/Admin/Propsconf#GLOBAL_SETTINGS thoroughly.

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

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