<?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: How to extract a field that is changing position in the logs? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278763#M84204</link>
    <description>&lt;P&gt;try:&lt;/P&gt;

&lt;P&gt;If it only had quotes at the end like mentioned in question &lt;CODE&gt;005003"&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearch
| rex "\"\&amp;lt;\"BusinessPartnerCode\&amp;gt;(?&amp;lt;businessCode&amp;gt;[^\"]+)\"\&amp;lt;\"\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it has quote at start and at end &lt;CODE&gt;"005003"&lt;/CODE&gt;` try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearch
| rex "\"\&amp;lt;\"BusinessPartnerCode\&amp;gt;\"(?&amp;lt;businessCode&amp;gt;[^\"]+)\"\&amp;lt;\"\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 24 Oct 2016 16:54:32 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-10-24T16:54:32Z</dc:date>
    <item>
      <title>How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278760#M84201</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to extract a field that is changing position in the logs and cannot figure out how to extract it.&lt;/P&gt;

&lt;P&gt;"&amp;lt;"BusinessPartnerCode&amp;gt;005003"&amp;lt;"/BusinessPartnerCode&amp;gt; (without the quotes)&lt;/P&gt;

&lt;P&gt;The entry looks like above and I am trying to get the numbers in between and name the field. When I mark it with the Splunk Field tool it doesn't work correctly, since the entry changes positions in the events.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;

&lt;P&gt;Oliver&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 16:47:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278760#M84201</guid>
      <dc:creator>omuelle1</dc:creator>
      <dc:date>2016-10-24T16:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278761#M84202</link>
      <description>&lt;P&gt;Is it always the same number? Is it always 6 digits? Please share some sample events.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 16:50:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278761#M84202</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-10-24T16:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278762#M84203</link>
      <description>&lt;P&gt;The number is changing but it's always 6 digits.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 16:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278762#M84203</guid>
      <dc:creator>omuelle1</dc:creator>
      <dc:date>2016-10-24T16:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278763#M84204</link>
      <description>&lt;P&gt;try:&lt;/P&gt;

&lt;P&gt;If it only had quotes at the end like mentioned in question &lt;CODE&gt;005003"&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearch
| rex "\"\&amp;lt;\"BusinessPartnerCode\&amp;gt;(?&amp;lt;businessCode&amp;gt;[^\"]+)\"\&amp;lt;\"\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it has quote at start and at end &lt;CODE&gt;"005003"&lt;/CODE&gt;` try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearch
| rex "\"\&amp;lt;\"BusinessPartnerCode\&amp;gt;\"(?&amp;lt;businessCode&amp;gt;[^\"]+)\"\&amp;lt;\"\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2016 16:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278763#M84204</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-10-24T16:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278764#M84205</link>
      <description>&lt;P&gt;Add this to the sourcetype stanza in props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-bpc = \&amp;lt;BusinessPartnerCode\&amp;gt;(?&amp;lt;BusinessPartnerCode&amp;gt;\d{6})\&amp;lt;\/BusinessPartnerCode\&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or you take the way above for extraction during the search.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 16:57:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278764#M84205</guid>
      <dc:creator>TStrauch</dc:creator>
      <dc:date>2016-10-24T16:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278765#M84206</link>
      <description>&lt;P&gt;Thank you. Actually my number does not have any quotes (just had to put them there because the Splunk website wouldn't allow the brackets otherwise).&lt;/P&gt;

&lt;P&gt;Would this be the correct version without quotes?&lt;/P&gt;

&lt;P&gt;| rex "\"&amp;lt;\"BusinessPartnerCode&amp;gt;(?[^\"]+)&amp;lt;\"\/BusinessPartnerCode&amp;gt;"&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 18:03:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278765#M84206</guid>
      <dc:creator>omuelle1</dc:creator>
      <dc:date>2016-10-24T18:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278766#M84207</link>
      <description>&lt;P&gt;I was riding the same boat as you few days ago. Use the "code Sample" formatting button from text editor whenever you are putting a text which splunk website is messing up for tags. So for example If i type below, then select it and press "Code Sample" button, it will appear as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "\"\&amp;lt;\"BusinessPartnerCode\&amp;gt;(?&amp;lt;businessCode&amp;gt;[^\"]+)\"\&amp;lt;\"\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I type without highlighting and formatting it as "Code Sample" it looks like below:&lt;BR /&gt;
rex "\"&amp;lt;\"BusinessPartnerCode&amp;gt;(?[^\"]+)\"&amp;lt;\"\/BusinessPartnerCode&amp;gt;"&lt;/P&gt;

&lt;P&gt;See how &lt;CODE&gt;?&amp;lt;businessCode&amp;gt;&lt;/CODE&gt; disappears in above in comparison to code sample piece.&lt;BR /&gt;
So use "Code Sample" button and give the exact sample of  line for which you want the regex to be modified and I can paste it here in response.&lt;/P&gt;

&lt;P&gt;However if there are no quotes in your sample above and your sample then is below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;BusinessPartnerCode&amp;gt;005003&amp;lt;/BusinessPartnerCode&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can use this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex "\&amp;lt;BusinessPartnerCode\&amp;gt;(?&amp;lt;businessCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2016 18:11:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278766#M84207</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-10-24T18:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278767#M84208</link>
      <description>&lt;P&gt;Got you, I was wondering what was the trick. Thank you very much.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;BusinessPartnerCode&amp;gt;001999&amp;lt;/BusinessPartnerCode&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So what would be the regex without all the quotes? The one I posted isn't highlighting the the 6 digit code.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 18:15:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278767#M84208</guid>
      <dc:creator>omuelle1</dc:creator>
      <dc:date>2016-10-24T18:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract a field that is changing position in the logs?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278768#M84209</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| rex "\&amp;lt;BusinessPartnerCode\&amp;gt;(?&amp;lt;businessCode&amp;gt;[^\&amp;lt;]+)\&amp;lt;\/BusinessPartnerCode\&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I had pasted it above as well in the ending part of the comment later on.&lt;/P&gt;

&lt;P&gt;OR alternatively if you wanna focus on the digits part (as above extracts everything till it enounters &amp;lt;, use below. Either should work&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex "\&amp;lt;BusinessPartnerCode\&amp;gt;(?&amp;lt;businessCode&amp;gt;\d{6})\&amp;lt;\/BusinessPartnerCode\&amp;gt;"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 18:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-a-field-that-is-changing-position-in-the-logs/m-p/278768#M84209</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-10-24T18:31:04Z</dc:date>
    </item>
  </channel>
</rss>

