Splunk Enterprise

Transforms.conf adding host to log message

winter4
Loves-to-Learn

Hi Splunk Community, 

Is there a way to capture the host of a UF as its passing through a HF to add the host right before the log messaging being processed. I have tried a few things with no luck but asking here while i dig through the documentations. Thanks!

Labels (2)
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

It's... complicated.

Splunk doesn't keep network-level metadata about its sources. So (apart from the values set in the default metadata fields by input settings) you can't - for example - tell from which IP the syslog data came or which UF sent particular event.

You can set it on the source by using _meta setting per input but it has its own share of issues.

1. If you want to capture the source UF name or IP you'd need to set it to a different value for each UF. That's hard to maintain since - except for some very rare cases - splunk conf files don't use variables/templates so you need to set it explicitly per each host.

2. There is only a single _meta entry for each input so if you wanted to set two different values (for example -  one metadata field for a forwarder name and one for the network zone name), you can't set them in different places and have Splunk merge them into one combined setting. One would overwrite another.

So while it is "kinda possible", it's not a very useful way to do so. You might be able to pull it off if you used an external tool to manage your forwarders' configs - one which supports templating and you could dynamically create those configs for forwarders.

3. Oh, and remember that if you specify [default] settings for inputs you still need a separate setting for [wineventlog] inputs - the default ones are not applied there.

0 Karma

PaulPanther
Motivator

Where to you wanna  exactly add the hostname of the uf? To the log event itself or do you wanna override the host metadata field?

 

Maybe following links could be helpful for you:

Set host values based on event data - Splunk Documentation

Set a default host for a file or directory input - Splunk Documentation

 

Feel free to share your configuration to double check it.

0 Karma

winter4
Loves-to-Learn

thanks @PaulPanther 


I am trying to add the uf host name to the raw event so trying to manipulate the raw event to have something like “HOSTNAME — _raw_events” 

 

I am trying to configure this on the heavyforwarder and not trying to go into each uf to make configuration changes 

0 Karma

PaulPanther
Motivator

@winter4 wrote:

thanks @PaulPanther 


I am trying to add the uf host name to the raw event so trying to manipulate the raw event to have something like “HOSTNAME — _raw_events” 

 

I am trying to configure this on the heavyforwarder and not trying to go into each uf to make configuration changes 


Why would you do this? What is your usecase at the end? If you do it like this you have to touch every individual event.

0 Karma

winter4
Loves-to-Learn

@PaulPanther 

 

Just side experiment & wondering if it’s possible 

0 Karma

PaulPanther
Motivator

Could you please try:

transforms.conf

[add_hostname]
REGEX=.*
FORMAT=host::$1 $0
SOURCE_KEY=MetaData:Host
DEST_KEY=_raw

 

 

 

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