<?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: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496667#M138386</link>
    <description>&lt;P&gt;Hi &lt;BR /&gt;
If you could share an example of your logs it could be easier for me to check the regex to filter your logs!&lt;/P&gt;

&lt;P&gt;Anyway in the REGEX option, you have to insert the exact regex for filtering your logs, so if your logs are something like these&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;pppppppppppp logtype::ABC.123 pppppppid::IDB-28123.ppppp  pppppppp username::ppppppp
pppppppppppp logtype::ABC.123 qqqqqid::IDB-28123.qqqq pppppppp username::qqq
pppppppppppp logtype::ABC.123 rrrrrrid::IDB-28123.rrr pppppppp username::rrTEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could use a regex like this one (that you can test in &lt;A href="https://regex101.com/r/D5HhNZ/1"&gt;https://regex101.com/r/D5HhNZ/1&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;logtype::[^ ]*\s+\w+id::IDB-28123.\w+\s\w+\s+username::\w+TEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that filter only the last event.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 02 Oct 2019 09:42:33 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2019-10-02T09:42:33Z</dc:date>
    <item>
      <title>filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496665#M138384</link>
      <description>&lt;P&gt;I have filter applied in transforms.conf as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[send_to_heavy_forwarder]
CAN_OPTIMIZE = True
CLEAN_KEYS = True
DEFAULT_VALUE = 
DEST_KEY = _TCP_ROUTING
FORMAT = heavy_forwarder
KEEP_EMPTY_VALS = False
LOOKAHEAD = 4096
MATCH_LIMIT = 100000
MV_ADD = False
RECURSION_LIMIT = 1000
REGEX = (logtype::ABC.*id::IDB-28123.*username::((?!-TEST).)*$)
SOURCE_KEY = _meta
WRITE_META = False
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;All I'm trying here is to filter sending logs If the following conditions satisfies&lt;/P&gt;

&lt;P&gt;logtype=ABC, id=IDB-28123 and username value doesn't end with TEST&lt;/P&gt;

&lt;P&gt;which is not working but it is working if I removed the username part in the regex. &lt;/P&gt;

&lt;P&gt;It's not working before due to the negative look back I applies. If so, how can I filter those test user logs?&lt;/P&gt;

&lt;P&gt;Any help would be great.  &lt;/P&gt;

&lt;P&gt;Check below for more details :- &lt;/P&gt;

&lt;P&gt;Logs in Indexer :- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    pppppppppppp logtype::ABC id::IDB-28123  pppppppp username::ppppppp
    pppppppppppp logtype::ABC id::IDB-28123 pppppppp username::qqq
    pppppppppppp logtype::ABC id::IDB-28123 pppppppp username::rrTEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regex should skip sending the below logs :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;pppppppppppp logtype::ABC id::IDB-28123 pppppppp username::rrTEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Regex should send the below logs :- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; pppppppppppp logtype::ABC id::IDB-28123  pppppppp username::ppppppp
        pppppppppppp logtype::ABC id::IDB-28123 pppppppp username::qqq
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Oct 2019 18:06:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496665#M138384</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2019-10-01T18:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496666#M138385</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Is it possible you to provide some sample raw data (Please mask any sensitive data) ?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 08:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496666#M138385</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-10-02T08:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496667#M138386</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
If you could share an example of your logs it could be easier for me to check the regex to filter your logs!&lt;/P&gt;

&lt;P&gt;Anyway in the REGEX option, you have to insert the exact regex for filtering your logs, so if your logs are something like these&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;pppppppppppp logtype::ABC.123 pppppppid::IDB-28123.ppppp  pppppppp username::ppppppp
pppppppppppp logtype::ABC.123 qqqqqid::IDB-28123.qqqq pppppppp username::qqq
pppppppppppp logtype::ABC.123 rrrrrrid::IDB-28123.rrr pppppppp username::rrTEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could use a regex like this one (that you can test in &lt;A href="https://regex101.com/r/D5HhNZ/1"&gt;https://regex101.com/r/D5HhNZ/1&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;logtype::[^ ]*\s+\w+id::IDB-28123.\w+\s\w+\s+username::\w+TEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;that filter only the last event.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 09:42:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496667#M138386</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-10-02T09:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496668#M138387</link>
      <description>&lt;P&gt;Thanks for the response @gcusello. Here I want to skip the logs which has the string "TEST" at the end of the username field. The regex you provided Just doing the opposite. On your regex example It should select the remaining except the log with username which has string "TEST" at the end. &lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 13:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496668#M138387</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2019-10-02T13:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496669#M138388</link>
      <description>&lt;P&gt;It's just the "-" in your negative lookahead. Currently you will discard anything that ends with "-TEST". You don't have a "-" in your example. This should work:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;REGEX = (logtype::ABC.*id::IDB-28123.*username::((?!TEST).)*$)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Edit: I don't know why two of the "*" weren't showing up.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 14:22:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496669#M138388</guid>
      <dc:creator>rmjharris</dc:creator>
      <dc:date>2019-10-02T14:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496670#M138389</link>
      <description>&lt;P&gt;Thanks @rmjharris. what if I have "-" at the end of some username fields like below &lt;/P&gt;

&lt;P&gt;username=abcd-TEST&lt;/P&gt;

&lt;P&gt;does your answer still works for the above example too&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 14:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496670#M138389</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2019-10-02T14:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: filter logs containing a specific string in username field so that they won't transfer to heavy forwarder from indexer using transforms.conf?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496671#M138390</link>
      <description>&lt;P&gt;It will work if "TEST" (case sensitive) is in the username. Any of these&lt;BR /&gt;
user-TEST&lt;BR /&gt;
userTEST&lt;BR /&gt;
TESTuser&lt;BR /&gt;
usTESTer&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 20:04:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/filter-logs-containing-a-specific-string-in-username-field-so/m-p/496671#M138390</guid>
      <dc:creator>rmjharris</dc:creator>
      <dc:date>2019-10-02T20:04:06Z</dc:date>
    </item>
  </channel>
</rss>

