What is the most efficient way to parse Microsoft DNS Server debug logs into something more tidy, say into a CSV or KVP format on the nxlog agent?

Consider the following log message:

"24/02/2017 16:37:22 09B0 PACKET  0000009657E7BA40 UDP Rcv   a490   Q [0001   D   NOERROR] A      (7)example(3)com(0)"

First of all, what would be the most efficient way performance-wise to convert this into a CSV or KVP format?

And also, is there some other way besides using Exec and replacing parenthesis and numbers in a sed-like manner to get the clean query name? We have tried to use the Exec method before, but we were hitting some serious performance issues on busy DNS servers.

I have currently switched on to using the pm_pattern module to drop invalid log lines (the beginning of the log file and empty lines) and I was wondering if there would be some easy way to perform both of the tasks (the formatting and the cleaning) using the pm_pattern module?

An example output could look something like the following:

datetime=24/02/2017 16:37:22,thread_id=09B0,context=PACKET,packet_id=0000009657E7BA40,protocol=UDP,action=Rcv,remote_ip=,

The empty or "-" values result from fields specified in the DNS debug log format that are not present in the above message (e.g. all possible flags would be "ATDR", and event_type is "-" because "R" marks a response but an empty value (whitespace) marks a query.

And of course, if the above even is possible, would it be too resource consuming?

AskedFebruary 24, 2017 - 3:59pm

Comments (2)

  • tsigidibam's picture

    I currently have the following in my nxlog.conf:


    ## Input module for Microsoft DNS server audit logs
    <Input dns>
        Module im_file
        File "C:\\DNSLogs\\dns*.log"
        InputType LineBased
        PollInterval 15
        CloseWhenIdle TRUE


    <Processor pattern>
        Module pm_pattern
        PatternFile %ROOT%\conf\patterndb.xml


    ## For outputting the DNS log to Syslog
    <Output default_out>
        Module om_udp
        Host loghost.example.com
        Port 514
        Exec to_syslog_ietf();


    <Route 2>
        Path        dns => pattern => default_out


    And the patterndb.xml looks like this:


    <?xml version='1.0' encoding='UTF-8'?>
        <created>2017-24-02 14:00:00</created>

            <name>microsoft dns server</name>

                <name>header row or empty row</name>




                <name>drop authorative answers</name>






    For some reason I am still getting a lot of empty messages, i.e. I only receive the Syslog header. I am NOT getting lines from the log that would match e.g. pattern #2. I thought that the drop() statement in the patterndb.xml would stop the processing pipeline for the lines that match either one of the patterns specified, but this seems to not be the case. What could be wrong here?

  • b0ti's picture

    The above drop() in the pattern.xml does the exact same thing as the following:

    Exec if $raw_event =~ /^[^0-9]/ drop();

    In earlier versions to_syslog_*() used $Message only. This was causing an empty payload with only the syslog header in such use cases when transforming plain text files into syslog, but now it also honors $raw_event.

    Also note that pm_pattern will stop matching at the first successful match! If you have multiple patterns that can match the same line it won't be deterministic due to pattern reordering.

    Other than that I'm not sure what the issue is, I suggest removing pm_pattern from your conf to see if it is related.


Answer (1)