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!
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.
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.
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
@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.
Could you please try:
transforms.conf
[add_hostname]
REGEX=.*
FORMAT=host::$1 $0
SOURCE_KEY=MetaData:Host
DEST_KEY=_raw