<?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 Is there a way to get 'values' working with the top command? Or get the same effect? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78665#M19906</link>
    <description>&lt;P&gt;We use this search to give me a ranked view of active clients of a certain type:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="exchange_index" cs_user_agent="Mac+OS*" | top c_ip,cs_username,cs_user_agent,sc_status limit="30"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;exchange_index has iis logs from an Exchange server. We see cases, where a given IP number has two different matches: one with a username and status 200, and one with no username and status 401, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;128.200.235.121 AD\mcuser Mac+OS+X/10.8.3+(12D78);+ExchangeWebServices/3.0+(157);+Mail/6.3+(1503) 200
128.200.235.121 -         Mac+OS+X/10.8.3+(12D78);+ExchangeWebServices/3.0+(157);+Mail/6.3+(1503) 401
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We'd like to be able to treat the sc_status as values to the other fields which are the same, and produce an output like this (or at least similar to it):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;128.200.235.121 AD\mcuser Mac+OS+X/10.8.3+(12D78);+ExchangeWebServices/3.0+(157);+Mail/6.3+(1503) 200
                -                                                                                 401
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am able to do this with the stats command, as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="exchange_index" cs_user_agent="Mac+OS*" | stats values(cs_username), values(sc_status) by c_ip cs_user_agent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with this output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  c_ip            cs_usr_agent                    values(cs_username)     values(sc_status)
1 101.172.170.148 Mac+OS+X/10.8.3+(12D78)+CalendarAgent/55        -       200
                                                                  AD\usrx 401

2 107.16.155.76   Mac+OS+X/10.8.3+(12D78)+CalendarAgent/55        -       200
                                                                  AD\usry 401
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But of course, stats does not give me the same results as top does, and top does not seem to work with values, even though the syntax is so similar to stats.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2013 22:21:46 GMT</pubDate>
    <dc:creator>wrangler2x</dc:creator>
    <dc:date>2013-03-28T22:21:46Z</dc:date>
    <item>
      <title>Is there a way to get 'values' working with the top command? Or get the same effect?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78665#M19906</link>
      <description>&lt;P&gt;We use this search to give me a ranked view of active clients of a certain type:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="exchange_index" cs_user_agent="Mac+OS*" | top c_ip,cs_username,cs_user_agent,sc_status limit="30"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;exchange_index has iis logs from an Exchange server. We see cases, where a given IP number has two different matches: one with a username and status 200, and one with no username and status 401, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;128.200.235.121 AD\mcuser Mac+OS+X/10.8.3+(12D78);+ExchangeWebServices/3.0+(157);+Mail/6.3+(1503) 200
128.200.235.121 -         Mac+OS+X/10.8.3+(12D78);+ExchangeWebServices/3.0+(157);+Mail/6.3+(1503) 401
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We'd like to be able to treat the sc_status as values to the other fields which are the same, and produce an output like this (or at least similar to it):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;128.200.235.121 AD\mcuser Mac+OS+X/10.8.3+(12D78);+ExchangeWebServices/3.0+(157);+Mail/6.3+(1503) 200
                -                                                                                 401
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am able to do this with the stats command, as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="exchange_index" cs_user_agent="Mac+OS*" | stats values(cs_username), values(sc_status) by c_ip cs_user_agent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with this output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  c_ip            cs_usr_agent                    values(cs_username)     values(sc_status)
1 101.172.170.148 Mac+OS+X/10.8.3+(12D78)+CalendarAgent/55        -       200
                                                                  AD\usrx 401

2 107.16.155.76   Mac+OS+X/10.8.3+(12D78)+CalendarAgent/55        -       200
                                                                  AD\usry 401
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But of course, stats does not give me the same results as top does, and top does not seem to work with values, even though the syntax is so similar to stats.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2013 22:21:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78665#M19906</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2013-03-28T22:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to get 'values' working with the top command? Or get the same effect?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78666#M19907</link>
      <description>&lt;P&gt;what exactly is top doing that stats isn't doing? do you like the &lt;CODE&gt;limit=30&lt;/CODE&gt; thing that top does?  Or maybe the calculation of percentages?  Both can be done in other ways.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2013 05:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78666#M19907</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-03-29T05:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to get 'values' working with the top command? Or get the same effect?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78667#M19908</link>
      <description>&lt;P&gt;There are multiple ways of doing this including using transactions, subsearch and join etc. but probably the easiest for you would be to just sort your results. I wouldn't sort by a multi value field so your search should look somthing like :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="exchange_index" cs_user_agent="Mac+OS*" | stats values(cs_username) as usernames, values(sc_status) as status by c_ip cs_user_agent | sort 30 c_ip cs_user_agent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you want the results to be in the same order as previously, add the table command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | table c_ip, usernames, cs_user_agent, status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bob&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2013 08:40:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78667#M19908</guid>
      <dc:creator>BobM</dc:creator>
      <dc:date>2013-03-29T08:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to get 'values' working with the top command? Or get the same effect?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78668#M19909</link>
      <description>&lt;P&gt;I've been meaning to get back to this for days, but had fires to put out. Your suggestion is very close to the mark, but to get the same output as top and the same results I had to make some minor modifications (top seems to do by-descending count):&lt;/P&gt;

&lt;P&gt;index="exchange_index" cs_user_agent="Mac+OS*" | stats values(cs_username) as usernames, values(sc_status) as status count by c_ip cs_user_agent | sort 30 -count c_ip cs_user_agent | eventstats sum(count) as total | eval percent=100*count/total | strcat percent "%" percent | table c_ip, usernames, cs_user_agent, status, count, percent&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:39:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78668#M19909</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2020-09-28T13:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to get 'values' working with the top command? Or get the same effect?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78669#M19910</link>
      <description>&lt;P&gt;With total on the count column:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="exchange_index" cs_user_agent="Mac+OS*"
| stats values(cs_username) as usernames, values(sc_status) as status count by c_ip cs_user_agent | sort 30 -count c_ip cs_user_agent
| eventstats sum(count) as total
| eval percent=100*count/total| strcat percent "%" percent
| table c_ip, usernames, cs_user_agent, status, count, percent| addtotals col=t count row=f
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Apr 2013 17:46:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-get-values-working-with-the-top-command-Or-get/m-p/78669#M19910</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2013-04-03T17:46:57Z</dc:date>
    </item>
  </channel>
</rss>

