<?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: Counting xml tags in raw event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179412#M51643</link>
    <description>&lt;P&gt;Try following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=gatewaylogs1 |  rex "^\&amp;lt;(?&amp;lt;eventType&amp;gt;[^\&amp;gt;]+)" | stats count by eventType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give your count of event for transaction/error.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2013 19:06:48 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2013-12-16T19:06:48Z</dc:date>
    <item>
      <title>Counting xml tags in raw event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179408#M51639</link>
      <description>&lt;P&gt;my event records are xml based as shown below coming in from one file, one sourcetype-&lt;BR /&gt;
&lt;TRANSACTION&gt;&lt;ID&gt;12&lt;/ID&gt;........&lt;/TRANSACTION&gt;&lt;BR /&gt;
&lt;TRANSACTION&gt;.....&lt;/TRANSACTION&gt;  // inside transaction tag i can contain anything&lt;BR /&gt;
&lt;TRANSACTION&gt;.....&lt;/TRANSACTION&gt;&lt;BR /&gt;
&lt;ERROR&gt;.....&lt;/ERROR&gt;&lt;BR /&gt;
&lt;ERROR&gt;.....&lt;/ERROR&gt;&lt;BR /&gt;
&lt;TRANSACTION&gt;.....&lt;/TRANSACTION&gt;&lt;BR /&gt;
&lt;TRANSACTION&gt;.....&lt;/TRANSACTION&gt;&lt;BR /&gt;
&lt;ERROR&gt;.....&lt;/ERROR&gt;&lt;BR /&gt;
I am able to extract child tags inside each one - thats not an issue.&lt;BR /&gt;
But how do i count how many records were of type Transaction and how many were of type Error.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 01:03:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179408#M51639</guid>
      <dc:creator>ajaysamantbms</dc:creator>
      <dc:date>2013-12-16T01:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Counting xml tags in raw event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179409#M51640</link>
      <description>&lt;P&gt;how are you extracting fields? Using regular expression for each field or using spath?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 06:11:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179409#M51640</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-16T06:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Counting xml tags in raw event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179410#M51641</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=gatewaylogs1 "&amp;lt;transaction&amp;gt;" OR "&amp;lt;error&amp;gt;" 
| eval type=case (match(_raw,"\&amp;lt;transaction\&amp;gt;", "Transaction",  match(_raw,"\&amp;lt;error\&amp;gt;", "Error")
| stats count by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if the transaction contains an XML error field, it will be counted only as a transaction, not as an error&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 12:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179410#M51641</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-12-16T12:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Counting xml tags in raw event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179411#M51642</link>
      <description>&lt;P&gt;Tried this &lt;/P&gt;

&lt;P&gt;sourcetype=gatewaylogs1 | eval type=case ( match(_raw,"&amp;lt;error&amp;gt;"), "Error", match(_raw,"&amp;lt;transaction&amp;gt;"), "Transaction" ) | stats count by type&lt;/P&gt;

&lt;P&gt;No errors...but no output..all it says 16 events..shows number of events..16 events (before 12/16/13 11:25:23.000 AM ) but no output in Statistics tab &lt;/P&gt;

&lt;P&gt;And 16 is total events including events that has &lt;ACCESS&gt; tags which i wanted to filter..so this query is really not doing anything..&lt;/ACCESS&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:29:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179411#M51642</guid>
      <dc:creator>ajaysamantbms</dc:creator>
      <dc:date>2020-09-28T15:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting xml tags in raw event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179412#M51643</link>
      <description>&lt;P&gt;Try following &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=gatewaylogs1 |  rex "^\&amp;lt;(?&amp;lt;eventType&amp;gt;[^\&amp;gt;]+)" | stats count by eventType
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give your count of event for transaction/error.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 19:06:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179412#M51643</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-16T19:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Counting xml tags in raw event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179413#M51644</link>
      <description>&lt;P&gt;Well, your search isn't filtering out anything, so it will certainly have all the events from gatewaylogs1. I have updated the search. But not sure yet if it will work.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 23:14:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-xml-tags-in-raw-event/m-p/179413#M51644</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-12-16T23:14:59Z</dc:date>
    </item>
  </channel>
</rss>

