<?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: query explanation in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80703#M20391</link>
    <description>&lt;P&gt;Wow, great explanation.  May take a while to digest.  Thanks much! &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Sep 2011 15:30:55 GMT</pubDate>
    <dc:creator>DTERM</dc:creator>
    <dc:date>2011-09-27T15:30:55Z</dc:date>
    <item>
      <title>query explanation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80701#M20389</link>
      <description>&lt;P&gt;Cab someone please explain what the following parts of the query do (just the bolded portion, not the entire query).  Thanks.&lt;/P&gt;

&lt;P&gt;The duration field that is being calculated looks like &lt;STRONG&gt;&lt;EM&gt;myapp_duration=0d 0h 0m 0s&lt;/EM&gt;&lt;/STRONG&gt; in the native format.&lt;/P&gt;

&lt;P&gt;The whole search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myapp NOT EIT_Net NOT businessUnit=EIT |
eval myapp_duration=replace(replace(replace(myapp_duration,"d\s","+"),"h|m|s",""),"\s",":") 
| convert dur2sec(myapp_duration) 
| stats avg(myapp_duration) as avg_myapp_duration by severity 
| eval avg_myapp_duration=tostring(round(avg_myapp_duration,0),"duration")
| eval severity=case(severity==0,"Cleared", 
  severity==1,"Intermediate", 
  severity==2,"Warning",   
  severity==3,"Maintenance", 
  severity==4,"Major",
  severity==5,"Critical") 
| rename severity as Severity 
| rename avg_myapp_duration as "Average Duration"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Portion of interest:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval myapp_duration=replace(replace(replace(myapp_duration,"d\s","+"),"h|m|s",""),"\s",":") 
| convert dur2sec(myapp_duration) 
| stats avg(myapp_duration) as avg_myapp_duration by severity 
| eval avg_myapp_duration=tostring(round(avg_myapp_duration,0),"duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Sep 2011 14:06:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80701#M20389</guid>
      <dc:creator>DTERM</dc:creator>
      <dc:date>2011-09-23T14:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: query explanation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80702#M20390</link>
      <description>&lt;P&gt;Well it takes the myapp_duration field, and replaces every occurrence of "ds" with "+",  then from that output it removes every occurrence of the literal string "h|m|s".&lt;/P&gt;

&lt;P&gt;Then still in the same expression it replaces every occurrence of the character "s" with ":".   &lt;/P&gt;

&lt;P&gt;Then this modified version of the myapp_duration field gets assigned back to overwrite the original value of myapp_duration in each result row.&lt;/P&gt;

&lt;P&gt;Then it gets piped to the convert command which will turn that field from a human readable time string into a number of seconds. &lt;/P&gt;

&lt;P&gt;Then it's all piped to the stats command, which will graph the average of myapp_duration for each unique value of severity, where each value of severity has its own row,  and there's a column called "avg_myapp_duration". &lt;/P&gt;

&lt;P&gt;Last but not least, another eval command will first round that value to an integer, then use the tostring function to turn it back into a string of the form "HH:MM:SS"&lt;/P&gt;

&lt;P&gt;This page is the reference you want to use to look up all the little eval commands and arguments: &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/CommonEvalFunctions&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80702#M20390</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T09:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: query explanation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80703#M20391</link>
      <description>&lt;P&gt;Wow, great explanation.  May take a while to digest.  Thanks much! &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2011 15:30:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80703#M20391</guid>
      <dc:creator>DTERM</dc:creator>
      <dc:date>2011-09-27T15:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: query explanation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80704#M20392</link>
      <description>&lt;P&gt;@DTERM, you should really accept some answers - just to say thanks to the people that have helped you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; (Click on the tick on the answer to accept it)&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2011 15:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/query-explanation/m-p/80704#M20392</guid>
      <dc:creator>Drainy</dc:creator>
      <dc:date>2011-09-27T15:56:36Z</dc:date>
    </item>
  </channel>
</rss>

