<?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 Re: Extract key-value pairs while ignoring &amp;quot;header&amp;quot; data using regex. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313697#M93900</link>
    <description>&lt;P&gt;Looks like this might work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+(?&amp;lt;key1&amp;gt;[^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)(?&amp;lt;value1&amp;gt;[^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;on that site (regexr.com), it would be like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+([^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)([^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 21 Feb 2017 20:32:17 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-02-21T20:32:17Z</dc:date>
    <item>
      <title>Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313693#M93896</link>
      <description>&lt;P&gt;I have a regular expression that works on part of my data.&lt;BR /&gt;
Given the log entry:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;pam_vas: Authentication &amp;lt;succeeded&amp;gt; for &amp;lt;active directory&amp;gt; user: &amp;lt;bobtheperson&amp;gt; account: &amp;lt;bobtheperson@com.com&amp;gt; reason: &amp;lt;N/A&amp;gt; Access cont(upn): &amp;lt;bob&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i can use the regular expression: &lt;CODE&gt;[\&amp;gt;\:]*\s+(.*?)\:?\s\&amp;lt;(.+?)\&amp;gt;&lt;/CODE&gt; and get the result I am looking for. (&lt;A href="http://regexr.com/3fatg"&gt;http://regexr.com/3fatg&lt;/A&gt;)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Authentication = succeeded
for = active directory
user = bobtheperson
account = bobtheperson@com.com
reason = N/A
Access cont(upn) = bob
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately, when I was building this regular expression, I was ignoring a vital part of the log -- the first part. &lt;BR /&gt;
The log actually looks like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Feb 16 20:04:37 hostname su[1111]: [id 123456 auth.info] pam_vas: Authentication &amp;lt;succeeded&amp;gt; for &amp;lt;active directory&amp;gt; user: &amp;lt;bobtheperson&amp;gt; account: &amp;lt;bobtheperson@com.com&amp;gt; reason: &amp;lt;N/A&amp;gt; Access cont(upn): &amp;lt;bob&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My extraction no longer works right -- it is thrown off by the first part. (&lt;A href="http://regexr.com/3fbod"&gt;http://regexr.com/3fbod&lt;/A&gt;)&lt;BR /&gt;
How would I exclude the beginning information from this log file?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;**Feb 16 20:04:37 hostname su[1111]: [id 123456 auth.info]** pam_vas: Authentication &amp;lt;succeeded&amp;gt; for &amp;lt;active directory&amp;gt; user: &amp;lt;bobtheperson&amp;gt; account: &amp;lt;bobtheperson@com.com&amp;gt; reason: &amp;lt;N/A&amp;gt; Access cont(upn): &amp;lt;bob&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think I need to start my search after the last occurrence of a ]  (right before pam_vas) but I cant figure out how to exclude that.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 19:05:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313693#M93896</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T19:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313694#M93897</link>
      <description>&lt;P&gt;Can you provide a couple more examples?  Specifically, do all relevant log events contain "pam_vas:" or are there other items that potentially appear there?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 19:56:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313694#M93897</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-21T19:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313695#M93898</link>
      <description>&lt;P&gt;Also, are the fields name and their order always the same (authentication, user account etc)?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:11:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313695#M93898</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-21T20:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313696#M93899</link>
      <description>&lt;P&gt;At this time, all logs seem to have pam_vas. I cant be completely sure they will all have it though.&lt;BR /&gt;
The format DOES seem consistent -- the "] " (not "] [") seems to be a good breaker (right before pam_vas)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:57:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313696#M93899</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2020-09-29T12:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313697#M93900</link>
      <description>&lt;P&gt;Looks like this might work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+(?&amp;lt;key1&amp;gt;[^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)(?&amp;lt;value1&amp;gt;[^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;on that site (regexr.com), it would be like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+([^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)([^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313697#M93900</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-21T20:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313698#M93901</link>
      <description>&lt;P&gt;Although the format stays the same, the log content may change. i need the "pairs" to be generic.&lt;BR /&gt;
Edit: Looking at more logs, they all seem to be the same. I do hate to hard-code the key though, just in case things update.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:33:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313698#M93901</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T20:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313699#M93902</link>
      <description>&lt;P&gt;I paste these into a site that explains the entire regex to me, and it just overwhelms me with what people can do with this tool. This looks like it will work -- testing now.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:38:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313699#M93902</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T20:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313700#M93903</link>
      <description>&lt;P&gt;I designed this regex by building up from the right.  The only decent /clear/permanent boundary was the value in angle brackets, so I started with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   \&amp;lt;(?&amp;lt;value1&amp;gt;[^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That works to grab anything in angle brackets, NOT including other angle brackets.  &lt;/P&gt;

&lt;P&gt;Then I wanted to extend back to grab the colon, if any, getting this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?:\:?\s\&amp;lt;)(?&amp;lt;value1&amp;gt;[^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The "?:" was because we didn't want to capture that group, but I really wanted to think of it as a group.&lt;BR /&gt;
Next, we had to deal with that last key field -- "Access cont(upn)" -- having a space and parenthesis in it. &lt;BR /&gt;
Reviewing the rest of the key fields, I ended up deciding that the characters really could be anything but a colon or an angle bracket, getting this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;key1&amp;gt;[^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)(?&amp;lt;value1&amp;gt;[^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that excluding the colon also made sure that pam_vas would not be grabbed.  That regex was grabbing everything I wanted, but also grabbing one space before the key field. So the final version became this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s+(?&amp;lt;key1&amp;gt;[^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)(?&amp;lt;value1&amp;gt;[^\&amp;gt;]+)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:39:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313700#M93903</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-21T20:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313701#M93904</link>
      <description>&lt;P&gt;Given a solaris BSM authentication log, I was able to extract key/value pairs using the following:&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[MyKVP]
REGEX = \s+([^\:\&amp;lt;\&amp;gt;]+)(?:\:?\s\&amp;lt;)([^\&amp;gt;]+)\&amp;gt;
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sol_bsm] #my sourcetype in this test
REPORT-MyKVP = MyKVP
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:46:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313701#M93904</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T20:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313702#M93905</link>
      <description>&lt;P&gt;If the only thing that you must do is to skip past all end-square-brackets ( &lt;CODE&gt;]&lt;/CODE&gt; ), then you need a leading &lt;CODE&gt;postitive-lookahead&lt;/CODE&gt; that specifies that everything until the end must contain anything EXCEPT that character.  Try this RegEx:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?=[^\]]*$)[\&amp;gt;\:]*\s+(.*?)\:?\s\&amp;lt;(.+?)\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313702#M93905</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-21T20:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313703#M93906</link>
      <description>&lt;P&gt;This one works as well, except for capturing the pam_vas text. But you call that out, of course, as it does not fit the others and the ] standard item. It is an odd variable.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313703#M93906</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T21:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313704#M93907</link>
      <description>&lt;P&gt;So does this provide the solution or not?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:04:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313704#M93907</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-21T21:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313705#M93908</link>
      <description>&lt;P&gt;It does -- im not quite sure what to when more than one valid answer happens, though. &lt;BR /&gt;
I can only accept one.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:10:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313705#M93908</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T21:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313706#M93909</link>
      <description>&lt;P&gt;You are quite welcome.  &lt;/P&gt;

&lt;P&gt;Yes, a complex regex still often looks like gobbledy gook to me, and understanding what changes need to be made to use it in a .conf file instead of in a search is an adventure.  This was a chance to explore positive and negative lookaheads, but I ended up not requiring them to meet your needs.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:11:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313706#M93909</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-21T21:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313707#M93910</link>
      <description>&lt;P&gt;I ended up focusing in on the angle brackets as the only "fixed" item, and from there it expanded pretty easily to what you needed.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:13:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313707#M93910</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-21T21:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313708#M93911</link>
      <description>&lt;P&gt;IMHO, you should always up-vote correct answers and then select the BEST one by clicking &lt;CODE&gt;Accept&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313708#M93911</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-21T21:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract key-value pairs while ignoring "header" data using regex.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313709#M93912</link>
      <description>&lt;P&gt;Upvoted! I will keep that in mind for next time.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 21:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-key-value-pairs-while-ignoring-quot-header-quot-data/m-p/313709#M93912</guid>
      <dc:creator>oliverj</dc:creator>
      <dc:date>2017-02-21T21:31:52Z</dc:date>
    </item>
  </channel>
</rss>

