Splunk Search

host_Regex help

a212830
Champion

Hi,

I want to name my host based upon a value in the logfile. I know it can be done via regex but it's not working.

The name of the files are like this...

SG_HTTP.AGW-US123-PLUG.140124.122345.log.gz
SG_HTTP.AGW-US301-PLUG.140124.122345.log.gz

my host regex is = (IGW+[a-zA-Z0-9_])

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Assuming the host name is between the first two dots, this may work for you.

'rex "[.]*\.(?<host>[^.]+?)\.[.]*"'

---
If this reply helps you, Karma would be appreciated.

View solution in original post

somesoni2
Revered Legend

If AGW-US123-PLUG is the host name from the file name, use this

\.([-a-zA-Z0-9]+)\.

If just US123-PLUG is the host name , use this

-([-a-zA-Z0-9]+)\.

E.g. inputs.conf
[monitor://<path>]
host_regex = <your_regex>
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Assuming the host name is between the first two dots, this may work for you.

'rex "[.]*\.(?<host>[^.]+?)\.[.]*"'

---
If this reply helps you, Karma would be appreciated.

richgalloway
SplunkTrust
SplunkTrust

Then you'll want to create a transforms.conf stanza with a 'REGEX = [.]*\.(?<host>[^\.]+?)\.(?<date>[^\.]*?)\.(?<time>[^\.]*?)' statement.

---
If this reply helps you, Karma would be appreciated.
0 Karma

a212830
Champion

I'm looking to to this in the inputs.conf, not the search bar.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...