Getting Data In

How to replace meta information?

rahiparikh
Explorer

Hi,

I have a small lab where there is a heavy forwarder. I can/want to perform transformation on Meta info at Heavy forwarder level. I have two related questions.

The first question --

I have a source field something like -- /<dir1>/<dir2>/<logfilename> and I want to remove /<dir1>/<dir2> from source field. How can I do that?

I also want to rewrite sourcetype field before sending data to indexer. Let's say if we find secure in any part of sourcetype then sourcetype should be secure. (i.e. remove all other characters except secure )

Please help!

Thanks!

0 Karma
1 Solution

_d_
Splunk Employee
Splunk Employee

You can try rewriting (reformating) the source key for your first question. You can use transforms and props to do that. Here's an example of how transforms.conf may look like:

transforms.conf

[<unique_transform_stanza_name>]
SOURCE_KEY = MetaData:Source
REGEX = <regular_expression>
FORMAT = source::$1
DEST_KEY = MetaData:Source

props.conf

[<spec>]
TRANSFORMS-<value> = <unique_stanza_name>

For your second question you can do pretty much the same thing, but operate on MetaData:Sourcetype instead of Source.

There is additional and very helpful information here:

http://docs.splunk.com/Documentation/Splunk/4.2.4/Admin/Transformsconf

http://docs.splunk.com/Documentation/Splunk/4.2.4/Data/Configureindex-timefieldextraction

- please upvote if you find this answer useful

View solution in original post

_d_
Splunk Employee
Splunk Employee

You can try rewriting (reformating) the source key for your first question. You can use transforms and props to do that. Here's an example of how transforms.conf may look like:

transforms.conf

[<unique_transform_stanza_name>]
SOURCE_KEY = MetaData:Source
REGEX = <regular_expression>
FORMAT = source::$1
DEST_KEY = MetaData:Source

props.conf

[<spec>]
TRANSFORMS-<value> = <unique_stanza_name>

For your second question you can do pretty much the same thing, but operate on MetaData:Sourcetype instead of Source.

There is additional and very helpful information here:

http://docs.splunk.com/Documentation/Splunk/4.2.4/Admin/Transformsconf

http://docs.splunk.com/Documentation/Splunk/4.2.4/Data/Configureindex-timefieldextraction

- please upvote if you find this answer useful

rahiparikh
Explorer

Will this work? I want to perform transformation on Heavy Forwarder and send data to indexer. I do not index locally.

0 Karma

_d_
Splunk Employee
Splunk Employee

In that case then i would try using priority=n in the affected props stanzas. More on priority or precedence can be found here: http://docs.splunk.com/Documentation/Splunk/latest/Admin/Propsconf

0 Karma

rahiparikh
Explorer

Thanks for reply! This works. I have already tried this. But problem with it is -- is a device name. I use host_segment to extract device name. Now, when I use both together, the host_segment will not have effect! 😞

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!

Splunk Enterprise Security: An Automated Phishing Response Workflow

Originally posted on Splunk.com.   Key takeaways  The volume of phishing emails can overwhelm even the most ...

Sharper ES Detections, Agentic AI Integrations, Smarter Workload Management, and More ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Data Outage Monitoring and Reporting

We’ve all been there, right? Living our best life, working on our Splunk environment, when out of nowhere a ...