<?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 How to remove fields from a search that will be used in dashboard drill down panel in dashboard. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311826#M160159</link>
    <description>&lt;P&gt;All,&lt;BR /&gt;
I am running this search to build a drilldown panel in a dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os "invoked oom-killer:" 
| eval stime=_time 
| eval tearliest=relative_time(stime,"-1") | eval tlatest=relative_time(stime,"+1") 
| stats by _time stime tearliest tlatest
| fields _time stime tearliest tlatest
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The new "evaled" fields stime tearliest tlatest  will be used when we click in the line in the result panel. This search will generate the following result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     _time                   stime          tearliest             tlatest
1   2017-07-06 09:50:42     1499359842  1499359841.000000   1499359843.000000
2   2017-07-09 21:16:32     1499660192  1499660191.000000   1499660193.000000
3   2017-07-09 21:16:35     1499660195  1499660194.000000   1499660196.000000
4   2017-07-09 21:16:36     1499660196  1499660195.000000   1499660197.000000
5   2017-07-10 15:40:50     1499726450  1499726449.000000   1499726451.000000 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I click on one of the lines, drilldown will build another panel that contains all events between &lt;STRONG&gt;tearliest&lt;/STRONG&gt;  and &lt;STRONG&gt;tlatest&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os earliest=$tearliest$ latest=$tlatest$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is working very well, but the result of the first search is ugly and it is causing confusion with my users.&lt;/P&gt;

&lt;P&gt;How can I remove &lt;STRONG&gt;stime&lt;/STRONG&gt; &lt;STRONG&gt;tearliest&lt;/STRONG&gt; &lt;STRONG&gt;tlatest&lt;/STRONG&gt; from the search result, without interfere in the drill down? The simple XML of my dashboard is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;oom-killer invoked&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Between $timer.earliest$ and $timer.latest$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=os "invoked oom-killer:" 
| eval stime=_time 
| eval tearliest=relative_time(stime,"-1") | eval tlatest=relative_time(stime,"+1") 
| stats by _time stime tearliest tlatest
| fields _time stime tearliest tlatest
          &amp;lt;earliest&amp;gt;$timer.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$timer.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;50&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;true&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;false&amp;lt;/option&amp;gt;
        **&amp;lt;drilldown&amp;gt;
          &amp;lt;eval token="tearliest"&amp;gt;'row.tearliest'&amp;lt;/eval&amp;gt;
          &amp;lt;eval token="tlatest"&amp;gt;'row.tlatest'&amp;lt;/eval&amp;gt;
        &amp;lt;/drilldown&amp;gt;**
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;



    &amp;lt;panel depends="$tearliest$,$tlatest$"&amp;gt;
      &amp;lt;title&amp;gt;All events in timerange&amp;lt;/title&amp;gt;
      &amp;lt;event&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=os earliest=$tearliest$ latest=$tlatest$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="list.drilldown"&amp;gt;full&amp;lt;/option&amp;gt;
        &amp;lt;option name="list.wrap"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="maxLines"&amp;gt;5&amp;lt;/option&amp;gt;
        &amp;lt;option name="raw.drilldown"&amp;gt;full&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="table.drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
        &amp;lt;option name="table.sortDirection"&amp;gt;asc&amp;lt;/option&amp;gt;
        &amp;lt;option name="table.wrap"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="type"&amp;gt;list&amp;lt;/option&amp;gt;
      &amp;lt;/event&amp;gt;
    &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Gerson&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2017 23:41:52 GMT</pubDate>
    <dc:creator>GersonGarcia</dc:creator>
    <dc:date>2017-07-12T23:41:52Z</dc:date>
    <item>
      <title>How to remove fields from a search that will be used in dashboard drill down panel in dashboard.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311826#M160159</link>
      <description>&lt;P&gt;All,&lt;BR /&gt;
I am running this search to build a drilldown panel in a dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os "invoked oom-killer:" 
| eval stime=_time 
| eval tearliest=relative_time(stime,"-1") | eval tlatest=relative_time(stime,"+1") 
| stats by _time stime tearliest tlatest
| fields _time stime tearliest tlatest
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The new "evaled" fields stime tearliest tlatest  will be used when we click in the line in the result panel. This search will generate the following result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     _time                   stime          tearliest             tlatest
1   2017-07-06 09:50:42     1499359842  1499359841.000000   1499359843.000000
2   2017-07-09 21:16:32     1499660192  1499660191.000000   1499660193.000000
3   2017-07-09 21:16:35     1499660195  1499660194.000000   1499660196.000000
4   2017-07-09 21:16:36     1499660196  1499660195.000000   1499660197.000000
5   2017-07-10 15:40:50     1499726450  1499726449.000000   1499726451.000000 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I click on one of the lines, drilldown will build another panel that contains all events between &lt;STRONG&gt;tearliest&lt;/STRONG&gt;  and &lt;STRONG&gt;tlatest&lt;/STRONG&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os earliest=$tearliest$ latest=$tlatest$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is working very well, but the result of the first search is ugly and it is causing confusion with my users.&lt;/P&gt;

&lt;P&gt;How can I remove &lt;STRONG&gt;stime&lt;/STRONG&gt; &lt;STRONG&gt;tearliest&lt;/STRONG&gt; &lt;STRONG&gt;tlatest&lt;/STRONG&gt; from the search result, without interfere in the drill down? The simple XML of my dashboard is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;oom-killer invoked&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Between $timer.earliest$ and $timer.latest$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=os "invoked oom-killer:" 
| eval stime=_time 
| eval tearliest=relative_time(stime,"-1") | eval tlatest=relative_time(stime,"+1") 
| stats by _time stime tearliest tlatest
| fields _time stime tearliest tlatest
          &amp;lt;earliest&amp;gt;$timer.earliest$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$timer.latest$&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;50&amp;lt;/option&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;cell&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;true&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;false&amp;lt;/option&amp;gt;
        **&amp;lt;drilldown&amp;gt;
          &amp;lt;eval token="tearliest"&amp;gt;'row.tearliest'&amp;lt;/eval&amp;gt;
          &amp;lt;eval token="tlatest"&amp;gt;'row.tlatest'&amp;lt;/eval&amp;gt;
        &amp;lt;/drilldown&amp;gt;**
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;



    &amp;lt;panel depends="$tearliest$,$tlatest$"&amp;gt;
      &amp;lt;title&amp;gt;All events in timerange&amp;lt;/title&amp;gt;
      &amp;lt;event&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=os earliest=$tearliest$ latest=$tlatest$&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
        &amp;lt;option name="list.drilldown"&amp;gt;full&amp;lt;/option&amp;gt;
        &amp;lt;option name="list.wrap"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="maxLines"&amp;gt;5&amp;lt;/option&amp;gt;
        &amp;lt;option name="raw.drilldown"&amp;gt;full&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;0&amp;lt;/option&amp;gt;
        &amp;lt;option name="table.drilldown"&amp;gt;all&amp;lt;/option&amp;gt;
        &amp;lt;option name="table.sortDirection"&amp;gt;asc&amp;lt;/option&amp;gt;
        &amp;lt;option name="table.wrap"&amp;gt;1&amp;lt;/option&amp;gt;
        &amp;lt;option name="type"&amp;gt;list&amp;lt;/option&amp;gt;
      &amp;lt;/event&amp;gt;
    &amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Gerson&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 23:41:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311826#M160159</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-07-12T23:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove fields from a search that will be used in dashboard drill down panel in dashboard.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311827#M160160</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/98303"&gt;@GersonGarcia&lt;/a&gt;, I think stime field in your query is just duplicate data. You should perform evals after transforming query aggregates results to smaller buckets. You have also not mentioned what exact stats you need to aggregate. Since your fields command in the final pipe just retains time related field it seems confusing. &lt;BR /&gt;
In your example relative_time is missing time unit which implies -1 will reduce time by 1 second and +1 will increase by 1 second. Do you really want this? It is always better to define the unit of time as well. like 1h implies 1 hour etc.&lt;BR /&gt;
Do you want to show a table only with _time?&lt;BR /&gt;
Do you need stats? If not you should use just one like count. Just typing stats will calculate all stats and then you seem to drop all of them.&lt;/P&gt;

&lt;P&gt;You have two ways to do this. If you just want to show _time field in the table, &lt;CODE&gt;&amp;lt;fields&amp;gt;_time&amp;lt;/fields&amp;gt;&lt;/CODE&gt; Simple XML code is required in both examples.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1&lt;/STRONG&gt;: Use &lt;CODE&gt;&amp;lt;fields&amp;gt;&lt;/CODE&gt; Simple XML option to show only required fields in the table. Other fields are hidden but still available for drilldown. Following example retains just _time field for display since I am not sure whether you need fields from stats to be displayed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=os "invoked oom-killer:" 
 | stats count by _time
 | eval tearliest=relative_time(stime,"-1h") 
 | eval tlatest=relative_time(stime,"+1h") 

Your drilldown code remains the same:

     &amp;lt;fields&amp;gt;_time&amp;lt;/fields&amp;gt;
     &amp;lt;drilldown&amp;gt;
       &amp;lt;eval token="tearliest"&amp;gt;$row.tearliest$&amp;lt;/eval&amp;gt;
       &amp;lt;eval token="tlatest"&amp;gt;$row.tlatest$&amp;lt;/eval&amp;gt;
     &amp;lt;/drilldown&amp;gt;**
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2&lt;/STRONG&gt;: Just have the _time field passed to drilldown and use &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt; to calculate &lt;STRONG&gt;"-1h" and "+1h"&lt;/STRONG&gt; relative_time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=os "invoked oom-killer:" 
 | stats count by _time

Drilldown code changes to use eval to compute tearliest and tlatest through relative_time() function (fields is required if you just want to show _time field):

    &amp;lt;fields&amp;gt;_time&amp;lt;/fields&amp;gt;
    &amp;lt;drilldown&amp;gt;
      &amp;lt;eval token="tearliest"&amp;gt;relative_time($click.value$,"-1h")&amp;lt;/eval&amp;gt;
      &amp;lt;eval token="tlatest"&amp;gt;relative_time($click.value$,"+1h")&amp;lt;/eval&amp;gt;
    &amp;lt;/drilldown&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Ideally since your table is depicting time series data, you should consider timechart command with span=1h or similar as per your need instead of stat. Even for stats you can define span (or buckets of time for aggregation of results). For 1 hour you can add the following before stats command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| bin _time span=1h
| stats count by _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:54:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311827#M160160</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T14:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove fields from a search that will be used in dashboard drill down panel in dashboard.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311828#M160161</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/98303"&gt;@GersonGarcia&lt;/a&gt; - &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;'s advice is spot-on.  The &lt;STRONG&gt;only&lt;/STRONG&gt; thing you need to display is the exact _time, the rest can be hidden, and there's no reason at all to copy _time to stime, since the formatted one meets the need.  &lt;/P&gt;

&lt;P&gt;I would add that the title for _time should be something like "TIme of Oom-killer Invocation" , or the title of the panel might be "Select Desired TIme of Oom-Killer Invocation"&lt;/P&gt;

&lt;P&gt;Also, since _time is the only thing you are keeping from the records, you can do a &lt;CODE&gt;table&lt;/CODE&gt; and &lt;CODE&gt;dedup&lt;/CODE&gt; commands right at the beginning to eliminate all the other dead weight fields and events, which means you don't need &lt;CODE&gt;stats&lt;/CODE&gt; at all.  And, since we're just adding/subtracting exactly 1 second in epoch time, we can just use straight math rather than &lt;CODE&gt;relative_time&lt;/CODE&gt;.   It only saves a couple of machine instructions, but it's the principle of the thing.&lt;/P&gt;

&lt;P&gt;Here's your revised query...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt;index=os "invoked oom-killer:" 
| dedup _time 
| table _time 
| eval tearliest=_time-1 
| eval tlatest=_time+1 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:54:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311828#M160161</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-09-29T14:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove fields from a search that will be used in dashboard drill down panel in dashboard.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311829#M160162</link>
      <description>&lt;P&gt;@DalJeanis and @niketnilay, thank you very much. The  tag in Simple XML was the trick. I also replace the stat command by table (duhhh). But I don't want dedup the output since each line is one process analyzed by oom-killer and it may be for different hosts.&lt;BR /&gt;
Another point is I am adding and subtracting 1s of the 2nd search because earliest and latest with the same value returns no data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=os earliest=1499726450 latest=1499726450

No results found. 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 16:43:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311829#M160162</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-07-13T16:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove fields from a search that will be used in dashboard drill down panel in dashboard.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311830#M160163</link>
      <description>&lt;P&gt;@GersonGarcia, has the solution worked for you. Please accept the answer if it has. If not please let us know what is still not working.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2017 08:54:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-fields-from-a-search-that-will-be-used-in/m-p/311830#M160163</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-15T08:54:56Z</dc:date>
    </item>
  </channel>
</rss>

