<?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: How to run multiple queries at once, with calculations? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286682#M86800</link>
    <description>&lt;P&gt;Take a look at the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Append"&gt;append&lt;/A&gt; command and see it that helps.&lt;/P&gt;

&lt;P&gt;For example, if I wanted to combine the output of three different searches against the _internal index, I could do the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source="/Applications/Splunk/var/log/splunk/metrics.log" | stats latest(_time) as _time
| append [
   | search index=_internal source="/Applications/Splunk/var/log/splunk/splunkd_ui_access.log" | reverse | head 1 | eval End_Time=strftime(_time, "%Y-%m-%d %H:%M:%S") | table _time, End_Time
]
| append [
   | search index=_internal source="/Applications/Splunk/var/log/splunk/splunkd_access.log" | stats count
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if that's what you are looking for. Keep in mind you can also combine the final output from the query above by using eval or stats.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2016 13:48:20 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2016-04-08T13:48:20Z</dc:date>
    <item>
      <title>How to run multiple queries at once, with calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286681#M86799</link>
      <description>&lt;P&gt;I am trying to calculate TPS with the help of the queries below:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Start Time&lt;/P&gt;

&lt;P&gt;Query&lt;BR /&gt;
&lt;B&gt;host=X source=Y.log "data available" | reverse | head 1 | table _time&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Result (without =&amp;gt; table _time) - &lt;B&gt;abcde.abcdefg.abcdefg#001(2426) 2016/04/07 13:41:59 -VWXYZ- {1:3}                                                       [job.abcde.abcdefg.abcdefg.abc:33] Data available&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Result (with =&amp;gt; table _time), as time is actually needed. The timestamp of _time and the dataset is same - 2016-04-07 13:41:59&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;End Time&lt;/P&gt;

&lt;P&gt;Query&lt;BR /&gt;
&lt;B&gt;host=X source=Z.log "ILIKEYO_KNOW" AND "WAR_RIGG_IS_BAD" AND "5.7_WOLFER" | head 1 | eval End_Time=strftime(_time,  "%Y-%m-%d %H:%M:%S") | table _time, End_Time&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Result (without =&amp;gt; table _time) - &lt;B&gt;2016-04-07T16:20:59,455 INFO  [[abcdef4-abcdefghij].abcdefghijklm.nopqrstu.25] [AbcDefghi] ABCD  EFGH : ILIKEYO_KNOW | ABCDE FGHI : WAR_RIGG_IS_BAD | ABCDEF GH : XYZ1190560709120516-88328[ABCDEFG HIJKLM : 5.7_WOLFER]&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Result (with =&amp;gt; table _time), as time is actually needed. Used eval to remove milliseconds. The timestamp of _time and the dataset is same - 2016-04-07 16:20:59&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Count of Unique Dataset&lt;/P&gt;

&lt;P&gt;Query&lt;BR /&gt;
 &lt;B&gt;host=X source=Y.log | stats count(ITIM_ID)&lt;/B&gt;&lt;/P&gt;

&lt;P&gt;Result - 100&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Is it possible to run all the above 3 queries at one time, and have a similar output as per below:&lt;/P&gt;

&lt;P&gt;Start Time - 2016-04-07 13:41:59&lt;BR /&gt;
End Time - 2016-04-07 16:20:59&lt;BR /&gt;
Count (ITIM_ID) - 100&lt;BR /&gt;
TPS=(End Time-Start Time/Count(ITIM_ID)) - No. as per formulae&lt;/P&gt;

&lt;P&gt;Koushik&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:22:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286681#M86799</guid>
      <dc:creator>koushiknandan</dc:creator>
      <dc:date>2020-09-29T09:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple queries at once, with calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286682#M86800</link>
      <description>&lt;P&gt;Take a look at the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Append"&gt;append&lt;/A&gt; command and see it that helps.&lt;/P&gt;

&lt;P&gt;For example, if I wanted to combine the output of three different searches against the _internal index, I could do the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source="/Applications/Splunk/var/log/splunk/metrics.log" | stats latest(_time) as _time
| append [
   | search index=_internal source="/Applications/Splunk/var/log/splunk/splunkd_ui_access.log" | reverse | head 1 | eval End_Time=strftime(_time, "%Y-%m-%d %H:%M:%S") | table _time, End_Time
]
| append [
   | search index=_internal source="/Applications/Splunk/var/log/splunk/splunkd_access.log" | stats count
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if that's what you are looking for. Keep in mind you can also combine the final output from the query above by using eval or stats.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2016 13:48:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286682#M86800</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-04-08T13:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple queries at once, with calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286683#M86801</link>
      <description>&lt;P&gt;I would use appendcols, and "stats min(_time)" or "stats max(_time)" instead of reverses, heads and tails:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=X source=Y.log "data available" | stats min(_time) as EARLIEST
| appendcols [
    search host=X source=Z.log ILIKEYO_KNOW WAR_RIGG_IS_BAD 5.7_WOLFER | stats max(_time) as LATEST ] 
| appendcols [
    search host=X source=Y | stats count(ITIM_ID) as count ] 
| eval TPS=count/(LATEST-EARLIEST)
| eval EARLIEST=strftime(EARLIEST,"%Y-%m-%d %H:%M:%S")
| eval LATEST=strftime(LATEST,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:19:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286683#M86801</guid>
      <dc:creator>twinspop</dc:creator>
      <dc:date>2020-09-29T09:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple queries at once, with calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286684#M86802</link>
      <description>&lt;P&gt;I modified your query and it works as well, but I need to practice more.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2016 19:26:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286684#M86802</guid>
      <dc:creator>koushiknandan</dc:creator>
      <dc:date>2016-04-08T19:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to run multiple queries at once, with calculations?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286685#M86803</link>
      <description>&lt;P&gt;I am trying to use the above query, and plot a graph for the TPS field.&lt;/P&gt;

&lt;P&gt;So, if I draw a chart with the TPS values over a day (duration) with a span of 1 min/hour, it would show a line graph over a day (duration).&lt;/P&gt;

&lt;P&gt;Tried the following, didn't work (Change between **). What am I doing wrong?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     host=X source=Y.log "data available" | stats min(_time) as EARLIEST
     | appendcols [
         search host=X source=Z.log ILIKEYO_KNOW WAR_RIGG_IS_BAD 5.7_WOLFER | stats max(_time) as LATEST ] 
     | appendcols [
         search host=X source=Y | stats count(ITIM_ID) as count ] 
     **| timechart span=1d avg(eval(TPS=count/(LATEST-EARLIEST)))**
     | eval EARLIEST=strftime(EARLIEST,"%Y-%m-%d %H:%M:%S")
     | eval LATEST=strftime(LATEST,"%Y-%m-%d %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Jun 2016 13:00:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-multiple-queries-at-once-with-calculations/m-p/286685#M86803</guid>
      <dc:creator>koushiknandan</dc:creator>
      <dc:date>2016-06-21T13:00:56Z</dc:date>
    </item>
  </channel>
</rss>

