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

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...