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
Builder

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
Builder

@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
Builder

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!

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...

SignalFlow: What? Why? How?

What is SignalFlow? Splunk Observability Cloud’s analytics engine, SignalFlow, opens up a world of in-depth ...