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
Get Updates on the Splunk Community!

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...

4 Ways the Splunk Community Helps You Prepare for .conf25

.conf25 is right around the corner, and whether you’re a first-time attendee or a seasoned Splunker, the ...

Enhance Your Splunk App Development: New Tools & Support

UCC FrameworkAdd-on Builder has been around for quite some time. It helps build Splunk apps faster, but it ...