<?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: tune spl command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/575897#M200694</link>
    <description>&lt;P&gt;It looks like you are effectively running a report on the previous day, so schedule a search sometime between 23:30 and 01:00 the following day and save the results as&amp;nbsp; a saved search, then you just need to ref(erence) the saved report.&lt;/P&gt;&lt;P&gt;Other things you might try are, having evaluated status and set sendTime and receiveTime appropriately, it might be slightly quicker to evaluate whether these are null or not instead of doing the same string compare again.&lt;/P&gt;&lt;P&gt;Also, has _time already been set correctly when the event was indexed? If so, you might not need to extract timestamp and parse it again.&lt;/P&gt;&lt;P&gt;Why extract product date and servername if you are not using them?&lt;/P&gt;</description>
    <pubDate>Mon, 22 Nov 2021 16:08:58 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-11-22T16:08:58Z</dc:date>
    <item>
      <title>tune spl command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/575890#M200691</link>
      <description>&lt;P&gt;Hi How can I tune this spl command?&lt;/P&gt;&lt;P&gt;this spl execute daily, and return something like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;servername send&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; receive&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;customer&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ID&amp;nbsp; &amp;nbsp; status&lt;BR /&gt;Customer4 2021-21-11 12:12:39&amp;nbsp; 2021-21-11 12:15:03&amp;nbsp; CUS.AaBB-APP1-12345_CUS&amp;nbsp; &amp;nbsp; 10&amp;nbsp; 144.772000&lt;BR /&gt;Customer3 2021-21-11 12:09:58&amp;nbsp; 2021-21-11 12:12:03&amp;nbsp; CUS.AaBB-APP1-98765_CUS&amp;nbsp; &amp;nbsp; &amp;nbsp;20 125.616000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is statics belong this query:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;events&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;72,070,802&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;(11/21/21 12:00:00.000 AM to 11/22/21 12:00:00.000 AM)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Size&amp;nbsp; 2.09 GB&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Statistics (248,138)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;it take huge time to return result is there any way to tune query or any trick that return this result faster?&lt;/P&gt;&lt;P&gt;FYI: I try to use summer index but still take long time to return result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my query:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;index="myindex" source="/data/product/*/customer*" (date_hour&amp;gt;=1 AND (date_hour&amp;lt;23 OR (date_hour=23 date_minute&amp;lt;30))) "Packet Processed" OR "Normal Packet Received"&lt;BR /&gt;| rex field=source "\/data\/(?&amp;lt;product&amp;gt;\w+)\/(?&amp;lt;date&amp;gt;\d+)\/(?&amp;lt;servername&amp;gt;\w+)"&lt;BR /&gt;| rex ID\[(?&amp;lt;ID&amp;gt;\d+)&lt;BR /&gt;&lt;BR /&gt;| rex "^(?&amp;lt;timestamp&amp;gt;.{23}) INFO (?&amp;lt;customer&amp;gt;.*) \[AppServiceName\] (?&amp;lt;status&amp;gt;.*): M\[(?&amp;lt;Acode&amp;gt;.*)\] T\[(?&amp;lt;Bcode&amp;gt;\d+)\]"&lt;BR /&gt;| rex field=customer "_(?&amp;lt;customer2&amp;gt;.*)"&lt;BR /&gt;| eval customer2=coalesce(customer2,customer), customer=if(customer=customer2,null(),customer)&lt;BR /&gt;| eval sendTime=if(status="Packet Processed",strptime(timestamp,"%Y-%m-%d %H:%M:%S,%3Q"),null()), receiveTime=if(status="Normal Packet Received",strptime(timestamp,"%Y-%m-%d %H:%M:%S,%3Q"),null())&lt;BR /&gt;| eval AcodeSend=if(status="Packet Processed",Acode,null()),BcodeSend=if(status="Packet Processed",Bcode,null()),AcodeReceive=if(status="Normal Packet Received",Acode,null()),BcodeReceive=if(status="Normal Packet Received",Bcode,null())&lt;BR /&gt;| eval AcodeReceiveLookFor=AcodeSend+10,acr=coalesce(AcodeReceive,AcodeReceiveLookFor)&lt;BR /&gt;| fields - Acode _time timestamp status AcodeReceiveLookFor&lt;BR /&gt;| stats values(*) as *,count by customer2,acr,Bcode&lt;BR /&gt;| eval duration=receiveTime-sendTime , customer=coalesce(customer,customer2)&lt;BR /&gt;| eval status=case(isnull(AcodeSend),"No Send",isnull(AcodeReceive),"No receive")&lt;BR /&gt;| eventstats max(duration) as duration by customer2&lt;BR /&gt;| where count=2 OR (status="No receive" AND isnull(duration))&lt;BR /&gt;| eval status=coalesce(status,duration)&lt;BR /&gt;| search NOT status="No receive"&lt;BR /&gt;| search NOT status="No Send"&lt;BR /&gt;| search status&amp;gt;2&lt;BR /&gt;| eval send=strftime(sendTime, "%Y-%d-%m %H:%M:%S") | eval receive=strftime(receiveTime, "%Y-%d-%m %H:%M:%S")&lt;BR /&gt;&lt;BR /&gt;| table servername send receive customer ID status&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 15:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/575890#M200691</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2021-11-22T15:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: tune spl command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/575897#M200694</link>
      <description>&lt;P&gt;It looks like you are effectively running a report on the previous day, so schedule a search sometime between 23:30 and 01:00 the following day and save the results as&amp;nbsp; a saved search, then you just need to ref(erence) the saved report.&lt;/P&gt;&lt;P&gt;Other things you might try are, having evaluated status and set sendTime and receiveTime appropriately, it might be slightly quicker to evaluate whether these are null or not instead of doing the same string compare again.&lt;/P&gt;&lt;P&gt;Also, has _time already been set correctly when the event was indexed? If so, you might not need to extract timestamp and parse it again.&lt;/P&gt;&lt;P&gt;Why extract product date and servername if you are not using them?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2021 16:08:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/575897#M200694</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-11-22T16:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: tune spl command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/576082#M200759</link>
      <description>&lt;P&gt;The first rex statement is redundant - you don't use the fields.&lt;/P&gt;&lt;P&gt;You are setting status to "No receive" or "No Send". Then you are testing those string values later on and then you exclude those from results with the search filter. Why not set these to some negative numeric - I assume you will not get negative durations, so then&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval status=case(isnull(AcodeSend),-999,isnull(AcodeReceive),-998) 
| eventstats max(duration) as duration by customer2 
| where count=2 OR (status=-998 AND isnull(duration)) 
| eval status=coalesce(status,duration) 
| search status&amp;gt;2 &lt;/LI-CODE&gt;&lt;P&gt;However, I'm a little unsure of your where statement, which allows "No receive" case to pass through, then you search for NOT status="No receive" to remove it. Am I missing something?&lt;/P&gt;&lt;P&gt;It's worth looking at the job inspector to help understand where the time is spent. I suspect it might be useful to convert the initial status to a type, so that you do not have to do those 'if (status="blablabla") comparisons 6 times for every event. 3 will match quickly, but 3 will not, so instead do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval type=case(status="Packet Processed", 1,
                 status="Normal Packet Received", 2)&lt;/LI-CODE&gt;&lt;P&gt;and then use type instead of status for the other tests.&amp;nbsp; The string length for received events is 22 characters, * 3 * 72,000,000 events, so it will only satisfy the match when fully matched.&lt;/P&gt;&lt;P&gt;AcodeReceiveLookFor variable is not necessary - just use the AcodeSend+10 value in the coalesce directly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 20:45:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tune-spl-command/m-p/576082#M200759</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-11-23T20:45:17Z</dc:date>
    </item>
  </channel>
</rss>

