<?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: How to mask a field at search time only if the data is &amp;gt; 30 days? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228422#M67539</link>
    <description>&lt;P&gt;You will need to re-index the event after modifying it and the delete the original event.  You can use &lt;CODE&gt;collect&lt;/CODE&gt; to do this.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2016 21:41:13 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2016-04-29T21:41:13Z</dc:date>
    <item>
      <title>How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228421#M67538</link>
      <description>&lt;P&gt;I have a requirement to mask the value of a field after 30 days.&lt;/P&gt;

&lt;P&gt;The events are json events.  The users need to be able to see/search all the fields except 1 for up to a year.  The 1 field must be hidden from view after 30 days. &lt;/P&gt;

&lt;P&gt;My plan was to define a calculated field that, when _time is more than 30 days ago overwrites the value of the field with one I supply.  The calculation would be performed for every search.  What I failed to consider was 2 things:&lt;/P&gt;

&lt;P&gt;First, The field to be overwritten is a json field.  The fieldname is  foo{}.id  If I use &lt;BR /&gt;
&lt;CODE&gt;|eval foo{}.id = if ((_time &amp;lt; (now() - (86400*30))), "TOO OLD", foo{}.id)&lt;/CODE&gt;, I get an error that the eval is malformed.  If I add quotes around the field names like this:  &lt;CODE&gt;|eval "foo{}.id" = if ((_time &amp;lt; (now() - (86400*30))), "TOO OLD", "foo{}.id")&lt;/CODE&gt;, I get a new field called foo.id which = TOO OLD, but I still have the original foo{}.id with the original value.&lt;/P&gt;

&lt;P&gt;Second, Even if I can get the calculated field to behave properly, the original value is still in the _raw field which is easily visible in the events view or by adding _raw to a table. &lt;/P&gt;

&lt;P&gt;So, is it possible to overwrite a single field at search time such that every search will return the overwritten value?  &lt;/P&gt;

&lt;P&gt;Also, can I somehow remove the _raw field for every search, and if so, are there any weird consequences from doing that?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 21:37:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228421#M67538</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-04-29T21:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228422#M67539</link>
      <description>&lt;P&gt;You will need to re-index the event after modifying it and the delete the original event.  You can use &lt;CODE&gt;collect&lt;/CODE&gt; to do this.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 21:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228422#M67539</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-29T21:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228423#M67540</link>
      <description>&lt;P&gt;I saw a reference to this solution in another answer, but didn't understand it.     I thought summary indexes were mainly used to collect the output of stats commands so you can keep counts longer than the actual data.  How does a summary index work when you just want to re-index an entire event that is already indexed?  Does it just send the _raw field value through the index/parsing pipeline again?  if so, do I just need to use |rex to mask the field in the raw json? &lt;/P&gt;

&lt;P&gt;Are the same props and transforms applied to the summary indexed data that is applied to the original data?  I want to make sure that I can just add the summary index to all of my searches and have them still work.&lt;/P&gt;

&lt;P&gt;Any details you can give me would be greatly appreciated.  I'd really like to more fully understand how this works.&lt;/P&gt;

&lt;P&gt;Thanks...&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 22:21:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228423#M67540</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-04-29T22:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228424#M67541</link>
      <description>&lt;P&gt;Although &lt;CODE&gt;collect&lt;/CODE&gt; is &lt;EM&gt;intended&lt;/EM&gt; to write to a &lt;CODE&gt;Summary Index&lt;/CODE&gt;, in actuality, it can write to &lt;EM&gt;any&lt;/EM&gt; Index.  Play around with it and you will see what it does.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|noop|stats count AS TestOfCollect | collect index=myIndex
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then check it out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex | where isnotnull(TestOfCollect)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then throw it away and refine:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex | where isnotnull(TestOfCollect) | delete
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Apr 2016 14:10:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228424#M67541</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-30T14:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228425#M67542</link>
      <description>&lt;P&gt;Be aware that using &lt;CODE&gt;collect&lt;/CODE&gt; to a non-Summary Index will incur double-license hit.&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2016 02:21:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228425#M67542</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-01T02:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228426#M67543</link>
      <description>&lt;P&gt;I would do this: At the time of index, modify the event to create a hash using the time-sensitive field and replace the field value in the raw event with the hash.  At the same time, add the value with the hash and a date in a &lt;CODE&gt;KV store&lt;/CODE&gt; so that the data exists in 2 separate places.  Then every day purge the &lt;CODE&gt;KV store&lt;/CODE&gt; of any data that is older than 30 days.  When you search, use a &lt;CODE&gt;lookup&lt;/CODE&gt; on the hash in the event to pull in the field value from the &lt;CODE&gt;KV store&lt;/CODE&gt; and after 30-days, the &lt;CODE&gt;lookup&lt;/CODE&gt; will fail.&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2016 02:24:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228426#M67543</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-01T02:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228427#M67544</link>
      <description>&lt;P&gt;This sounds like a great approach.  So, I'd need a script to pre-process the data files before they are given to the splunk Universal Forwarder, right?&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 16:57:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228427#M67544</guid>
      <dc:creator>lyndac</dc:creator>
      <dc:date>2016-05-02T16:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to mask a field at search time only if the data is &gt; 30 days?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228428#M67545</link>
      <description>&lt;P&gt;You've got it.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 17:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-mask-a-field-at-search-time-only-if-the-data-is-gt-30/m-p/228428#M67545</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-02T17:08:26Z</dc:date>
    </item>
  </channel>
</rss>

