<?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 query help...!!!!!! in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242031#M72004</link>
    <description>&lt;P&gt;I have a requirement to find the average duration taken by the &lt;CODE&gt;SERVICE&lt;/CODE&gt; in a day.&lt;/P&gt;

&lt;P&gt;Expected o/p1 for 1st service query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATE             SERVICE       AVERAGE(SEC)
2014-01-22       WORST         6.5        (calculation: 09+04/2(no of worst services)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Expected o/p2 for another service query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATE             SERVICE       AVERAGE(SEC)
2014-01-22       BEST          7.3        (calculation: 07+08+07/3(no of best service) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here are some sample raw evens:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;20140122T100510 SERVICE=WORST MESSAGE=REQ COUNTRY=USA ACCNO=1234 
20140122T100513 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1
20140122T100515 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1
20140122T100516 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=0
20140122T100519 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1       (20140122T100510-20140122T100519)=09sec

20140122T080520 SERVICE=WORST MESSAGE=REQ COUNTRY=USA ACCNO=1000 
20140122T080524 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1000 TYPE=GOLD COUNT=0        (20140122T080520-   20140122T080520)=04sec

20140122T100514 SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1432 
20140122T100515 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=1
20140122T100519 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=0
20140122T100521 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=1               (07sec)

20140122T100543 SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1256 
20140122T100551 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1256 TYPE=SILVER COUNT=1               (08sec)

20140122T100545 SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1900 
20140122T100552 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1900 TYPE=SILVER COUNT=1               (07sec)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The query I tried is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index= mmartin st=m01 host=defr4456  SERVICE=WORST |transaction SERVICE startswith=REQ  endswith RES |timechart span=1d avg(duration) as AVERAGE(SEC)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(not getting proper results for this query)&lt;/P&gt;

&lt;P&gt;any ideas??&lt;BR /&gt;
Thanks..!!&lt;BR /&gt;
-MARTIN&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2016 02:27:09 GMT</pubDate>
    <dc:creator>martinapple381</dc:creator>
    <dc:date>2016-07-01T02:27:09Z</dc:date>
    <item>
      <title>query help...!!!!!!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242031#M72004</link>
      <description>&lt;P&gt;I have a requirement to find the average duration taken by the &lt;CODE&gt;SERVICE&lt;/CODE&gt; in a day.&lt;/P&gt;

&lt;P&gt;Expected o/p1 for 1st service query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATE             SERVICE       AVERAGE(SEC)
2014-01-22       WORST         6.5        (calculation: 09+04/2(no of worst services)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Expected o/p2 for another service query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATE             SERVICE       AVERAGE(SEC)
2014-01-22       BEST          7.3        (calculation: 07+08+07/3(no of best service) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here are some sample raw evens:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;20140122T100510 SERVICE=WORST MESSAGE=REQ COUNTRY=USA ACCNO=1234 
20140122T100513 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1
20140122T100515 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1
20140122T100516 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=0
20140122T100519 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1       (20140122T100510-20140122T100519)=09sec

20140122T080520 SERVICE=WORST MESSAGE=REQ COUNTRY=USA ACCNO=1000 
20140122T080524 SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1000 TYPE=GOLD COUNT=0        (20140122T080520-   20140122T080520)=04sec

20140122T100514 SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1432 
20140122T100515 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=1
20140122T100519 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=0
20140122T100521 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=1               (07sec)

20140122T100543 SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1256 
20140122T100551 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1256 TYPE=SILVER COUNT=1               (08sec)

20140122T100545 SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1900 
20140122T100552 SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1900 TYPE=SILVER COUNT=1               (07sec)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The query I tried is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Index= mmartin st=m01 host=defr4456  SERVICE=WORST |transaction SERVICE startswith=REQ  endswith RES |timechart span=1d avg(duration) as AVERAGE(SEC)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(not getting proper results for this query)&lt;/P&gt;

&lt;P&gt;any ideas??&lt;BR /&gt;
Thanks..!!&lt;BR /&gt;
-MARTIN&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 02:27:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242031#M72004</guid>
      <dc:creator>martinapple381</dc:creator>
      <dc:date>2016-07-01T02:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: query help...!!!!!!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242032#M72005</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= mmartin st=m01 host=defr4456
| stats max(_time) AS _time range(_time) AS duration BY SERVICE ACCNO
| timechart span=1d avg(duration) AS dailyAvgDuration BY SERVICE
| untable _time service dailyAvgDuration
| eval dailyAvgDuration=tostring(dailyAvgDuration, "duration")
| xyseries _time service dailyAvgDuration
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jul 2016 15:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242032#M72005</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-07-01T15:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: query help...!!!!!!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242033#M72006</link>
      <description>&lt;P&gt;try this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Index= mmartin st=m01 host=defr4456  SERVICE=* 
|transaction SERVICE ACCNO startswith=REQ  maxspan=1m
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1) RES is on multiple records before the end of the transaction, so you can't use it for the endswith parameter.&lt;BR /&gt;&lt;BR /&gt;
2) All the records must have the same ACCNO (or they aren't relevant to each other and aren't part of a single transaction)&lt;BR /&gt;
3) Since you are looking at 5-to-10 second response times, I set the maximum duration (maxspan) for a transaction to be 1m.  If you expect transactions longer than that, increase it to 2m or 3m or whatever.&lt;/P&gt;

&lt;P&gt;Now you have a single transaction record for each chunk of events, contianing their field values and the duration.  _time contains the start of the transaction.  You can apply the timechart function now. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| timechart span=1d avg(duration) as avgDuration by service
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 20:09:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242033#M72006</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T20:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: query help...!!!!!!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242034#M72007</link>
      <description>&lt;P&gt;By the way, this creates your test data -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval mydata = mvappend("20140122T100510!!!!SERVICE=WORST MESSAGE=REQ COUNTRY=USA ACCNO=1234", 
 "20140122T100513!!!!SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1",
 "20140122T100515!!!!SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1",
 "20140122T100516!!!!SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=0",
 "20140122T100519!!!!SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1234 TYPE=GOLD COUNT=1",
 "20140122T080520!!!!SERVICE=WORST MESSAGE=REQ COUNTRY=USA ACCNO=1000", 
 "20140122T080524!!!!SERVICE=WORST MESSAGE=RES COUNTRY=USA ACCNO=1000 TYPE=GOLD COUNT=0",
 "20140122T100514!!!!SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1432", 
 "20140122T100515!!!!SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=1",
 "20140122T100519!!!!SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=0",
 "20140122T100521!!!!SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1432 TYPE=SILVER COUNT=1",
 "20140122T100543!!!!SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1256", 
 "20140122T100551!!!!SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1256 TYPE=SILVER COUNT=1",
 "20140122T100545!!!!SERVICE=BEST MESSAGE=REQ COUNTRY=USA ACCNO=1900", 
 "20140122T100552!!!!SERVICE=BEST MESSAGE=RES COUNTRY=USA ACCNO=1900 TYPE=SILVER COUNT=1")
| mvexpand mydata
| eval mydata=split(mydata,"!!!!")
| eval _time = strptime(mvindex(mydata,0),"%Y%m%dT%H%M%S")
| eval _raw = mvindex(mydata,1)
| table _time _raw
| sort -_time
| rex field=_raw "SERVICE=(?&amp;lt;SERVICE&amp;gt;[^\s]*)\s*MESSAGE=(?&amp;lt;MESSAGE&amp;gt;[^\s]*)\s*COUNTRY=(?&amp;lt;COUNTRY&amp;gt;[^\s]*)\s*ACCNO=(?&amp;lt;ACCNO&amp;gt;[^\s]*)\s*TYPE=(?&amp;lt;TYPE&amp;gt;[^\s]*)\s*COUNT=(?&amp;lt;COUNT&amp;gt;[^\s]*)"
| table _time _raw SERVICE MESSAGE COUNTRY ACCNO TYPE COUNT
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and this finishes up, matching the case of the above &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| transaction SERVICE ACCNO startswith=REQ  maxspan=1m
| timechart span=1d avg(duration) as avgDuration by SERVICE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 20:14:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-help/m-p/242034#M72007</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-02-09T20:14:02Z</dc:date>
    </item>
  </channel>
</rss>

