<?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: Can you mask data at index-time conditionally? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236962#M70431</link>
    <description>&lt;P&gt;Hi twinspop,&lt;/P&gt;

&lt;P&gt;Try to follow this example using your sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01/19/2016 11:34 v1=1 v2=2 v3=3.45 v4=4 key=bad
01/19/2016 11:22 v1=6 v2=7 v3=8.45 key=good v4=9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the given SEDCMD regex below, using Positives Lookbehind/Lookahead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
SEDCMD = s/(?&amp;lt;=v1=).*(?=\sv2=.*?\skey=bad)/X.XX/g s/(?&amp;lt;=v2=).*(?=\sv3=.*?\sv4=.*?\skey=bad)/X.XX/g s/(?&amp;lt;=v3=).*(?=\sv4=.*?\skey=bad)/X.XX/g s/(?&amp;lt;=v4=)\d(?=\skey=bad)/X.XX/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jan 2016 19:15:20 GMT</pubDate>
    <dc:creator>alemarzu</dc:creator>
    <dc:date>2016-01-19T19:15:20Z</dc:date>
    <item>
      <title>Can you mask data at index-time conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236961#M70430</link>
      <description>&lt;P&gt;Given data like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;v1=1 v2=2 v3=3.45 v4=4 key=bad
v1=6 v2=7 v3=8.45 key=good v4=9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to mask the vX values in the case of key=bad only. I cannot guarantee order. Results should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;v1=x.xx v2=x.xx v3=x.xx v4=x.xx key=bad
v1=6 v2=7 v3=8.45 key=good v4=9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 17:52:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236961#M70430</guid>
      <dc:creator>twinspop</dc:creator>
      <dc:date>2016-01-19T17:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can you mask data at index-time conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236962#M70431</link>
      <description>&lt;P&gt;Hi twinspop,&lt;/P&gt;

&lt;P&gt;Try to follow this example using your sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01/19/2016 11:34 v1=1 v2=2 v3=3.45 v4=4 key=bad
01/19/2016 11:22 v1=6 v2=7 v3=8.45 key=good v4=9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With the given SEDCMD regex below, using Positives Lookbehind/Lookahead.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
SEDCMD = s/(?&amp;lt;=v1=).*(?=\sv2=.*?\skey=bad)/X.XX/g s/(?&amp;lt;=v2=).*(?=\sv3=.*?\sv4=.*?\skey=bad)/X.XX/g s/(?&amp;lt;=v3=).*(?=\sv4=.*?\skey=bad)/X.XX/g s/(?&amp;lt;=v4=)\d(?=\skey=bad)/X.XX/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 19:15:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236962#M70431</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2016-01-19T19:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can you mask data at index-time conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236963#M70432</link>
      <description>&lt;P&gt;This might lead to the correct way, but the field names (aside from key) are variable. I should have included that tidbit. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Reading up on PLBs and PLAs. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 23:22:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236963#M70432</guid>
      <dc:creator>twinspop</dc:creator>
      <dc:date>2016-01-19T23:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can you mask data at index-time conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236964#M70433</link>
      <description>&lt;P&gt;I'm not able to make this work because the fields that need masking occur an arbitrary number of times. Roughly speaking what I need is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if (/key=bad/)
    s/v(\d+)=\d+\.\d{2}/v\1=x.xx/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(this will teach me to use better sample data -- sorry)&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 23:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236964#M70433</guid>
      <dc:creator>twinspop</dc:creator>
      <dc:date>2016-01-19T23:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can you mask data at index-time conditionally?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236965#M70434</link>
      <description>&lt;P&gt;It's okey mate, dont worry about it.&lt;/P&gt;

&lt;P&gt;Check this out, based on your sample data again, this regex should match (n) amount of fields.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;s/(?&amp;lt;==)(\d+\.\d{1,}+|\d+)(?=.*?key=bad)/X.XX/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: regex101 example, &lt;A href="https://regex101.com/r/uM9nW8/1"&gt;https://regex101.com/r/uM9nW8/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:57:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-mask-data-at-index-time-conditionally/m-p/236965#M70434</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2016-01-20T20:57:23Z</dc:date>
    </item>
  </channel>
</rss>

