<?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 X number of fields based on another field value in the data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262186#M78706</link>
    <description>&lt;P&gt;What you could do is, create a multi-value field. In your props.conf add the following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-msg_bytes = \]\s(?&amp;lt;msg_bytes&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will extract all the message bytes into a mv field called msg_bytes. You can then use this in your search query to get to individual bits using &lt;CODE&gt;split()&lt;/CODE&gt; or &lt;CODE&gt;makemv&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search that returns in msg_bytes amongst others | makemv msg_bytes delim=" " | eval msg_length=mvcount(msg_bytes) mvexpand msg_bytes | you should now have msg_bytes extract into individual events.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt; if you just want a specific one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search that returns in msg_bytes amongst others | eval msg_bit=mvindex(split(msg_bytes, " "), 0) | this will give you the first bit etc.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 04 Dec 2016 15:57:03 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-12-04T15:57:03Z</dc:date>
    <item>
      <title>How to extract X number of fields based on another field value in the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262184#M78704</link>
      <description>&lt;P&gt;I am capturing some machine data and am wondering if it is possible to grab more or fewer fields via field extraction based on a size field in the data itself?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1480823739.999999 bus device [6] aa bb ff 00 33 33 
1480823741.999999 bus device [2] ab f0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with the [6] and [2] in the data being the size values respectively.&lt;BR /&gt;
My present field extraction regex looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^\s+\(\d+\.\d+\)\s+(?P&amp;lt;bus&amp;gt;\w{1,4})\s+(?P&amp;lt;device&amp;gt;\w{2,3})\s+\[(?P&amp;lt;data_len&amp;gt;\d)\]\s+
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gets me extracted up to the message bytes. While I can just import the data values as a single field, I would like to be able to pull each two hex characters into separate fields based on this size data.&lt;/P&gt;

&lt;P&gt;Expanding on my regex, if I add multiple byte extractions to cover all instances, the smaller messages will not be extracted.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ^\s+\(\d+\.\d+\)\s+(?P&amp;lt;bus&amp;gt;\w{1,4})\s+(?P&amp;lt;device&amp;gt;\w{2,3})\s+\[(?P&amp;lt;data_len&amp;gt;\d)\]\s+(?P&amp;lt;byte0&amp;gt;\w[0-9A-F]+)\s+(?P&amp;lt;byte1&amp;gt;\w[0-9A-F]+)\s+(?P&amp;lt;byte2...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This results in the 6 byte messages being trapped and none of the smaller messages will.&lt;/P&gt;

&lt;P&gt;Can I have Splunk create multiple &amp;gt;byte1&amp;lt;,&amp;gt;byte2&amp;lt;,&amp;gt;byteN&amp;lt;... extractions based on the &amp;gt;data_len&amp;lt; field?&lt;/P&gt;

&lt;P&gt;Thank you, &lt;BR /&gt;
Wilsonite&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2016 04:26:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262184#M78704</guid>
      <dc:creator>wilsonite</dc:creator>
      <dc:date>2016-12-04T04:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract X number of fields based on another field value in the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262185#M78705</link>
      <description>&lt;P&gt;Read this.  I think this will help:  &lt;A href="https://answers.splunk.com/answers/103700/how-do-i-create-a-field-whose-name-is-the-value-of-another-field-like-backticks-or-eval-in-other-languages.html"&gt;https://answers.splunk.com/answers/103700/how-do-i-create-a-field-whose-name-is-the-value-of-another-field-like-backticks-or-eval-in-other-languages.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2016 15:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262185#M78705</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2016-12-04T15:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract X number of fields based on another field value in the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262186#M78706</link>
      <description>&lt;P&gt;What you could do is, create a multi-value field. In your props.conf add the following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-msg_bytes = \]\s(?&amp;lt;msg_bytes&amp;gt;.*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will extract all the message bytes into a mv field called msg_bytes. You can then use this in your search query to get to individual bits using &lt;CODE&gt;split()&lt;/CODE&gt; or &lt;CODE&gt;makemv&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search that returns in msg_bytes amongst others | makemv msg_bytes delim=" " | eval msg_length=mvcount(msg_bytes) mvexpand msg_bytes | you should now have msg_bytes extract into individual events.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt; if you just want a specific one&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search that returns in msg_bytes amongst others | eval msg_bit=mvindex(split(msg_bytes, " "), 0) | this will give you the first bit etc.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Dec 2016 15:57:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262186#M78706</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-12-04T15:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract X number of fields based on another field value in the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262187#M78707</link>
      <description>&lt;P&gt;sundareshr,  I cannot wait to try this tonight.  Thank you for your insight!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 15:49:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262187#M78707</guid>
      <dc:creator>wilsonite</dc:creator>
      <dc:date>2016-12-05T15:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract X number of fields based on another field value in the data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262188#M78708</link>
      <description>&lt;P&gt;That is a good link as well, thank you dmaislin!  Will let you folks know how it turns out.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 18:15:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-X-number-of-fields-based-on-another-field-value/m-p/262188#M78708</guid>
      <dc:creator>wilsonite</dc:creator>
      <dc:date>2016-12-05T18:15:04Z</dc:date>
    </item>
  </channel>
</rss>

