Splunk Search

Regex for host field inputs.conf

conner9
Path Finder

Anyone with ideas on how to convert this rex search string into host_regex= input for the Host field, to be a host name in inputs.conf.

rex "(?P<App>\S+)__(?P<Loc>\S+)__(?P<Host>\S+)__(?P<PID>\d+)."

1 Solution

hexx
Splunk Employee
Splunk Employee

I would suggest:

host_regex = _+([^_]+)(?:__\d+)?\.\w+$

...but you should really test this out against some data samples before rolling it out to production.

View solution in original post

hexx
Splunk Employee
Splunk Employee

I would suggest:

host_regex = _+([^_]+)(?:__\d+)?\.\w+$

...but you should really test this out against some data samples before rolling it out to production.

conner9
Path Finder

Seems to be working perfectly, Thanks so much for the help.

0 Karma

hexx
Splunk Employee
Splunk Employee

That's ok, when I said "path" I was being inclusive of the file name.

0 Karma

conner9
Path Finder

Nah, I wish it was that easy, these are the actual file names that I'm trying to extract the hostname from.

0 Karma

hexx
Splunk Employee
Splunk Employee

This is helpful, but just to be clear : These strings are part of the path to the source file?

0 Karma

conner9
Path Finder

I know it's a wreck, just looking for good ideas.

Here are some of the myriad of possibilities:

timing_manager_main____iccsfwint0001__13618.term
HOSTNAME=iccsfwin0001

target_diag_manager__optical__iccsint0001.log
HOSTNAME=iccsint0001

target_diag_manager__Video__main-frame-int1__8783.term

HOSTNAME=main-frame-int1

target_area_manager____main-frame-int2.log2
HOSTNAME=main-frame-int2

Timing_FEP____its-master2.log
HOSTNAME=its-master2

hexx
Splunk Employee
Splunk Employee

It's not really possible to answer your question without a data sample showing a string from which you want to extract the value of 'host'. Also, is that string going to be found in the 'source' field of the event?

Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...