<?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 Re: Excluding a field name from fields command exclusions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310574#M93143</link>
    <description>&lt;P&gt;Your lookup should have only single column, say fieldName, with all the field names that you want to keep.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;fieldName
 Authentication.action
 ...
 tag::eventtype,tag::eventtype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now your search should be like this (see the rename and parameter to &lt;CODE&gt;format&lt;/CODE&gt; command, that's the trick. Passing 6 empty double quote set separated by space)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * [|inputlookup myfieldstolookup.csv | table fieldName | rename fieldName as query | format "" "" "" "" "" "" ] | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 01 Dec 2017 21:18:47 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-12-01T21:18:47Z</dc:date>
    <item>
      <title>Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310567#M93136</link>
      <description>&lt;P&gt;The &lt;CODE&gt;fields -&lt;/CODE&gt; command expects a list of field names to exclude, and one can use wildcards in that list. But what I need to exclude a long list of fields that match a wildcard expression except for one? Here's an example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * | fields - Authentication.user api* autojoin buckets date_* enable_lookups extra_fields file_modify_time max* savedsearch_name search* splunk_server_group timestamp ttl vendor_status + date_zone | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This excludes a bunch of fields named &lt;CODE&gt;date_hour&lt;/CODE&gt;, &lt;CODE&gt;date_mday&lt;/CODE&gt;, &lt;CODE&gt;date_minute&lt;/CODE&gt; and so forth, but say I want to keep &lt;CODE&gt;date_zone&lt;/CODE&gt;? One (clumsy) solution I've found is to copy the field before running the exclusions and then copy it back:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * | eval datezone=date_zone | fields - Authentication.user api* autojoin buckets date_* enable_lookups extra_fields file_modify_time max* savedsearch_name search* splunk_server_group timestamp ttl vendor_status | eval date_zone = datezone | fields - datezone | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a better way?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 15:46:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310567#M93136</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-01T15:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310568#M93137</link>
      <description>&lt;P&gt;I think the way you did it is already very smart &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Eventually you could use rename instead of eval!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 16:24:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310568#M93137</guid>
      <dc:creator>damien_chillet</dc:creator>
      <dc:date>2017-12-01T16:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310569#M93138</link>
      <description>&lt;P&gt;Indeed, &lt;CODE&gt;rename&lt;/CODE&gt; is one step better, allowing one to skip the second &lt;CODE&gt;fields -&lt;/CODE&gt; call:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| from datamodel:Authentication.Successful_Authentication | search sourcetype=audittrail | table * | rename date_zone as datezone | fields - api* autojoin buckets date_* enable_lookups extra_fields file_modify_time max* savedsearch_name search* splunk_server_group timestamp ttl user vendor_status | rename datezone as date_zone | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I was hoping there was a way to use some sort of regex to replace the wildcard, that is to say, a way of specifying &lt;CODE&gt;date_[^z].*&lt;/CODE&gt; instead of &lt;CODE&gt;date_*&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 18:54:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310569#M93138</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-01T18:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310570#M93139</link>
      <description>&lt;P&gt;Maybe something in the spirit of @somesoni2 with a &lt;CODE&gt;lookup&lt;/CODE&gt; at &lt;A href="https://answers.splunk.com/answers/128889/search-all-fields-except.html"&gt;Search all fields except ____&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 19:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310570#M93139</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2017-12-01T19:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310571#M93140</link>
      <description>&lt;P&gt;The name and number of default &lt;CODE&gt;date_*&lt;/CODE&gt; fields are constant, so one option could be to create a macro, say &lt;CODE&gt;date_fields_to_filter&lt;/CODE&gt; with definition as &lt;CODE&gt;date_hour date_mday date_minute date_month date_second date_wday date_year&lt;/CODE&gt;. Your query will be like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * | fields - Authentication.user api* autojoin buckets `date_fields_to_filter` enable_lookups extra_fields file_modify_time max* savedsearch_name search* splunk_server_group timestamp ttl vendor_status | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 20:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310571#M93140</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-12-01T20:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310572#M93141</link>
      <description>&lt;P&gt;I tried:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * [|inputlookup myfieldstolookup.csv | eval query="searchTerm=".fieldName | table query | format ] | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where I used the Lookup Editor app to create &lt;CODE&gt;myfieldstolookup.csv&lt;/CODE&gt; but I'm not sure what the contents of that file should be. I tried a file that looks like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;fieldName,fieldNameOut
Authentication.action,Authentication.action
...
tag::eventtype,tag::eventtype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Far from filtering on the 17 fields I want, it added 21 fields ( &lt;CODE&gt;addr&lt;/CODE&gt;, &lt;CODE&gt;auid&lt;/CODE&gt;, &lt;CODE&gt;dev&lt;/CODE&gt;...) to the unfiltered 49-field search. The fragment:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[|inputlookup myfieldstolookup.csv | eval query="searchTerm=".fieldName | table query | format ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;returns&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;( ("searchTerm=Authentication.action") OR ... )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead of the expected&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;( (searchTerm=Authentication.action) OR ... )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 21:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310572#M93141</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-01T21:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310573#M93142</link>
      <description>&lt;P&gt;The macro solution is a good one, simpler than &lt;CODE&gt;inputlookup&lt;/CODE&gt;. By the same token, it may be easier to do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields + `date_fields_to_keep`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Although I do realize that the two solutions are not equivalent when the events don't have a uniform field signature)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 21:08:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310573#M93142</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-01T21:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310574#M93143</link>
      <description>&lt;P&gt;Your lookup should have only single column, say fieldName, with all the field names that you want to keep.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;fieldName
 Authentication.action
 ...
 tag::eventtype,tag::eventtype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now your search should be like this (see the rename and parameter to &lt;CODE&gt;format&lt;/CODE&gt; command, that's the trick. Passing 6 empty double quote set separated by space)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * [|inputlookup myfieldstolookup.csv | table fieldName | rename fieldName as query | format "" "" "" "" "" "" ] | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 21:18:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310574#M93143</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-12-01T21:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310575#M93144</link>
      <description>&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.0/Knowledge/Usefieldlookupstoaddinformationtoyourevents"&gt;http://docs.splunk.com/Documentation/Splunk/7.0.0/Knowledge/Usefieldlookupstoaddinformationtoyourevents&lt;/A&gt; says "The table in the CSV file should have at least two columns", which is what initially led me to put two columns in there.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 21:31:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310575#M93144</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-01T21:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310576#M93145</link>
      <description>&lt;P&gt;It gets closer, but the fragment:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup myfieldstolookup.csv | table fieldName | rename fieldName as query | format "" "" "" "" "" ""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;now yields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Authentication.action" "Authentication.app" "Authentication.dest" "Authentication.src" "Authentication.src_user" "Authentication.tag" date_zone eventtype host index info linecount source sourcetype splunk_server "tag::action" "tag::eventtype"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which again fails to filter the fields. Looks like the quotes get added when "punctuation" (i.e. colons and periods) is present in the field names.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 21:36:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310576#M93145</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-01T21:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310577#M93146</link>
      <description>&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [
 | inputlookup myfieldstolookup.csv 
 | table fieldName 
 | format "" "" "" "" "" "" 
 | rex mode=sed field=search "s/\"//g"
 ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 21:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310577#M93146</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-12-01T21:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310578#M93147</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rename foo1234 AS _foo1234
| fields - foo*
| rename _foo1234 AS foo1234
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Fields that start with &lt;CODE&gt;_&lt;/CODE&gt; are not included in wildcard matches except for &lt;CODE&gt;_*&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2017 20:55:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310578#M93147</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-12-02T20:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310579#M93148</link>
      <description>&lt;P&gt;That does get rid of the quotes in the fragment, but it turns out they're not the problem: the problem is very simply the '*' before the fragment, which voids the filtering being attempted. All that was needed was to change:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table * [ | inputlookup myfieldstolookup.csv | table fieldName | rename fieldName as query | format "" "" "" "" "" "" ] | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;into:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| datamodel Authentication Successful_Authentication search | search sourcetype=audittrail | table [ | inputlookup myfieldstolookup.csv | table fieldName | rename fieldName as query | format "" "" "" "" "" "" ] | fieldsummary
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Dec 2017 14:25:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310579#M93148</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-04T14:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310580#M93149</link>
      <description>&lt;P&gt;First mentioned by damien_chillet, this is by far the simplest approach. It would also be amenable to being made into a macro if I were so inclined.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 14:28:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310580#M93149</guid>
      <dc:creator>DUThibault</dc:creator>
      <dc:date>2017-12-04T14:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Excluding a field name from fields command exclusions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310581#M93150</link>
      <description>&lt;P&gt;I didn't notice that (I don't generally read the other comments, just the answers, when I am posting my answer), but there is big value in the &lt;CODE&gt;_*&lt;/CODE&gt; portion that he did not mention, too.  I upvoted his comment and you should do the same.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Dec 2017 14:48:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Excluding-a-field-name-from-fields-command-exclusions/m-p/310581#M93150</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-12-04T14:48:52Z</dc:date>
    </item>
  </channel>
</rss>

