<?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 Group results by eval syntax in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226706#M66876</link>
    <description>&lt;P&gt;Hi, i'm trying to group my results from these eval commands&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User   &lt;BR /&gt;
| eval term=last_login-first_login   &lt;BR /&gt;
| eval term=case(term&amp;lt;86400, "Very Short", term&amp;gt;86400 AND term&amp;lt;(86400*7), "Short", term&amp;gt;(86400*7), "Long") &lt;BR /&gt;
| stats count dc(User) as usercount values(term) as term by IP_address&lt;BR /&gt;
| stats sum(usercount) as TotalUsers by term&lt;BR /&gt;
| iplocation IP_address&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;this gives me the terms (Very short, short, long) and the Total users for the respective terms. &lt;/P&gt;

&lt;P&gt;what i need to do is show the TotalUsers for the three terms -- for their locations around the world..&lt;/P&gt;

&lt;P&gt;So for example, &lt;/P&gt;

&lt;P&gt;China: Very short - 10 users&lt;BR /&gt;
             Short - 5 users&lt;BR /&gt;
             Long - 1 user&lt;/P&gt;

&lt;P&gt;I'm pretty new to Splunk so i'm not completely sure if this is possible, i've been googling and messing around with this the past few days and can't really make any headway.&lt;/P&gt;

&lt;P&gt;Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 18:46:06 GMT</pubDate>
    <dc:creator>zsizemore</dc:creator>
    <dc:date>2016-06-23T18:46:06Z</dc:date>
    <item>
      <title>Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226706#M66876</link>
      <description>&lt;P&gt;Hi, i'm trying to group my results from these eval commands&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User   &lt;BR /&gt;
| eval term=last_login-first_login   &lt;BR /&gt;
| eval term=case(term&amp;lt;86400, "Very Short", term&amp;gt;86400 AND term&amp;lt;(86400*7), "Short", term&amp;gt;(86400*7), "Long") &lt;BR /&gt;
| stats count dc(User) as usercount values(term) as term by IP_address&lt;BR /&gt;
| stats sum(usercount) as TotalUsers by term&lt;BR /&gt;
| iplocation IP_address&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;this gives me the terms (Very short, short, long) and the Total users for the respective terms. &lt;/P&gt;

&lt;P&gt;what i need to do is show the TotalUsers for the three terms -- for their locations around the world..&lt;/P&gt;

&lt;P&gt;So for example, &lt;/P&gt;

&lt;P&gt;China: Very short - 10 users&lt;BR /&gt;
             Short - 5 users&lt;BR /&gt;
             Long - 1 user&lt;/P&gt;

&lt;P&gt;I'm pretty new to Splunk so i'm not completely sure if this is possible, i've been googling and messing around with this the past few days and can't really make any headway.&lt;/P&gt;

&lt;P&gt;Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:46:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226706#M66876</guid>
      <dc:creator>zsizemore</dc:creator>
      <dc:date>2016-06-23T18:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226707#M66877</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User | eval term=last_login-first_login | eval term=case(term&amp;lt;86400, "Very Short", term&amp;gt;86400 AND term&amp;lt;(86400*7), "Short", term&amp;gt;(86400*7), "Long") | chart dc(User) as usercount over IP_address by term | iplocation IP_address | table City "Very Short" Short Long
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:51:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226707#M66877</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T18:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226708#M66878</link>
      <description>&lt;P&gt;Add this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count AS numUsers BY Country term
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 18:52:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226708#M66878</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-23T18:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226709#M66879</link>
      <description>&lt;P&gt;Thanks for the quick response -- this seems to pretty much do what I was looking for.&lt;/P&gt;

&lt;P&gt;I'm having trouble sorting this table, I tried &lt;CODE&gt;sort 0 term&lt;/CODE&gt; and &lt;CODE&gt;sort 0 usercount&lt;/CODE&gt; . &lt;/P&gt;

&lt;P&gt;Also would it be possible then to display this data on a map with geostats to be able to hover over a country/region and see each term's usercount for it?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 19:15:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226709#M66879</guid>
      <dc:creator>zsizemore</dc:creator>
      <dc:date>2016-06-23T19:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226710#M66880</link>
      <description>&lt;P&gt;The column names have been changes to "Very Short", Short and Long (see the last table command), so to sort it based on any of those terms, use &lt;CODE&gt;| sort 0 "Very Short&lt;/CODE&gt; and so on.&lt;/P&gt;

&lt;P&gt;Try this for geostats&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your base search| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User | eval term=last_login-first_login | eval term=case(term&amp;lt;86400, "Very Short", term&amp;gt;86400 AND term&amp;lt;(86400*7), "Short", term&amp;gt;(86400*7), "Long") | chart dc(User) as usercount over IP_address by term | iplocation IP_address | table "Very Short" Short Long lat lon | geostats latfield=lat longfield=lon values(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 19:21:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226710#M66880</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T19:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226711#M66881</link>
      <description>&lt;P&gt;with that, hovering over the country, the fields displayed are "gs_cntlat, gs_cntlong, gs_sumlat, gs_sumlong"&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:02:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226711#M66881</guid>
      <dc:creator>zsizemore</dc:creator>
      <dc:date>2020-09-29T10:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226712#M66882</link>
      <description>&lt;P&gt;How about this (I'm probably not the best person for geostats)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User | eval term=last_login-first_login | eval term=case(term&amp;lt;86400, "Very Short", term&amp;gt;86400 AND term&amp;lt;(86400*7), "Short", term&amp;gt;(86400*7), "Long") | chart dc(User) as usercount over IP_address by term | iplocation IP_address | table City "Very Short" Short Long lat lon | geostats latfield=lat longfield=lon values('Very Short') as "Very Short" values(Short) as Short values(Long) as Long by City
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 19:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226712#M66882</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T19:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226713#M66883</link>
      <description>&lt;P&gt;i've got an error in 'geostats' command: the argument 'Short' is invalid.  It doesn't give an error for 'Very Short' which comes before it, so i'm not sure why its giving an error for that..&lt;/P&gt;

&lt;P&gt;That's fine if you're not the best person for geostats haha all of this is very much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 19:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226713#M66883</guid>
      <dc:creator>zsizemore</dc:creator>
      <dc:date>2016-06-23T19:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226714#M66884</link>
      <description>&lt;P&gt;Mind trying this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search| stats earliest(_time) as first_login latest(_time) as last_login by IP_address User | eval term=last_login-first_login | eval term=case(term&amp;lt;86400, "Very Short", term&amp;gt;86400 AND term&amp;lt;(86400*7), "Short", term&amp;gt;(86400*7), "Long") 
| stats dc(User) as usercount by IP_address term | iplocation IP_address  | geostats latfield=lat longfield=lon values(usercount) by term
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jun 2016 20:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226714#M66884</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-23T20:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Group results by eval syntax</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226715#M66885</link>
      <description>&lt;P&gt;This seems to be working! Thanks for all of your help, I should be able to play around with this myself.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 20:28:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Group-results-by-eval-syntax/m-p/226715#M66885</guid>
      <dc:creator>zsizemore</dc:creator>
      <dc:date>2016-06-23T20:28:48Z</dc:date>
    </item>
  </channel>
</rss>

