Sending ETW Logs to Splunk with NXLog

NXLog supports direct collection of Event Tracing for Windows (ETW) data. DNS Analytical logs, for example, can be forwarded to Splunk or another SIEM for monitoring and analysis.

Collecting ETW Logs

Event Tracing for Windows (ETW) is a kernel-level tracing facility that provides high-performance logging of kernel and application events. ETW events can be written to a log file or collected directly from the system in realtime via the Consumers API. ETW is a valuable source of event data that is underutilized compared to the well-known Windows Event Log. The Debug and Analytical channels, which are based on ETW, cannot be collected through Windows Event Log directly. For more information, see our white paper Solving Windows Log Collection Challenges with Event Tracing.

ETW logging is of particular interest for collecting DNS Server activity logs. Prior to Windows Server 2012 R2, activity logs were only available through DNS Server’s debug logging feature (See DNS Debug Logging in the NXLog User Guide.) Unfortunately, debug logging can significantly impact DNS Server performance and it was never intended to be enabled permanently. With the introduction of DNS Server Analytical logs in Server 2012 R2 and 2016, high-performance DNS activity logging is available through ETW.

The logman and tracerpt commands can be used to work with traces:

Creating and Controlling Traces with Logman
> logman query providers
Microsoft-Windows-DNSServer              {EB79061A-A566-4698-9119-3ED2807060E7}
[...]
> logman create trace DNSTrace -p Microsoft-Windows-DNSServer -o c:\trace.etl
> logman start DNSTrace
[Wait for activity to be logged]
> logman stop DNSTrace
> logman delete DNSTrace
Using Tracerpt to Generate a Dump File and Summary
> tracerpt c:\trace_000001.etl
[...]
DumpFile:           dumpfile.xml
Summary:            summary.txt

While these tools are suitable for working with temporary traces, they do not offer a good solution for setting up regular collection of ETW logs. A similar multi-stage process would need to be implemented to use the Splunk Universal Forwarder for Windows, as it does not support ETW directly.

NXLog Enterprise Edition, however, implements the ETW Consumers API to collect ETW events directly from the source for robust, efficient ETW logging. NXLog handles tracing setup, so it is not necessary for the user to run logman or tracerpt commands. NXLog does not require events to be written to disk, reducing the overhead required and allowing NXLog to perform well even at high event rates.

Configuring the HEC Data Source in Splunk

Before adding the NXLog configuration, a new log source needs to be added in Splunk to receive the logs.

  1. In the Settings menu, click Data inputs.

    splunk 1 data inputs
  2. In the Local Input section, for the HTTP Event Collector input type, click Add new, then select New Token.

  3. To configure the input source, enter the Name, then click Next. The remaining settings are optional.

  4. In the input settings, select Automatic or set the Source type to json, choose an App context; for example, Search & Reporting (search). The remaining settings are optional, then click Review.

    splunk hec 2
  5. Once reviewed, select Submit, then copy the Token for future use in the NXLog configuration.

  6. Returning back to the HTTP Event Collector page, select the Global Settings button.

  7. Select Enabled to enable Tokens, select Enable SSL if using SSL, then take note of the HTTP Port Number as it will be used in the NXLog configuration.

    splunk hec 1

    Now that an appropriate Splunk log source has been configured, you can continue by setting up NXLog Enterprise Edition to collect and forward ETW logs.

Configuring NXLog to Collect and Forward ETW Logs via HEC

NXLog can collect logs from ETW with the im_etw module. The Provider directive specifies the ETW provider to collect logs from, while the optional Level directive can be used to select a log level (the default is the "verbose" level). It is also possible to collect kernel trace logs with the KernelFlags directive and a comma-separated list of flags. For full configuration details, see im_etw in the NXLog Reference Manual.

Note
DNS Server Analytical logging is available beginning with Windows Server 2012 R2. For more information, and an alternative method for previous versions of Windows Server, see Windows DNS Server in the NXLog User Guide.
Adding the NXLog ETW Module Input

In the following configuration, NXLog reads DNS Server Analytical logs directly from the Microsoft-Windows-DNSServer ETW provider using the im_etw input module.

nxlog.conf
1
2
3
4
<Input in_dns>
    Module      im_etw
    Provider    Microsoft-Windows-DNSServer
</Input>
Adding the NXLog HEC Output Module

Send logs to the Splunk HEC endpoint by Configuring HTTP Event Collection (HEC) both on Splunk and NXLog.

Specify the HTTP Port Number and Token using the URL and AddHeader directives, respectively. For example, https://127.0.0.1:8088/services/collector and Authorization: Splunk 452d2e2d-b5c5-4001-bd47-d181de90af99.

Enable SSL via the HTTPSCAFile directive available in the om_http module if it is not already set in the Splunk configuration file.

The configuration sample below shows the output module instance with the necessary connection parameters as well as the processing needed in the <Exec> block to match the metadata and data formats Splunk expects to receive.

nxlog.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<Extension _json>
    Module  xm_json
</Extension>

<Output splunk_out_hec>
    Module      om_http
    URL         https://127.0.0.1:8088/services/collector
    AddHeader   Authorization: Splunk 452d2e2d-b5c5-4001-bd47-d181de90af99
    HTTPSCAFile %CERTDIR%/cacert.pem
    <Exec>
        # Rename event fields to what Splunk uses
        if $Severity rename_field($Severity, $vendor_severity);
        if $SeverityValue rename_field($SeverityValue, $severity_id);

        # Convert all fields to JSON and write to $event field
        $event = to_json();

        # Convert $EventTime to decimal seconds since epoch UTC
        $time = string(integer($EventTime));
        $time =~ /^(?<sec>\d+)(?<ms>\d{6})$/;
        $time = $sec + "." + $ms;

        # Specify the log source type
        $sourcetype = "_json";

        # Add other HEC metadata fields if available in the event data
        if $Hostname $host = $Hostname;
        if $SourceName $source = $SourceName;

        # Remove all non-metadata fields (already stored in $event)
        clean_splunk_fields->process();

        # Write to JSON
        to_json();
    </Exec>
</Output>
Adding the Splunk Route

Add a route for the ETW logs. If no route is specified in the configuration, NXLog will automatically create a single default route connecting all inputs to all outputs.

nxlog.conf
1
2
3
<Route splunk>
    Path    in_dns => splunk_out_hec
</Route>

The nxlog service should be restarted to apply the new configuration.

Confirming Log Collection in Splunk

To confirm data collection, go to the Splunk Search & Reporting dashboard and search for the correct logs, using either host name or source name.

splunk out
Figure 1. ETW Sample of a Forward Lookup Zone Deletion Event

Once forwarded to Splunk, administrators can leverage Splunk’s features such as visualizations, alerts, and other Splunk apps.

To read more about Splunk, please see the Splunk User Guide or contact us if you are interested in learning how NXLog can further enhance your Splunk deployments.

NXLog Ltd. develops multi-platform log collection tools that support many different log sources, formats, transports, and integrations. The tools help administrators collect, parse, and forward logs so they can more easily respond to security issues, investigate operational problems, and analyze event data. NXLog distributes the free and open source NXLog Community Edition and offers additional features and support with the NXLog Enterprise Edition.

This document is provided for informational purposes only and is subject to change without notice. Trademarks are the properties of their respective owners.

Download a fully functional trial of the Enterprise Edition for free