<?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 How to filter XmlWinEventLog in Heavy Forwarder with regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346803#M102675</link>
    <description>&lt;P&gt;Hi, &lt;BR /&gt;
I have XML rendered log from sysmon and i need to extract from this log only interesting fields, for example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Image|UtcTime|ProcessGuid|CommandLine|User|ParentProcessGuid|ParentImage|ParentCommandLine|Hashes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But my conf doesn't work.&lt;BR /&gt;
What i did wrong and how to fix that?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;here is the sample xml&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;- &amp;lt;Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&amp;gt;
- &amp;lt;System&amp;gt;
  &amp;lt;Provider Name="Microsoft-Windows-Sysmon" Guid="{5770385F-C22A-43E0-BF4C-06F5698FFBD9}" /&amp;gt; 
  &amp;lt;EventID&amp;gt;1&amp;lt;/EventID&amp;gt; 
  &amp;lt;Version&amp;gt;5&amp;lt;/Version&amp;gt; 
  &amp;lt;Level&amp;gt;4&amp;lt;/Level&amp;gt; 
  &amp;lt;Task&amp;gt;1&amp;lt;/Task&amp;gt; 
  &amp;lt;Opcode&amp;gt;0&amp;lt;/Opcode&amp;gt; 
  &amp;lt;Keywords&amp;gt;0x8000000000000000&amp;lt;/Keywords&amp;gt; 
  &amp;lt;TimeCreated SystemTime="2017-03-13T12:16:18.234566900Z" /&amp;gt; 
  &amp;lt;EventRecordID&amp;gt;1098206&amp;lt;/EventRecordID&amp;gt; 
  &amp;lt;Correlation /&amp;gt; 
  &amp;lt;Execution ProcessID="2416" ThreadID="2476" /&amp;gt; 
  &amp;lt;Channel&amp;gt;Microsoft-Windows-Sysmon/Operational&amp;lt;/Channel&amp;gt; 
  &amp;lt;Computer&amp;gt;HOSTNAME&amp;lt;/Computer&amp;gt; 
  &amp;lt;Security UserID="S-1-5-18" /&amp;gt; 
  &amp;lt;/System&amp;gt;
- &amp;lt;EventData&amp;gt;
  &amp;lt;Data Name="UtcTime"&amp;gt;2017-03-13 12:16:18.203&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ProcessGuid"&amp;gt;{EF92ED9B-8D92-58C6-0000-0010B2A27B04}&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ProcessId"&amp;gt;2832&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="Image"&amp;gt;C:\Windows\System32\cmd.exe&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="CommandLine"&amp;gt;"C:\Windows\system32\cmd.exe" /c type "C:\ProgramData\****.txt"&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="CurrentDirectory"&amp;gt;c:\program files\*****\&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="User"&amp;gt;NT AUTHORITY\SYSTEM&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="LogonGuid"&amp;gt;{****************************}&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="LogonId"&amp;gt;0x3e7&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="TerminalSessionId"&amp;gt;0&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="IntegrityLevel"&amp;gt;System&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="Hashes"&amp;gt;SHA1=0F3C4FF28F354AEDE2,MD5=5746BD7E255DD61,SHA256=DB06C3534964E3FC79D0CA336F4A0FE724B75AAFF386,IMPHASH=D00585440EB0A&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentProcessGuid"&amp;gt;{**************************}&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentProcessId"&amp;gt;1564&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentImage"&amp;gt;C:\Program Files\****.exe&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentCommandLine"&amp;gt;"C:\Program Files\******" 1452&amp;lt;/Data&amp;gt; 
  &amp;lt;/EventData&amp;gt;
+ &amp;lt;RenderingInfo Culture="en-US"&amp;gt;
  &amp;lt;Message&amp;gt; **************************************************************&amp;lt;/Message&amp;gt; 
  &amp;lt;Level&amp;gt;Information&amp;lt;/Level&amp;gt; 
  &amp;lt;Task&amp;gt;Process Create (rule: ProcessCreate)&amp;lt;/Task&amp;gt; 
  &amp;lt;Opcode&amp;gt;Info&amp;lt;/Opcode&amp;gt; 
  &amp;lt;Channel /&amp;gt; 
  &amp;lt;Provider /&amp;gt; 
  &amp;lt;Keywords /&amp;gt; 
  &amp;lt;/RenderingInfo&amp;gt;
  &amp;lt;/Event&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;And this is my conf:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[WinEventLog://ForwardedEvents]
    disabled = false
    start_from = oldest
    current_only = 0
    checkpointInterval = 5
    renderXml = true
    suppress_text = 1
    index = sysmon
    sourcetype=XmlWinEventLog:Microsoft-Windows-Sysmon/Operational
    whitelist1 = 1,5,6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [source::WinEventLog://ForwardedEvents]
    TRANSFORMS-setnull = sysmon-setnull
    TRANSFORMS-keep = sysmon-keep
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sysmon-setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[sysmon-keep]
REGEX = (?i)Name=".*(Image|UtcTime|ProcessGuid|CommandLine|User|ParentProcessGuid|ParentImage|ParentCommandLine|Hashes)"
DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Mar 2017 14:45:39 GMT</pubDate>
    <dc:creator>borshoff</dc:creator>
    <dc:date>2017-03-13T14:45:39Z</dc:date>
    <item>
      <title>How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346803#M102675</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I have XML rendered log from sysmon and i need to extract from this log only interesting fields, for example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Image|UtcTime|ProcessGuid|CommandLine|User|ParentProcessGuid|ParentImage|ParentCommandLine|Hashes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But my conf doesn't work.&lt;BR /&gt;
What i did wrong and how to fix that?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;here is the sample xml&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;- &amp;lt;Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&amp;gt;
- &amp;lt;System&amp;gt;
  &amp;lt;Provider Name="Microsoft-Windows-Sysmon" Guid="{5770385F-C22A-43E0-BF4C-06F5698FFBD9}" /&amp;gt; 
  &amp;lt;EventID&amp;gt;1&amp;lt;/EventID&amp;gt; 
  &amp;lt;Version&amp;gt;5&amp;lt;/Version&amp;gt; 
  &amp;lt;Level&amp;gt;4&amp;lt;/Level&amp;gt; 
  &amp;lt;Task&amp;gt;1&amp;lt;/Task&amp;gt; 
  &amp;lt;Opcode&amp;gt;0&amp;lt;/Opcode&amp;gt; 
  &amp;lt;Keywords&amp;gt;0x8000000000000000&amp;lt;/Keywords&amp;gt; 
  &amp;lt;TimeCreated SystemTime="2017-03-13T12:16:18.234566900Z" /&amp;gt; 
  &amp;lt;EventRecordID&amp;gt;1098206&amp;lt;/EventRecordID&amp;gt; 
  &amp;lt;Correlation /&amp;gt; 
  &amp;lt;Execution ProcessID="2416" ThreadID="2476" /&amp;gt; 
  &amp;lt;Channel&amp;gt;Microsoft-Windows-Sysmon/Operational&amp;lt;/Channel&amp;gt; 
  &amp;lt;Computer&amp;gt;HOSTNAME&amp;lt;/Computer&amp;gt; 
  &amp;lt;Security UserID="S-1-5-18" /&amp;gt; 
  &amp;lt;/System&amp;gt;
- &amp;lt;EventData&amp;gt;
  &amp;lt;Data Name="UtcTime"&amp;gt;2017-03-13 12:16:18.203&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ProcessGuid"&amp;gt;{EF92ED9B-8D92-58C6-0000-0010B2A27B04}&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ProcessId"&amp;gt;2832&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="Image"&amp;gt;C:\Windows\System32\cmd.exe&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="CommandLine"&amp;gt;"C:\Windows\system32\cmd.exe" /c type "C:\ProgramData\****.txt"&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="CurrentDirectory"&amp;gt;c:\program files\*****\&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="User"&amp;gt;NT AUTHORITY\SYSTEM&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="LogonGuid"&amp;gt;{****************************}&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="LogonId"&amp;gt;0x3e7&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="TerminalSessionId"&amp;gt;0&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="IntegrityLevel"&amp;gt;System&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="Hashes"&amp;gt;SHA1=0F3C4FF28F354AEDE2,MD5=5746BD7E255DD61,SHA256=DB06C3534964E3FC79D0CA336F4A0FE724B75AAFF386,IMPHASH=D00585440EB0A&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentProcessGuid"&amp;gt;{**************************}&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentProcessId"&amp;gt;1564&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentImage"&amp;gt;C:\Program Files\****.exe&amp;lt;/Data&amp;gt; 
  &amp;lt;Data Name="ParentCommandLine"&amp;gt;"C:\Program Files\******" 1452&amp;lt;/Data&amp;gt; 
  &amp;lt;/EventData&amp;gt;
+ &amp;lt;RenderingInfo Culture="en-US"&amp;gt;
  &amp;lt;Message&amp;gt; **************************************************************&amp;lt;/Message&amp;gt; 
  &amp;lt;Level&amp;gt;Information&amp;lt;/Level&amp;gt; 
  &amp;lt;Task&amp;gt;Process Create (rule: ProcessCreate)&amp;lt;/Task&amp;gt; 
  &amp;lt;Opcode&amp;gt;Info&amp;lt;/Opcode&amp;gt; 
  &amp;lt;Channel /&amp;gt; 
  &amp;lt;Provider /&amp;gt; 
  &amp;lt;Keywords /&amp;gt; 
  &amp;lt;/RenderingInfo&amp;gt;
  &amp;lt;/Event&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;And this is my conf:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[WinEventLog://ForwardedEvents]
    disabled = false
    start_from = oldest
    current_only = 0
    checkpointInterval = 5
    renderXml = true
    suppress_text = 1
    index = sysmon
    sourcetype=XmlWinEventLog:Microsoft-Windows-Sysmon/Operational
    whitelist1 = 1,5,6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [source::WinEventLog://ForwardedEvents]
    TRANSFORMS-setnull = sysmon-setnull
    TRANSFORMS-keep = sysmon-keep
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sysmon-setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[sysmon-keep]
REGEX = (?i)Name=".*(Image|UtcTime|ProcessGuid|CommandLine|User|ParentProcessGuid|ParentImage|ParentCommandLine|Hashes)"
DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Mar 2017 14:45:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346803#M102675</guid>
      <dc:creator>borshoff</dc:creator>
      <dc:date>2017-03-13T14:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346804#M102676</link>
      <description>&lt;P&gt;Hi borshoff,&lt;BR /&gt;
you cannot filter your events to take only a part of them (only selected fields), You can filter events to take (or discard) all (full) events that match a regex, the only way to limit the dimensions of your events is to put a limit to the number of characters to take for each event (see limits.conf).&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 15:16:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346804#M102676</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-03-13T15:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346805#M102677</link>
      <description>&lt;P&gt;The configuration that you've is for event filtering, means if an (whole) event is matching a regex, drop the event altogether. The configuration that you're looking for is &lt;A href="https://docs.splunk.com/Documentation/Splunk/6.5.2/Data/Anonymizedata"&gt;data masking&lt;/A&gt; where you can replace all the not-required lines with blank. &lt;/P&gt;

&lt;P&gt;I'm guessing that your xml &lt;CODE&gt;&amp;lt;Event&amp;gt;&lt;/CODE&gt; has section &lt;CODE&gt;&amp;lt;EventData&amp;gt;&lt;/CODE&gt; and that's the only thing you want to ingest and drop everything else. So give this a try (inputs.conf can stay the same)&lt;/P&gt;

&lt;P&gt;props.conf (on indexer/heavy forwarder)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::WinEventLog://ForwardedEvents]
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)(?=\s*\&amp;lt;EventData\&amp;gt;)
SEDCMD-removeheader=s/^(\s*\&amp;lt;Event xmlns(.+[\r\n]*)+)//
SEDCMD-removefooter=s/(\s*\&amp;lt;RenderingInfo (.+[\r\n]*)+)//
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Mar 2017 15:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346805#M102677</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-13T15:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346806#M102678</link>
      <description>&lt;P&gt;The way to do this is to use &lt;CODE&gt;SEDCMD&lt;/CODE&gt; to replace the undesired parts with nothing:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Data/Anonymizedata"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Data/Anonymizedata&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 19:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346806#M102678</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-13T19:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346807#M102679</link>
      <description>&lt;P&gt;Hi, somesoni2&lt;BR /&gt;
Yes you right, I need only  EventData section.&lt;BR /&gt;
I've try props.conf on heavy forwarder as you describe, but it doesnt work.  Headers and footers don't remove.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 16:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346807#M102679</guid>
      <dc:creator>borshoff</dc:creator>
      <dc:date>2017-03-14T16:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346808#M102680</link>
      <description>&lt;P&gt;I've updated the regex for removefooter.&lt;/P&gt;

&lt;P&gt;How are you getting the data into heavy forwarder, from universal forwarder? Were heavy forwarder restarted after making the change? Try keep these configurations on Universal forwarder. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 16:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346808#M102680</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-14T16:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter XmlWinEventLog in Heavy Forwarder with regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346809#M102681</link>
      <description>&lt;P&gt;I found what was wrong.&lt;BR /&gt;
In input.conf we set "renderXml = true" . That's why props.conf doesn't apply to source::WinEventLog://ForwardedEvents. Cause  source::WinEventLog://ForwardedEvents doesn't exist !&lt;/P&gt;

&lt;P&gt;When i change it to "renderXml = false", filter start working!&lt;BR /&gt;
But, i still need get this events in XML. Is there any way to do that?&lt;/P&gt;

&lt;P&gt;"How are you getting the data into heavy forwarder, from universal forwarder?"&lt;BR /&gt;
No, we collect all events by Windows Event collecor server in ForwardedEvents log. On the same VM we deploy heavy forwarder + Windows_TA addon with all necessary conf.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 13:11:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-XmlWinEventLog-in-Heavy-Forwarder-with-regex/m-p/346809#M102681</guid>
      <dc:creator>borshoff</dc:creator>
      <dc:date>2017-03-16T13:11:36Z</dc:date>
    </item>
  </channel>
</rss>

