<?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: Using stats instead of transaction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579449#M201919</link>
    <description>&lt;P&gt;The search commands don't make sense since the first will eliminate both your example events as neither has both these strings, and the even without the first search, the second will eliminate all the ReST log events since they don't appear to have matching strings.&lt;/P&gt;&lt;P&gt;The rex to extract the query string doesn't make sense since it isn't a match for your example.&lt;/P&gt;&lt;P&gt;The rex to extract tmsIds and tmsProviderProgramIds don't make sense since all they will do is both effectively copy the query string (which presumably has already been extracted?)&lt;/P&gt;</description>
    <pubDate>Wed, 29 Dec 2021 10:58:10 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-12-29T10:58:10Z</dc:date>
    <item>
      <title>Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579413#M201906</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Looking for some assistance in reconstructing my query, which is currently using | transaction with a traceId value to tie together a couple different sourcetypes/sources.&lt;/P&gt;&lt;P&gt;My query runs really slow, some of the sourcetype log results number in the 200million range so looking to speed it up using&lt;STRONG&gt; | stats by &amp;lt;traceId&amp;gt;&lt;/STRONG&gt; instead to get the query to run faster.&lt;/P&gt;&lt;P&gt;First source example snippet shows the highlighted traceId and 404 response code i am looking for.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#3366FF"&gt;time=2021-12-11T23:59:51-07:00 time_ms=2021-12-11T23:59:51-07:00.620+ requestId=-1796576042&lt;STRONG&gt; traceId=-1796576042&lt;/STRONG&gt; servicePath="/nationalnavigation/" remoteAddr=x.x.x.x clientIp=x.x.x.xclientAppVersion=NOT_AVAILABLE clientDeviceType=NOT_AVAILABLE app_version=- apiKey=somekey&amp;nbsp;oauth_leg=2-legged authMethod=oauth apiAuth=true apiAuthPath=/ oauth_version=1.0 target_bg=default requestHost=services.timewarnercable.com requestPort=8080 requestMethod=GET requestURL="/nationalnavigation/V1/symphoni/event/tmsid/blah.com::TVNF0321206000538347?division=FTWR&amp;amp;lineup=15&amp;amp;profile=sg_v1&amp;amp;cacheID=959&amp;amp;longAdvisory=false&amp;amp;vodId=fort_worth&amp;amp;tuneToChannel=false&amp;amp;watchLive=true&amp;amp;watchOnDemand=true&amp;amp;rtReviewsLimit=0&amp;amp;includeAdult=f" requestSize=835 &lt;STRONG&gt;responseStatus=404&lt;/STRONG&gt; responseSize=420 responseTime=0.405 userAgent="Java/1.xxx" mapTEnabled="F" cClientIp="V-1|IP-x.x.x.x|SourcePort-12345|TrafficOriginID-x.x.x.x" sourcePort="12345" appleEgressEnabled="F" oauth_consumer_key="somekey" x_pi_auth_failure="-" pi_log="pi_ngxgw_access"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;second source example shows the REST server logs with an exception.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#3366FF"&gt;&lt;SPAN class=""&gt;2021-12-11&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;23&lt;/SPAN&gt;:59:51&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;261&lt;/SPAN&gt; &lt;SPAN class=""&gt;ERROR&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN class=""&gt;qtp1647496677-7239&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;STRONG&gt;[&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;-1796576042&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;]&lt;/STRONG&gt; [&lt;/SPAN&gt;&lt;SPAN class=""&gt;c.t.a.n.r.s.r.s.SymphoniRestServiceBroker.handleNnsServiceErrorHeaders:1363&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;SPAN class=""&gt;An&lt;/SPAN&gt; &lt;SPAN class=""&gt;internal&lt;/SPAN&gt; &lt;SPAN class=""&gt;service&lt;/SPAN&gt; &lt;SPAN class=""&gt;error&lt;/SPAN&gt; &lt;SPAN class=""&gt;occurred:&lt;/SPAN&gt; &lt;SPAN class=""&gt;com.twc.atgw.nationalnavigation.SymphoniWebException:&lt;/SPAN&gt; &lt;SPAN class=""&gt;Event&lt;/SPAN&gt; &lt;SPAN class=""&gt;Not&lt;/SPAN&gt; &lt;SPAN class=""&gt;Found&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Here's the current query i am looking to improve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index=vap sourcetype=nns_all OR sourcetype=pi_ngxgw_access "nationalnavigation.SymphoniWebException: Event Not Found" OR "responseStatus=404"
| rex "\] \[(?&amp;lt;traceId&amp;gt;.+)\] \[c.t.a.n.r.s.r.s"
| transaction keepevicted=true by traceId
| search "nationalnavigation.SymphoniWebException: Event Not Found" AND "responseStatus=404"
| mvexpand requestURL
| search requestURL="/nationalnavigation/V1/symphoni/series/tmsproviderprogramid*" OR "/nationalnavigation/V1/symphoni/event/tmsid*"
| eval requestURLLength=len(requestURL)
| rex field=requestURL "/nationalnavigation/V1/symphoni/event/tmsid/.*\%3A\%3A(?&amp;lt;queryString&amp;gt;.+)"
| eval endpoint=case(match(requestURL,"/nationalnavigation/V1/symphoni/series/tmsproviderprogramid*"), "/nationalnavigation/V1/symphoni/series/tmsproviderprogramid",
match(requestURL,"/nationalnavigation/V1/symphoni/event/tmsid*"), "/nationalnavigation/V1/symphoni/event/tmsid",1=1,requestURL)
| rex field=queryString "(?&amp;lt;tmsIds&amp;gt;[^?]*)"
| rex field=queryString "(?&amp;lt;tmsProviderProgramIds&amp;gt;[^?]*)"
| eval assetIds=coalesce(tmsIds,tmsProviderProgramIds)
| eval assetCount=mvcount(split(assetIds,","))
| stats count AS TxnCount by endpoint&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 22:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579413#M201906</guid>
      <dc:creator>sonicZ</dc:creator>
      <dc:date>2021-12-29T22:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579437#M201914</link>
      <description>&lt;P&gt;Just want to see the size of the resultset we're talking about. Could you run this:&lt;/P&gt;&lt;P&gt;index=vap sourcetype=nns_all OR sourcetype=pi_ngxgw_access "nationalnavigation.SymphoniWebException: Event Not Found" OR "responseStatus=404" earliest=-1h@h&lt;BR /&gt;| stats count as event_count by sourcetype&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 06:22:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579437#M201914</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2021-12-29T06:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579449#M201919</link>
      <description>&lt;P&gt;The search commands don't make sense since the first will eliminate both your example events as neither has both these strings, and the even without the first search, the second will eliminate all the ReST log events since they don't appear to have matching strings.&lt;/P&gt;&lt;P&gt;The rex to extract the query string doesn't make sense since it isn't a match for your example.&lt;/P&gt;&lt;P&gt;The rex to extract tmsIds and tmsProviderProgramIds don't make sense since all they will do is both effectively copy the query string (which presumably has already been extracted?)&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 10:58:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579449#M201919</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-12-29T10:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579526#M201942</link>
      <description>&lt;P&gt;&lt;STRONG&gt;EDIT -&amp;nbsp;&lt;/STRONG&gt;oops for some reason my initial post i removed the | transaction, sorry if this was misleading.&lt;/P&gt;&lt;P&gt;Hey ITWhisperer,&lt;/P&gt;&lt;P&gt;Thanks for responding, the query is working as expected it just takes forever.&lt;/P&gt;&lt;P&gt;So the first part of the search includes an OR so splunk finds the 404 from the event below, the lower chunk splunk finds the exception with "event not found", The transaction command combines them into an single event like this one below. These are from two different source files, with only the traceId as the unifying paramter to query on (so the&amp;nbsp;284461955)&lt;/P&gt;&lt;P&gt;so then the second search with the AND only looks for events that are combined with the transaction.&lt;BR /&gt;Here's another example of a combined event from the transaction i think the post was stripping parts of the results&lt;/P&gt;&lt;P&gt;results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;time=2021-12-29T21:59:49+00:00 time_ms=2021-12-29T21:59:49.211+00:00 requestId=284461955 traceId=284461955 servicePath="/nationalnavigation/" remoteAddr=x.x.x.x clientIp=x.x.x.x clientAppVersion=NOT_AVAILABLE clientDeviceType=NOT_AVAILABLE app_version=- apiKey=x oauth_leg=2-legged authMethod=oauth apiAuth=true apiAuthPath=/ oauth_version=1.0 target_bg=default requestHost=services.timewarnercable.com requestPort=8080 requestMethod=GET requestURL="/nationalnavigation/V1/symphoni/event/tmsid/x.com::CCDN4200000005529014?division=BUF&amp;amp;lineup=354&amp;amp;profile=sg_v1&amp;amp;cacheID=439&amp;amp;longAdvisory=false&amp;amp;vodId=BUF&amp;amp;tuneToChannel=false&amp;amp;watchLive=true&amp;amp;watchOnDemand=true&amp;amp;rtReviewsLimit=0&amp;amp;includeAdult=true" requestSize=825 responseStatus=404 responseSize=418 responseTime=0.173 userAgent="Java/1.8.0_232" mapTEnabled="F" charterClientIp="V-1|IP-x.x.x.x|SourcePort-41098|TrafficOriginID-x.x.x.x" sourcePort="x" appleEgressEnabled="F" oauth_consumer_key="x" x_pi_auth_failure="-" pi_log="pi_ngxgw_access" 

2021-12-29 14:59:49,202 ERROR [qtp115457323-2259] [284461955] [c.t.a.n.r.s.r.s.SymphoniRestServiceBroker.handleNnsServiceErrorHeaders:1365] An internal service error occurred: 
com.twc.atgw.nationalnavigation.SymphoniWebException: Event Not Found&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;As to the &amp;lt;queryString&amp;gt; it basically captures everything past the "::" in the request url&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;so this part&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;CCDN4200000005529014?division=BUF&amp;amp;lineup=354&amp;amp;profile=sg_v1&amp;amp;cacheID=439&amp;amp;longAdvisory=false&amp;amp;vodId=BUF&amp;amp;tuneToChannel=false&amp;amp;watchLive=true&amp;amp;watchOnDemand=true&amp;amp;rtReviewsLimit=0&amp;amp;includeAdult=true"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Then the tsmIds is created grabbing everything from before the "?"&lt;/P&gt;&lt;PRE&gt;| rex field=queryString "(?&amp;lt;tmsIds&amp;gt;[^?]*)"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;So will grab "&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;CCDN4200000005529014&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;" in this example.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;really the main question is on first part is the most important, i am trying to use | stats to not use | transaction as its super slow&lt;/P&gt;&lt;PRE&gt;index=vap sourcetype=nns_all OR sourcetype=pi_ngxgw_access "nationalnavigation.SymphoniWebException: Event Not Found" OR "responseStatus=404"
| rex "\] \[(?&amp;lt;traceId&amp;gt;.+)\] \[c.t.a.n.r.s.r.s"
| transaction keepevicted=true by traceId
| search "nationalnavigation.SymphoniWebException: Event Not Found" AND "responseStatus=404"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 22:58:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579526#M201942</guid>
      <dc:creator>sonicZ</dc:creator>
      <dc:date>2021-12-29T22:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579528#M201943</link>
      <description>&lt;P&gt;Sure here you go, quite a bit in just one hour &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sonicZ_0-1640817600046.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/17363iF9774AD7332135F3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sonicZ_0-1640817600046.png" alt="sonicZ_0-1640817600046.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 22:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579528#M201943</guid>
      <dc:creator>sonicZ</dc:creator>
      <dc:date>2021-12-29T22:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579534#M201945</link>
      <description>&lt;P&gt;Assuming that the both data sources are indexed around the same time, we can try using streamstats to filter out traceid not found in both sourcetype during say a 1m window. Also you want to optimize the regex throw out non matching events as soon as possible.&lt;/P&gt;&lt;P&gt;Did not test but you can try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=vap (sourcetype=nns_all OR sourcetype=pi_ngxgw_access) ("nationalnavigation.SymphoniWebException: Event Not Found" OR "responseStatus=404")
| rex "^\d+[^\[]*\[[^\[]*\[(?&amp;lt;traceId&amp;gt;\-\d+)"
| streamstats dc(sourcetype) AS dc_sourcetype by traceId time_window=1m
| where dc_sourcetype=2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If you want to keep all the nns_all events:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where dc_sourcetype=2 OR sourcetype="nns_all"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 23:40:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579534#M201945</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2021-12-29T23:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using stats instead of transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579562#M201952</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="time=2021-12-29T21:59:49+00:00 time_ms=2021-12-29T21:59:49.211+00:00 requestId=284461955 traceId=284461955 servicePath=\"/nationalnavigation/\" remoteAddr=x.x.x.x clientIp=x.x.x.x clientAppVersion=NOT_AVAILABLE clientDeviceType=NOT_AVAILABLE app_version=- apiKey=x oauth_leg=2-legged authMethod=oauth apiAuth=true apiAuthPath=/ oauth_version=1.0 target_bg=default requestHost=services.timewarnercable.com requestPort=8080 requestMethod=GET requestURL=\"/nationalnavigation/V1/symphoni/event/tmsid/x.com::CCDN4200000005529014?division=BUF&amp;amp;lineup=354&amp;amp;profile=sg_v1&amp;amp;cacheID=439&amp;amp;longAdvisory=false&amp;amp;vodId=BUF&amp;amp;tuneToChannel=false&amp;amp;watchLive=true&amp;amp;watchOnDemand=true&amp;amp;rtReviewsLimit=0&amp;amp;includeAdult=true\" requestSize=825 responseStatus=404 responseSize=418 responseTime=0.173 userAgent=\"Java/1.8.0_232\" mapTEnabled=\"F\" charterClientIp=\"V-1|IP-x.x.x.x|SourcePort-41098|TrafficOriginID-x.x.x.x\" sourcePort=\"x\" appleEgressEnabled=\"F\" oauth_consumer_key=\"x\" x_pi_auth_failure=\"-\" pi_log=\"pi_ngxgw_access\"!2021-12-29 14:59:49,202 ERROR [qtp115457323-2259] [284461955] [c.t.a.n.r.s.r.s.SymphoniRestServiceBroker.handleNnsServiceErrorHeaders:1365] An internal service error occurred: com.twc.atgw.nationalnavigation.SymphoniWebException: Event Not Found" 
| eval event=split(_raw,"!") 
| mvexpand event
| rename event as _raw 
| extract
``` The lines above set up data as per example ```

``` Extract traceId only if match on Exception capturing enf field to signify event not found match ```
| rex "\] \[(?&amp;lt;traceId&amp;gt;.+)\] \[c.t.a.n.r.s.r.s.*nationalnavigation\.SymphoniWebException: (?&amp;lt;enf&amp;gt;Event Not Found)"
``` Gather events by traceId ```
| stats values(*) as * by traceId
``` Eliminate traceIds which don't have Event Not Found ```
| where isnotnull(enf)
| eval requestURLLength=len(requestURL)
``` Modified the following rex to use :: - you may need to change this back if your data really does contain %3A ```
| rex field=requestURL "/nationalnavigation/V1/symphoni/event/tmsid/.*::(?&amp;lt;queryString&amp;gt;.+)"
| eval endpoint=case(match(requestURL,"/nationalnavigation/V1/symphoni/series/tmsproviderprogramid*"), "/nationalnavigation/V1/symphoni/series/tmsproviderprogramid",
match(requestURL,"/nationalnavigation/V1/symphoni/event/tmsid*"), "/nationalnavigation/V1/symphoni/event/tmsid",1=1,requestURL)
``` These two rex extract exactly the same thing so either one is redundant or wrong ```
| rex field=queryString "(?&amp;lt;tmsIds&amp;gt;[^?]*)"
| rex field=queryString "(?&amp;lt;tmsProviderProgramIds&amp;gt;[^?]*)"
| eval assetIds=coalesce(tmsIds,tmsProviderProgramIds)
| eval assetCount=mvcount(split(assetIds,","))
| stats count AS TxnCount by endpoint&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Dec 2021 09:13:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-stats-instead-of-transaction/m-p/579562#M201952</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-12-30T09:13:01Z</dc:date>
    </item>
  </channel>
</rss>

