{"id":29861,"date":"2021-02-08T19:21:16","date_gmt":"2021-02-08T19:21:16","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=29861"},"modified":"2021-02-08T19:21:16","modified_gmt":"2021-02-08T19:21:16","slug":"remembering-sqrt","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=29861","title":{"rendered":"remembering sqrt"},"content":{"rendered":"<p>A couple weeks ago some folks in the <a href=\"https:\/\/splunk-usergroups.slack.com\/\">splunk-usergroups.slack<\/a> helped me using\u00a0<code><a href=\"https:\/\/docs.splunk.com\/Documentation\/Splunk\/latest\/SearchReference\/accum\">accum<\/a><\/code>\u00a0and calculating with a modulus to make a grid menu from a list. <\/p>\n<p>My original search had been along the lines of:<\/p>\n<pre class=\"wp-block-preformatted\">| inputlookup mylookup<br \/>| stats count by type<br \/>| fields - count<br \/>| transpose<br \/>| fields - column<\/pre>\n<p>Which was great &#8230; until my list grew more than about 12 entries (and scrolling became a pain).<\/p>\n<p>A couple folks here helped me flip it to this format:<\/p>\n<pre class=\"wp-block-preformatted\">| Inputlokup mylookup<br \/>| stats count by type<br \/>| eval num=1<br \/>| accum num<br \/>| eval num=num-1<br \/>| eval mod=floor(num\/12)<br \/>| eval type.{mod}=type <br \/>| fields - mod num type count<br \/>| stats list(*) as *<\/pre>\n<p>Which works awesomely.<\/p>\n<p>Unless the modulus value (currently 12) gets too small (if the total list grows to more than modval^2 .. each individual box is no longer in alphabetical order (and then alpha from box to box).<\/p>\n<p>So I made this modification so that regardless of the size of the list, the grid will automanage itself:<\/p>\n<pre class=\"wp-block-preformatted\">| inputlookup mylookup<br \/>| stats count by type<br \/>| eventstats count as _tot<br \/>| eval modval=ceil(sqrt(_tot))<br \/>| eval num=1<br \/>| accum num<br \/>| eval num=num-1<br \/>| eval mod-floor(num\/modval)<br \/>| eval type.{mod}=type<br \/>| fields - modval mod num type count<br \/>| stats list(*) as *<\/pre>\n<p>Dunno if that&#8217;ll help anyone else, but wanted to share-back that self-managing aspect I added in case anyone was interested\u00a0<img decoding=\"async\" src=\"https:\/\/a.slack-edge.com\/production-standard-emoji-assets\/13.0\/apple-medium\/1f642@2x.png\" alt=\":slightly_smiling_face:\"\/><\/p>\n<p>from antipaucity https:\/\/antipaucity.com\/2021\/02\/08\/remembering-sqrt\/<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple weeks ago some folks in the splunk-usergroups.slack helped me using\u00a0accum\u00a0and calculating with a modulus to make a grid menu from a list. My original search had been along the lines of: | inputlookup mylookup| stats count by type| fields &#8211; count| transpose| fields &#8211; column Which was great &#8230; until my list grew &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=29861\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">remembering sqrt<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","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_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4],"tags":[95],"keyring_services":[],"class_list":["post-29861","post","type-post","status-publish","format-standard","hentry","category-blih","tag-antipaucity"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/29861","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=29861"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/29861\/revisions"}],"predecessor-version":[{"id":29862,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/29861\/revisions\/29862"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29861"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=29861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}