<?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 Error in 'tstats' command: This command must be the first command of a search. in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625380#M14899</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/252478"&gt;@Frofro87&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;tstats commad need to at the start of the qurey&lt;BR /&gt;&lt;BR /&gt;as you are using tstats in the middle of the qurey its thoriwng the error ,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;either you can move tstats to start or add tstats in subsearch belwo is the hightlited&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=netsec_index sourcetype=pan* OR sourctype=fgt* user=saic-corp\\heathl misc=* OR url=* earliest=-4d| eval Domain=coalesce(misc, url)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval domain=misc + "," + url&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| makemv delim="," domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields _time action category rule session_end_reason http_category vendor_action url misc domain Domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| table _time action category rule session_end_reason http_category vendor_action url misc domain Domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| stats count by domain `comment("Search for High Volume of Packets in/out (Show Megabytes/Gigabytes) back by earliest=-1d. Exclude app=ipsec.")`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;[| tstats summariesonly=true count from datamodel=Network_Traffic where All_Traffic.action=allowed AND NOT All_Traffic.app=ipsec-esp-udp earliest=-1d by All_Traffic.src_ip All_Traffic.dest_ip All_Traffic.app All_Traffic.packets_in All_Traffic.packets_out All_Traffic.bytes All_Traffic.bytes_in All_Traffic.bytes_out All_Traffic.action All_Traffic.rule All_Traffic.user]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;| rename All_Traffic.* as *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| sort - bytes_out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Megabytes_out=round(bytes_out/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Megabytes_in=round(bytes_in/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Gigabytes_out=round(bytes_out/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Gigabytes_in=round(bytes_in/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval packets_in=tostring(packets_in, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval packets_out=tostring(packets_out, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes=tostring(bytes, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes_in=tostring(bytes_in, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes_out=tostring(bytes_out, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields - count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| head 100&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Dec 2022 06:44:58 GMT</pubDate>
    <dc:creator>SanjayReddy</dc:creator>
    <dc:date>2022-12-28T06:44:58Z</dc:date>
    <item>
      <title>Error in 'tstats' command: This command must be the first command of a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625364#M14897</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I was using a search and getting an error message stated in the subject. I have tried moving the tstats around and editing some of the commands but either run into the same error or tsidx error. Here is the search as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=netsec_index sourcetype=pan* OR sourctype=fgt* user=saic-corp\\heathl misc=* OR url=* earliest=-4d| eval Domain=coalesce(misc, url)
| eval domain=misc + "," + url
| makemv delim="," domain
| fields _time action category rule session_end_reason http_category vendor_action url misc domain Domain
| table _time action category rule session_end_reason http_category vendor_action url misc domain Domain
| stats count by domain `comment("Search for High Volume of Packets in/out (Show Megabytes/Gigabytes) back by earliest=-1d. Exclude app=ipsec.")`
| tstats summariesonly=true count from datamodel=Network_Traffic where All_Traffic.action=allowed AND NOT All_Traffic.app=ipsec-esp-udp earliest=-1d by All_Traffic.src_ip All_Traffic.dest_ip All_Traffic.app All_Traffic.packets_in All_Traffic.packets_out All_Traffic.bytes All_Traffic.bytes_in All_Traffic.bytes_out All_Traffic.action All_Traffic.rule All_Traffic.user
| rename All_Traffic.* as *
| sort - bytes_out
| eval Megabytes_out=round(bytes_out/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`
| eval Megabytes_in=round(bytes_in/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`
| eval Gigabytes_out=round(bytes_out/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`
| eval Gigabytes_in=round(bytes_in/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`
| eval packets_in=tostring(packets_in, "commas")
| eval packets_out=tostring(packets_out, "commas")
| eval bytes=tostring(bytes, "commas")
| eval bytes_in=tostring(bytes_in, "commas")
| eval bytes_out=tostring(bytes_out, "commas")
| fields - count
| head 100



&lt;/LI-CODE&gt;
&lt;P&gt;If any guidance can be provided I would be appreciate it. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 04:20:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625364#M14897</guid>
      <dc:creator>Frofro87</dc:creator>
      <dc:date>2022-12-29T04:20:00Z</dc:date>
    </item>
    <item>
      <title>Error in 'tstats' command: This command must be the first command of a search.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625380#M14899</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/252478"&gt;@Frofro87&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;tstats commad need to at the start of the qurey&lt;BR /&gt;&lt;BR /&gt;as you are using tstats in the middle of the qurey its thoriwng the error ,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;either you can move tstats to start or add tstats in subsearch belwo is the hightlited&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=netsec_index sourcetype=pan* OR sourctype=fgt* user=saic-corp\\heathl misc=* OR url=* earliest=-4d| eval Domain=coalesce(misc, url)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval domain=misc + "," + url&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| makemv delim="," domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields _time action category rule session_end_reason http_category vendor_action url misc domain Domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| table _time action category rule session_end_reason http_category vendor_action url misc domain Domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| stats count by domain `comment("Search for High Volume of Packets in/out (Show Megabytes/Gigabytes) back by earliest=-1d. Exclude app=ipsec.")`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;[| tstats summariesonly=true count from datamodel=Network_Traffic where All_Traffic.action=allowed AND NOT All_Traffic.app=ipsec-esp-udp earliest=-1d by All_Traffic.src_ip All_Traffic.dest_ip All_Traffic.app All_Traffic.packets_in All_Traffic.packets_out All_Traffic.bytes All_Traffic.bytes_in All_Traffic.bytes_out All_Traffic.action All_Traffic.rule All_Traffic.user]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;| rename All_Traffic.* as *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| sort - bytes_out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Megabytes_out=round(bytes_out/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Megabytes_in=round(bytes_in/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Gigabytes_out=round(bytes_out/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Gigabytes_in=round(bytes_in/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval packets_in=tostring(packets_in, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval packets_out=tostring(packets_out, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes=tostring(bytes, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes_in=tostring(bytes_in, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes_out=tostring(bytes_out, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields - count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| head 100&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 06:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625380#M14899</guid>
      <dc:creator>SanjayReddy</dc:creator>
      <dc:date>2022-12-28T06:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'tstats' command: This command must be the first command of a search.</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625417#M14905</link>
      <description>&lt;P&gt;Hi Sanjay,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reply. I have tried moving the tstats command to the beginning of the search. I apologize for not mentioning it in the original posting. I still end up with the same error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;index=netsec_index sourcetype=pan* OR sourctype=fgt* user=saic-corp\\heathl misc=* OR url=* earliest=-4d| eval Domain=coalesce(misc, url)&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG&gt;| tstats summariesonly=true count from datamodel=Network_Traffic where All_Traffic.action=allowed AND NOT All_Traffic.app=ipsec-esp-udp earliest=-1d by All_Traffic.src_ip All_Traffic.dest_ip All_Traffic.app All_Traffic.packets_in All_Traffic.packets_out All_Traffic.bytes All_Traffic.bytes_in All_Traffic.bytes_out All_Traffic.action All_Traffic.rule All_Traffic.user&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval domain=misc + "," + url&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| makemv delim="," domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields _time action category rule session_end_reason http_category vendor_action url misc domain Domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| table _time action category rule session_end_reason http_category vendor_action url misc domain Domain&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| stats count by domain `comment("Search for High Volume of Packets in/out (Show Megabytes/Gigabytes) back by earliest=-1d. Exclude app=ipsec.")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| rename All_Traffic.* as *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| sort - bytes_out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Megabytes_out=round(bytes_out/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Megabytes_in=round(bytes_in/1024/1024,2) `comment("Math for bytes &amp;gt; Megabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Gigabytes_out=round(bytes_out/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval Gigabytes_in=round(bytes_in/1024/1024/1024,2) `comment("Math for bytes &amp;gt; Gigabytes")`&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval packets_in=tostring(packets_in, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval packets_out=tostring(packets_out, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes=tostring(bytes, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes_in=tostring(bytes_in, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| eval bytes_out=tostring(bytes_out, "commas")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields - count&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| head 100&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2022 13:37:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Error-in-tstats-command-This-command-must-be-the-first-command/m-p/625417#M14905</guid>
      <dc:creator>Frofro87</dc:creator>
      <dc:date>2022-12-28T13:37:52Z</dc:date>
    </item>
  </channel>
</rss>

