{"id":66963,"date":"2022-11-23T02:27:41","date_gmt":"2022-11-23T02:27:41","guid":{"rendered":"https:\/\/merikebi.warrenmyers.com\/?p=66963"},"modified":"2022-11-23T02:27:41","modified_gmt":"2022-11-23T02:27:41","slug":"conditionally-remove-a-field-in-splunk","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=66963","title":{"rendered":"Conditionally remove a field in Splunk"},"content":{"rendered":"<p>I have a table generated by <code>chart<\/code> that lists the results of a compliance scan<\/p>\n<p>These results are <em>typically<\/em> Pass, Fail, and Error &#8211; but <em>sometimes<\/em> there is &quot;Unknown&quot; as a response<\/p>\n<p>I want to show the percentage of each (Pass, Fail, Error, Unknown), so I do the following:<\/p>\n<pre><code>| fillnull value=0 Pass Fail Error Unknown\n| eval _total=Pass+Fail+Error+Unknown\n&lt;calculate percentages for each field&gt;\n&lt;append &quot;%&quot; to each value (Pass, Fail, Error, Unknown)&gt;\n<\/code><\/pre>\n<p>What I want to do is eliminate a &quot;totally&quot; empty column, and only display it if it actually exists somewhere in the source data (not merely because of the <code>fillnull<\/code> command)<\/p>\n<p>Is this possible?<\/p>\n<p>I was thinking something like this, but cannot figure out the second step:<\/p>\n<pre><code>| eventstats max(Unknown) as _unk\n| &lt;if _unk is 0, drop the field&gt;\n<\/code><\/pre>\n<p>from User warren &#8211; Stack Overflow https:\/\/stackoverflow.com\/questions\/74541096\/conditionally-remove-a-field-in-splunk<br \/>\nvia <a href=\"https:\/\/ifttt.com\/?ref=da&#038;site=wordpress\">IFTTT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a table generated by chart that lists the results of a compliance scan These results are typically Pass, Fail, and Error &#8211; but sometimes there is &quot;Unknown&quot; as a response I want to show the percentage of each (Pass, Fail, Error, Unknown), so I do the following: | fillnull value=0 Pass Fail Error &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=66963\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">Conditionally remove a field in Splunk<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[991],"keyring_services":[],"class_list":["post-66963","post","type-post","status-publish","format-standard","hentry","category-blih","tag-stackexchange"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/66963","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=66963"}],"version-history":[{"count":1,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/66963\/revisions"}],"predecessor-version":[{"id":66964,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/66963\/revisions\/66964"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66963"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=66963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}