{"id":3342,"date":"2018-07-24T22:19:14","date_gmt":"2018-07-25T02:19:14","guid":{"rendered":"https:\/\/antipaucity.com\/?p=3342"},"modified":"2018-07-24T22:19:14","modified_gmt":"2018-07-25T02:19:14","slug":"stats-values-vs-stats-list-in-splunk","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=3342","title":{"rendered":"stats values vs stats list in splunk"},"content":{"rendered":"<p>{{Splunk}}&#8217;s <code><a href=\"http:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/stats\">| stats<\/a><\/code> functions are incredibly useful and powerful.<\/p>\n<p>There are two, <code><a href=\"http:\/\/docs.splunk.com\/Documentation\/Splunk\/7.1.2\/SearchReference\/Multivaluefunctions\">list<\/a><\/code> and <code><a href=\"http:\/\/docs.splunk.com\/Documentation\/Splunk\/7.1.2\/SearchReference\/Multivaluefunctions\">values<\/a><\/code> that <em>look<\/em> identical&#8230;at first blush.<\/p>\n<p>But they are subtly different. Here&#8217;s how they&#8217;re not the same.<\/p>\n<p><code>values<\/code> is an aggregating, uniquifying function.<\/p>\n<p><code>list<\/code> is an aggregating, <em>not<\/em> uniquifying function.<\/p>\n<p>&#8220;Whahhuh?!&#8221; I hear you ask.<\/p>\n<p>Here&#8217;s a prime example &#8211; say you&#8217;re aggregating on the field <code>IP_addr<\/code> all <code>user<\/code> values.<\/p>\n<p>Your search might contain the following chunk: <code>| stats values(user) as user by IP_addr<\/code>. So for each unique IP address, you will collate a uniquified list of users. Maybe you have the following two IP addresses: <code>10.10.10.10<\/code> &amp; <code>10.10.20.10<\/code>. And you have the following user-IP address pairings: <code>kingpin11 10.10.10.10<\/code>, <code>fergus97 10.10.20.10<\/code>, <code>gerfluggle 10.10.10.10<\/code>, <code>kingping11 10.10.10.10<\/code>, <code>jbobgorry 10.10.10.10<\/code>.<\/p>\n<p><code>values<\/code> will aggregate all of the following users associated with IP addresses: <code>10.10.10.10<\/code> &amp; <code>gerfluggle, jbobgorry, kingping11<\/code>; <code>10.10.20.10<\/code> &amp; <code>fergus97<\/code>.<\/p>\n<p>That&#8217;s nice &#8211; it&#8217;s pretty.<\/p>\n<p>But it exports in lousy form if you need to further process the data in another tool (eg {{Microsoft Excel}}).<\/p>\n<p>When {{Splunk}} exports those results in a CSV, instead of getting a nice, processable file, you get tabs separating what would otherwise be individual items that have all been grouped into one field.<\/p>\n<p>Enter <code>list<\/code>.<\/p>\n<p><code>list<\/code> doesn&#8217;t uniquify the values given to it, so while you still only get one <em>line<\/em> per IP address (since that was our <code>by<\/code> clause in the snippet above), you get as many IP addresses listed as there are users (in this example).<\/p>\n<p>This makes for an exportable, more processable set of results that a tool like {{Excel}} can ingest to perform further analysis with relatively little reformatting needed.<\/p>\n<p>Come back tomorrow for how to get the export to work &#8220;out of the box&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>{{Splunk}}&#8217;s | stats functions are incredibly useful and powerful. There are two, list and values that look identical&#8230;at first blush. But they are subtly different. Here&#8217;s how they&#8217;re not the same. values is an aggregating, uniquifying function. list is an aggregating, not uniquifying function. &#8220;Whahhuh?!&#8221; I hear you ask. Here&#8217;s a prime example &#8211; say &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=3342\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">stats values vs stats list in splunk<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[41],"tags":[705],"keyring_services":[],"class_list":["post-3342","post","type-post","status-publish","format-standard","hentry","category-technical","tag-splunk"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/3342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3342"}],"version-history":[{"count":0,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/3342\/revisions"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3342"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=3342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}