Getting Data In

Extract field values

shangshin
Builder

Hi, I have having the following stanza in transforms.conf

[apache_fields]
DELIMS = "\t"
FIELDS = clientip,remotelogname,user_id,timestamp,resource_requested,http_status_code,content_length,referrer,user_agent,response_time

clientip field value could be 1 or 2 IP separated by comma
10.39.127.164
10.39.127.164, 10.183.135.2

Is it possible to add another stanza so I can extract ip1 and ip2 if it exists.

Thanks in advance!

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Have you considered replacing the DELIMS and FIELDS statements with a REGEX? For example:

[apache_fields]
REGEX = (?<ip1>.*?)(,\s(?<ip2>.*?))?\s(?<remotelogname>.*?)\s(?<user_id>.*?)\s(?<timestamp>.*?)\s(?<resource_requested>.*?)\s(?<http_status_code>.*?)\s(?<content_length>.*?)\s(?<referrer>.*?)\s(?<user_agent>.*?)\s(?<response_time>.*)
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Have you considered replacing the DELIMS and FIELDS statements with a REGEX? For example:

[apache_fields]
REGEX = (?<ip1>.*?)(,\s(?<ip2>.*?))?\s(?<remotelogname>.*?)\s(?<user_id>.*?)\s(?<timestamp>.*?)\s(?<resource_requested>.*?)\s(?<http_status_code>.*?)\s(?<content_length>.*?)\s(?<referrer>.*?)\s(?<user_agent>.*?)\s(?<response_time>.*)
---
If this reply helps you, Karma would be appreciated.

shangshin
Builder

Thank you. This works!

0 Karma

shangshin
Builder

yes, the delimiter is comma. I tried to add a new stanza below but it didn't work out. Thank you!

[clientip]
DELIMS = ", "
FIELDS = aip1, aip2

0 Karma

lukejadamec
Super Champion

So, there is white space for a delimiter, but only a comma between the IPs?

0 Karma
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 ...