<?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 filter the log using REGEX? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431621#M123368</link>
    <description>&lt;P&gt;Those numbers are a bit confusing. When I look at the debugger, the &lt;CODE&gt;\s&lt;/CODE&gt; option is actually quicker at finding the 1st match, since &lt;CODE&gt;\b&lt;/CODE&gt; also matches some of the special characters in the timestamp, while &lt;CODE&gt;\s&lt;/CODE&gt; doesn't.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Apr 2019 13:49:30 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2019-04-29T13:49:30Z</dc:date>
    <item>
      <title>How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431608#M123355</link>
      <description>&lt;P&gt;I have logs which contains 'LogonType=Owner'  and some logs  which contains 'InternalLogonType=Owner'.&lt;BR /&gt;
I want to send 'LogonType=Owner' to nullqueue while the latter not, so how can i write regex for it? &lt;BR /&gt;
As writing regex for 'LogonType=Owner'  would also capture 'InternalLogonType=Owner' and send it to nullqueue i assume.&lt;/P&gt;

&lt;P&gt;Note: logs are big 'LogonType=Owner' &amp;amp; 'InternalLogonType=Owner' are just one string in it.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 12:13:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431608#M123355</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-25T12:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431609#M123356</link>
      <description>&lt;P&gt;Can you share a sample log or two?  We need to see what comes before "LogonType=Owner" to create the regex.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 12:58:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431609#M123356</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-04-25T12:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431610#M123357</link>
      <description>&lt;P&gt;Either define a regex that actually detects when it is just LogonType="Owner". Quite likely a REGEX like &lt;CODE&gt;\s+LogonType="Owner"&lt;/CODE&gt; might work, to only detect LogonType="Owner" preceded by whitespace (incl. newline). But as @richgalloway mentions: if you want proper help with that, we would need to see a full sample.&lt;/P&gt;

&lt;P&gt;Alternatively, you can use 2 transforms (naturally, this is less efficient):&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
TRANSFORMS-filter = logontype-setnull,internallogontype-setparse
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[logontype-setnull]
REGEX = LogonType="Owner"
DEST_KEY = queue
FORMAT = nullQueue

[internallogontype-setparse]
REGEX = InternalLogonType="Owner"
DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This causes first to apply the null queue to both types (because the regex matches both options) and then sets the queue back to indexqueue for the InternalLogonType="Owner" case.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 14:48:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431610#M123357</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-25T14:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431611#M123358</link>
      <description>&lt;P&gt;You need to use &lt;CODE&gt;negative look-behind&lt;/CODE&gt;, like this:&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
TRANSFORMS-filter = logontype-setnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[logontype-setnull]
REGEX = (?&amp;lt;!Internal)LogonType=
DEST_KEY = queue
FORMAT = nullQueue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2019 04:59:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431611#M123358</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-26T04:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431612#M123359</link>
      <description>&lt;P&gt;Below are the logs which contains both 'LogonType=Owner' &amp;amp; 'InternalLogonType=Owner' &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1.    **LogonType="Owner"** MailboxOwnerUPN="" MailboxOwnerSid="" DestMailboxOwnerUPN="" DestMailboxOwnerSid="" DestMailboxGuid="" CrossMailboxOperation="" LogonUserDisplayName="" LogonUserSid="" SourceItems="" SourceFolders="" SourceItemIdsList="" SourceItemSubjectsList="" SourceItemAttachmentsList="" SourceItemFolderPathNamesList="Inbox" SourceFolderPathNamesList="" ItemId="" ItemSubject="" ItemAttachments="" DirtyProperties="" OriginatingServer="" MailboxGuid="" MailboxResolvedOwnerName="" LastAccessed="" Identity="=" IsValid="True" ObjectState="New"


2.  2019-04-01T00:14:59+02:00 Operation="" OperationResult="" LogonType="Admin" ExternalAccess="False" DestFolderId="" DestFolderPathName="" FolderId="" FolderPathName="" ClientInfoString="Client=POP3/IMAP4;Protocol=IMAP4" ClientIPAddress="" ClientMachineName="" ClientProcessName="" ClientVersion="" **InternalLogonType="Owner"** MailboxOwnerUPN="" MailboxOwnerSid="" DestMailboxOwnerUPN="" DestMailboxOwnerSid="" DestMailboxGuid="" CrossMailboxOperation="" LogonUserDisplayName="" LogonUserSid="" SourceItems="" SourceFolders="" SourceItemIdsList=" SourceItemSubjectsList="" SourceItemAttachmentsList="" SourceItemFolderPathNamesList="Inbox" SourceFolderPathNamesList="" ItemId="" ItemSubject="" ItemAttachments="" DirtyProperties="" OriginatingServer="" MailboxGuid="" MailboxResolvedOwnerName="" LastAccessed="" Identity="" IsValid="True" ObjectState="New"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i want the first log to be discarded but not the second one.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 17:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431612#M123359</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-27T17:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431613#M123360</link>
      <description>&lt;P&gt;i have pasted the sample above, however i have doubt over your suggestion to move &lt;STRONG&gt;interlogontype&lt;/STRONG&gt; to index queue, because there are many logs in the same sourcetype , so  would i need to write regex for every other logs except for &lt;STRONG&gt;logontype=Owner&lt;/STRONG&gt; to move to index queue? or other logs would be directly indexed?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 17:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431613#M123360</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-27T17:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431614#M123361</link>
      <description>&lt;P&gt;Thanks, i would try this and confirm.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 17:26:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431614#M123361</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-27T17:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431615#M123362</link>
      <description>&lt;P&gt;Other logs are not affected, as those will not match the &lt;CODE&gt;logontype=Owner&lt;/CODE&gt;, so they will just keep their original queue destination (being the indexqueue).&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 06:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431615#M123362</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-29T06:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431616#M123363</link>
      <description>&lt;P&gt;There are already valid answers here, but I think the regex can be improved. Instead of using a negative lookbehind, I would either use &lt;CODE&gt;\b&lt;/CODE&gt; to find a word boundary before the literal &lt;CODE&gt;LogonType&lt;/CODE&gt; (which &lt;CODE&gt;InternalLogonType&lt;/CODE&gt; will not match):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\bLogonType=Owner
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But based off of your comment showing example events, an even better option is to go with an explicit match including the &lt;CODE&gt;*&lt;/CODE&gt; before &lt;CODE&gt;LogonType&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\*LogonType="Owner
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Either of these works, but compare the step count yourself and you'll see that they are not equally performant: &lt;A href="https://regex101.com/r/56KiRq/1"&gt;Negative Lookbehind&lt;/A&gt; 116 steps, &lt;A href="https://regex101.com/r/56KiRq/2"&gt;word boundary&lt;/A&gt; 69 steps and &lt;A href="https://regex101.com/r/56KiRq/3"&gt;explicit match&lt;/A&gt; 32 steps for your two sample events.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 07:47:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431616#M123363</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2019-04-29T07:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431617#M123364</link>
      <description>&lt;P&gt;Would that first log also have the timestamp and operation= and operationresult fields preceding the logontype field?&lt;/P&gt;

&lt;P&gt;Also: the &lt;CODE&gt;**&lt;/CODE&gt; are because you were trying to make these parts &lt;STRONG&gt;bold&lt;/STRONG&gt; I guess? Not because those &lt;CODE&gt;*&lt;/CODE&gt; characters are in your actual logs?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 07:54:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431617#M123364</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-29T07:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431618#M123365</link>
      <description>&lt;P&gt;I think he was trying to make those bits &lt;STRONG&gt;bold&lt;/STRONG&gt;, don't think those asterisks are part of his log. Assuming the events all follow the same structure, (but the timestamp and first few fields are missing from his sample), &lt;CODE&gt;\sLogonType="Owner&lt;/CODE&gt; should do the trick.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 07:56:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431618#M123365</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-29T07:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431619#M123366</link>
      <description>&lt;P&gt;PS: from your sample log it seems it contains a &lt;CODE&gt;"&lt;/CODE&gt; before the field value? I added that to the REGEX in my answer.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 07:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431619#M123366</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-29T07:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431620#M123367</link>
      <description>&lt;P&gt;Yeah, probably. No accurate regexes without accurate data &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;
&lt;CODE&gt;\s&lt;/CODE&gt; and &lt;CODE&gt;\b&lt;/CODE&gt; should both do the trick, but &lt;CODE&gt;\b&lt;/CODE&gt; is still way better because it has fewer matches (I've recreated the two events this time, they now both have time and the other fields, and removed the asterisks, and they compare &lt;A href="https://regex101.com/r/KhJSlH/1"&gt;66&lt;/A&gt; to &lt;A href="https://regex101.com/r/KhJSlH/2"&gt;1569&lt;/A&gt; steps - check out the debugger to see why).&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 13:38:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431620#M123367</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2019-04-29T13:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431621#M123368</link>
      <description>&lt;P&gt;Those numbers are a bit confusing. When I look at the debugger, the &lt;CODE&gt;\s&lt;/CODE&gt; option is actually quicker at finding the 1st match, since &lt;CODE&gt;\b&lt;/CODE&gt; also matches some of the special characters in the timestamp, while &lt;CODE&gt;\s&lt;/CODE&gt; doesn't.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 13:49:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431621#M123368</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-04-29T13:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431622#M123369</link>
      <description>&lt;P&gt;Yes the ** ** was to make it bold, some how it didn't, and the structure is same as i pasted the logs above.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 01:13:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431622#M123369</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-30T01:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431623#M123370</link>
      <description>&lt;P&gt;This worked, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 01:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431623#M123370</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-30T01:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431624#M123371</link>
      <description>&lt;P&gt;&lt;CODE&gt;&amp;lt;\b&amp;gt;&lt;/CODE&gt;also worked, however it doesn't have ability to accept this one also as answer, but thanks much!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 01:23:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431624#M123371</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-30T01:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter the log using REGEX?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431625#M123372</link>
      <description>&lt;P&gt;Yes &lt;CODE&gt;**&lt;/CODE&gt;  for the bold, my bad! and structure is same as i pasted above.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 01:28:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-the-log-using-REGEX/m-p/431625#M123372</guid>
      <dc:creator>sarwshai</dc:creator>
      <dc:date>2019-04-30T01:28:24Z</dc:date>
    </item>
  </channel>
</rss>

