<?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 multiple field values for a field from single log event and cross check with the data from a file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447886#M126944</link>
    <description>&lt;P&gt;Hi All, I found the solution for this , Will take a chance to update the answer here&lt;/P&gt;

&lt;P&gt;Firstly I had written the regex to extract the multiple values of MID's and TID's from the raw logs &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype TID MID | rex max_match=50 "&amp;lt;MID&amp;gt;(?P&amp;lt;mid_extracted&amp;gt;[^\&amp;lt;]+)"|rex max_match=50 "TID\=\"(?P&amp;lt;tid_extracted&amp;gt;[^\"]+)" |table mid_extracted , tid_extracted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now to split the multiple values in a singe event used  &amp;gt; MVEXPAND and finally performed the join with the externally uploaded lookup file .Lookup table contains 2 columns . one is MID Values/TID Values second one is Status .Under MID Values/Tid Values columns we have all the values to be checked and in second column all the values were written as MATCHED &lt;/P&gt;

&lt;P&gt;The final query having join condition is as below &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype TID MID |rex max_match=50 "TID\=\"(?P&amp;lt;tid_extracted&amp;gt;[^\"]+)" |mvexpand tid_extracted |table tid_extracted |join type=left tid_extracted [| inputlookup tid_test.csv]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now If any value in Splunk extracted output matches the value in Lookup file , The status field value displays as MATCHED &lt;BR /&gt;
else&lt;BR /&gt;
displays empty value&lt;/P&gt;

&lt;P&gt;Note: In lookup file the column heading should be exactly as splunk output field heading means tid_extraced should be same &lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2019 05:07:19 GMT</pubDate>
    <dc:creator>raj_mpl</dc:creator>
    <dc:date>2019-03-26T05:07:19Z</dc:date>
    <item>
      <title>How to extract multiple field values for a field from single log event and cross check with the data from a file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447882#M126940</link>
      <description>&lt;P&gt;Hi All , Good Day&lt;/P&gt;

&lt;P&gt;My log will generate 2 types of log events &lt;BR /&gt;
1)&lt;STRONG&gt;tid&lt;/STRONG&gt; and &lt;STRONG&gt;mid&lt;/STRONG&gt;  in single log event&lt;BR /&gt;
2)multiple field values for a single fields (tid and mid) from a single log event &lt;/P&gt;

&lt;P&gt;Now I have a list of tid or mid values with me in an excel sheet , How to compare whether the values are present in the splunk output output with the values I have in excel sheet?&lt;/P&gt;

&lt;P&gt;below are the sample events&lt;/P&gt;

&lt;P&gt;Event 1:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;From *********&amp;gt;
    &amp;lt;To *********&amp;lt;/To&amp;gt;
    &amp;lt;MID&amp;gt;ABC&amp;lt;/MID&amp;gt;

  &amp;lt;Transactions&amp;gt;
    &amp;lt;Transaction tID="123" transactionDate="date"&amp;gt; 
    &amp;lt;From ***/From&amp;gt;
    **
    &amp;lt;MID&amp;gt;DEF&amp;lt;/MID&amp;gt;

  &amp;lt;Transactions&amp;gt;

  &amp;lt;Transaction tID="456" transactionDate="**********&amp;gt;

    &amp;lt;To *****/To&amp;gt;
    &amp;lt;MID&amp;gt;GHI&amp;lt;/MessageID&amp;gt;

 &amp;lt;Transactions&amp;gt;

  &amp;lt;Transaction tID="789" transactionDate="**********&amp;gt;
    &amp;lt;To *****/To&amp;gt;
    &amp;lt;MID&amp;gt;JKL&amp;lt;/MessageID&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Event 2:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;Transactions&amp;gt;

  &amp;lt;Transaction tID="zyxy" transactionDate="**********&amp;gt;

    &amp;lt;To *****/To&amp;gt;
    &amp;lt;MID&amp;gt;a2128u&amp;lt;/MessageID&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to extract the fields first using regex ? And how to cross check with the TID values in excel sheet with splunk output?&lt;/P&gt;

&lt;P&gt;Please help . Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 06:37:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447882#M126940</guid>
      <dc:creator>raj_mpl</dc:creator>
      <dc:date>2019-03-18T06:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple field values for a field from single log event and cross check with the data from a file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447883#M126941</link>
      <description>&lt;P&gt;@raj_mpl &lt;/P&gt;

&lt;P&gt;Have you tried with &lt;CODE&gt;xpath&lt;/CODE&gt;??  &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/xpath"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/xpath&lt;/A&gt;&lt;BR /&gt;
You can use &lt;CODE&gt;xpath&lt;/CODE&gt; for extracting all transactions from the 1st event.&lt;/P&gt;

&lt;P&gt;You can use join command to relate those transactions with the 2nd event. &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.4/SearchReference/Join"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.4/SearchReference/Join&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you want help in search design then share both valid XML events. So we can help you batter.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 07:15:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447883#M126941</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-03-18T07:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple field values for a field from single log event and cross check with the data from a file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447884#M126942</link>
      <description>&lt;P&gt;Hi @kamlesh_vaghela , Thanks for your response on this&lt;BR /&gt;
I tried using &lt;CODE&gt;xpath&lt;/CODE&gt; command but no luck &lt;BR /&gt;
below is the event &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Header&amp;gt;
&amp;lt;To&amp;gt;xxx&amp;lt;/To&amp;gt;
&amp;lt;MID&amp;gt;CBC&amp;lt;/MID&amp;gt;
&amp;lt;TransactionGroup&amp;gt;NEEY&amp;lt;/TransactionGroup&amp;gt;
&amp;lt;Priority&amp;gt;Low&amp;lt;/Priority&amp;gt;
&amp;lt;/Header&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And tried like below&lt;BR /&gt;&lt;BR /&gt;
    sourcetype=something tID MID| xpath "//Header/MID" outfield=MID&lt;/P&gt;

&lt;P&gt;I formed a query using regex to extract all the values by using below one.its extracting all the values from events which are having more number of values in them. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=something tID MID | rex max_match=50 "&amp;lt;MID&amp;gt;(?P&amp;lt;mid_extract&amp;gt;[^\&amp;lt;]+)"|rex max_match=50 "tID\=\"(?P&amp;lt;tid_extract&amp;gt;[^\"]+)" |table mid_extract,tid_extract
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If my approach and the output is correct ? Then my requirement is to validate the output values with my tid's or mid's in external file &lt;BR /&gt;
please help&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 09:41:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447884#M126942</guid>
      <dc:creator>raj_mpl</dc:creator>
      <dc:date>2019-03-18T09:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple field values for a field from single log event and cross check with the data from a file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447885#M126943</link>
      <description>&lt;P&gt;@raj_mpl &lt;/P&gt;

&lt;P&gt;Can you please share XML  Event 1 and Event 2 mentioned in the question? I think I can help you with the search. Mask original values with the sample values in the event. &lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 09:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447885#M126943</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-03-18T09:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple field values for a field from single log event and cross check with the data from a file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447886#M126944</link>
      <description>&lt;P&gt;Hi All, I found the solution for this , Will take a chance to update the answer here&lt;/P&gt;

&lt;P&gt;Firstly I had written the regex to extract the multiple values of MID's and TID's from the raw logs &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype TID MID | rex max_match=50 "&amp;lt;MID&amp;gt;(?P&amp;lt;mid_extracted&amp;gt;[^\&amp;lt;]+)"|rex max_match=50 "TID\=\"(?P&amp;lt;tid_extracted&amp;gt;[^\"]+)" |table mid_extracted , tid_extracted
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now to split the multiple values in a singe event used  &amp;gt; MVEXPAND and finally performed the join with the externally uploaded lookup file .Lookup table contains 2 columns . one is MID Values/TID Values second one is Status .Under MID Values/Tid Values columns we have all the values to be checked and in second column all the values were written as MATCHED &lt;/P&gt;

&lt;P&gt;The final query having join condition is as below &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mysourcetype TID MID |rex max_match=50 "TID\=\"(?P&amp;lt;tid_extracted&amp;gt;[^\"]+)" |mvexpand tid_extracted |table tid_extracted |join type=left tid_extracted [| inputlookup tid_test.csv]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now If any value in Splunk extracted output matches the value in Lookup file , The status field value displays as MATCHED &lt;BR /&gt;
else&lt;BR /&gt;
displays empty value&lt;/P&gt;

&lt;P&gt;Note: In lookup file the column heading should be exactly as splunk output field heading means tid_extraced should be same &lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 05:07:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-field-values-for-a-field-from-single-log/m-p/447886#M126944</guid>
      <dc:creator>raj_mpl</dc:creator>
      <dc:date>2019-03-26T05:07:19Z</dc:date>
    </item>
  </channel>
</rss>

