<?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: Search in XML file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126706#M34316</link>
    <description>&lt;P&gt;Thanks a lot for giving your precious time. Now it is working as expected. &lt;BR /&gt;
There is one request, can you explain what have you done in regular expression. It will help me a lot.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "Step ID=\"(?&amp;amp;lt;FailedStepID&amp;amp;gt;[^\"]*)\" Name=\"(?&amp;amp;lt;FailedStepName&amp;amp;gt;[^\"]*)\" Status=\"Fail\" StepSer=\"(?&amp;amp;lt;FailedStepSer&amp;amp;gt;[^\"]*)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks once again!!!&lt;/P&gt;</description>
    <pubDate>Fri, 29 May 2015 04:56:43 GMT</pubDate>
    <dc:creator>adityaanand</dc:creator>
    <dc:date>2015-05-29T04:56:43Z</dc:date>
    <item>
      <title>Search in XML file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126704#M34314</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I am new in splunk world.&lt;BR /&gt;
I have an XML file that contains following data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;TargetMachines&amp;gt;
         &amp;lt;TargetMachine Name="win7a2" IPAddress="10.167.177.30" Status="Running" &amp;gt;
              &amp;lt;Tasks&amp;gt;
                      &amp;lt;Task TaskSer="137" PackageName="Client Applications" PackageVersion="V13.5 (P1007499-002)"  Status="Fail"&amp;gt;
                          &amp;lt;Steps&amp;gt;
                                 &amp;lt;Step ID="f2b56177-" Name="ARIA PM" Status="Pass" StepSer="4738" /&amp;gt;
                                 &amp;lt;Step ID="46b4db06" Name="ARIA RO" Status="Fail" StepSer="4739"&amp;gt;
                                 &amp;lt;Step ID="3de785d5-c6" Name="Deluxe Reports" Status="NotStarted" StepSer="4742" /&amp;gt;
                                  ...........
                                  ...........
                           &amp;lt;Steps&amp;gt;
                      &amp;lt;Task&amp;gt;
                 &amp;lt;Tasks&amp;gt;
      &amp;lt;/TargetMachine&amp;gt;
      &amp;lt;TargetMachine Name="win7a3" IPAddress="10.167.177.31" Status="Running" &amp;gt;
              &amp;lt;Tasks&amp;gt;
                      &amp;lt;Task TaskSer="138" PackageName="Client Applications" PackageVersion="V13.5 (P1007499-002)"  Status="Fail"&amp;gt;
                          &amp;lt;Steps&amp;gt;
                                 &amp;lt;Step ID="f2b56174-" Name="ARIA PM" Status="Pass" StepSer="4656" /&amp;gt;
                                 &amp;lt;Step ID="46b4db03" Name="ARIA RO" Status="Fail" StepSer="4657"&amp;gt;
                                 &amp;lt;Step ID="3de785d5" Name="Deluxe Reports" Status="NotStarted" StepSer="4658" /&amp;gt;
                                  ..................
                                 ..................
                           &amp;lt;Steps&amp;gt;
                      &amp;lt;Task&amp;gt;
                 &amp;lt;Tasks&amp;gt;
      &amp;lt;/TargetMachine&amp;gt;
 &amp;lt;/TargetMachines&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The file contains huge data as above .&lt;BR /&gt;
I have broken the events using regular expression making changes in props.conf&lt;BR /&gt;
  BREAK_ONLY_BEFORE = &amp;gt; &lt;CODE&gt;&amp;amp;lt;Task Task&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I am trying to find fail count of &lt;STRONG&gt;step&lt;/STRONG&gt;  by &lt;STRONG&gt;Step Name&lt;/STRONG&gt; of a particular package, so that i can understand  which step is being failed most.&lt;BR /&gt;
Here package name is &lt;STRONG&gt;Client Applications&lt;/STRONG&gt;&lt;BR /&gt;
My search query is :&lt;/P&gt;

&lt;P&gt;source="RSDReport.xml" host="PU4D9W0ND02" index="test" sourcetype="RSD_Log" | spath | search "Task{@PackageName}"="Client Applications" "Task.Steps.Step{@Status}"="Fail" |stats count(Task.Steps.Step{@StepSer}) by Task.Steps.Step{@Name}| where "Task.Steps.Step{@Status}"=="Fail"&lt;/P&gt;

&lt;P&gt;Result: No results found. &lt;BR /&gt;
But It is showing 9 events.&lt;/P&gt;

&lt;P&gt;When i run following search query :&lt;/P&gt;

&lt;P&gt;source="RSDReport.xml" host="PU4D9W0ND02" index="test" sourcetype="RSD_Log" | spath | search "Task{@PackageName}"="Client Applications" "Task.Steps.Step{@Status}"="Fail" |stats count(Task.Steps.Step{@StepSer})&lt;/P&gt;

&lt;P&gt;It gives  result  -  count(Task.Steps.Step{@StepSer}) =351&lt;/P&gt;

&lt;P&gt;But when i run following search query :&lt;/P&gt;

&lt;P&gt;source="RSDReport.xml" host="PU4D9W0ND02" index="test" sourcetype="RSD_Log" | spath | search "Task{@PackageName}"="Client Applications" "Task.Steps.Step{@Status}"="Fail" |stats count(Task.Steps.Step{@StepSer}) by Task.Steps.Step{@Name}&lt;/P&gt;

&lt;P&gt;It gives result &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   Task.Steps.Step{@Name}          count(Task.Steps.Step{@StepSer})
   ARIA Import Export NLS            351
    ARIA PM                            351
    ARIA PM NLS                        351
    ARIA RO                            351
   ARIA RO NLS                         351
   Application Frame NLS               351
   Application Framework              351
  Biological Optimization            351  
  .................
 .................
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and more step name and its count&lt;/P&gt;

&lt;P&gt;Please help me.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Aditya&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:04:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126704#M34314</guid>
      <dc:creator>adityaanand</dc:creator>
      <dc:date>2020-09-28T20:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Search in XML file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126705#M34315</link>
      <description>&lt;P&gt;This will do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="RSDReport.xml" host="PU4D9W0ND02" index="test" sourcetype="RSD_Log" | spath | search "Task{@Status}"="Fail" | rex "Step ID=\"(?&amp;lt;FailedStepID&amp;gt;[^\"]*)\" Name=\"(?&amp;lt;FailedStepName&amp;gt;[^\"]*)\" Status=\"Fail\" StepSer=\"(?&amp;lt;FailedStepSer&amp;gt;[^\"]*)\"" | stats count by "Task{@PackageName}",FailedStepName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 May 2015 01:47:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126705#M34315</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-27T01:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Search in XML file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126706#M34316</link>
      <description>&lt;P&gt;Thanks a lot for giving your precious time. Now it is working as expected. &lt;BR /&gt;
There is one request, can you explain what have you done in regular expression. It will help me a lot.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex "Step ID=\"(?&amp;amp;lt;FailedStepID&amp;amp;gt;[^\"]*)\" Name=\"(?&amp;amp;lt;FailedStepName&amp;amp;gt;[^\"]*)\" Status=\"Fail\" StepSer=\"(?&amp;amp;lt;FailedStepSer&amp;amp;gt;[^\"]*)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks once again!!!&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 04:56:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126706#M34316</guid>
      <dc:creator>adityaanand</dc:creator>
      <dc:date>2015-05-29T04:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Search in XML file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126707#M34317</link>
      <description>&lt;P&gt;The &lt;CODE&gt;rex&lt;/CODE&gt; command uses standard &lt;CODE&gt;PCRE&lt;/CODE&gt; with &lt;CODE&gt;named capturing groups&lt;/CODE&gt; to create ad-hoc fields that are associated only with the search that you run.  You can learn about &lt;CODE&gt;PCRE&lt;/CODE&gt; in hundreds of places around the web.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 05:42:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126707#M34317</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-29T05:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Search in XML file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126708#M34318</link>
      <description>&lt;P&gt;Is regex is dependent on how do i break events?&lt;BR /&gt;
Actually Earlier i broke the events on &amp;lt;Task&amp;gt; tag.&lt;BR /&gt;
But now i broke the events on &amp;lt;TargetMachine&amp;gt; tag and used the same query as above. But this time output is not correct. &lt;BR /&gt;
I found that there is  two &amp;lt;Task&amp;gt; in &amp;lt;TargetMachine&amp;gt;...&amp;lt;/TargetMachine&amp;gt; and both are failed. So which ever task found earlier, that included into result and other one is excluded . &lt;BR /&gt;
It is my thinking that might be if splunk found a particular match in an event then it ignores the rest of part of that event.&lt;BR /&gt;
Am I right ?&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 09:21:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126708#M34318</guid>
      <dc:creator>adityaanand</dc:creator>
      <dc:date>2015-05-29T09:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Search in XML file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126709#M34319</link>
      <description>&lt;P&gt;Yes, &lt;CODE&gt;rex&lt;/CODE&gt; will only run once against your event but you can create a &lt;CODE&gt;field extraction&lt;/CODE&gt; with the same &lt;CODE&gt;RegEx&lt;/CODE&gt; that will run more than once; read about it here (and search for &lt;CODE&gt;mv_add&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/latest/admin/Transformsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 12:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-in-XML-file/m-p/126709#M34319</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-05-29T12:39:38Z</dc:date>
    </item>
  </channel>
</rss>

