<?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: group over multiple fields for stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602094#M209573</link>
    <description>&lt;P&gt;No sir, that didn't work. It still gave me a much higher number for the total calls.&lt;/P&gt;&lt;P&gt;Adding more details, this is how the message looks like:&lt;/P&gt;&lt;P&gt;[11:06:04 INF 7166e33f-bde7-49dd-aa72-523d8e7501a9] Server|Transaction|POST|aa72-523d8e7501a9|c1|200|0.2|127.0.0.1|GetProduct|ElasticSearch|3|/v1/getproduct&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=nprod sourcetype="xxxxxx" "Server|Transaction" | rex field=msg "Transaction\|[\"]?(?P&amp;lt;verb&amp;gt;[\w]*)[\"]?\|[\"]?(?P&amp;lt;correlationId&amp;gt;[a-zA-Z0-9-]*)[\"]?\|[\"]?(?P&amp;lt;clientName&amp;gt;[\w]*)[\"]?\|(?P&amp;lt;httpStatus&amp;gt;\d*)\|(?P&amp;lt;timeTaken&amp;gt;[\d.]*)\|[\"]?(?P&amp;lt;clientIP&amp;gt;[\d.]*)[\"]?\|[\"]?(?P&amp;lt;apiMethod&amp;gt;[\w]*)[\"]?\|[\"]?(?P&amp;lt;sourceSystem&amp;gt;[\w]*)[\"]?\|(?:(?P&amp;lt;version&amp;gt;[\d]+)?)" | eval version=coalesce(version, "N/A") | table clientName, apiMethod, sourceSystem, httpStatus, version, timeTaken | stats count as totalCalls avg(timeTaken) as avgTimeTaken by clientName, apiMethod, sourceSystem, httpStatus, version | eval avgTimeTaken=round(avgTimeTaken, 2)&lt;/LI-CODE&gt;&lt;P&gt;The version is an optional field so I'm coalescing it to 'NA' when it's not present.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2022 14:15:50 GMT</pubDate>
    <dc:creator>nmarun</dc:creator>
    <dc:date>2022-06-16T14:15:50Z</dc:date>
    <item>
      <title>How to group over multiple fields for stats?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602076#M209561</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm able to get the response in a tabular format using the command:&lt;/P&gt;
&lt;P&gt;table clientName, apiMethod, sourceSystem, httpStatus, version, timeTaken&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nmarun_0-1655385037486.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20131i2A1190F06002E190/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nmarun_0-1655385037486.png" alt="nmarun_0-1655385037486.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What I want is to do some aggregation on them and get the result like:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nmarun_1-1655385094069.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20132iF06E02F0B6B6121E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nmarun_1-1655385094069.png" alt="nmarun_1-1655385094069.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Basically, group by clientName, apiMethod, sourceSystem, httpStatus, and version to get the total calls and the average time.&lt;/P&gt;
&lt;P&gt;The below command is clearly misleading:&lt;/P&gt;
&lt;P&gt;stats count(clientName) as TotalCalls, avg(timeTaken) as avgTimeTakenS by clientName, apiMethod, sourceSystem, httpStatus, version&lt;/P&gt;
&lt;P&gt;Please help.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Arun&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 15:46:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602076#M209561</guid>
      <dc:creator>nmarun</dc:creator>
      <dc:date>2022-06-21T15:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: group over multiple fields for stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602088#M209569</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your base search
| table clientName, apiMethod, sourceSystem, httpStatus, version, timeTaken
| stats count as totalCalls avg(timeTaken) as avgTimeTaken by clientName apiMethod sourceSystem httpStatus version&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Jun 2022 13:57:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602088#M209569</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-06-16T13:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: group over multiple fields for stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602094#M209573</link>
      <description>&lt;P&gt;No sir, that didn't work. It still gave me a much higher number for the total calls.&lt;/P&gt;&lt;P&gt;Adding more details, this is how the message looks like:&lt;/P&gt;&lt;P&gt;[11:06:04 INF 7166e33f-bde7-49dd-aa72-523d8e7501a9] Server|Transaction|POST|aa72-523d8e7501a9|c1|200|0.2|127.0.0.1|GetProduct|ElasticSearch|3|/v1/getproduct&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=nprod sourcetype="xxxxxx" "Server|Transaction" | rex field=msg "Transaction\|[\"]?(?P&amp;lt;verb&amp;gt;[\w]*)[\"]?\|[\"]?(?P&amp;lt;correlationId&amp;gt;[a-zA-Z0-9-]*)[\"]?\|[\"]?(?P&amp;lt;clientName&amp;gt;[\w]*)[\"]?\|(?P&amp;lt;httpStatus&amp;gt;\d*)\|(?P&amp;lt;timeTaken&amp;gt;[\d.]*)\|[\"]?(?P&amp;lt;clientIP&amp;gt;[\d.]*)[\"]?\|[\"]?(?P&amp;lt;apiMethod&amp;gt;[\w]*)[\"]?\|[\"]?(?P&amp;lt;sourceSystem&amp;gt;[\w]*)[\"]?\|(?:(?P&amp;lt;version&amp;gt;[\d]+)?)" | eval version=coalesce(version, "N/A") | table clientName, apiMethod, sourceSystem, httpStatus, version, timeTaken | stats count as totalCalls avg(timeTaken) as avgTimeTaken by clientName, apiMethod, sourceSystem, httpStatus, version | eval avgTimeTaken=round(avgTimeTaken, 2)&lt;/LI-CODE&gt;&lt;P&gt;The version is an optional field so I'm coalescing it to 'NA' when it's not present.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 14:15:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602094#M209573</guid>
      <dc:creator>nmarun</dc:creator>
      <dc:date>2022-06-16T14:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: group over multiple fields for stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602101#M209577</link>
      <description>&lt;P&gt;Given that clientIP and correlationId both could be zero length, they could still appear in your numbers - could this account for the discrepancy?&lt;/P&gt;&lt;P&gt;If not, perhaps if you could reduce your search so you only have a small number of events with a discrepancy, and look at the actual events that are being included in the count to see if you can spot a pattern.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 14:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602101#M209577</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-16T14:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: group over multiple fields for stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602102#M209578</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;,&amp;nbsp;neither of those fields can be zero length, but I'll try your suggestion of limiting the fields and seeing which one breaks it.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 14:59:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602102#M209578</guid>
      <dc:creator>nmarun</dc:creator>
      <dc:date>2022-06-16T14:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: group over multiple fields for stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602105#M209580</link>
      <description>&lt;P&gt;If they can't be zero length, use "+" instead of "*" - "+" means 1 or more, "*" means zero or more&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 15:10:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602105#M209580</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-16T15:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: group over multiple fields for stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602363#M209662</link>
      <description>&lt;P&gt;I've sent these details to our internal Splunk team and am waiting for their response.&lt;/P&gt;&lt;P&gt;In the meantime, I can accept both your answers as the solution since you took the time to provide some assistance, or can wait till I hear back from my team.&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 06:29:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-group-over-multiple-fields-for-stats/m-p/602363#M209662</guid>
      <dc:creator>nmarun</dc:creator>
      <dc:date>2022-06-20T06:29:51Z</dc:date>
    </item>
  </channel>
</rss>

