<?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 Remove columns that meet a criteria in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48209#M11512</link>
    <description>&lt;P&gt;I have a query that digs through Windows perf data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perfjava host=blah ((sourcetype="Perfmon:CPULoad" AND instance=_Total) OR (sourcetype="Perfmon:RunningProcesses" AND instance!=_Total)) counter="% Processor Time"  |timechart span=1m limit=0 avg(Value) as CPU by instance |where VALUE_Total&amp;gt;85
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns a series of occurrences where the total CPU is over 85%.  The header looks something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time VALUE__Total process1, process2, process3, process4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'd like to do is take all of the columns and remove any that do not have a row (any row) that has a value over 20.  In other words, if one row exists with a value over 20, the column should stay.&lt;/P&gt;

&lt;P&gt;Should I be doing something like a transpose, filter, and then transpose again?&lt;/P&gt;</description>
    <pubDate>Thu, 10 May 2012 14:50:10 GMT</pubDate>
    <dc:creator>ttanasovski</dc:creator>
    <dc:date>2012-05-10T14:50:10Z</dc:date>
    <item>
      <title>Remove columns that meet a criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48209#M11512</link>
      <description>&lt;P&gt;I have a query that digs through Windows perf data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perfjava host=blah ((sourcetype="Perfmon:CPULoad" AND instance=_Total) OR (sourcetype="Perfmon:RunningProcesses" AND instance!=_Total)) counter="% Processor Time"  |timechart span=1m limit=0 avg(Value) as CPU by instance |where VALUE_Total&amp;gt;85
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns a series of occurrences where the total CPU is over 85%.  The header looks something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time VALUE__Total process1, process2, process3, process4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I'd like to do is take all of the columns and remove any that do not have a row (any row) that has a value over 20.  In other words, if one row exists with a value over 20, the column should stay.&lt;/P&gt;

&lt;P&gt;Should I be doing something like a transpose, filter, and then transpose again?&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 14:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48209#M11512</guid>
      <dc:creator>ttanasovski</dc:creator>
      <dc:date>2012-05-10T14:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns that meet a criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48210#M11513</link>
      <description>&lt;P&gt;Probably the better thing to do is &lt;EM&gt;not&lt;/EM&gt; use &lt;CODE&gt;timechart&lt;/CODE&gt; and instead use a combination of &lt;CODE&gt;makecontinuous span-=1m _time | stats avg(Value) as CPU by _time,instance&lt;/CODE&gt;, then filter with a more complex &lt;CODE&gt;where&lt;/CODE&gt; clause, then use &lt;CODE&gt;xyseries _time instance CPU&lt;/CODE&gt; to rotate the rows. (Or you could skip the xyseries command if the resulting format from &lt;CODE&gt;stats&lt;/CODE&gt; is fine.)&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2012 20:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48210#M11513</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-05-10T20:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns that meet a criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48211#M11514</link>
      <description>&lt;P&gt;I wound up doing the following - this allows multiple hosts:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perfjava ((sourcetype="Perfmon:CPULoad" instance=_Total) OR (sourcetype="Perfmon:RunningProcesses" AND instance!=_Total AND instance!=Idle)) counter="% Processor Time"  |eval CPU=if(instance=="_Total",Value,null())|lookup numcpusperfjava.csv host |eval Value=if(instance=="_Total",Value,(Value/CPUs)) |bin _time span=1m |where Value&amp;gt;=10 |eval Value=round(Value,1)|eval Procs=if(instance=="_Total",null(),(instance+" = "+Value)) |stats avg(CPU) as CPU Values(Procs) as Processes by _time host|eval CPU=round(CPU,1) |where CPU&amp;gt;85 | eval time=strftime(_time, "%m/%d/%y %H:%M")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;numcpus.csv is a lookup table that is run nightly:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=perfjava sourcetype="Perfmon:RunningProcesses" counter="% Processor Time" instance=_Total|stats max(Value) as CPUs by host |eval CPUs=round((CPUs/100),0) |outputlookup numcpus.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The timestr at the end is just for Excel compatibility.&lt;/P&gt;

&lt;P&gt;I'm not sure if there's a better way to do this.  I mean ideally, the contents of Procs that I am setting should each create their own row in the table.  Is there a way to split a multi-value element into multiple rows rather than just calling Values() on it?&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2012 02:37:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48211#M11514</guid>
      <dc:creator>ttanasovski</dc:creator>
      <dc:date>2012-05-11T02:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns that meet a criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48212#M11515</link>
      <description>&lt;P&gt;Duh!  mvexpand does that, doesn't it?  bah.  Well at least it's working now.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2012 02:56:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48212#M11515</guid>
      <dc:creator>ttanasovski</dc:creator>
      <dc:date>2012-05-11T02:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Remove columns that meet a criteria</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48213#M11516</link>
      <description>&lt;P&gt;Try this, if I understand the question correctly (and yes I realize this is necroing an old post, but this post kept coming up in my searches, so I figure it's doing that for others):&lt;/P&gt;

&lt;P&gt;for the fields you want to ignore in your final output, set the fields to null() that you don't want to show up, e.g.&lt;/P&gt;

&lt;P&gt;| eval process3a=if(process3&amp;lt;20,null(),process3)&lt;BR /&gt;
| fields - process3&lt;BR /&gt;
| rename process3a as process3&lt;/P&gt;

&lt;P&gt;This &lt;EM&gt;should&lt;/EM&gt; have the effect you're looking for: if there are no rows in the result with a non-null value for process3, then the process3 column won't even show up.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jan 2015 22:24:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Remove-columns-that-meet-a-criteria/m-p/48213#M11516</guid>
      <dc:creator>capnjosh</dc:creator>
      <dc:date>2015-01-16T22:24:01Z</dc:date>
    </item>
  </channel>
</rss>

