Splunk Search

Adding domain name to hostnames

msupino
Explorer

I have multiple LightForwarded, in different domains, who have similar host names (machines inside one domain are the same as machines in another domain),

how can i configure each splunk LightForwarder to add the domain name of any event it sends to the Central splunk ?

Tags (1)

Lowell
Super Champion

I recommend using a transformer for adding a static domain name to your host field. I've previously posted some config examples (linke below) that works for the syslog (and various derived) sourcetypes. The example shown is smart enough not to accidentally append your domain to an IP address.

Please see my answer here:

0 Karma

Lowell
Super Champion

I don't know of any way to really "debug" this type of activity other than to actually try it. Hopefully fixing the transformer name will resolve the issue.

0 Karma

Lowell
Super Champion

Note that I had a typo on that page, which has been fixed now. The transformer should have been named syslog_add_fqdn. Hopefully that was obvious from the context, but it was a mistake which has been corrected now.

0 Karma

msupino
Explorer

and have a few quesions,
first, can this be debuged somehow ?
or log showing whats happening ?
also, why do the entries inside [] dont match ? should they ?

0 Karma

msupino
Explorer

i looked at the example above, and see :

[syslog_add_mfpsdotcom]
DEST_KEY = MetaData:Host
SOURCE_KEY = MetaData:Host
REGEX = host::([A-Za-z][-_A-Za-z0-9]*[A-Za-z0-9])$
FORMAT = host::$1.my-domain-name.com

[syslog]
TRANSFORMS-zz_fix_host = syslog_add_fqdn

[linux_messages_syslog]
TRANSFORMS-zz_fix_host = syslog_add_fqdn

[linux_secure]
TRANSFORMS-zz_fix_host = syslog_add_fqdn

[postfix_syslog]
TRANSFORMS-zz_fix_host = syslog_add_fqdn

[sendmail_syslog]
TRANSFORMS-zz_fix_host = syslog_add_fqdn

0 Karma

Lowell
Super Champion

I'm not 100% sure, you can try it. Worst case scenario is that you have to put it on the indexer. I think this also depends on your Splunk version, I think 4.0 does more on light forwarder than was handled by the 3.x light forwarders.

0 Karma

msupino
Explorer

will this work on a LightForwarder ?

0 Karma

msupino
Explorer

this will change the local events, but events from the syslog, for example, will not be changed by this, which is fine, as they might come from other machines in the same domain.

so, i want to add .something.com to all hostname evetns, is that possible somehow ?

0 Karma

Lowell
Super Champion

Splunk has a transformer that extracts "host" from syslog sourcetypes, and that will override any given host=myhostname that you setup in inputs.conf. Just for the record, I do think setting your hostname in this way is also a good idea, but I suggest doing so at the top of system/local/inputs.conf (as ftk suggests) rather than in the unix app--this way the setting is fully global and not limited to a single app context.

0 Karma

msupino
Explorer

just to be clear, *nix is parsing /var/log/syslog

0 Karma

msupino
Explorer

syslog has info from local and remove machines

the *nix app is fixed by host= entry
but, the same host writes things to syslog,and other nodes writes to syslog through syslogd, these entires dont have the domaine, for example,

Aug 12 14:20:06 xen00 last message repeated 3 times
this doesnt have the domain name, so the same machine, from different SplunkLightForwarders in different locations will be indexed under the same hostname.

i want splunk in each location to add a domain name to the hostname it sees in syslog.

0 Karma

ftk
Motivator

I'm sorry, but i'm not sure what you're trying to get at here. Your question indicated you're using a forwarder setup rather than syslog. How are you sending your syslog to splunk? Via a direct network input in splunk or via syslog-ng and then indexing the resulting logs?

0 Karma

ftk
Motivator

You can edit the hostname assigned to events from a host by editing the host= value in your $SPLUNK_HOME/etc/system/local/inputs.conf. Just change it from

host=hostname

to

host=hostname.domain.com
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...