<?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: Retrieving unique values of an indexed field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13380#M1225</link>
    <description>&lt;P&gt;Actually, we were hoping that, because it is an indexed field, there is some kind of metadata or list that is persisted that we could access quickly, without running a search over all our events.  I guess the simplest case would be source, sourcetype, or host - is there any quick way to find the list of all indexed hosts without going through stats or some other search? It seems like there must be, because the summary view displays those. We'd like to pull that type of summary information for any indexed field to get a list of all possible field values.&lt;/P&gt;</description>
    <pubDate>Thu, 13 May 2010 23:23:38 GMT</pubDate>
    <dc:creator>esachs</dc:creator>
    <dc:date>2010-05-13T23:23:38Z</dc:date>
    <item>
      <title>Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13378#M1223</link>
      <description>&lt;P&gt;Is there a quick way to retrieve the list of all unique values of an indexed field?&lt;/P&gt;

&lt;P&gt;I know I could search for the field and pipe to uniq, but hoping there might be something faster.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2010 02:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13378#M1223</guid>
      <dc:creator>NancyCunningham</dc:creator>
      <dc:date>2010-05-13T02:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13379#M1224</link>
      <description>&lt;P&gt;Absolutely. There's several ways to do this.  Lets assume your field is called 'foo'.  &lt;/P&gt;

&lt;P&gt;The most straightforward way is to use the &lt;CODE&gt;stats&lt;/CODE&gt; command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | stats count by foo
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using stats opens up the door to collect other statistics by those unique values. For example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | stats count avg(duration) dc(username) by foo
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which will take the average of a field called &lt;CODE&gt;duration&lt;/CODE&gt; and the distinct count of values of &lt;CODE&gt;username&lt;/CODE&gt;, with each statistic being computed just for a given value of &lt;CODE&gt;foo&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Stats" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Stats&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Another way worth mentioning is to just use &lt;CODE&gt;top&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | top foo limit=10000
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 May 2010 03:08:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13379#M1224</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-05-13T03:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13380#M1225</link>
      <description>&lt;P&gt;Actually, we were hoping that, because it is an indexed field, there is some kind of metadata or list that is persisted that we could access quickly, without running a search over all our events.  I guess the simplest case would be source, sourcetype, or host - is there any quick way to find the list of all indexed hosts without going through stats or some other search? It seems like there must be, because the summary view displays those. We'd like to pull that type of summary information for any indexed field to get a list of all possible field values.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2010 23:23:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13380#M1225</guid>
      <dc:creator>esachs</dc:creator>
      <dc:date>2010-05-13T23:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13381#M1226</link>
      <description>&lt;P&gt;can you add this as a comment to Nick's answer, and not as a new answer?&lt;/P&gt;</description>
      <pubDate>Sat, 15 May 2010 02:30:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13381#M1226</guid>
      <dc:creator>piebob</dc:creator>
      <dc:date>2010-05-15T02:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13382#M1227</link>
      <description>&lt;P&gt;For some reason, I don't see an "add comment" field on Nick's answer. Is there some other way to do that?&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2010 22:28:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13382#M1227</guid>
      <dc:creator>esachs</dc:creator>
      <dc:date>2010-05-18T22:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13383#M1228</link>
      <description>&lt;P&gt;For &lt;CODE&gt;host&lt;/CODE&gt;, &lt;CODE&gt;source&lt;/CODE&gt;, and &lt;CODE&gt;sourcetype&lt;/CODE&gt; specifically, you can use the &lt;CODE&gt;|metadata&lt;/CODE&gt; search command.&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2010 20:27:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13383#M1228</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-31T20:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13384#M1229</link>
      <description>&lt;P&gt;For &lt;CODE&gt;host&lt;/CODE&gt;, &lt;CODE&gt;source, and&lt;/CODE&gt;sourcetype&lt;CODE&gt;specifically, you can use the&lt;/CODE&gt;| metadata` search command, which can certainly be much faster. If you need this a lot, run a scheduled search that runs over recent data and updates a lookup table (...| append [ inputlookup mytable ] | dedup myfield1, myfield2 | outputlookup mytable), i.e., basically you generate and maintain the metadata yourself periodically.&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2010 20:30:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13384#M1229</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-05-31T20:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving unique values of an indexed field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13385#M1230</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;|tstats values(&amp;lt;indexed__field_name&amp;gt;) where index=&amp;lt;index_name&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will totally avoid going over any events. It gets its answer from looking at metadata in .tsidx files, so no perf hit for scanning events. Orders of magnitude faster than piping a search to stats.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 19:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Retrieving-unique-values-of-an-indexed-field/m-p/13385#M1230</guid>
      <dc:creator>ghendrey_splunk</dc:creator>
      <dc:date>2019-09-18T19:17:00Z</dc:date>
    </item>
  </channel>
</rss>

