<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic facing issue in field extraction for regex in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/facing-issue-in-field-extraction-for-regex/m-p/482113#M8578</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;Hi All,
I wish to create a regex that should work with multiple log format
using  2 type log format.
1)
log format:
5 auth_mechanism: SSO_ISE auth group

[syslog_pass1]
regex =(?P&amp;lt;user_agent&amp;gt;\s+[(\S+)])(?P&amp;lt;cust_field&amp;gt;(?:\s+(?:\")?([^\"$]+))?)
FORMAT= user_agent::$1  cust_field::$2

2)
In second log format , one new field(proxy_id) is added in between user_agent ad cust_field.
Log Format:
 5 3 auth_mechanism: SSO_ISE auth group

[syslog_pass2]
regex =(?P&amp;lt;user_agent&amp;gt;\s+[(\S+)])(?P&amp;lt;proxy_instance_id&amp;gt;\s+[(\S+)])(?P&amp;lt;cust_field&amp;gt;(?:\s+(?:\")?([^\"$]+))?) 
FORMAT= user_agent::$1 proxy_id::$2 cust_field::$3

we wrote 2 regex for different log format.but field extration is not happening properly
if log is coming in  this log  format:  5 auth_mechanism: SSO_ISE  but so i am getting field value for user_agent is 5 , proxy_id is a , cust_field is auth_mechanism: SSO_ISE.
how to correct the regex for getting correct value of field ?
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 14 Sep 2019 09:59:48 GMT</pubDate>
    <dc:creator>pragycho</dc:creator>
    <dc:date>2019-09-14T09:59:48Z</dc:date>
    <item>
      <title>facing issue in field extraction for regex</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/facing-issue-in-field-extraction-for-regex/m-p/482113#M8578</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;Hi All,
I wish to create a regex that should work with multiple log format
using  2 type log format.
1)
log format:
5 auth_mechanism: SSO_ISE auth group

[syslog_pass1]
regex =(?P&amp;lt;user_agent&amp;gt;\s+[(\S+)])(?P&amp;lt;cust_field&amp;gt;(?:\s+(?:\")?([^\"$]+))?)
FORMAT= user_agent::$1  cust_field::$2

2)
In second log format , one new field(proxy_id) is added in between user_agent ad cust_field.
Log Format:
 5 3 auth_mechanism: SSO_ISE auth group

[syslog_pass2]
regex =(?P&amp;lt;user_agent&amp;gt;\s+[(\S+)])(?P&amp;lt;proxy_instance_id&amp;gt;\s+[(\S+)])(?P&amp;lt;cust_field&amp;gt;(?:\s+(?:\")?([^\"$]+))?) 
FORMAT= user_agent::$1 proxy_id::$2 cust_field::$3

we wrote 2 regex for different log format.but field extration is not happening properly
if log is coming in  this log  format:  5 auth_mechanism: SSO_ISE  but so i am getting field value for user_agent is 5 , proxy_id is a , cust_field is auth_mechanism: SSO_ISE.
how to correct the regex for getting correct value of field ?
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Sep 2019 09:59:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/facing-issue-in-field-extraction-for-regex/m-p/482113#M8578</guid>
      <dc:creator>pragycho</dc:creator>
      <dc:date>2019-09-14T09:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: facing issue in field extraction for regex</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/facing-issue-in-field-extraction-for-regex/m-p/482114#M8579</link>
      <description>&lt;P&gt;Assuming that is the entire message and useragent/proxy id will be numbers, I'd probably write it like this, with just one regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^\s*(?&amp;lt;user_agent&amp;gt;\d+)\s*(?&amp;lt;proxy_id&amp;gt;\d*)\s*(?&amp;lt;cust_field&amp;gt;[^:]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I believe if you specify the named capture group in your regex, then you don't need to specify the FORMAT....at least at search time.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 13:10:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/facing-issue-in-field-extraction-for-regex/m-p/482114#M8579</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2019-09-14T13:10:18Z</dc:date>
    </item>
  </channel>
</rss>

