<?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 Combining these multiple queries into one in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96658#M24983</link>
    <description>&lt;P&gt;I have a list of channels that I want to query, and for each one, I'd like to retrieve the latest value.  For example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chan_name=B-1111 | head 1 | table _time, dn
chan_name=B-1112 | head 1 | table _time, dn
chan_name=B-1113 | head 1 | table _time, dn
chan_name=B-1114 | head 1 | table _time, dn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What's the best way to combine this query so that it shows up neatly in a table (and ultimately JSON object)?&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2012 18:51:23 GMT</pubDate>
    <dc:creator>vhwang</dc:creator>
    <dc:date>2012-03-19T18:51:23Z</dc:date>
    <item>
      <title>Combining these multiple queries into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96658#M24983</link>
      <description>&lt;P&gt;I have a list of channels that I want to query, and for each one, I'd like to retrieve the latest value.  For example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chan_name=B-1111 | head 1 | table _time, dn
chan_name=B-1112 | head 1 | table _time, dn
chan_name=B-1113 | head 1 | table _time, dn
chan_name=B-1114 | head 1 | table _time, dn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What's the best way to combine this query so that it shows up neatly in a table (and ultimately JSON object)?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2012 18:51:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96658#M24983</guid>
      <dc:creator>vhwang</dc:creator>
      <dc:date>2012-03-19T18:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Combining these multiple queries into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96659#M24984</link>
      <description>&lt;P&gt;You could use &lt;CODE&gt;stats&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chan_name=* | stats first(dn),first(_time) by chan_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or &lt;CODE&gt;dedup&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chan_name=* | dedup chan_name | table _time,dn
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2012 18:57:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96659#M24984</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-03-19T18:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combining these multiple queries into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96660#M24985</link>
      <description>&lt;P&gt;I don't want to do all the chan_names, just an inputted list. Is there a way to do something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chan_name=['B-1111, B-1112']
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2012 19:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96660#M24985</guid>
      <dc:creator>vhwang</dc:creator>
      <dc:date>2012-03-19T19:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Combining these multiple queries into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96661#M24986</link>
      <description>&lt;P&gt;chan_name=B-1111 OR chan_name=B-1112 OR. ..&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:32:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96661#M24986</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2020-09-28T11:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combining these multiple queries into one</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96662#M24987</link>
      <description>&lt;P&gt;To add to Ayn's answers:&lt;/P&gt;

&lt;P&gt;You can create a new eventtype using the following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chan_name=B-1111 OR chan_name=B-1112 OR chan_name=B-1113 OR chan_name=B-1113
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then pipe the results of this new eventtype to dedup or stats.  So the new query would look something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=channel_names | dedup chan_name | table _time,dn
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should you need to modify the list of channel names to include in the query, you can do it at the eventtype level.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2012 19:50:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-these-multiple-queries-into-one/m-p/96662#M24987</guid>
      <dc:creator>williamche</dc:creator>
      <dc:date>2012-03-19T19:50:13Z</dc:date>
    </item>
  </channel>
</rss>

