<?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 Group By optional fields in splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120141#M32258</link>
    <description>&lt;P&gt;I am trying the following search. EXECUTED, TRANSLATION_UID, DOCUMENT_TYPE are present in the logs but MAP_TYPE and MAP_NAME are not yet added. They will be added later. The search should work without them and MAP_TYPE, MAP_NAME should get added to the group by list once they are in the logs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| stats  sum(EXECUTED) as Total_Time, count as Num_of_Executions, avg(EXECUTED) as Avg_exectime, perc80(EXECUTED) as 80th_percentile BY TRANSLATION_UID,DOCUMENT_TYPE, MAP_TYPE*,MAP_NAME* 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried the above seeing the following search for adding optional fields as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table Total_Time,Num_of_Executions,MAP_TYPE* MAP_NAME* TRANSLATION_UID DOCUMENT_TYPE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works. But when I added '&lt;CODE&gt;*&lt;/CODE&gt;' to fields in group by list it does not work. Thanks for your help in advance!!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:55:49 GMT</pubDate>
    <dc:creator>adityainamdar89</dc:creator>
    <dc:date>2020-09-28T16:55:49Z</dc:date>
    <item>
      <title>Group By optional fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120141#M32258</link>
      <description>&lt;P&gt;I am trying the following search. EXECUTED, TRANSLATION_UID, DOCUMENT_TYPE are present in the logs but MAP_TYPE and MAP_NAME are not yet added. They will be added later. The search should work without them and MAP_TYPE, MAP_NAME should get added to the group by list once they are in the logs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| stats  sum(EXECUTED) as Total_Time, count as Num_of_Executions, avg(EXECUTED) as Avg_exectime, perc80(EXECUTED) as 80th_percentile BY TRANSLATION_UID,DOCUMENT_TYPE, MAP_TYPE*,MAP_NAME* 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried the above seeing the following search for adding optional fields as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;table Total_Time,Num_of_Executions,MAP_TYPE* MAP_NAME* TRANSLATION_UID DOCUMENT_TYPE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works. But when I added '&lt;CODE&gt;*&lt;/CODE&gt;' to fields in group by list it does not work. Thanks for your help in advance!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:55:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120141#M32258</guid>
      <dc:creator>adityainamdar89</dc:creator>
      <dc:date>2020-09-28T16:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Group By optional fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120142#M32259</link>
      <description>&lt;P&gt;In general, the wildcard represents all the fields that are present. If the field is not present, as in your example, then the wildcard cannot represent it.&lt;/P&gt;

&lt;P&gt;That said, I want to understand your question further. When you say you "added '*' to fields in group by list" do you mean your search now ends in the following:&lt;/P&gt;

&lt;P&gt;...BY TRANSLATION_UID,DOCUMENT_TYPE,MAP_TYPE,MAP_NAME,*&lt;/P&gt;

&lt;P&gt;or did you replace the entire list of field names with just the wildcard?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120142#M32259</guid>
      <dc:creator>aweitzman</dc:creator>
      <dc:date>2020-09-28T16:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Group By optional fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120143#M32260</link>
      <description>&lt;P&gt;The following worked for me:&lt;/P&gt;

&lt;P&gt;stats  values(MAP_TYPE) as MAP_TYPE, values(MAP_NAME) as MAP_NAME, sum(EXECUTED) as Total_Time, count as Num_of_Executions, avg(EXECUTED) as Avg_exectime, perc80(EXECUTED) as 80th_percentile BY TRANSLATION_UID,DOCUMENT_TYPE.&lt;/P&gt;

&lt;P&gt;This worked for me only because there is a one to one mapping between the other Group by fields and MAP_TYPE,MAP_NAME. Due to this the values() converted the duplicates to a single value. Else this solution would not have worked.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120143#M32260</guid>
      <dc:creator>adityainamdar89</dc:creator>
      <dc:date>2020-09-28T16:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Group By optional fields in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120144#M32261</link>
      <description>&lt;P&gt;In the &lt;CODE&gt;table&lt;/CODE&gt; command, if you list fields that do not exist, the existing fields are still listed.&lt;/P&gt;

&lt;P&gt;In the &lt;CODE&gt;stats&lt;/CODE&gt; command, if you try to group by fields that do not exist, you will get no results.&lt;/P&gt;

&lt;P&gt;You need to change your search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| stats  sum(EXECUTED) as Total_Time, count as Num_of_Executions, avg(EXECUTED) as Avg_exectime, perc80(EXECUTED) as 80th_percentile BY TRANSLATION_UID,DOCUMENT_TYPE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jun 2014 00:23:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-By-optional-fields-in-splunk/m-p/120144#M32261</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-06-26T00:23:30Z</dc:date>
    </item>
  </channel>
</rss>

