<?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: Add a column with count stats in addition to an existing column with avarage stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496288#M138303</link>
    <description>&lt;P&gt;@to4kawa just tried but seems not wotking&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values where index=my_index by callee, timestampStart, timestampEnd  | eval duration = (strptime(timestampEnd, "%Y-%m-%dT%H:%M:%S.%6N%Z") - strptime(timestampStart, "%Y-%m-%dT%H:%M:%S.%6N%Z")) | stats avg(duration) as duration by callee | eval duration=round(duration,2)  | append [| tstats count where index=my_index by callee]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In addition I've tried  this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values where index=my_index by callee,caller,  timestampStart, timestampEnd | eval duration = round((strptime(termine, "%Y-%m-%dT%H:%M:%S.%6N%Z") - strptime(inizio, "%Y-%m-%dT%H:%M:%S.%6N%Z")),2)| stats avg(duration) as duration , count(callee) as total by callee | eval duration=round(duration,2) | table callee, caller, duration, total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and seems working&lt;/P&gt;</description>
    <pubDate>Mon, 16 Mar 2020 13:38:44 GMT</pubDate>
    <dc:creator>piefragnisp</dc:creator>
    <dc:date>2020-03-16T13:38:44Z</dc:date>
    <item>
      <title>Add a column with count stats in addition to an existing column with avarage stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496286#M138301</link>
      <description>&lt;P&gt;I have a json file with some information regarding soa requests. Basically info such as callee, caller, start and end timestamp of a request (write me if you want more details).&lt;/P&gt;

&lt;P&gt;By the way I have a splunk-query to group all the events by the callee and calculate the average duration of the difference between end and start timestamp.&lt;/P&gt;

&lt;P&gt;Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values where index=my_index by callee, timestampStart, timestampEnd  | eval duration= round((strptime(timestampEnd  , "%Y-%m-%dT%H:%M:%S.%6N%Z") - strptime(timestampStart, "%Y-%m-%dT%H:%M:%S.%6N%Z")),2)| stats avg(duration) as duration by callee| eval duration=round(duration,2) |table callee, duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In addition to the avarage duration I would also add a column with the count of all events regarding that callee but (if I understand well) I can do this only with a Tstats count.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Thank a lot&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 12:06:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496286#M138301</guid>
      <dc:creator>piefragnisp</dc:creator>
      <dc:date>2020-03-16T12:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Add a column with count stats in addition to an existing column with avarage stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496287#M138302</link>
      <description>&lt;P&gt;&lt;CODE&gt;tstats&lt;/CODE&gt; is fast.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;....
| append [| tstats count where index=my_index by callee]
| stats values(duration) as duration by callee
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;how about this?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 12:30:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496287#M138302</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-16T12:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add a column with count stats in addition to an existing column with avarage stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496288#M138303</link>
      <description>&lt;P&gt;@to4kawa just tried but seems not wotking&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values where index=my_index by callee, timestampStart, timestampEnd  | eval duration = (strptime(timestampEnd, "%Y-%m-%dT%H:%M:%S.%6N%Z") - strptime(timestampStart, "%Y-%m-%dT%H:%M:%S.%6N%Z")) | stats avg(duration) as duration by callee | eval duration=round(duration,2)  | append [| tstats count where index=my_index by callee]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In addition I've tried  this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values where index=my_index by callee,caller,  timestampStart, timestampEnd | eval duration = round((strptime(termine, "%Y-%m-%dT%H:%M:%S.%6N%Z") - strptime(inizio, "%Y-%m-%dT%H:%M:%S.%6N%Z")),2)| stats avg(duration) as duration , count(callee) as total by callee | eval duration=round(duration,2) | table callee, caller, duration, total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and seems working&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 13:38:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496288#M138303</guid>
      <dc:creator>piefragnisp</dc:creator>
      <dc:date>2020-03-16T13:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Add a column with count stats in addition to an existing column with avarage stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496289#M138304</link>
      <description>&lt;P&gt;Hi @piefragnisp,&lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats values where index=my_index by callee, timestampStart, timestampEnd 
| eval duration= round((strptime(timestampEnd , "%Y-%m-%dT%H:%M:%S.%6N%Z") - strptime(timestampStart, "%Y-%m-%dT%H:%M:%S.%6N%Z")),2) 
| stats avg(duration) as duration by callee 
| eval duration=round(duration,2) 
| append 
    [| tstats count where index=my_index by callee] 
| stats values(*) by * by callee 
| table callee, duration, count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Mar 2020 15:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496289#M138304</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-16T15:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Add a column with count stats in addition to an existing column with avarage stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496290#M138305</link>
      <description>&lt;P&gt;good job, accept your answer.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 20:38:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Add-a-column-with-count-stats-in-addition-to-an-existing-column/m-p/496290#M138305</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-16T20:38:22Z</dc:date>
    </item>
  </channel>
</rss>

