Nxlog User Guide
Nxlog User Guide
Nxlog User Guide
NXLog Ltd.
2. About NXLog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3. System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4. Available Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
OS Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
35. IBM AIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
86.2. Collecting and Parsing SCEP Data from Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
86.3. Collecting and Parsing SCEP Data from an SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 940
137.12. Increasing the Open File Limit for NXLog Manager Using systemd . . . . . . . . . . . . . . . . . . . . . . . . . . 1367
Introduction
1
NXLog User Guide Chapter 1. About This Guide
NXLog is available in two versions, the Community Edition and the Enterprise Edition. Features that are unique to
the Enterprise Edition are noted as such, except in the Reference Manual (the Community Edition Reference
Manual is published separately). For more details about the functionality provided by these two NXLog editions,
see the following chapters (in particular, About NXLog and Available Modules).
Though most of the content applies to all versions of NXLog Community Edition and NXLog
Enterprise Edition, this Guide was written specifically for NXLog Enterprise Edition version
WARNING
5.2.6418. Some features covered by this book may not be available in earlier versions of
NXLog, and earlier versions of NXLog may behave differently than documented here.
If you would like to copy/paste configuration content from the Guide, please do so using
WARNING the HTML format. It is not possible to guarantee appropriate selection behavior with the
PDF format.
2
Chapter 2. About NXLog NXLog User Guide
At NXLog’s inception, there were various logging solutions available, but none with the required features. Most
were single-threaded and Syslog-oriented, without native support for Windows. Work on NXLog began with the
goal of building a modern logger with a multi-threaded design, a clear configuration syntax, multi-platform
support, and clean source code. NXLog was born in 2009 as a closed source product heavily used in several
production deployments. The source code of NXLog Community Edition was released in November 2011.
NXLog can process event logs from thousands of different sources with volumes over 100,000 events per second.
It can accept event logs over TCP, TLS/SSL, and UDP; from files and databases; and in Syslog, Windows EventLog,
and JSON formats. NXLog can also perform advanced processing on log messages, such as rewriting, correlating,
alerting, pattern matching, scheduling, and log file rotation. It supports prioritized processing of certain log
messages, and can buffer messages on disk or in memory to work around problems with input latency or
network congestion. After processing, NXLog can store or forward event logs in any of many supported formats.
Inputs, outputs, log formats, and complex processing are implemented with a modular architecture and a
powerful configuration language.
Multi-platform deployment
Installer packages are provided for multiple platforms, including Linux, Windows, and Android. You can use
NXLog across your entire infrastructure, without resorting to different tools for different platforms.
Security
NXLog provides features throughout the application to maintain the security of your log data and systems.
The core can be configured to run as an unprivileged user, and special privileges (such as binding to ports
below 1024) are accessed through Linux capabilities rather than requiring the application to run as root.
TLS/SSL is supported for encrypted, authenticated communications and to prevent data interception or
alteration during transmission.
3
NXLog User Guide Chapter 2. About NXLog
Modular architecture
NXLog has a lightweight, modular architecture, providing a reduced memory footprint and increased
flexibility for different uses. The core handles files, events, and sockets, and provides the configuration
language; modules provide the input, output, and processing capabilities. Because modules use a common
API, you can write new modules to extend the features of NXLog.
Message buffering
Log messages can be buffered in memory or on disk. This increases reliability by holding messages in a
temporary cache when a network connectivity issue or dropout occurs. Conditional buffering can be
configured by using the NXLog language to define relevant conditions. For example, UDP messages may
arrive faster than they can be processed, and NXLog can buffer the messages to disk for processing when the
system is under less load. Conditional buffering can be used to explicitly buffer log messages during certain
hours of the day or when the system load is high.
Prioritized processing
NXLog can be configured to separate high-priority log processing from low-priority log processing, ensuring
that it processes the most important data first. When the system is experiencing high load, NXLog will avoid
dropping important incoming messages. For example, incoming UDP messages can be prioritized to prevent
dropped logs if a high volume of TCP messages overloads the system.
Message durability
Built-in flow control ensures that a blocked output does not cause dropped log messages when buffers are
full. In combination with the previously mentioned parallel processing, buffering, and prioritization, the
possibility of message loss is greatly reduced.
Offline processing
Sometimes log messages need to be processed in batches for conversion, filtering, or analysis. NXLog
provides an offline mode in which it processes all input and then exits. Because NXLog does not assume that
the event time and processing time are identical, time-based correlation features can be used even during
offline log processing.
4
Chapter 2. About NXLog NXLog User Guide
On-the-wire compression
Log data can be transferred in compressed batches with the im_batchcompress and om_batchcompress
input/output modules. This can help in limited bandwidth scenarios.
Remote management
The dedicated xm_admin extension module enables NXLog agents to be managed remotely over a secure
SOAP/JSON SSL connection or to be integrated with existing monitoring and management tools. The
configurations, correlation rules, patterns, and certificates can all be updated remotely from the NXLog
Manager web interface or from scripts. In addition, the NXLog agents and the individual modules can be
stopped/started and log collection statistics can be queried for real-time statistics.
Crash recovery
Additional functionality is provided to guarantee a clean recovery in the case of a system crash, ensuring that
no messages are lost or duplicated.
Event correlation
The pm_evcorr processor module can efficiently solve complex event correlation tasks, with capabilities
similar to what the open-source SEC tool provides.
HTTP/HTTPS support
The im_http and om_http input and output modules make it possible to send or receive log message data
over HTTP or HTTPS.
5
NXLog User Guide Chapter 2. About NXLog
Registry monitoring
The im_regmon module facilitates the monitoring of the Windows Registry and generates event records in
case of changes in the monitored registry entries.
Network monitoring
The passive monitoring of network traffic can be implemented via utilizing the im_pcap module.
XML support
The xm_xml extension module can parse nested XML and data stored in XML attributes.
JSON support
Parsing of nested JSON is implemented in the xm_json module. UTF-8 character encoding validation can be
enforced to avoid parser failures caused by invalid UTF-8 encoding from other tools.
6
Chapter 2. About NXLog NXLog User Guide
Name resolution
The xm_resolver extension module provides cached DNS lookup functions for translating between IP
addresses and host names. User and group names can also be mapped to/from user and group ids.
Elasticsearch integration
The om_elasticsearch output module allows log data to be loaded directly into an Elasticsearch server without
requiring Logstash.
Redis Support
Redis is often used as an intermediate queue for log data. Two native modules, im_redis and om_redis, are
available to push and pull data to and from Redis servers.
SNMP input
The xm_snmp extension module can be used to parse SNMP traps. The traps can then be handled like regular
log messages: converted to Syslog, stored, forwarded, etc.
HDFS output
The om_webhdfs output module is available to support the Hadoop ecosystem.
7
NXLog User Guide Chapter 2. About NXLog
Netflow support
The xm_netflow extension module can parse Netflow packets received over UDP. It supports Netflow v1, v5,
v7, v9, and IPFIX.
ZeroMQ support
ZeroMQ is a popular high performance messaging library. The im_zmq and om_zmq modules provide input
and output support for the ZeroMQ protocol.
Testing facilities
Simple test events can be generated using the im_testgen module according to the specified counter. The
im_null and om_null module can be used for testing purposes as well.
The om_blocker module can be used for blocking messages to simulate a blocked route.
Mark messages
Via the im_mark module, NXLog can send mark messages confirming its correct operation.
Data transformation
NXLog Enterprise Edition supports conversion of message strings between various character sets. This may
be useful when the encoding of accepted messages differs from UTF-8.
Compression and encryption operations with logs are available via the xm_zlib and xm_crypto modules.
Buffering of messages
Using the pm_buffer prevents from losing messages which arrive over UDP.
8
Chapter 2. About NXLog NXLog User Guide
Extensive documentation
Our constantly updated, ever-growing documentation, already well above 1300 pages, is a stand-alone
product in itself. It is complete with configuration samples, real-world examples, and integration guides
offering much more than a generic manual.
There are three possible scenarios in how the features overlap and differentiate between the two editions:
For easier interpretation, all NXLog features are grouped into the following logical subsections:
• Supported Formats
• Programming Languages Support
• Data Transformation
• Administration and Monitoring
• Log Sources
• Protocols
• Miscellaneous Modules
• Supported Core Functionalities
This subsection compares the data formats NXLog supports. In addition to these formats, NXLog can read and
process log data using pattern matching to transform unstructured data into normalized, structured data.
AIX Audit Format (xm_aixaudit) In combination with the im_file module, this
module can collect and parse AIX Audit events.
Apple System Log (xm_asl) Apple system logs stored as ASL files and can be
read and parsed using this module.
Solaris OS Basic Security Module Reads and processes BSM audit events either
(BSM) Auditing API (im_bsm, from file (xm_bsm) or directly from the kernel
xm_bsm) (im_bsm).
9
NXLog User Guide Chapter 2. About NXLog
ArcSight Common Event Format Using this feature, the ArcSight CEF-formatted
(xm_cef) events can be both generated and read.
Graylog Extended Log Format This module enables receiving data in GELF
(xm_gelf) format over the network as well as formatting
data to GELF while forwarding it over the
network.
Log Event Extended Format ( Generates and reads the Log Event Extended
xm_leef) Format (LEEF) commonly used by IBM Security
QRadar products.
DNS Server Logs (xm_msdns) Reads Windows DNS Server logs and parses over
20 fields commonly used with these events.
SNMP Trap Messages (xm_snmp) Provides facilities for reading SNMP v1, v2c, and
v3 trap messages.
W3C Extended Log File Format Supports parsing of data in the W3C Extended
(xm_w3c) Log File Format, Zeek format, and Microsoft
Exchange Message Tracking logs.
Binary WTMP Files (xm_wtmp) Enables processing of binary wtmp files when
used in conjunction with the im_file module.
Parsing with Grok Patterns ( Functionality for reading any kind of text log
xm_grok) messages using Grok patterns.
10
Chapter 2. About NXLog NXLog User Guide
Parsing with the Pattern Database Efficient, non-linear pattern matching using a
(xm_pattern) pattern database in XML format. Each pattern
definition can contain multiple field definitions
thus allowing multi-dimensional pattern
matching.
The following features are available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
2.3.1.1. CSV
Although both versions of NXLog support processing CSV data, only the Enterprise Edition provides Field Count
Enforcement with its StrictMode directive that accepts a boolean value. When set to TRUE, the parser will ignore
any CSV line not having the same number of fields as those listed in the Fields directive.
TCP input
When set to GELF_TCP and used in conjunction with the im_tcp input module, the InputType directive allows
GELF data to be received over TCP.
Hidden fields
The IncludeHiddenFields directive, with a default boolean value of TRUE, supports inclusion of fields with
names having a leading dot (.) or underscore (_) which would otherwise be discarded.
Event enrichment
GELF events are enriched with some additional fields: $EventTime, $FullMessage, $Hostname,
$SeverityValue, $ShortMessage, $SourceLine, $SyslogFacility, and $version.
2.3.1.3. JSON
The xm_json module of the Enterprise Edition has several directives for customizing how JSON data is parsed and
prepared for output:
{"event":{"time":"2015-01-01T00:00:00.000Z","severity":"ERROR"}}
will be converted to
11
NXLog User Guide Chapter 2. About NXLog
{"event.time":"2015-01-01T00:00:00.000Z","event.severity":"ERROR"}
ForceUTF8
Converts the output to validated UTF-8 encoding regardless of the input encoding.
IncludeHiddenFields
Preserves hidden fields, i.e. those having names with a leading dot (.) or underscore (_).
ParseDate
Enables automatic parsing of strings beginning with a 4-digit year as timestamps.
PrettyPrint
Takes single-line JSON records, puts each key-value pair on a new line, and indents elements based on the
depth of nesting for creating a more human-readable data record.
UnFlatten
Is the inverse of the Flatten process when using to_json() to recreate nested structures on output.
2.3.1.5. Syslog
The Enterprise Edition of NXLog can improve readability of Syslog data by replacing line breaks inside messages
with other characters using the ReplaceLineBreaks directive. This option can be used with the to_syslog_bsd(),
to_syslog_ietf(), and to_syslog_snare() procedures. The to_syslog_ietf() procedure’s local time information can be
replaced with UTC/GMT timestamps using the UTCTimestamp directive.
2.3.1.6. XML
The Enterprise Edition of NXLog additionally provides features for working with XML, such as:
IgnoreRootTag
Results in fields being "flattened" by not having the XML root tag Event prefixed to them with dot notation.
For example, $Event.timestamp will be simply $timestamp.
IncludeHiddenFields
Preserves hidden fields, i.e. those having names with a leading dot (.) or underscore (_).
ParseAttributes
Provides the ability to parse an XML field’s attributes in addition to its value. Given this XML sample
will be parsed as $Msg.time, $Msg.type, and $Msg fields. Otherwise, only $Msg with its string value foo
would be added to event record.
PrefixWinEvent
In the context of XML-formatted Windows events, this is the inverse process of IgnoreRootTag, in which
events gleaned from parse_windows_eventlog_xml() will have their fields prefixed with either EventData or
UserData using dot notation depending on which XML section they belong to.
12
Chapter 2. About NXLog NXLog User Guide
The Enterprise Edition of NXLog supports programming languages via the following types of modules:
Perl (im_perl, om_perl, xm_perl) Perl, with its native regular expression
capabilities, allows rapid development of terse
scripts for high performance, complex parsing of
logs.
Ruby (im_ruby, om_ruby, xm_ruby) Ruby, with its native support for structured data
formats like XML and JSON, can be used to
develop applications for custom log processing.
The following feature is available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
2.3.2.1. Perl
The Community Edition only supports the Perl extension module, whereas NXLog Enterprise Edition allows Perl
scripts to be loaded and executed as input and output modules as well.
In addition, the Enterprise Edition can also parse configuration parameters of Perl scripts using the Config
directive.
The following table shows the features that can be used to transform data according to each edition of NXLog.
13
NXLog User Guide Chapter 2. About NXLog
Converting via Character Sets Log data can be converted between character
(xm_charconv) sets (codepages) prior to parsing.
Blacklisting and Whitelisting of Log Based on the contents of each file, files can be
Entries (xm_filelist) whitelisted or blacklisted using this feature.
Encryption and Decryption of Logs Enables log files to be encrypted and decrypted
(xm_crypto) using AES symmetric encryption for secure
storage and/or transport over a network.
The following features are available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
14
Chapter 2. About NXLog NXLog User Guide
Changes in Files and Directories This feature enables the monitoring of changes
(im_fim) in specific files and directories for integrity
monitoring.
The following features are available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
The Restart directive of the Enterprise Edition can restart a process if it terminates unexpectedly.
Accounting Logs From a Linux or Enables collecting and processing logs from a
BSD Kernel (im_acct) Linux or BSD kernel.
AIX Audit (im_aixaudit) Along with the xm_aixaudit module, AIX Audit
logs can be read and parsed directly from the
kernel.
Microsoft Azure Application Logs Parses logs from Microsoft Azure applications
(im_azure) received over various TLS and SSL protocols.
Check Point Device Logs Remote collection of logs from Check Point
(im_checkpoint) devices using the OPSEC LEA protocol.
Database Logs via the libdbi library Convenient method for pulling and saving data
(im_dbi, om_dbi) to external databases using the libdbi database
abstraction library.
15
NXLog User Guide Chapter 2. About NXLog
Kernel Application Logs Using Event High-performance log collection using Event
Tracing for Windows (im_etw) Tracing for Windows (ETW).
Kafka Server Logs (im_kafka, Enables the collecting of event records from a
om_kafka) Kafka topic as well as publishing event records to
a Kafka topic.
Logs From the Kernel Log Buffer Collects events from the kernel log buffer on
(im_kernel) Unix-like operating systems.
Windows Event Log (im_mseventlog, Collects Windows Event Log messages using its
im_msvistalog) native API.
Kernel Logs via Audit Rules Collects logs directly from the kernel using
(im_linuxaudit) custom rules without the need for installing
auditd or other userspace software.
Database Table Logs via ODBC Uses ODBC for storing logs in ODBC-compliant
(im_odbc, om_odbc) databases.
Forwarding Logs to Raijin Server Sends batched JSON records to Raijin Server for
(om_raijin) further analysis and archival.
Redis Server Log Tranfers (im_redis, Enables the retrieval of data stored in a Redis
om_redis) server as well as populating a Redis server with
log data.
Systemd Journal Logs (im_systemd) Reads, parses, and processes events from the
systemd journal.
The following features are available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
16
Chapter 2. About NXLog NXLog User Guide
DeviceFile
For accessing the device file to read events on non-Linux systems.
PollInterval
Sets the interval to check for new events.
AddPrefix
Adds the EventData prefix to fields which are parsed from the EventData section of the event.
ReadBatchSize
Specifies the number of event records the Window Event Log API will pass to NXLog for further processing.
CaptureEventXML
Enables the $EventXML field to store the raw XML-formatted event data.
File
Enables NXLog to read directly from the .evt, .evtx, or .etl log files.
Language
Sets the locale to use for rendering language/region-specific event fields such as date/time, currency, etc.
RemoteAuthMethod
Sets the authentication method.
RemoteDomain
Specifies the authentication domain of the remote server for collecting event logs.
RemotePassword
Accepts the user password of the remote server for collecting event logs.
RemoteServer
Sets the name of the remote server from which event logs will be captured.
RemoteUser
Sets the user name on the remote server for collecting event logs.
ResolveGUID
Enables GUID to resolve values of the object names in the $Message field.
ResolveSID
Enables SID to resolve values of the object names in the $Message field.
17
NXLog User Guide Chapter 2. About NXLog
TolerateQueryErrors
Will prevent the module from starting if any source is invalid when set to FALSE (the default value).
2.3.6. Protocols
Both editions of NXLog provide support for various protocols for working with logs, see the table below.
Files (im_file, om_file) Facilities for reading log messages from files and
writing processed data to them.
Named Pipes (im_pipe, om_pipe) With this feature, named pipes of Unix-like
operating systems can be utilized to send and
receive log messages.
TCP (im_tcp, om_tcp) Accepts TCP connections for receiving event data
and can send events to remote hosts over TCP.
UDP With Spoofing (om_udpspoof) With spoofing enabled, UDP packets will contain
the IP address of the originating client that
produced the message instead of the forwarding
server.
Unix Domain Sockets (im_uds, Enables log data to be sent or received over a
om_uds) Unix domain socket.
The following features are available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
2.3.6.1. Files
The im_file module of the Enterprise Edition additionally provides the following optional directives:
Exclude
Specifies a file or a set of files to be excluded.
18
Chapter 2. About NXLog NXLog User Guide
InputType
Sets the input reader function.
NoEscape
Specifies whether the backslash (\) in file paths should be disabled as an escape sequence.
OnEOF
A group of statements to be executed after a file has been completely read (on end-of-file).
The om_file module provides the optional CacheSize directive to keep files open and reduce the overhead caused
by open/close operations.
2.3.6.2. HTTP
The Community Edition of NXLog provides only the output HTTP facility via the om_http module. The Enterprise
Edition supports the input and output facilities via the im_http and om_http modules.
The Enterprise Edition supports the add_http_header() procedure to dynamically add a custom HTTP header to
requests.
The Enterprise Edition’s om_udp module supports multiple definitions of the Host directive which can be used to
configure failover.
The URL directive of the Enterprise Edition can be specified multiple times for configuring failover. Its
HTTPSCADir and HTTPSCAFile directives provide additional support for self-signed certificates.
The Enterprise Edition supports the following optional directives not found in the Community Edition:
AddHeader
An additional header to be added to each HTTP request.
BatchMode
Toggles whether the data is sent as single event or a batch of events.
ContentType
Specifies the Content-Type HTTP header which can be used in conjunction with the BatchMode directive.
FlushInterval
Sets the period of time after which accumulated data will be sent in batch mode.
FlushLimit
The number of events to be batched together in a single POST request.
HTTPSCAThumbprint
The certificate thumbprint of the certificate authority (CA) which can be used to look up the CA certificate
from the Windows certificate store.
HTTPSCertThumbprint
The certificate thumbprint to be used for the SSL handshake.
HTTPSCRLDir
The path to the certificate revocation list. This list is used for verifying the certificate of the remote HTTPS
server.
HTTPSSSLCipher
Can be used to set the permitted SSL cipher list, overriding the default.
19
NXLog User Guide Chapter 2. About NXLog
HTTPSSSLCiphersuites
Can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol directive is set to TLSv1.3.
HTTPSSSLProtocol
Can be used to set the allowed TLS/SSL protocol(s).
HTTPSSSLCompression
Enables data compression when sending over the network.
HTTPSSSLProtocol
Sets the allowed TLS/SSL protocol(s).
ProxyAddress
The IP address of the proxy server.
ProxyPort
The port number of the proxy server.
SNI
The host name for Server Name Indication (SNI) in HTTPS mode.
2.3.6.3. TLS/SSL
The im_ssl module of the Enterprise Edition supports self-signed certificates and the following optional
directives:
CAThumbprint
The certificate thumbprint of the certificate authority (CA) which can be used to look up the CA certificate
from the Windows certificate store.
CertThumbprint
The certificate thumbprint to be used for the SSL handshake.
SSLCipher
Can be used to set the permitted SSL cipher list, overriding the default.
SSLCiphersuites
Can be used to define the permitted SSL cipher list in case the HSSLProtocol directive is set to TLSv1.3.
SSLCompression
Enables data compression when sending over the network.
SSLProtocol
Sets the allowed TLS/SSL protocol(s).
The om_ssl module of the Enterprise Edition provides additional functionalities to the following directives:
Host
Can be specified multiple times to work in a failover configuration.
20
Chapter 2. About NXLog NXLog User Guide
CAThumbprint
The certificate thumbprint of the certificate authority (CA) which can be used to look up the CA certificate
from the Windows certificate store.
CertThumbprint
The certificate thumbprint to be used for the SSL handshake.
LocalPort
The local port number of the connection.
SNI
The host name for Server Name Indication (SNI).
SSLCipher
Can be used to set the permitted SSL cipher list, overriding the default.
SSLCiphersuites
Can be used to define the permitted SSL cipher list in case the SSLProtocol directive is set to TLSv1.3.
SSLCompression
Enables data compression when sending over the network.
SSLProtocol
Sets the allowed TLS/SSL protocol(s).
TCPNoDelay
Can be used to turn off the network optimization performed by Nagle’s algorithm.
2.3.6.4. TCP
The im_tcp module of Enterprise Edition supports the ReusePort directive to enable synchronous listening on the
same port by multiple module instances.
The Host directive of the om_tcp module can be defined several times to work in a failover configuration.
LocalPort
The local port number of the connection.
Reconnect
Sets the reconnect interval in seconds.
TCPNoDelay
Turns off network optimization performed by Nagle’s algorithm.
2.3.6.5. UDP
The Enterprise Edition im_udp module provides the following directives:
ReusePort
Enables synchronous listening on the same port by multiple module instances.
UseRecvmmsg
Specifies that the recvmmsg() system call should be used whenever possible. This improves performance by
enabling the reception of multiple messages per call.
21
NXLog User Guide Chapter 2. About NXLog
The Enterprise Edition’s om_udp module supports multiple definitions of the Host directive which can be used to
configure failover.
The om_udp module of the Enterprise Edition also supports the following directives:
LocalPort
The local port number of the connection.
OutputType
Sets the output writer function for UDP datagrams.
Reconnect
Sets the reconnect interval in seconds.
Generating Test Events (im_testgen) For generating simple events which can be read
and processed before running the system in
production.
ASLR (address space layout Binaries built using ASLR are more resistant to
randomization) memory allocation exploits. (Windows only).
The following features are available in both editions of NXLog, but the Enterprise Edition provides additional or
enhanced functionality.
22
Chapter 2. About NXLog NXLog User Guide
• General Directives can be used by all modules throughout the entire NXLog configuration.
• Global Directives control the overall behavior of NXLog.
This subsection compares general directives which are supported by both editions of NXLog.
The following global directives can be used to fine-tune NXLog’s caching and batching settings.
23
NXLog User Guide Chapter 2. About NXLog
Caching Directives
Batching Directives
The following general directives provide options for customizing NXLog’s persistent queuing and flow control
features.
Persistent Queuing
24
Chapter 2. About NXLog NXLog User Guide
Flow Control
25
NXLog User Guide Chapter 2. About NXLog
26
Chapter 2. About NXLog NXLog User Guide
• a graphical interface (or "dashboard") for searching logs and displaying reports,
• vulnerability detection or integration with external threat data,
• automatic analysis and correlation algorithms, or
• pre-configured compliance and retention policies.
NXLog does provide processing features that can be used to set up analysis, correlation, retention, and alerting;
NXLog can be integrated with many other products to provide a complete solution for aggregation, analysis, and
storage of log data.
27
NXLog User Guide Chapter 3. System Architecture
• The most common event record is a single line. Thus the default is LineBased for the InputType and
OutputType directives.
• It is also common for an event record to use a single UDP datagram. NXLog can send and receive UDP events
with the im_udp and om_udp modules.
• Some event records are generated using multiple lines. These can be joined into a single event record with
the xm_multiline module.
• Event records may be stored in a database. Each row in the database represents an event. In this case the
im_odbc and om_odbc modules can be used.
• It is common for structured event records to be formatted in CSV, JSON, or XML formats. The xm_csv,
xm_json, and xm_xml modules provide functions and procedures for parsing these.
• NXLog provides a Binary InputType and OutputType for use when compatibility with other logging software
is not required. This format preserves parsed fields and their types.
In NXLog, each event record consists of the raw event data (in a field named $raw_event) and additional fields
generated during processing and parsing.
3.1.2. Fields
All event log messages contain important data such as user names, IP addresses, and application names.
Traditionally, these logs have been generated as free form text messages prepended by basic metadata like the
time of the event and a severity value.
While this format is easy for humans to read, it is difficult to perform log analysis and filtering on thousands of
free-form logs. In contrast, structured logging provides means for matching messages based on key-value pairs.
With structured logging, an event is represented as a list of key-value pairs. The name of the field is the key and
the field data is the value. NXLog’s core design embraces structured logging. Using various features provided by
NXLog, a message can be parsed into a list of key-value pairs for processing or as part of the message sent to the
destination.
When a message is received by NXLog, it creates an internal representation of the log message using fields. Each
field is typed and represents a particular attribute of the message. These fields passes through the log route, and
are available in each successive module in the chain, until the log message has been sent to its destination.
1. The special $raw_event field contains the raw data received by the input module. Most input and output
modules only transfer $raw_event by default.
2. The core adds a few additional fields by default:
a. $EventReceivedTime (type: datetime) The time when the event is received. The value is not modified if
the field already exists.
b. $SourceModuleName (type: string) The name of the module instance, for input modules. The value is not
modified if the field already exists.
28
Chapter 3. System Architecture NXLog User Guide
c. $SourceModuleType (type: string) The type of module instance (such as im_file), for input modules.
The value is not modified if the field already exists.
3. The input module may add other fields. For example, the im_udp module adds a $MessageSourceAddress
field.
4. Some input modules, such as im_msvistalog and im_odbc, map fields from the source directly to fields in the
NXLog event record.
5. Parsers such as the parse_syslog() procedure will add more fields.
6. Custom fields can be added by using the NXLog language and an Exec directive.
7. The NXLog language or the pm_pattern module can be used to set fields using regular expressions. See
Extracting Data.
When the configured output module receives the log message, in most cases it will use the contents of the
$raw_event field only. If the event’s fields have been modified, it is therefore important to update $raw_event
from the other fields. This can be done with the NXLog language, perhaps using a procedure like to_syslog_bsd().
A field is denoted and referenced in the configuration by a preceding dollar sign ($). See the Fields section in the
Reference Manual for more information.
29
NXLog User Guide Chapter 3. System Architecture
This example shows a Syslog event and its corresponding fields as processed by NXLog. A few fields are
omitted for brevity.
<38>Nov 22 10:30:12 myhost sshd[8459]: Failed password for invalid user linda from
192.168.1.60 port 38176 ssh2↵
2. The raw event data is stored in the $raw_event field when NXLog receives a log message. The NXLog
core and input module add additional fields.
{
"raw_event": "<38>Nov 22 10:30:12 myhost sshd[8459]: Failed password for invalid user
linda from 192.168.1.60 port 38176 ssh2",
"EventReceivedTime": "2019-11-22 10:30:13",
"MessageSourceAddress": "192.168.1.1",
3. The xm_syslog parse_syslog() procedure parses the basic format of the Syslog message, reading from
$raw_event by default. This procedure adds a few more fields:
"SyslogFacility": "USER",
"SyslogSeverity": "NOTICE",
"EventTime": "2019-11-22 10:30:12",
"Hostname": "myhost",
"SourceName": "sshd",
"ProcessID": 8459,
"Message": "Failed password for invalid user linda from 192.168.1.60 port 38176 ssh2",
4. Further metadata can be extracted from the free-form $Message field with regular expressions or other
methods; see Extracting Data.
"Status": "failed",
"AuthenticationMethod": "password",
"Reason": "invalid user",
"User": "linda",
"SourceIPAddress": "192.168.1.60",
"SourcePort": 38176,
"Protocol": "ssh2"
}
For example, below is the log message containing the EventTime and Message fields.
"EventTime":2020-05-13 00:00:00
"Message":"The service has started"
After applying to_json() procedure, the message obtains the additional raw_event field containing the
EventTime and Message fields in the JSON format.
30
Chapter 3. System Architecture NXLog User Guide
"EventTime":2020-05-13 00:00:00
"Message":"The service has started"
"raw_event":"{"EventTime":"2020-05-13 00:00:00", "Message":"The service has started"}"
When forwarding over TCP via the default LineBased type, NXLog sends only the contents of the raw_event
field.
After this message has been forwarded, the raw_event name returns to it and and other fields are added
automatically to create the event record.
Before it can be processed by the receiving NXLog instance, the event record should be parsed. Consequently,
preservation of all fields in the LineBased mode requires conversion and parsing procedures before and after
forwarding.
Application of the Binary function in the OutputType directive preserves all fields for forwarding without
conversion and parsing procedures, so the forwarded event record will contain unmodified fields.
"EventTime":2020-05-13 00:00:00
"Message":"The service has started"
Application of both approaches to the same set of data, i.e. conversion to JSON and NXLog binary formats will
duplicate and significantly increase the size of forwarded data.
"EventTime":2020-05-13 00:00:00
"Message":"The service has started"
"raw_event":"{"EventTime":"2020-05-13 00:00:00", "Message":"The service has started"}
The examples below provide detailed explanations of preservation via JSON and NXLog binary format.
31
NXLog User Guide Chapter 3. System Architecture
This example demonstrates how to preserve forwarded data through conversion to JSON. The sample of
the forwarded message is shown below.
The configuration below defines the EVENT_REGEX regular expression to read messages, and the Exec
block contains parsing instructions as per this expression.
nxlog.conf (Sender)
1 define EVENT_REGEX /(?x)^"EventTime":(\d+-\d+-\d+)\s+\
2 (\d+:\d+:\d+)\s+"Message":"(.*)"/
3
4 <Extension json>
5 Module xm_json
6 </Extension>
7
8 <Input from_file>
9 Module im_file
10 File '/tmp/input'
11 <Exec>
12 if $raw_event =~ %EVENT_REGEX%
13 {
14 $EventTime = strptime($1 + $2,'%Y-%m-%d %T');
15 $Message = $3;
16 to_json();
17 }
18 else drop();
19 </Exec>
20 </Input>
21
22 <Output to_tcp>
23 Module om_tcp
24 Host 192.168.31.122
25 Port 10500
26 </Output>
After the message is parsed, this configuration creates the following fields for the event record:
• $EventTime is combined from the date and time values of the source log message using the strptime()
function,
• $Message contains The service has started text of the message.
◦ $SourceModuleName contains the name of the module instance which initially received the
message,
◦ $SourceModuleType contains the NXLog module name which initially received the message.
Finally, the event record is converted to JSON using to_json() procedure of the xm_json module and can be
sent via TCP using the om_tcp module. The result of conversion is shown in the sample below.
32
Chapter 3. System Architecture NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-06-18T09:06:03.891218+00:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"EventTime": "2020-05-13T00:00:00.000000+00:00",
"Message": "The service has started"
}
After forwarding, this message can be parsed into fields using the parse_json() procedure, see the
configuration below.
nxlog.conf (Receiver)
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_tcp>
6 Module im_tcp
7 Host 192.168.31.122
8 Port 10500
9 <Exec>
10 parse_json();
11 $EventTime = parsedate($EventTime);
12 $Message = $Message;
13 </Exec>
14 </Input>
33
NXLog User Guide Chapter 3. System Architecture
The configuration below reads messages from a file. In the Exec block, the $raw_event length is calculated
using the size() function. The message is dropped in case its length is not 5 characters or longer. Otherwise,
the message length is stored into the $MessageSize field for forwarding over the network.
nxlog.conf (Sender)
1 <Input from_file>
2 Module im_file
3 File '/tmp/input'
4 ReadFromLast TRUE
5 <Exec>
6 if size($raw_event) < 5 drop();
7 $MessageSize = size($raw_event);
8 </Exec>
9 </Input>
10
11 <Output to_tcp>
12 Module om_tcp
13 Host 192.168.31.150
14 Port 10500
15 OutputType Binary
16 </Output>
• $EventReceivedTime contains the time when the message was received by NXLog,
• $SourceModuleName contains the name of the module instance which initially received the message,
• $SourceModuleType contains the NXLog module name which initially received the message,
Finally, the event record is converted to NXLog binary format and forwarded over the network using the
om_tcp module.
To accept a message, the InputType directive of the im_tcp module instance can be configured to the Binary
function.
nxlog.conf (Receiver)
1 <Input from_tcp>
2 Module im_tcp
3 Host 192.168.31.150
4 Port 10500
5 InputType Binary
6 </Input>
7
8 <Output to_file>
9 Module om_file
10 File '/tmp/output'
11 Exec to_json();
12 </Output>
34
Chapter 3. System Architecture NXLog User Guide
Files and sockets are added to the core by the various modules, and the core delegates events when necessary.
Modules also dispatch log events to the core, which passes each one to the appropriate module. In this way, the
core can centrally control all events and the order of their execution making prioritized processing possible. Each
event belonging to the same module instance is executed in sequential order, not concurrently. This ensures that
message order is kept and allows modules to be written without concern for concurrency. Yet because the
modules and routes run concurrently, the global log processing flow remains parallelized.
3.2.1. Modules
A module is a foo.so or foo.dll that can be loaded by the NXLog core and provides a particular capability. A
module instance is a configured module that can be used in the configured data flow. For example, the
configuration block for an input module instance begins with <Input instancename>. See the Instance examples
below. A single module can be used in multiple instances. With regard to configuration, a module instance is
often referred to as simply a module.
Input
Functionality for accepting or retrieving log data is provided by input modules. An input module instance is a
source or producer. It accepts log data from a source and produces event records.
Output
Output modules provide functionality for sending log data to a local or remote destination. An output module
instance is a sink, destination, or consumer. It is responsible for consuming event records produced by one or
more input module instances.
Extension
The NXLog language can be extended with extension modules. Extension module instances do not process
log data directly. Instead, they provide features (usually functions and procedures) that can be used from
other parts of the processing pipeline. Many extension module instances require no directives other than the
Module directive.
35
NXLog User Guide Chapter 3. System Architecture
In this example, the xm_syslog module is loaded by the Extension block. This module provides the
parse_syslog() procedure, in addition to other functions and procedures. In the following Input
instance, the Exec directive calls parse_syslog() to parse the Syslog-formatted event.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File '/var/log/messages'
8 Exec parse_syslog();
9 </Input>
Processor
Processor modules offer features for transforming, filtering, or converting log messages. One or more
processor module instances can be used in a route between input and output module instances.
Many processing functions and procedures are available through the NXLog language and
can be accessed through the Exec directive in an Input or Output block without using a
NOTE
separate processor module instance. However, a separate processor module (pm_null,
perhaps) will use a separate worker thread, providing additional processing parallelization.
3.2.2. Routes
Most log processing solutions are built around the same concept. The input is read from a source, log messages
are processed, and then log data is written to a destination. In NXLog, this path is called a "route" and is
configured with a Route block.
Routes are made up of one or more inputs, zero or more processors, and one or more outputs.
36
Chapter 3. System Architecture NXLog User Guide
This route accepts input with the in module and sends it to the out module. This is the simplest functional
route.
nxlog.conf
1 <Route r1>
2 Path in => out
3 </Route>
This route extends the previous example by adding an intermediate processing module proc.
nxlog.conf
1 <Route r2>
2 Path in => proc => out
3 </Route>
37
NXLog User Guide Chapter 3. System Architecture
This route uses two input modules and two output modules. Input from in1 and in2 will be combined and
sent to both out1 and out2.
nxlog.conf
1 <Route r3>
2 Path in1, in2 => out1, out2
3 </Route>
A module can be used by multiple routes simultaneously, as in this example. The in1 module instance is
only declared once, but is used by both routes.
nxlog.conf
1 <Route r1>
2 Path in => out1
3 </Route>
4
5 <Route r2>
6 Path in => proc => out2
7 </Route>
38
Chapter 3. System Architecture NXLog User Guide
Log Queues
Every processor and output module instance has an input log queue for events that have not yet been
processed by that module instance. When the preceding module has processed an event, it is placed in this
queue. Log queues are enabled by default for all processor and output module instances; adjusting log
queue sizes is the preferred way to control buffering behavior.
Flow Control
NXLog’s flow control functionality provides automatic, zero-configuration handling of many cases where
buffering would otherwise be required. Flow control takes effect when the following sequence of events
occurs in a route:
1. a processor or output module instance is not able to process log data at the incoming rate,
2. that module instance’s log queue becomes full, and
3. the preceding input or processor module instance has flow control enabled (which is the default).
In this case, flow control will cause the input or processor module instance to suspend processing until the
succeeding module instance is ready to accept more log data.
For more information about these and other buffering features, including log queue persistence, disabling flow
control, read/write buffers, and examples for specific scenarios, see Using Buffers.
• Agent-Based Collection: NXLog runs on the system that is generating the log data.
• Agent-Less Collection: Hosts or devices generate log data and send it over the network to NXLog.
• Offline Log Processing: The nxlog-processor(8) tool performs batch log processing.
39
NXLog User Guide Chapter 3. System Architecture
We recommend agent-based log collection for most use cases. In particular, we recommend this
NOTE mode if you need strong security and reliability or need to transform log data before it leaves
the system on which it was generated.
Agent-based log collection offers several important advantages over agent-less collection.
• Log data can be collected from more sources. For example, you can collect logs directly from files, instead of
relying on a logging process to send log data across the network.
• NXLog’s processing features are available. You can filter, normalize, and rewrite log data before sending it to
a destination, whether a NXLog instance or a log aggregation system. This includes the ability to send
structured log data, such as JSON and key-value pairs.
• You have full control over the transfer of the log data. Messages can be sent using a variety of protocols,
including over TLS/SSL encrypted connections for security. Log data can be sent in compressed batches and
can be buffered if necessary.
• Log collection in this mode is more reliable. NXLog includes delivery guarantees and flow control systems
which ensure your log data reaches its destination. You can monitor the health of the NXLog agent to verify
its operational integrity.
Although agent-based collection has many compelling advantages, it is not well suited to some use cases.
• Many network and embedded systems, such as routers and firewalls, do not support installing third-party
software. In this case it would not be possible to install the NXLog agent.
• Installing the NXLog agent on each system in a large-scale deployment may not be practical compared to
reading from the existing logging daemon on each system.
We recommend agent-less log collection in cases where agent-based log collection is not
NOTE feasible, for example from legacy or embedded systems that do not support installing the
NXLog agent.
• It is not necessary to install an NXLog agent application on the target system to collect log data from it.
• Generally, a device or system requires only minimal configuration to send log data over the network to an
NXLog instance in its native format.
Agent-less log collection has some disadvantages that should be taken into consideration.
• Agent-less log collection may provide lower performance than agent-based collection. On Windows systems,
the Windows Management Instrumentation process can consume more system resources than the NXLog
agent.
• Reliability is also a potential issue. Since most Syslog log forwarders use UDP to transfer log data, some data
could be lost if the server restarts or becomes unreachable over the network. Unlike agent-based log
collection, you often cannot monitor the health of the logging source.
• Data transfers are less secure when using agent-less collection since most Syslog sources transfer data over
unencrypted UDP.
• BSD Syslog (RFC 3164) and IETF Syslog (RFC 5424) sources (see Collecting and Parsing Syslog)
40
Chapter 3. System Architecture NXLog User Guide
◦ Windows Event Forwarding, using the im_wseventing module (see Remote Collection With
im_wseventing)
Common input sources are files and databases. This tool is useful for log processing tasks such as:
41
NXLog User Guide Chapter 4. Available Modules
Module Description
xm_aixaudit — AIX Auditing (Enterprise Parses AIX audit events that have been written to file.
Edition only)
xm_asl — Apple System Logs (Enterprise Parses events in the Apple System Log (ASL) format.
Edition only)
xm_bsm — Basic Security Module Auditing Supports parsing of events written to file in Sun’s Basic Security
(Enterprise Edition only) Module (BSM) Auditing binary format.
xm_cef — CEF (Enterprise Edition only) Provides functions for generating and parsing data in the
Common Event Format (CEF) used by HP ArcSight™ products.
xm_charconv — Character Set Conversion Provides functions and procedures to help you convert strings
between different character sets (code pages).
xm_crypto — Encryption (Enterprise Edition Provides encryption and decryption of logs by using data
only) converters which implement the AES symmetric-key algorithm.
xm_exec — External Program Execution Passes log data through a custom external program for
processing, either synchronously or asynchronously.
xm_go — Go or Golang (Enterprise Edition Provides support for processing log data with methods written in
only) the Go language.
xm_grok — Grok Patterns (Enterprise Edition Provides support for parsing events with Grok patterns.
only)
xm_java — Java (Enterprise Edition only) Provides support for processing log data with methods written in
the Java language.
42
Chapter 4. Available Modules NXLog User Guide
Module Description
xm_kvp — Key-Value Pairs Provides functions and procedures to parse and generate data
that is formatted as key-value pairs.
xm_leef — LEEF (Enterprise Edition only) Provides functions for parsing and generating data in the Log
Event Extended Format (LEEF), which is used by IBM Security
QRadar products.
xm_msdns — DNS Server Debug Log Parses Microsoft Windows DNS Server debug logs
Parsing (Enterprise Edition only)
xm_multiline — Multi-Line Message Parser Parses log entries that span multiple lines.
xm_netflow — NetFlow (Enterprise Edition Provides a parser for NetFlow payload collected over UDP.
only)
xm_nps — NPS (Enterprise Edition only) Provides functions and procedures for processing data in NPS
Database Format stored in files by Microsoft Radius services.
xm_pattern — Pattern Matcher (Enterprise Applies advanced pattern matching logic to log data, which can
Edition only) give greater performance than normal regular expression
statements. Replaces pm_pattern.
xm_python — Python (Enterprise Edition Processes log data using Python. Only versions 3.x of Python are
only) supported.
xm_resolver — Resolver (Enterprise Edition Resolves key identifiers that appear in log messages into more
only) meaningful equivalents, including IP addresses to host names, and
group/user IDs to friendly names.
xm_snmp — SNMP Traps (Enterprise Edition Parses SNMPv1 and SNMPv2c trap messages.
only)
xm_stdinpw — Passwords on standard input Reads passwords on standard input. This module has been
(Enterprise Edition only) deprecated.
xm_syslog — Syslog Provides helpers that let you parse and output the BSD Syslog
protocol as defined by RFC 3164.
xm_w3c — W3C (Enterprise Edition only) Parses data in the W3C Extended Log File Format, the BRO format,
and Microsoft Exchange Message Tracking logs.
xm_zlib — Compression (Enterprise Edition This module compresses and decompresses log data using the
only) gzip data format defined in RFC 1952 and the zlib format defined
in RFC 1950.
43
NXLog User Guide Chapter 4. Available Modules
Module Description
im_acct — BSD/Linux Process Accounting Collects process accounting logs from a Linux or BSD kernel.
(Enterprise Edition only)
im_aixaudit — AIX Auditing (Enterprise Collects AIX audit events directly from the kernel.
Edition only)
im_azure — Azure (Enterprise Edition only) Collects logs from Microsoft Azure applications.
im_bsm — Basic Security Module Auditing Collects audit events directly from the kernel using Sun’s Basic
(Enterprise Edition only) Security Module (BSM) Auditing API.
im_checkpoint — Check Point OPSEC Provides support for collecting logs remotely from Check Point
(Enterprise Edition only) devices over the OPSEC LEA protocol.
im_dbi — DBI Collects log data by reading data from an SQL database using the
libdbi library.
im_etw — Event Tracing for Windows (ETW) Implements ETW controller and consumer functionality in order to
(Enterprise Edition only) collect events from the ETW system.
im_file — File Collects log data from a file on the local file system.
im_fim — File Integrity Monitoring Scans files and directories and reports detected changes.
(Enterprise Edition only)
im_go — Go or Golang (Enterprise Edition Provides support for collecting log data with methods written in
only) the Go language.
im_http — HTTP/HTTPS (Enterprise Edition Accepts incoming HTTP or HTTPS connections and collects log
only) events from client POST requests.
im_java — Java (Enterprise Edition only) Provides support for processing log data with methods written in
the Java language.
im_kafka — Apache Kafka (Enterprise Edition Implements a consumer for collecting from a Kafka cluster.
only)
im_kernel — Kernel (Enterprise Edition only Collects log data from the kernel log buffer.
for some platforms)
im_linuxaudit — Linux Audit System Configures and collects events from the Linux Audit System
(Enterprise Edition only)
44
Chapter 4. Available Modules NXLog User Guide
Module Description
im_null — Null Acts as a dummy log input module, which generates no log data.
You can use this for testing purposes.
im_oci — OCI (Enterprise Edition only) Reads log messages from an Oracle database. This module has
been deprecated.
im_odbc — ODBC (Enterprise Edition only) Uses the ODBC API to read log messages from database tables.
im_perl — Perl (Enterprise Edition only) Captures event data directly into NXLog using Perl code.
im_pipe — Named Pipes (Enterprise Edition This module can be used to read log messages from named pipes
only) on UNIX-like operating systems.
im_python — Python (Enterprise Edition only) Captures event data directly into NXLog using Python code. Only
versions 3.x of Python are supported.
im_regmon — Windows Registry Monitoring Periodically scans the Windows registry and generates event
(Enterprise Edition only) records if a change in the monitored registry entries is detected.
im_ruby — Ruby (Enterprise Edition only) Captures event data directly into NXLog using Ruby code.
im_ssl — SSL/TLS Collects log data over a TCP connection that is secured with
Transport Layer Security (TLS) or Secure Sockets Layer (SSL).
im_systemd — Systemd (Enterprise Edition This module accepts messages from the Linux systemd journal.
only)
im_uds — Unix Domain Socket Collects log data over a Unix domain socket (typically /dev/log).
im_wseventing — Windows Event Collects EventLog from Windows clients that have Windows Event
Forwarding (Enterprise Edition only) Forwarding configured.
im_zmq — ZeroMQ (Enterprise Edition only) Provides incoming message transport over ZeroMQ, a scalable
high-throughput messaging library.
Module Description
pm_blocker — Blocker Blocks log data from progressing through a route. You can use this
module for testing purposes, to simulate when a route is blocked.
45
NXLog User Guide Chapter 4. Available Modules
Module Description
pm_filter — Filter Forwards the log data only if the condition specified in the Filter
module configuration evaluates to true. This module has been
deprecated. Use the NXLog language drop() procedure
instead.
pm_hmac — HMAC Message Integrity Protect messages with HMAC cryptographic checksumming. This
(Enterprise Edition only) module has been deprecated.
pm_hmac_check — HMAC Message Integrity Check HMAC cryptographic checksums on messages. This module
Checker (Enterprise Edition only) has been deprecated.
pm_pattern — Pattern Matcher Applies advanced pattern matching logic to log data, which can
give greater performance than normal regular expression
statements in Exec directives. This module has been
deprecated. Use the xm_pattern module instead.
pm_transformer — Message Format Provides parsers for various log formats, and converts between
Converter them. This module has been deprecated. Use the xm_syslog,
xm_csv, xm_json, and xm_xml modules instead.
Module Description
om_blocker — Blocker Blocks log data from being written. You can use this module for
testing purposes, to simulate when a route is blocked.
om_dbi — DBI Stores log data in an SQL database using the libdbi library.
om_eventdb — EventDB (Enterprise Edition Uses libdrizzle to insert log message data into a MySQL database
only) with a special schema.
46
Chapter 4. Available Modules NXLog User Guide
Module Description
om_go — Go or Golang (Enterprise Edition Provides support for forwarding log data with methods written in
only) the Go language.
om_java — Java (Enterprise Edition only) Provides support for processing log data with methods written in
the Java language.
om_null — Null Acts as a dummy log output module. The output is not written or
sent anywhere. You can use this module for testing purposes.
om_oci — OCI (Enterprise Edition only) Writes log messages to an Oracle database. This module has
been deprecated.
om_odbc — ODBC (Enterprise Edition only) Uses the ODBC API to write log messages to database tables.
om_perl — Perl (Enterprise Edition only) Uses Perl code to handle output log messages from NXLog.
om_pipe — Named Pipes (Enterprise Edition This module allows log messages to be sent to named pipes on
only) UNIX-like operating systems.
om_python — Python (Enterprise Edition Uses Python code to handle output log messages from NXLog.
only) Only versions 3.x of Python are supported.
om_ruby — Ruby (Enterprise Edition only) Uses Ruby code to handle output log messages from NXLog.
om_ssl — SSL/TLS Sends log data over a TCP connection that is secured with
Transport Layer Security (TLS) or Secure Sockets Layer (SSL).
om_udpspoof — UDP with IP Spoofing Sends log data over a UDP connection, and spoofs the source IP
(Enterprise Edition only) address to make packets appear as if they were sent from another
host.
om_webhdfs — WebHDFS (Enterprise Edition Stores log data in Hadoop HDFS using the WebHDFS protocol.
only)
om_zmq — ZeroMQ (Enterprise Edition only) Provides outgoing message transport over ZeroMQ, a scalable
high-throughput messaging library.
47
NXLog User Guide Chapter 4. Available Modules
4.5.2. AmazonLinux 2
Table 20. Available Modules in nxlog-5.2.6418_amzn2_aarch64.tar.bz2
48
Chapter 4. Available Modules NXLog User Guide
nxlog-pcap-5.2.6418_amzn2_aarch64.rpm im_pcap
nxlog-systemd-5.2.6418_amzn2_aarch64.rpm im_systemd
nxlog-wseventing- im_wseventing
5.2.6418_amzn2_aarch64.rpm
49
NXLog User Guide Chapter 4. Available Modules
nxlog-checkpoint-5.2.6418_rhel6_x86_64.rpm im_checkpoint
nxlog-wseventing-5.2.6418_rhel6_x86_64.rpm im_wseventing
50
Chapter 4. Available Modules NXLog User Guide
nxlog-checkpoint-5.2.6418_rhel7_x86_64.rpm im_checkpoint
nxlog-pcap-5.2.6418_rhel7_x86_64.rpm im_pcap
nxlog-systemd-5.2.6418_rhel7_x86_64.rpm im_systemd
nxlog-wseventing-5.2.6418_rhel7_x86_64.rpm im_wseventing
51
NXLog User Guide Chapter 4. Available Modules
nxlog-checkpoint-5.2.6418_rhel8_x86_64.rpm im_checkpoint
nxlog-pcap-5.2.6418_rhel8_x86_64.rpm im_pcap
nxlog-systemd-5.2.6418_rhel8_x86_64.rpm im_systemd
nxlog-wseventing-5.2.6418_rhel8_x86_64.rpm im_wseventing
52
Chapter 4. Available Modules NXLog User Guide
53
NXLog User Guide Chapter 4. Available Modules
nxlog- im_checkpoint
checkpoint_5.2.6418_debian10_amd64.deb
nxlog-pcap_5.2.6418_debian10_amd64.deb im_pcap
nxlog-systemd_5.2.6418_debian10_amd64.deb im_systemd
nxlog- im_wseventing
wseventing_5.2.6418_debian10_amd64.deb
54
Chapter 4. Available Modules NXLog User Guide
nxlog- im_checkpoint
checkpoint_5.2.6418_debian8_amd64.deb
nxlog-pcap_5.2.6418_debian8_amd64.deb im_pcap
nxlog-systemd_5.2.6418_debian8_amd64.deb im_systemd
nxlog- im_wseventing
wseventing_5.2.6418_debian8_amd64.deb
55
NXLog User Guide Chapter 4. Available Modules
nxlog- im_checkpoint
checkpoint_5.2.6418_debian9_amd64.deb
nxlog-pcap_5.2.6418_debian9_amd64.deb im_pcap
56
Chapter 4. Available Modules NXLog User Guide
nxlog-systemd_5.2.6418_debian9_amd64.deb im_systemd
nxlog- im_wseventing
wseventing_5.2.6418_debian9_amd64.deb
4.5.10. FreeBSD 11
Table 28. Available Modules in nxlog-5.2.6418_fbsd_x86_64.tgz
4.5.11. MacOS
Table 29. Available Modules in nxlog-5.2.6387_macos.pkg
57
NXLog User Guide Chapter 4. Available Modules
58
Chapter 4. Available Modules NXLog User Guide
59
NXLog User Guide Chapter 4. Available Modules
60
Chapter 4. Available Modules NXLog User Guide
4.5.15. SLES 12
Table 33. Available Modules in nxlog-5.2.6418_sles12_x86_64.tar.bz2
61
NXLog User Guide Chapter 4. Available Modules
nxlog-checkpoint-5.2.6418_sles12_x86_64.rpm im_checkpoint
nxlog-pcap-5.2.6418_sles12_x86_64.rpm im_pcap
nxlog-systemd-5.2.6418_sles12_x86_64.rpm im_systemd
nxlog-wseventing-5.2.6418_sles12_x86_64.rpm im_wseventing
4.5.16. SLES 15
Table 34. Available Modules in nxlog-5.2.6418_sles15_x86_64.tar.bz2
62
Chapter 4. Available Modules NXLog User Guide
nxlog-checkpoint-5.2.6418_sles15_x86_64.rpm im_checkpoint
nxlog-pcap-5.2.6418_sles15_x86_64.rpm im_pcap
nxlog-systemd-5.2.6418_sles15_x86_64.rpm im_systemd
nxlog-wseventing-5.2.6418_sles15_x86_64.rpm im_wseventing
63
NXLog User Guide Chapter 4. Available Modules
64
Chapter 4. Available Modules NXLog User Guide
65
NXLog User Guide Chapter 4. Available Modules
nxlog- im_checkpoint
checkpoint_5.2.6418_ubuntu16_amd64.deb
nxlog-pcap_5.2.6418_ubuntu16_amd64.deb im_pcap
nxlog-systemd_5.2.6418_ubuntu16_amd64.deb im_systemd
nxlog- im_wseventing
wseventing_5.2.6418_ubuntu16_amd64.deb
66
Chapter 4. Available Modules NXLog User Guide
nxlog- im_checkpoint
checkpoint_5.2.6418_ubuntu18_amd64.deb
nxlog-pcap_5.2.6418_ubuntu18_amd64.deb im_pcap
nxlog-systemd_5.2.6418_ubuntu18_amd64.deb im_systemd
nxlog- im_wseventing
wseventing_5.2.6418_ubuntu18_amd64.deb
67
NXLog User Guide Chapter 4. Available Modules
nxlog- im_checkpoint
checkpoint_5.2.6418_ubuntu20_amd64.deb
nxlog-pcap_5.2.6418_ubuntu20_amd64.deb im_pcap
68
Chapter 4. Available Modules NXLog User Guide
nxlog-systemd_5.2.6418_ubuntu20_amd64.deb im_systemd
nxlog- im_wseventing
wseventing_5.2.6418_ubuntu20_amd64.deb
69
NXLog User Guide Chapter 4. Available Modules
70
Chapter 4. Available Modules NXLog User Guide
71
NXLog User Guide Chapter 4. Available Modules
72
Chapter 4. Available Modules NXLog User Guide
73
NXLog User Guide Chapter 4. Available Modules
74
Chapter 4. Available Modules NXLog User Guide
75
NXLog User Guide Chapter 4. Available Modules
76
Chapter 4. Available Modules NXLog User Guide
77
NXLog User Guide Chapter 4. Available Modules
78
Chapter 4. Available Modules NXLog User Guide
79
NXLog User Guide Chapter 4. Available Modules
80
Chapter 4. Available Modules NXLog User Guide
81
NXLog User Guide Chapter 4. Available Modules
82
Chapter 4. Available Modules NXLog User Guide
83
NXLog User Guide Chapter 4. Available Modules
84
Chapter 4. Available Modules NXLog User Guide
85
NXLog User Guide Chapter 4. Available Modules
86
Chapter 4. Available Modules NXLog User Guide
87
NXLog User Guide Chapter 4. Available Modules
88
Chapter 4. Available Modules NXLog User Guide
89
NXLog User Guide Chapter 4. Available Modules
90
Chapter 4. Available Modules NXLog User Guide
91
NXLog User Guide Chapter 4. Available Modules
92
Chapter 4. Available Modules NXLog User Guide
93
NXLog User Guide Chapter 4. Available Modules
94
Chapter 4. Available Modules NXLog User Guide
95
NXLog User Guide Chapter 4. Available Modules
96
Chapter 4. Available Modules NXLog User Guide
97
NXLog User Guide Chapter 4. Available Modules
98
Chapter 4. Available Modules NXLog User Guide
99
NXLog User Guide Chapter 4. Available Modules
100
Chapter 4. Available Modules NXLog User Guide
101
NXLog User Guide Chapter 4. Available Modules
102
Chapter 4. Available Modules NXLog User Guide
103
NXLog User Guide Chapter 4. Available Modules
104
Chapter 4. Available Modules NXLog User Guide
105
NXLog User Guide Chapter 4. Available Modules
106
Chapter 4. Available Modules NXLog User Guide
107
NXLog User Guide Chapter 4. Available Modules
108
Chapter 4. Available Modules NXLog User Guide
109
NXLog User Guide Chapter 4. Available Modules
110
Chapter 4. Available Modules NXLog User Guide
111
NXLog User Guide Chapter 4. Available Modules
112
NXLog User Guide
Deployment
113
NXLog User Guide Chapter 5. Supported Platforms
NXLog also provides generic packages compiled against glibc 2.5 to support RPM based legacy
distributions such as Redhat 5.11 and SLES 11 on both 32 and 64 bit hardware.
NOTE
The packages are named as nxlog-X.XX.XXXX_generic_glibc2.5_rpm_x86_64.rpm and
nxlog-X.XX.XXXX_generic_glibc2.5_rpm_i386.rpm respectively and available in the beta
version as well.
114
Chapter 5. Supported Platforms NXLog User Guide
Under the Technical Support Services Agreement, Linux and BSD binary packages may be provided
NOTE upon request for operating systems that have reached their end-of-life date (like RHEL 5), for
legacy 32-bit hardware, or for less common distributions (such as Linux Mint).
While the im_odbc input module is included in the Windows Nano Server package, currently
NOTE
Microsoft does not provide a reverse forwarder to support the ODBC API.
Docker x86_64
For log sources of the above platforms, see Apple macOS, IBM AIX, and Oracle Solaris.
The following Microsoft Windows operating systems are unsupported due to having reached end-of-life status,
but are known to work with NXLog.
115
NXLog User Guide Chapter 5. Supported Platforms
116
Chapter 6. Product Life Cycle NXLog User Guide
• X denotes the MA JOR release version. Long-term support is provided for each major release when
applicable.
• Y denotes the MINOR version. Minor releases provide backward compatible enhancements and features
during the lifetime of a major release.
• Z denotes the REVISION NUMBER. Hot-fix revisions may be released within the same minor version.
Upgrades within the same major version are backward compatible. Features and changes that may not be
backward compatible are added to major releases only.
For supported products, the end-of-life (EOL) date is at least one year after the next major version is released.
NXLog Enterprise Edition 4.x One year after the release of NXLog Enterprise Edition 5.0
NXLog Manager 5.x One year after the release of NXLog Manager 6.0
117
NXLog User Guide Chapter 7. System Requirements
These requirements are in addition to the operating system’s requirements, and the
NOTE requirements should be combined with the NXLog Manager’s System Requirements
cumulatively for systems running both NXLog Enterprise Edition and NXLog Manager.
Minimum Recommended
Processor cores 1 2
Memory/RAM 60 MB 250 MB
118
Chapter 8. Digital Signature Verification NXLog User Guide
In some cases, like with RPM packages, a public key is required to verify the digital signature. For this, the Public
PGP Key can be downloaded from NXLog’s public contrib repository.
For simplicity, this section explains how to verify NXLog packages using a shell script from the
NXLog contrib repository.
NOTE
The details of the verification process without the script application can be found in the HOWTO:
GPG sign and verify deb packages and APT repositories section of the Packagecloud website.
2. Download the contents of the deb-verify directory from the NXLog contrib repository.
3. Run the deb-verify script with the path to the NXLog deb-package as its parameter. For example, it may be
the following command:
# ./deb-verify ../nxlog-4.8.4835_ubuntu20_amd64.deb
This example uses the generic RPM package. Change the name of the package to match the
NOTE
package used in your environment.
1. Import the downloaded NXLog public key into the RPM with the following command:
2. Verify the package signature with the imported public key using the following command:
119
NXLog User Guide Chapter 8. Digital Signature Verification
NXLog is displayed as a signer for the installer. The algorithm used for the signature and the timestamp is
also visible.
3. In the Signature list, select NXLog, then click Details to display additional information about the signature.
In the General tab, the signer information and countersignatures are displayed. Click on View Certificate to
display the certificate or select the Advanced tab to display signature details.
For valid packages a green tick is displayed, indicating the validity of the certificate.
3. Click on the triangle next to Details to display additional information about the certificate.
120
Chapter 9. Red Hat Enterprise Linux & CentOS NXLog User Guide
9.1. Installing
First, download the appropriate NXLog installation file from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, download the correct file for the target
platform.
Platform Archive
The RHEL 6, RHEL 7 and RHEL 8 archives above each contain several RPMs (see Packages in
a RHEL Archive below). These RPMs have dependencies on system-provided RPMs.
NOTE The generic RPM above contains all the libraries (such as libpcre and libexpat) that are
needed by NXLog. The only dependency is libc. However, some modules are not available
(im_checkpoint, for example). The advantage of the generic RPM is that it can be installed on
most RPM-based Linux distributions.
3. Transfer the file to the target server using SFTP or a similar secure method.
4. Log in to the target server and extract the contents of the archive (unless you are using the generic package):
Package Description
nxlog-dbi-5.2.6418_rhel7.x86_64.rpm (available for RHEL 6 Provides the im_dbi and om_dbi modules
and RHEL 7 only)
121
NXLog User Guide Chapter 9. Red Hat Enterprise Linux & CentOS
Package Description
5. Optional: To change the NXLog user and group for the installation, set the NXLOG_USER and NXLOG_GROUP
environment variables. During installation a new user and and a new group will be created based on these
environment variables. They will be used for User and Group directives in nxlog.conf, and for the
ownership of some directories under /opt/nxlog. Specifying an already existing user or group is not
supported. The created user and group will be deleted on NXLog removal.
# export NXLOG_USER=nxlog2
# export NXLOG_GROUP=nxlog2
6. Download the public key file from the NXLog’s public contrib repository and import it to the RPM database.
For more details about the package verification, see the Signature Verification for RPM
NOTE
Packages section in the User Guide.
7. If you are installing the nxlog-zmq package, enable the EPEL repository so ZeroMQ dependencies will be
available:
8. Use yum to install the required NXLog packages (or the generic package) and dependencies.
# /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
122
Chapter 9. Red Hat Enterprise Linux & CentOS NXLog User Guide
9.2. Upgrading
To upgrade an NXLog installation to the latest release, use yum as in the installation instructions above. It is
recommended to make a backup of the configuration files before starting this process.
To replace a trial installation of NXLog Enterprise Edition with a licensed copy of the same version, follow the
installation instructions.
The same user and group will be used for the upgrade as was used for the original installation
NOTE (see installation step 4 above). Changing to a different user and group during upgrade is not
supported.
9.3. Uninstalling
To uninstall NXLog, use yum remove. To remove any packages that were dependencies of NXLog but are not
required by any other packages, include the --setopt=clean_requirements_on_remove=1 option. Verify the
operation before confirming!
This procedure may not remove all files that were created while configuring NXLog. Likewise,
any files created as a result of NXLog’s logging operations will not be removed. To find these
NOTE
files, examine the configuration files that were used with NXLog and check the installation
directory (/opt/nxlog).
123
NXLog User Guide Chapter 10. Debian & Ubuntu
10.1. Installing
First, download the appropriate NXLog installation file from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, download the correct file for the target
platform.
Platform Archive
The NXLog installer packages are digitally signed. For more details about package
NOTE
verification, see the Signature Verification for DEB Packages section in the User Guide.
3. Transfer the file to the target server using SFTP or a similar secure method.
4. Log in to the target server and extract the contents of the archive (unless you are using the generic package):
Package Description
124
Chapter 10. Debian & Ubuntu NXLog User Guide
Package Description
# export NXLOG_USER=nxlog2
# export NXLOG_GROUP=nxlog2
b. Use dpkg to install the required NXLog packages (or the generic package, if you are using that).
# dpkg -i nxlog-5.2.6418_amd64.deb
c. If dpkg returned errors about uninstalled dependencies, use apt-get to install them and complete the
NXLog installation.
# apt-get -f install
# /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
9. Check that the NXLog service is running with the service command.
10.2. Upgrading
To upgrade an NXLog installation to the latest release, or to replace a trial installation of NXLog Enterprise Edition
with a licensed copy, use dpkg as explained in the installation instructions above. It is recommended to make a
backup of the configuration files before starting this process.
# dpkg -i nxlog-5.2.6418_amd64.deb
125
NXLog User Guide Chapter 10. Debian & Ubuntu
When upgrading to a licensed copy with additional NXLog trial packages installed, such as nxlog-
trial-python, use dpkg -i --auto-configure.
Make sure to edit this example to include all nxlog-trial packages that are actually installed.
# apt-get -f install
The same user and group will be used for the upgrade as was used for the original installation
NOTE (see installation step 4a above). Changing to a different user and group during upgrade is not
supported.
10.3. Uninstalling
To uninstall NXLog, use apt-get. To remove any unused dependencies (system-wide), include the --auto
-remove option. Verify the operation before confirming!
Use apt-get purge instead to also remove configuration files. But in either case, this procedure
may not remove all files that were created in order to configure NXLog, or that were created as a
NOTE
result of NXLog’s logging operations. To find these files, consult the configuration files that were
used with NXLog and check the installation directory (/opt/nxlog).
126
Chapter 11. SUSE Linux Enterprise Server NXLog User Guide
11.1. Installing
First, download the appropriate NXLog install archive from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, download the correct archive for your system.
Platform Archive
3. Use SFTP or a similar secure method to transfer the archive to the target server.
4. Log in to the target server and extract the contents of the archive.
Package Description
5. Optional: To change the NXLog user and group for the installation, set the NXLOG_USER and NXLOG_GROUP
environment variables. During installation a new user and and a new group will be created based on these
environment variables. They will be used for User and Group directives in nxlog.conf, and for the
ownership of some directories under /opt/nxlog. Specifying an already existing user or group is not
127
NXLog User Guide Chapter 11. SUSE Linux Enterprise Server
supported. The created user and group will be deleted on NXLog removal.
# export NXLOG_USER=nxlog2
# export NXLOG_GROUP=nxlog2
6. Download the public key file from the NXLog’s public contrib repository and import it to the RPM database.
For more details about the package verification, see the Signature Verification for RPM
NOTE
Packages section in the User Guide.
7. Install the required NXLog packages and their dependencies (this example installs the main NXLog package
only).
# /opt/nxlog/bin/nxlog -v
2020-10-17 08:05:06 INFO configuration OK
11. Check that the NXLog service is running with the systemctl command.
11.2. Upgrading
To update an NXLog installation to the latest release, use zypper as in the installation instructions above. It is
recommended to make a backup of the configuration files before starting this process.
To replace a trial installation of NXLog Enterprise Edition with a licensed copy of the same version, follow the
installation instructions.
The same user and group will be used for the upgrade as was used for the original installation
NOTE (see installation step 4 above). Changing to a different user and group during upgrade is not
supported.
11.3. Uninstalling
To uninstall NXLog, use zypper remove. To remove any packages that were dependencies of NXLog but are not
required by any other packages, include the --clean-deps option. Verify the operation before confirming!
128
Chapter 11. SUSE Linux Enterprise Server NXLog User Guide
This procedure may not remove all files that were created while configuring NXLog. Likewise,
any files created as a result of NXLog’s logging operations will not be removed. To find these
NOTE
files, examine the configuration files that were used with NXLog and check the installation
directory (/opt/nxlog).
129
NXLog User Guide Chapter 12. FreeBSD
12.1. Installing
NXLog is available as a precompiled package for FreeBSD. Follow these steps to install NXLog.
First, download the appropriate NXLog install archive from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, choose the nxlog-
5.2.6418_fbsd_x86_64.tgz package.
3. Use SFTP or a similar secure method to transfer the archive to the target server.
4. Log in to the target server as the root user.
5. Optional: To change the NXLog user and group for the installation, set the NXLOG_USER and NXLOG_GROUP
environment variables. During installation a new user and and a new group will be created based on these
environment variables. They will be used for User and Group directives in nxlog.conf, and for the
ownership of some directories under /opt/nxlog. Specifying an already existing user or group is not
supported. The created user and group will be deleted on NXLog removal.
The installation path is /opt/nxlog. Configuration files are located in /opt/nxlog/etc. The rc init script is
placed in /etc/rc.d/ on installation. An nxlog user account is created, and NXLog will run under this user
by default.
# vi /opt/nxlog/etc/nxlog.conf
General information about configuring NXLog can be found in Configuration. For more details about
configuring NXLog to collect logs on BSD, see the FreeBSD summary.
# /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
9. To enable NXLog, add the line nxlog_enable="YES" to /etc/rc.conf. Then manage the NXLog service with
the service(8) utility.
130
Chapter 12. FreeBSD NXLog User Guide
12.2. Upgrading
To upgrade NXLog, first remove the old version and then install the new version. Make a backup of the
configuration files before starting this process to be able to use them with the new installation.
12.3. Uninstalling
1. Use the pkg(7) utility to uninstall the NXLog package.
The uninstall script will remove NXLog along with the user, group, and files. The pkg utility will not remove
new or modified files.
2. Manually remove the base directory. This will remove any new or modified files left behind by the previous
131
NXLog User Guide Chapter 12. FreeBSD
step.
# rm -rf /opt/nxlog
132
Chapter 13. OpenBSD NXLog User Guide
13.1. Installing
NXLog is available as precompiled packages for OpenBSD upon request. Follow these steps to install NXLog.
# export NXLOG_USER=nxlog2
# export NXLOG_GROUP=nxlog2
5. Install NXLog with the pkg_add(1) utility. The OpenBSD package is currently unsigned, use the -D unsigned
flag to install.
The installation prefix is /opt/nxlog. Configuration files are located in /opt/nxlog/etc. The rc init script is
placed in /etc/rc.d on installation.
# vi /opt/nxlog/etc/nxlog.conf
General information about configuring NXLog can be found in Configuration. For more details about
configuring NXLog to collect logs on BSD, see the OpenBSD summary.
# /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
You can also use rcctl(8) to check and set the configuration flags.
133
NXLog User Guide Chapter 13. OpenBSD
13.2. Upgrading
To upgrade from a previous NXLog version (whether a licensed copy or trial), use the pkg_add(1) utility. This
example shows an upgrade from version 3.0.1865 to 5.2.6418. It is recommended to make a backup of the
configuration files before starting this process.
# pkg_add -U nxlog-5.2.6418-obsd6_2_x86_64.tgz
nxlog-3.0.1865-obsd6_2\->5.2.6418-obsd6_2: ok
Read shared items: ok
To replace a trial installation of NXLog Enterprise Edition with a licensed copy of the same version, use pkg_add
with the replace flag (-r).
# pkg_add -r nxlog-5.2.6418-obsd6_2_x86_64.tgz
The same user and group will be used for the upgrade as was used for the original installation
NOTE (see installation step 4 above). Changing to a different user and group during upgrade is not
supported.
13.3. Uninstalling
To uninstall NXLog, follow these steps.
# pkg_delete nxlog
nxlog-5.2.6418-obsd6_2: ok
Read shared items: ok
--- -nxlog-5.2.6418-obsd6_2 -------------------
The uninstall script will remove NXLog along with the user, group, and files. The pkg_delete utility will not
remove new files or modified configuration files.
2. Manually remove the base directory. This will remove any new or modified files left behind by the previous
step.
# rm -rf /opt/nxlog
134
Chapter 14. Microsoft Windows NXLog User Guide
14.1. Installing
First, download the NXLog MSI file from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, choose the correct package for your system.
Platform Package
Using the 32-bit installer to install NXLog on a 64-bit system is unsupported and not
recommended. To override the installer check and proceed anyway, use the
WARNING
SKIP_X64_CHECK=1 property (for example, msiexec /i nxlog-
5.2.6418_windows_x64.msi /q SKIP_X64_CHECK=1).
The NXLog installer packages are digitally signed. For more details about package verification,
NOTE
see the Signature Verification for Windows section in the User Guide.
• Installing Interactively
• Installing with Msiexec
• Deploying via Group Policy
See also the MSI for NXLog Agent Setup add-on, which provides an example MSI package for bootstrapping
NXLog agents.
The service Startup type of newer versions of NXLog is set to Automatic (Delayed Start)
NOTE instead of Automatic. To change this option, open the service control manager and alter the
Startup type in the General tab.
135
NXLog User Guide Chapter 14. Microsoft Windows
4. Start NXLog by opening the Service Manager, finding the nxlog service in the list, and starting it. To run it in
the foreground instead, invoke the nxlog.exe executable with the -f command line argument.
5. Open the NXLog log file (by default, C:\Program Files\nxlog\data\nxlog.log) with Notepad and check
for errors.
Some text editors (such as Wordpad) use exclusive locking and will refuse to open the log
NOTE
file while NXLog is running.
To allow Windows to prompt for administrator privileges, but otherwise install unattended, use /qb instead.
These steps were tested with a Windows Server 2016 domain controller and a Windows 7 client.
NOTE There are multiple ways to configure NXLog deployment with Group Policy. The required steps
for your network may vary from those listed below.
c. Provide a name for the group (for example, nxlog). Use the Security group type and Global context (or
the context suitable for your case).
d. Add computers to the group by selecting one or more, clicking Actions › Add to a group…, and entering
the group name (nxlog).
3. Create a network share for distributing the NXLog files.
a. Create a folder in the desired location (for example, C:\nxlog-dist).
b. Set up the folder as a share: right-click, select Properties, open the Sharing tab, and click [Share…].
c. Add the group (nxlog) and click [Share]. Take note of the share name provided by the wizard, it will be
needed later (for example, \\WINSERV1\nxlog-dist).
d. Copy the required files to the shared folder. If using NXLog Manager, this will include at least three files:
nxlog-5.2.6418_windows_x64.msi, managed.conf, and CA certificate agent-ca.pem. If not using
NXLog Manager, use a custom nxlog.conf instead of managed.conf, omit the CA certificate, and include
any other files required by the configuration.
136
Chapter 14. Microsoft Windows NXLog User Guide
NOTE
The file managed.conf is located in the C:\Program Files\nxlog\conf\nxlog.d\ directory. Prior
to NXLog version 5, it had the name log4ensics.conf and was located in the C:\Program
Files\nxlog\conf\ directory.
b. In the console tree, under Domains, right-click on your domain and click Create a GPO in this domain,
and Link it here…; this will create a GPO under the Group Policy Objects folder and link it to the
domain.
c. Name the GPO (for example, nxlog) and click [OK].
a. Under Computer Configuration › Policies › Software Settings, right-click Software installation. Click
New › Package… to create a deployment package for NXLog.
b. Browse to the network share and open the nxlog-5.2.6418_windows_x64.msi package. It is important
to use the Uniform Naming Convention (UNC) path (for example, \\WINSERV1\nxlog-dist) so the file
will be accessible by remote computers.
c. Select the Assigned deployment method.
6. Add the required files to the GPO by following these steps for each file.
a. Under Computer Configuration › Preferences › Windows Settings, right-click on Files. Click New ›
File.
b. Select the Replace action in the drop-down.
c. Choose the source file on the network share (for example, \\WINSERV1\nxlog-dist\managed.conf or
137
NXLog User Guide Chapter 14. Microsoft Windows
\\WINSERV1\nxlog-dist\agent-ca.pem).
d. Type in the destination path for the file (for example, C:\Program
Files\nxlog\conf\nxlog.d\managed.conf or C:\Program Files\nxlog\cert\agent-ca.pem).
e. Check Apply once and do not reapply under the Common tab for files that should only be deployed
once. This is especially important for managed.conf because NXLog Manager will write configuration
changes to that file.
f. Click [OK] to create the File in the GPO.
7. After the Group Policy is updated on the clients and NXLog is installed, one more reboot will be required
before the NXLog service starts automatically.
For more information about Group Policy, see the following TechNet and MSDN articles:
14.2. Upgrading
To upgrade NXLog to the latest release, or to replace a trial installation of NXLog Enterprise Edition with a
licensed copy, follow these steps. It is recommended to make a backup of the configuration files before starting
this process.
1. Run the new MSI installer as described in the Installing section (interactively, with Msiexec, or via Group
Policy). The installer will detect the presence of the previous version and perform the upgrade within the
current installation directory.
To upgrade from v3.x, uninstall the previous version before installing the new version (see
Uninstalling). This is necessary to transition from a per-user to a per-machine installation.
NOTE This check can be skipped by passing the SKIP_PERUSER_CHECK property (such as msiexec
/i nxlog-5.2.6418_windows_x64.msi /q SKIP_PERUSER_CHECK=1). Note that using
SKIP_PERUSER_CHECK is unsupported and not recommended.
If the Services console (services.msc) is running, the installer may request the computer
NOTE to be rebooted or display a permission denied error. Please ensure that the Services
console is not running before attempting an upgrade.
2. Start the upgraded NXLog service via the Services console (services.msc) or by rebooting the system.
Check the log file (by default, C:\Program Files\nxlog\data\nxlog.log) to verify logging is working as
expected.
If you want to downgrade to a previous version of NXLog, you will need to manually uninstall the
NOTE
current version first. See Uninstalling.
138
Chapter 14. Microsoft Windows NXLog User Guide
14.3. Uninstalling
NXLog can be uninstalled in several different ways.
In addition to the above, NXLog provides a method to remove the Windows Registry traces after uninstalling.
NXLog v3.x installers will remove log4ensics.conf and nxlog.conf during the
WARNING uninstallation process, even if they have been modified. If these files need to be preserved,
they should be backed up to another location before uninstalling NXLog v3.x.
This procedure may not remove all files that were created while configuring NXLog. Likewise,
any files created as a result of NXLog’s logging operations will not be removed (except for v3.x
NOTE
installers as noted above). You may wish to remove the installation directory (by default,
C:\Program Files\nxlog) once the uninstallation process has completed.
1. Open the Group Policy Object (GPO) originally created for installation (see Create a Group Policy Object).
2. For each NXLog version that has been deployed, right-click the package and either:
◦ click All Tasks › Remove…, and choose the Immediately uninstall removal method; or
◦ click Properties, open the Deployment tab, and check Uninstall this application when it falls out of
the scope of management.
In this case, NXLog will be uninstalled when the GPO is no longer applied to the
NOTE computer. An additional action will be required, such as removing the selected
computer(s) from the nxlog group created in Set up an Active Directory group.
To remove the possibly left Windows Registry entries, use the following command:
139
NXLog User Guide Chapter 14. Microsoft Windows
To complete the procedure, the following files need to be present in the same directory:
• The exact version of the MSI installer, with which NXLog was installed.
The necessary files can be downloaded from the windows-uninstall directory of NXLog’s public contrib repository.
To start the automatic uninstall and trace removal procedure, use the following command:
The Readme.MD file in the public contrib repository explains details of the script operation.
Deployment via Group Policy already provides a way to deploy the configuration files. For this
NOTE reason, it might be more preferable to configure NXLog via GPO instead of creating a custom
MSI as described in this section.
140
Chapter 15. Microsoft Nano Server NXLog User Guide
15.1. Installing
Follow these steps to deploy NXLog on a Microsoft Nano Server system.
Microsoft Nano Server does not support the installation of MSI files. In its place, Microsoft
introduced the APPX format. The sandboxing and isolation imposed by the APPX format was
NOTE
found to be an unnecessary complication when deploying NXLog; therefore, users are provided
with a ZIP file that allows for manual installation instead.
First, download the NXLog ZIP archive from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, download nxlog-5.2.6418_nano.zip.
3. Transfer the NXLog ZIP file to the Microsoft Nano Server. One way to do so is to use WinRM and the Copy-
Item cmdlet. Uncompress the ZIP file at C:\Program Files\nxlog using the Expand-Archive cmdlet as
shown below.
4. To register NXLog as a service, navigate to the installation directory and execute the following.
5. Configure NXLog by editing the C:\Program Files\nxlog\nxlog.conf file. General information about
configuring NXLog can be found in Configuration. For more details about configuring NXLog to collect logs on
Windows, see the Microsoft Windows summary.
Because Microsoft Nano Server does not have a native console editor, the configuration file
NOTE must be edited on a different system and then transferred to the Nano Server. Alternatively,
a third party editor could be installed.
NXLog in now installed, registered, and configured. The NXLog service can be started by running Start-Service
nxlog.
The following installation options require altering the Windows Registry. Incorrect modifications
NOTE could potentially render the system unusable. Always double check the commands and ensure
it will be possible to revert to a known working state before altering the registry.
141
NXLog User Guide Chapter 15. Microsoft Nano Server
1. Follow the same installation procedure outlined above, but choose a different DestinationPath when
expanding the ZIP file. Also register the NXLog service as shown above.
2. At this point the registry entry for the NXLog service needs to be altered. View the current setting:
Type : 16
Start : 2
ErrorControl : 0
ImagePath : "c:\Program Files\nxlog\nxlog.exe" -c "c:\Program Files\nxlog\nxlog.conf"
DisplayName : nxlog
DependOnService : {eventlog}
ObjectName : LocalSystem
PSPath :
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\nxlog
PSParentPath :
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services
PSChildName : nxlog
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
3. The value of the ImagePath parameter needs to be modified in order to update the location of both the
NXLog executable and the configuration file. For example, if NXLog is installed in C:\nxlog, run the following
command to update the registry key.
4. The configuration file (nxlog.conf) also needs to be edited to reflect this change to a non-default installation
directory. Make sure define ROOT points to the correct location.
This command requires altering the Windows Registry. Incorrect modifications could potentially
NOTE render the system unusable. Always double check the commands and ensure it will be possible
to revert to a known working state before altering the registry.
15.2. Upgrading
To upgrade NXLog to the latest release, follow these steps. It is recommended to make a backup of the
configuration files before starting this process.
2. Back up any configuration files that have been altered, such as nxlog.conf, managed.conf, and any
certificates.
3. Either delete the nxlog directory and follow the installation procedure again or use the -Force parameter
when extracting the NXLog ZIP file. There is no need to register the service again.
142
Chapter 15. Microsoft Nano Server NXLog User Guide
15.3. Uninstalling
To uninstall NXLog, follow this procedure.
2. Unregister the NXLog service by navigating to the NXLog directory and running .\nxlog.exe -u.
143
NXLog User Guide Chapter 16. Apple macOS
16.1. Installing
To install NXLog under macOS, follow the steps below. You will need administrator privileges to complete the
installation process.
First, download the appropriate NXLog install package from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, choose the correct package for your system.
Platform Package
The NXLog installer packages are digitally signed. For more details about package
NOTE
verification, see the Signature Verification on macOS section in the User Guide.
3. Optional: To change the NXLog user and group for the installation, create a /tmp/.nxlog file with the
following command. During installation a new user and a new group will be created using the values
specified in this command. They will be used for User and Group directives in nxlog.conf, and for the
ownership of some directories under /opt/nxlog. Specifying an already existing user or group is not
supported. The created user and group will be deleted on NXLog removal.
4. Install the NXLog package. You can do the installation interactively or with the command line installer.
As of version 4.5 the installer should be signed with our developer certificate. If you see the following
message with an earlier version, go to System Preferences › Security & Privacy and click [Open
Anyway], then follow the instructions shown by the installer.
144
Chapter 16. Apple macOS NXLog User Guide
◦ To install the package using the command line installer, run the following command.
Upon installation, all NXLog files are placed under /opt/nxlog. The launchd(8) script is installed in
/Library/LaunchDaemons/com.nxlog.plist and has the KeepAlive flag set to true (launchd will
automatically restart NXLog). NXLog log files are managed by launchd and can be found in /var/log/.
$ sudo /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
7. To apply your changes, stop NXLog with the following command. The launchd manager will restart the
daemon and the new configuration will be loaded.
145
NXLog User Guide Chapter 16. Apple macOS
16.2. Upgrading
To upgrade NXLog, follow the installation instructions.
The installation script will not modify the existing configuration files, however it is recommended to make a
backup of the configuration files before starting this process. After the installation has completed, NXLog will
restart automatically.
The same user and group will be used for the upgrade that were used for the original
NOTE installation (see installation step 2 above). Changing to a different user and/or group during
upgrade is not supported.
16.3. Uninstalling
To properly uninstall NXLog, follow these steps.
This will remove custom configuration files, certificates, and any other files in the listed
WARNING
directories. Save these files to another location first if you do not wish to discard them.
NOTE Use the -n switch (instead of -y) if you would like to preserve user data.
2. Delete user data if you are sure it will not be needed anymore.
2. Delete the nxlog user and group that were created during installation. If a non-default user/group were used
during installation (see installation step 2 above), remove those instead.
This will remove custom configuration files, certificates, and any other files in the listed
WARNING
directories. Save these files to another location first if you do not wish to discard them.
146
Chapter 17. Docker NXLog User Guide
17.1. Installing
First, download the appropriate NXLog install archive from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, choose the nxlog-5.2.6418_docker.tar.gz
archive (which is based on CentOS 7).
3. Use SFTP or a similar secure method to transfer the archive to the target server.
4. Log in to the target server and extract the contents of the archive.
Package Description
5. Configure NXLog. Custom configuration files can be placed in the build directory of the NXLog Docker
version, before the build. Every file ending with .conf will be copied into the Docker image and placed in the
/opt/nxlog/etc directory.
◦ It is also possible to specify the IP address of an NXLog Manager instance at build time. In this case,
NXLog will connect automatically at startup. Before build, the CA certificate file, exported from NXLog
Manager in PEM format and named agent-ca.pem, must be placed in the Docker build directory.
8. Check that the NXLog container is running with the docker command.
147
NXLog User Guide Chapter 17. Docker
17.2. Upgrading
The upgrade process consists of creating a new NXLog Docker image build and running a new container instance
with the newly built image.
5. Any old containers and images that are no longer needed can be removed with docker rm -v
<containerID> and docker rmi <imageID>, respectively. See Uninstalling below for more information.
17.3. Uninstalling
The uninstallation process of the NXLog Docker version is simply removing the running container and the image.
1. Get the container ID of the running NXLog instance and stop the running container.
$ docker rm -v <containerID>
3. Any other remaining containers that are not running can be listed with docker ps -a, and removed.
$ docker images
$ docker rmi <containerID>
148
Chapter 18. IBM AIX NXLog User Guide
18.1. Installing
First, download the appropriate NXLog installer package from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › NXLog Enterprise Edition files tab, choose the nxlog-5.2.6418_aix_ppc.rpm
package.
3. Use SFTP or a similar secure method to transfer the archive to the target server.
4. Install the required NXLog package.
a. Optional: To change the NXLog user and group for the installation, set the NXLOG_USER and
NXLOG_GROUP environment variables. During installation a new user and and a new group will be created
based on these environment variables. They will be used for User and Group directives in nxlog.conf,
and for the ownership of some directories under /opt/nxlog. Specifying an already existing user or
group is not supported. The created user and group will be deleted on NXLog removal.
# export NXLOG_USER=nxlog2
# export NXLOG_GROUP=nxlog2
# /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
# ./init start
18.2. Upgrading
To update an NXLog installation to the latest release, use rpm as in the installation instructions above. It is
recommended to make a backup of the configuration files before starting this process.
The same user and group will be used for the upgrade as was used for the original installation
NOTE (see installation step 3a above). Changing to a different user and group during upgrade is not
supported.
149
NXLog User Guide Chapter 18. IBM AIX
18.3. Uninstalling
To uninstall NXLog use rpm with the -e option.
# rpm -e nxlog
This procedure may not remove all files that were created while configuring NXLog. Likewise,
any files created as a result of NXLog’s logging operations will not be removed. To find these
NOTE
files, examine the configuration files that were used with NXLog and check the installation
directory (/opt/nxlog).
150
Chapter 19. Oracle Solaris NXLog User Guide
19.1. Installing
First, download the appropriate NXLog install archive from the NXLog website.
1. Log in to your account, then click My account at the top of the page.
2. Under the Downloads › My downloads tab, choose the correct archive for your system.
Platform Archive
3. Use SFTP or a similar secure method to transfer the archive to the target server.
4. Log in to the target server and extract the contents of the archive.
$ gunzip nxlog-5.2.6418_solaris_sparc.pkg.gz
5. Optional: To change the NXLog user and group for the installation, create a
/var/sadm/install/admin/nxlog-user_group file with the following command. During installation a new
user and and a new group will be created based on the names specified. They will be used for User and
Group directives in nxlog.conf, and for the ownership of some directories under /opt/nxlog. Specifying an
already existing user or group is not supported. The created user and group will be deleted on NXLog
removal.
◦ For a quiet install, use an administration file. Place the file (nxlog-adm in this example) in the
/var/sadm/install/admin/ directory.
151
NXLog User Guide Chapter 19. Oracle Solaris
nxlog-adm
mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=quit
setuid=nocheck
conflict=nocheck
install
action=nocheck
basedir=/opt/nxlog
networktimeout=60
networkretries=3
authentication=quit
keystore=/var/sadm/security
proxy=
$ sudo /opt/nxlog/bin/nxlog -v
2017-03-17 08:05:06 INFO configuration OK
9. Check that the NXLog service is running with the svcs command.
$ svcs nxlog
online 12:40:37 svc:system/nxlog:default
10. Manage the NXLog service with svcadm (restart the service to load the edited configuration file).
To replace a trial installation of NXLog Enterprise Edition with a licensed copy of the same
NOTE
version, follow the same installation instructions (use instance=overwrite as shown).
19.2. Upgrading
19.2.1. Updating to a Minor Release
To update an NXLog installation to the latest minor release, remove the old version and then install the new
version.
1. Before removing the old version, run the backup script from /opt/nxlog/bin/backup. The backup script will
create a backup directory in /opt (the directory will be named according to this format: /opt/nxlog-
backup-YYYYMMDD_hhmmss).
152
Chapter 19. Oracle Solaris NXLog User Guide
3. To install the new NXLog release, use pkgadd as in the installation instructions above.
4. After reinstalling NXLog, use the restore script from the latest backup directory to restore data to the new
NXLog installation.
1. Perform steps 1-3 from Updating to a Minor Release. Do not use restore (step 4).
2. Manually migrate the necessary parts of the backup content to the new installation.
From NXLog version 5.0, the configuration file log4ensics.conf changed to managed.conf and it is in a
different location. This file contains NXLog Manager related configuration.
NOTE nxlog.conf shipped with v5.0 has NXLog Manager integration disabled by default.
v 4.x v 5.0
/opt/nxlog-backup- /opt/nxlog/etc/nxlog.d/managed.con
date_time/lib/nxlog/log4ensics.conf f
/opt/nxlog-backup-date_time/nxlog/cert/* /opt/nxlog/var/lib/nxlog/cert/
19.3. Uninstalling
To uninstall NXLog, use pkgrm. To remove the package files from the client’s file system, include the -A option.
This procedure may not remove all files that were created while configuring NXLog. Likewise,
any files created as a result of NXLog’s logging operations will not be removed. To find these
NOTE
files, examine the configuration files that were used with NXLog and check the installation
directory (/opt/nxlog).
153
NXLog User Guide Chapter 20. Hardening NXLog
Running as nxlog:nxlog
1 User nxlog
2 Group nxlog
Some operations require privileges that are normally not available to the nxlog user. In this case, the simplest
solution is to configure NXLog to retain full root privileges by removing the User and Group directives from the
configuration. This is not recommended, however; it is more secure to grant only the required privileges and to
avoid running NXLog as root. See the following sections for more information.
NOTE
In certain rare conditions, such as when NXLog is initially started with an empty configuration before receiving
a configuration update from NXLog Manager, the required capabilities might not be set automatically.
Capabilities cap_net_bind_service+ep
This capability directive configuration sets both the CAP_NET_BIND_SERVICE and the CAP_NET_RAW
capabilities.
Capabilities "cap_net_bind_service,cap_net_raw=+ep"
154
Chapter 20. Hardening NXLog NXLog User Guide
NOTE
In certain rare conditions, such as when NXLog is initially started with an empty configuration before received
a configuration update from NXLog Manager, the required capabilities might not be set automatically.
The process is divided into two parts. First, a base policy is created. Then the policy is deployed and tailored to
the specific requirements of the current NXLog configuration.
nxlog.te
Base policy information; this file defines all the types and rules for a particular domain.
nxlog.fc
File system information; this file defines he security contexts that are applied to files when the policy is
installed.
nxlog.if
Interface information; this file defines the default file context for the system.
nxlog.sh
A helper shell script for compiling and deploying the policy module and fixing the labeling on the system; for
use only on the target system.
nxlog_selinux.spec
A specification file that can be used to generate an RPM package from the policy, useful for deploying the
policy on another system later. This spec file is generated on RPM-based systems only.
155
NXLog User Guide Chapter 20. Hardening NXLog
2. Start the SELinux Policy Generation Tool from the system launcher.
3. In the first screen, select Standard Init Daemon for the policy type, then click [Forward].
4. On the second screen, enter the following details for the application and user role, then click [Forward].
Name
A custom name for the role (for example, nxlog)
Executable
The path to the NXLog executable (for example, /opt/nxlog/bin/nxlog)
Init script
The path of the NXLog system init script (for example, /etc/rc.d/init.d/nxlog)
156
Chapter 20. Hardening NXLog NXLog User Guide
5. On the third screen, enter the TCP and UDP used by the NXLog deployment, then click [Forward]. If the
ports are unknown or not yet determined, then leave these fields blank; they can be customized later.
6. On the fourth screen, select the appropriate application traits for NXLog, then click [Forward]. The default
configuration requires only the Interacts with the terminal trait. For collecting Syslog messages or creating
files in /tmp, include the appropriate traits.
7. On the fifth screen, specify all the arbitrary files and directories that the NXLog installation should have
access to, then click [Forward]. The default configuration requires only the NXLog system directory,
/opt/nxlog. Include the paths of any custom log files that NXLog needs to access.
157
NXLog User Guide Chapter 20. Hardening NXLog
8. Additional SELinux configuration values can be set on the sixth screen. None of these are required for NXLog.
Click [Forward] to continue.
9. The policy files are generated on the final screen. Click [Save] to write the policy to disk.
Additional managed directories can be added to the policy by passing to the -w parameter
NOTE
the full directory paths separated by spaces (for example, -w /opt/nxlog /var/log).
3. The policy files are generated when the command exits successfully; the policy is written to the current
working directory.
When set to permissive mode, SELinux generates alerts rather than actively blocking actions
WARNING as it does in enforcing mode. Because this reduces system security, it is recommended that
this be done in a test environment.
1. Make sure that NXLog is correctly configured with all required functionality.
2. Stop the NXLog service.
158
Chapter 20. Hardening NXLog NXLog User Guide
3. Transfer the files containing your SELinux base policy to the target system. All the files should be in the same
directory.
4. Apply the SELinux base policy by executing the policy script. This script will compile the policy module, set the
appropriate security flags on the directories specified, and install the policy.
$ sudo ./nxlog.sh
You may see the error message libsemanage.add_user: user system_u not in
password file. This is caused by a bug in the selinux-policy RPM or selinux-policy-
default DEB package and does not affect the policy at all. It has been fixed in later releases.
NOTE
You may see the error message InvalidRBACRuleType: a is not a valid RBAC rule
type. This is from a bug in the policycoreutils package. It only affects man page
generation, which is not generated in this case. This has been fixed in later releases.
6. Set SELinux to permissive mode. All events which would have been prevented by SELinux will now be
permitted and logged to /var/log/audit/audit.log (including events not related to NXLog).
$ sudo setenforce 0
7. Start and then stop the NXLog service. Any actions taken by NXLog that are not permitted by the policy will
result in events logged by the Audit system. Run audit2allow -a -l -w to view all policy violations (with
descriptions) since the last policy reload.
If NXLog has been configured to listen on TCP port 1514, but the appropriate rules are not specified in
the current SELinux policy, then various audit events will be generated when the NXLog process
initializes and binds to that port. These events can be viewed from the Audit log file directly, with
ausearch, or with audit2allow (as shown below).
$ sudo audit2allow -a -l -w
type=AVC msg=audit(1524239322.612:473): avc: denied { listen } for pid=5697 comm="nxlog"
lport=1514 scontext=system_u:system_r:nxlog_t:s0 tcontext=system_u:system_r:nxlog_t:s0
tclass=tcp_socket
Was caused by:
Missing type enforcement (TE) allow rule.
You can use audit2allow to generate a loadable module to allow this access.
Additional log messages will be generated for any other file or network action not permitted by the
SELinux policy. These actions would all be denied by SELinux when set to enforcing mode.
8. Use the helper script --update option to add additional rules to the policy based on logged policy violations
with the nxlog context. Review the suggested changes and press y to update the policy. If no changes are
required, the script will exit zero.
159
NXLog User Guide Chapter 20. Hardening NXLog
The script will offer to add any required rules. The following output corresponds to the example in the
previous step.
require {
type nxlog_rw_t;
type nxlog_t;
class capability dac_override;
class tcp_socket { bind create listen setopt };
class file execute;
class capability2 block_suspend;
}
9. Set the SELinux policy to enforcing mode. This can be set permanently in /etc/selinux/config.
$ sudo setenforce 1
In enterprise environments managed by Group Policy, the dedicated user account and its
NOTE
permissions must be managed by the domain administrator.
1. Create a new user account. Open the Computer Management console (compmgmt.msc), expand Local
Users and Groups and right-click on Users. Select New User… from the context menu.
2. Enter the svc-nxlog user name, description, and password; enable the Password never expires check box;
and click [Create].
160
Chapter 20. Hardening NXLog NXLog User Guide
3. Open the Services console (services.msc), right-click the nxlog service, and select Properties.
4. Under the Log On tab, select the This Account radio button, click [Browse…], select the svc-nxlog user
account, and enter the password. Then click [OK]. Windows will warn you that the service must be restarted.
161
NXLog User Guide Chapter 20. Hardening NXLog
5. Open the Local Security Settings console (secpol.msc), expand Local Policies, then select User Rights
Assignment in the left pane.
162
Chapter 20. Hardening NXLog NXLog User Guide
7. Click [Add User or Group…] and select the new user. The new user should appear in the list. Click [OK].
8. Add the new user to the the Manage auditing and security log policy also.
9. In Windows Explorer, browse to the NXLog installation directory (by default, C:\Program Files
(x86)\nxlog on 64-bit systems), right-click, and select Properties. Under the Security tab, select the new
user from the Group or user names list. Check Allow for the following permissions, and then click [OK].
◦ Modify
◦ Read & Execute
◦ List Folder Contents
◦ Read
◦ Write
163
NXLog User Guide Chapter 20. Hardening NXLog
10. In the Services console (services.msc), right-click the nxlog service and select Restart.
11. Check the NXLog log files for start-up errors. Successful startup should look like this:
nxlog.log
2016-11-16 16:53:10 INFO nxlog-5.2.6418 started↵
2016-11-16 16:53:10 INFO connecting to 192.168.40.43↵
2016-11-16 16:53:12 INFO successfully connected to 192.168.40.43:1514↵
2016-11-16 16:53:12 INFO successfully connected to agent manager at 192.168.40.43:4041 in SSL
mode↵
On some Windows systems, this procedure may result in the following access denied error
when attempting to access the Windows Event Log:
Refer to the Windows Event Log Error section in the troubleshooting guide for how to resolve
this error.
164
Chapter 21. Relocating NXLog NXLog User Guide
Both relocation and manual installation can result in a non-functional NXLog agent.
Furthermore, subsequent update and removal using the system’s package manager may
WARNING
not work correctly. Follow this procedure at your own risk. This is not recommended for
inexperienced users.
Move the NXLog directory structure to the new location. Though not required, it is best to keep the original
directory structure. Then proceed to the following sections.
NOTE In the examples that follow, NXLog is being relocated from /opt/nxlog to /opt/nxlog_new.
/etc/init.d/nxlog
BASE=/opt/nxlog_new
pidfile=$BASE/var/run/nxlog/nxlog.pid
nxlog=$BASE/bin/nxlog
conf=$BASE/etc/nxlog.conf
nxlog="$nxlog -c $conf"
On systems that use a hybrid System V and systemd, reload the init files by executing the following command.
# systemctl daemon-reload
165
NXLog User Guide Chapter 21. Relocating NXLog
nxlog.service
[Service]
Type=simple
User=root
Group=root
PIDFile=/opt/nxlog_new/var/run/nxlog/nxlog.pid
ExecStartPre=/opt/nxlog_new/bin/nxlog -v -c /opt/nxlog_new/etc/nxlog.conf
ExecStart=/opt/nxlog_new/bin/nxlog -f -c /opt/nxlog_new/etc/nxlog.conf
ExecStop=/opt/nxlog_new/bin/nxlog -s -c /opt/nxlog_new/etc/nxlog.conf
ExecReload=/opt/nxlog_new/bin/nxlog -r -c /opt/nxlog_new/etc/nxlog.conf
KillMode=process
# systemctl daemon-reload
nxlog.conf
1 define BASE /opt/nxlog_new
2 define CERTDIR %BASE%/var/lib/nxlog/cert
3 define CONFDIR %BASE%/etc/nxlog.d
4 define LOGDIR %BASE%/var/log/nxlog
5 define LOGFILE "%LOGDIR%/nxlog.log"
6
7 SpoolDir %BASE%/var/spool/nxlog
8
9 # default values:
10 PidFile %BASE%/var/run/nxlog/nxlog.pid
11 CacheDir %BASE%/var/spool/nxlog
12 ModuleDir %BASE%/lib/nxlog/modules
Depending on the architecture and whether system supplied libraries are used, NXLog will store
NOTE
the modules under a different directory such as %BASE%/libexec/nxlog/modules.
# ldd /opt/nxlog_new/bin/nxlog
166
Chapter 21. Relocating NXLog NXLog User Guide
Notice that libpcre and libapr are pointing to the included libraries in /opt/nxlog/lib/. To change the run-
time search path of the binaries, a tool such as chrpath or patchelf can be used.
Depending on the distribution, chrpath may have a limitation on the path length for the -r
<path> | --replace <path> option: "The new path must be shorter or the same length as the
current path."
/opt/nxlog_new/bin/nxlog: RUNPATH=/opt/nxlog/lib
new rpath '/opt/nxlog_new/lib' too large; maximum length 14
If your system has the chrpath limitation documented above, skip to Modifying rpath with patchelf.
nxlog: RPATH=/opt/nxlog/lib:/home/builder/workspace/nxlog3-rpm-generic-amd64/rpmbuild/BUILD/nxlog-
deps/opt/nxlog/lib
nxlog: new RPATH: /opt/nxlog_new/lib
NXLog modules are also linked against statically included libraries. Therefore, if the run-time search path of the
binaries required a change, then the rpath of the modules needs updated as well. To change the run-time
search path of all the modules (or binaries) in a directory, use a command like this.
# chrpath -r /opt/nxlog_new/lib *
167
NXLog User Guide Chapter 21. Relocating NXLog
On success the command prompt returns with no message, or if this is the first time patchelf has been run
after installation, the following warning will be shown:
warning: working around a Linux kernel bug by creating a hole of 1748992 bytes in ‘nxlog’
To confirm the modification of rpath, run ldd again on the binary. The new path should displayed in the output:
# ldd /opt/nxlog_new/bin/nxlog
linux-vdso.so.1 => (0x00007ffc15d36000)
libpcre.so.1 => /opt/nxlog_new/lib/libpcre.so.1 (0x00007ff7f311e000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ff7f2f14000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007ff7f2d0f000)
libapr-1.so.0 => /opt/nxlog_new/lib/libapr-1.so.0 (0x00007ff7f2ad9000)
librt.so.1 => /lib64/librt.so.1 (0x00007ff7f28d0000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007ff7f2699000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff7f247d000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff7f20bb000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff7f336d000)
libattr.so.1 => /lib64/libattr.so.1 (0x00007ff7f1eb6000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007ff7f1cb3000)
NXLog modules are also linked against statically included libraries. Therefore, if the run-time search path of the
binaries required a change, then the rpath of the modules needs updated as well. Unlike chrpath which accepts
a (*) wildcard for all modules (or binaries) in a given directory, patchelf can only be run on a single file. To
automate the process of changing rpath on multiple files, a shell script will need to be written if relocating
NXLog will need to be done on a regular basis, or on more than one installation.
168
Chapter 22. Monitoring and Recovery NXLog User Guide
While Monit can monitor and react to several conditions, the configuration presented here instructs Monit to
restart NXLog after a crash. To do so, include the following in the Monit configuration. It may be necessary to edit
the paths to match your installation. Then restart Monit.
/etc/monit/monitrc
check process nxlog with pidfile /opt/nxlog/var/run/nxlog/nxlog.pid
start program = "/etc/init.d/nxlog start"
stop program = "/etc/init.d/nxlog stop"
On recent Linux distributions employing systemd, the start and stop directives should use
NOTE
systemd calls instead (for example, /bin/systemctl start nxlog).
To simulate an NXLog crash, terminate the nxlog process by issuing the following command (where <PID>
represents the current nxlog process ID).
# kill -9 <PID>
169
NXLog User Guide Chapter 22. Monitoring and Recovery
Newer versions of NXLog enable automatic recovery during installation. For older versions,
NOTE automatic recovery can be enabled by manually editing the values under the Recovery tab of
the SCM.
To simulate an NXLog crash, execute the following in PowerShell (where <PID> represents the process ID of
NXLog).
170
NXLog User Guide
Configuration
171
NXLog User Guide Chapter 23. Configuration Overview
The configuration file is comprised of blocks and directives. Blocks are similar to XML tags containing multiple
directives. Directive names are not case-sensitive but arguments sometimes are.
nxlog.conf
1 Fields $Version, $Device_Vendor, $Device_Product, $Device_Version, \
2 $Signature_ID, $Name, $Severity, $_Extension
nxlog.conf
1 Exec if ($QueryName == 'wpad') OR \
2 ($QueryType != '1') drop();
Breaking regular expressions into multiple lines improves their readability. Below is the sample of the define
directive which includes backslashes to continue the expression on the new line.
nxlog.conf
1 define EVENT_REGEX /(?x)^(\d+.\d+.\d+)\s+(\d+:\d+:\d+).\d+\
2 \s+PID=(\d+)\s+TID=(\d+)\s+(\w+)\s+\
3 \S(\w+):\s+(.*)/
23.2. Comments
Blank lines in configuration files are ignored.
Lines starting with the hash mark (#) are also ignored and can be used as comments.
nxlog.conf
1 # This is the comment line
Each comment should start with a new line. Application of inline comments is impossible because each directive
can only contain the directive definition and the argument.
Comments inside the QueryXML directive must be XML-style comments using <!-- and -->, see the sample
below.
nxlog.conf
1 <!--
2 XML-style comments can
3 span multiple lines in
4 QueryXML blocks like this.
5 -->
172
Chapter 23. Configuration Overview NXLog User Guide
nxlog.conf
1 File "/tmp/input"
nxlog.conf
1 DeviceFile /dev/auditpipe
This configuration exemplifies the logical structure. The global parameters section contains two directives.
The modules section contains both an input and output instance. The route section contains a single route
with a path directing a single input to a single output.
nxlog.conf
1 # Global section
2 User nxlog
3 Group nxlog
4
5 # Modules section
6 <Input in>
7 Module im_null
8 </Input>
9
10 <Output out>
11 Module om_null
12 </Output>
13
14 # Route section
15 <Route r>
16 Path in => out
17 </Route>
The LogFile directive sets a destination file for NXLog internal logs. If this directive is unset, the log file is disabled
and internal NXLog logs are not written to file (unless configured via the im_internal module). See also Rotating
the Internal Log File.
With the User and Group directives set, NXLog will drop root privileges after starting and run under the specified
user and group. If for some reason, any capabilities are required to be held permanently, the capabilities
directive can be used. These directives are ignored if running on Windows.
After starting, NXLog will change its working directory to the directory specified by the SpoolDir directive. Non-
173
NXLog User Guide Chapter 23. Configuration Overview
See the Reference Manual for a complete list of available global directives.
23.6. Modules
NXLog will only load modules which are specified in the configuration file and used in an active route. A module
instance is specified according to its corresponding module type (Extension, Input, Processor, or Output).
Each module instance must have a unique name and a Module directive. The following is a skeleton
configuration block for an input module.
nxlog.conf
1 <Input instancename>
2 Module im_module
3 ...
4 </Input>
For more details about module instance names, see Configuration in the Reference Manual.
23.7. Routes
Routes define the flow and processing order of the log messages. Each route instance must have a unique name
and a Path.
This Route instance, named example, takes logs from Input module instances named in1 and in2,
processes the logs with the proc Processor module instance, and sends the resulting logs to both Output
module instances out1 and out2. These named module instances must be defined elsewhere in the
configuration file.
nxlog.conf
1 <Route example>
2 Path in1, in2 => proc => out1, out2
3 </Route>
For more details about route instance names, see Configuration in the Reference Manual.
If no Route block is specified in the configuration, NXLog will automatically generate a route, with all the Input
and Output instances specified in a single path.
174
Chapter 23. Configuration Overview NXLog User Guide
NXLog can use a configuration with no Route block, such as the following.
nxlog.conf
1 <Input in1>
2 Module im_null
3 </Input>
4
5 <Input in2>
6 Module im_null
7 </Input>
8
9 <Output out1>
10 Module om_null
11 </Output>
12
13 <Output out2>
14 Module om_null
15 </Output>
An NXLog define works in a similar way to the C language, where the pre-processor substitutes the value in
places where the macro is used. The NXLog configuration parser replaces all occurrences of the defined name
with its value, and then after this substitution the configuration check occurs.
175
NXLog User Guide Chapter 23. Configuration Overview
This example shows the use of two defines: BASEDIR and IGNORE_DEBUG. The first is a simple constant, and
its value is used in two File directives. The second is an NXLog language statement, it is used in an Exec
directive.
nxlog.conf
1 define BASEDIR /var/log
2 define IGNORE_DEBUG if $raw_event =~ /debug/ drop();
3
4 <Input messages>
5 Module im_file
6 File '%BASEDIR%/messages'
7 </Input>
8
9 <Input proftpd>
10 Module im_file
11 File '%BASEDIR%/proftpd.log'
12 Exec %IGNORE_DEBUG%
13 </Input>
The define directive can be used for statements as shown above, but multiple statements should be specified
using a code block, with curly braces ({}), to result in the expected behavior.
The following example shows an incorrect use of the define directive. After substitution, the drop()
procedure will always be executed; only the warning message will be logged conditionally.
nxlog.conf (incorrect)
1 define ACTION log_warning("dropping message"); drop();
2
3 <Input in>
4 Module im_file
5 File '/var/log/messages'
6 Exec if $raw_event =~ /dropme/ %ACTION%
7 </Input>
To avoid this problem, the action should be defined using a code block.
176
Chapter 23. Configuration Overview NXLog User Guide
This is similar to the previous example using a define, but here the value is fetched from the environment.
nxlog.conf
1 envvar BASEDIR
2
3 <Input in>
4 Module im_file
5 File '%BASEDIR%/messages'
6 </Input>
The SpoolDir directive does not take effect until after the configuration has been parsed, so
relative paths specified with these directives are relative to the working directory where NXLog
NOTE was started from. Generally, it is recommended to use absolute paths. If desired, define
directives can be used to simulate relative paths (see Using Defines to Include a Configuration
File).
With the include directive it is possible to specify a file or set of files to be included in the current NXLog
configuration.
This example includes the contents of the /opt/nxlog/etc/syslog.conf file in the current configuration.
nxlog.conf
1 include /opt/nxlog/etc/syslog.conf
In this example, two define directives are used to include an eventlog.conf configuration file on Windows
by defining parts of the path to this file.
nxlog.conf
1 define ROOT C:\Program Files (x86)\nxlog
2 define CONFDIR %ROOT%\conf
3 include %CONFDIR%\eventlog.conf
The include directive also supports filenames containing the wildcard character (*). For example, multiple .conf
files could be saved in the nxlog.d directory—or some other custom configuration directory—and then
automatically included in the NXLog configuration in ascending alphabetical order along with the nxlog.conf
file.
Each included file might contain a small set of configuration information focused exclusively on a single log
source. This essentially establishes a modular design for maintaining larger configurations. One benefit of this
modular configuration approach is the ability to add/remove .conf files to/ from such a directory for
enabling/disabling specific log sources without ever needing to modify the main nxlog.conf configuration.
177
NXLog User Guide Chapter 23. Configuration Overview
This solution could be used to specify OS-specific configuration snippets (like windows2003.conf) or application-
specific snippets (such as syslog.conf).
Including subdirectories inside the configuration directory is not supported, neither are wildcarded directories.
This example includes all .conf files located under the /opt/nxlog/etc/nxlog.d path.
nxlog.conf
1 include /opt/nxlog/etc/nxlog.d/*.conf
nxlog.conf
define CONFDIR /opt/nxlog/etc/nxlog.d
include %CONFDIR%/*.conf
This example includes all .conf files from the nxlog.d folder on Windows.
nxlog.conf
1 include C:\Program Files\nxlog\conf\nxlog.d\*.conf
nxlog.conf
1 define CONFDIR C:\Program Files\nxlog\conf\nxlog.d
2 include %CONFDIR%\*.conf
With the include_stdout directive, an external command can be used to provide configuration content. There are
many ways this could be used, including fetching, decrypting, and validating a signed configuration from a
remote host, or generating configuration content dynamically.
nxlog.conf
1 include_stdout /opt/nxlog/etc/fetch_conf.sh
178
Chapter 24. NXLog Language NXLog User Guide
The features of the NXLog language are not limited to those in the NXLog core: modules can register functions
and procedures to supplement built-in functions and procedures (see the xm_syslog functions, for example).
Due to the simplicity of the language there is no error handling available to the user, except for
function return values. If an error occurs during the execution of the NXLog pseudo-code,
usually the error is printed in the NXLog logs. If an error occurs during log message processing it
NOTE is also possible that the message will be dropped. If sophisticated error handling or more
complex processing is required, additional message processing can be implemented in an
external script or program via the xm_exec module, in a dedicated NXLog module, or in Perl via
the xm_perl module.
Types
All fields and other expressions in the NXLog language are typed.
Expressions
An expression is evaluated to a value at run-time and the value is used in place of the expression. All
expressions have types. Expressions can be used as arguments for some module directives.
Statements
The evaluation of a statement will cause a change in the state of the NXLog engine, the state of a module
instance, or the current event. Statements often contain expressions. Statements are used as arguments for
the Exec module directive, where they are then executed for each event (unless scheduled).
Variables
Variables store data persistently in a module instance, across multiple event records.
Statistical Counters
NXLog provides statistical counters with various algorithms that can be used for realtime analysis.
179
NXLog User Guide Chapter 24. NXLog Language
While this Guide provides many configuration examples, in some cases only statement examples are given.
Statements must be used with the Exec directive (or Exec block). The following statement example shows
one way to use the parsedate() function.
The following configuration example uses the above statement in an Exec block.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/var/log/app.log'
4 <Exec>
5 if $raw_event =~ /^(\w{3} \d{2} \d{2}:\d{2}:\d{2})/
6 $EventTime = parsedate($1);
7 </Exec>
8 </Input>
24.1. Types
The NXLog language is a typed language. Fields, literals, and other expressions evaluate to values with specific
types. This allows for stricter type-safety syntax checking when parsing the configuration. Note that fields and
some functions can return values with types that can only be determined at run-time.
The language provides only simple types. Complex types such as arrays and hashes (associative
NOTE arrays) are not supported. The language does support the undefined value similar to that in
Perl. See the xm_perl module if you require more complex types.
A log’s format must be parsed before its individual parts can be used for processing (see Fields). But even after
the message has been parsed into its parts, additional processing may still be required, for example, to prepare a
timestamp for comparison with another timestamp. This is a situation where typing is helpful: by converting all
timestamps to the datetime type they can be easily compared—and converted back to strings later if required—
using the functions and procedures provided. The same applies to other types.
180
Chapter 24. NXLog Language NXLog User Guide
The following illustrates the four steps NXLog performs with this configuration as it manually processes a
Syslog event record using only regular expressions on the core field $raw_event and the core function
parsedate().
nxlog.conf
1 <Input in>
2 # 1. New event record created
3 Module im_udp
4 Host 0.0.0.0
5 Port 514
6 <Exec>
7 # 2. Timestamp parsed from Syslog header
8 if $raw_event =~ /^(\w{3} \d{2} \d{2}:\d{2}:\d{2})/
9 {
10 # 3. parsedate() function converts from string to datetime
11 $EventTime = parsedate($1);
12 # 4. Datetime fields compared
13 if ( $EventReceivedTime - $EventTime ) > 60000000
14 log_warning('Message delayed more than 1 minute');
15 }
16 </Exec>
17 </Input>
1. NXLog creates a new event record for the incoming log message. The new event record contains the
$raw_event string type field, with the contents of the entire Syslog string.
2. A regular expression is used to parse the timestamp from the event. The captured sub-string is a string
type, not a datetime type.
3. The parsedate() function converts the captured string to a datetime type.
4. Two datetime fields are compared to determine if the message was delayed during delivery. The
datetime type $EventReceivedTime field is added by NXLog to each event when it is received.
For a full list of types, see the Reference Manual Types section. For NXLog language core functions that can be
used to work with types, see Functions. For functions and procedures that can work with types related to a
particular format, see the module corresponding to the required format.
24.2. Expressions
An expression is a language element that is dynamically evaluated to a value at run-time. The value is then used
in place of the expression. Each expression evaluates to a type, but not always to the same type.
The following language elements are expressions: literals, regular expressions, fields, operations, and functions.
181
NXLog User Guide Chapter 24. NXLog Language
There are three statements below, one per line. Each statement contains multiple expressions, with
parentheses added in various ways.
1 if 1 + 1 == (1 + 1) log_info("2");
2 if (1 + 1) == (1 + 1) log_info("2");
3 if ((1 + 1) == (1 + 1)) log_info("2");
This simple statement uses the log_info() procedure with an expression as its argument. In this case the
expression is a literal.
Here is a function (also an expression) that is used in the same procedure. It generates an internal event
with the current time when each event is processed.
1 log_info(now());
The File directive of the om_file module supports expressions. This allows the output filename to be set
dynamically for each individual event.
nxlog.conf
1 <Output out>
2 Module om_file
3 File "/var/log/nxlog/out_" + strftime($EventTime, "%Y%m%d")
4 </Output>
24.2.1. Literals
A literal is a simple expression that represents a fixed value. Common literals include booleans, integers, and
strings. The type of literal is detected by the syntax used to declare it.
NOTE This section demonstrates the use of literals by using examples with assignment statements.
Boolean literals can be declared using the constants TRUE or FALSE. Both are case-insensitive.
Integer literals are declared with an unquoted integer. Negative integers, hexademical notation, and base-2
modifiers (Kilo, Mega, and Giga) are supported.
182
Chapter 24. NXLog Language NXLog User Guide
String literals are declared by quoting characters with single or double quotes. Escape sequences are available
when using double quotes.
For a list of all available literals, see the Reference Manual Literals section.
Examples in this section use only simple patterns. See Extracting Data and other topic-specific
NOTE
sections for more extensive examples.
The event record will be discarded if the $raw_event field matches the regular expression.
Regular expression matching can also be used for extensive parsing, by capturing sub-strings for field
assignment.
If the $raw_event field contains the regular expression, the two fields will be set to the corresponding
captured sub-strings.
Regular expression matching also supports named capturing groups. This can be useful when writing long
regular expressions. Each captured group is automatically added to the event record as a field with the same
name.
183
NXLog User Guide Chapter 24. NXLog Language
This regular expression uses the named groups TestNumber and TestName to add corresponding
$TestNumber and $TestName fields to the event record.
Regular expression substitution can be used to modify a string. In this case, the regular expression follows the
form s/pattern/replace/. The result of the expression will be assigned to the field to the left of the operator.
The first regular expression match will be removed from the $raw_event field.
Global substitution is supported with the /g modifier. Without the /g modifier, only the first match in the string
will be replaced.
Every whitespace character in the $AlertType field will be replaced with an underscore (_).
1 $AlertType =~ s/\s/_/g;
A statement can be conditionally executed according to the success of a regular expression substitution.
For more information, see the following sections in the Reference Manual: Regular Expressions, =~, and !~.
24.2.3. Fields
When NXLog receives a log message, it creates an event record for it. An event record is a set of fields (see Fields
for more information). A field is an expression which evaluates to a value with a specific type. Each field has a
name, and in the NXLog language it is represented with the dollar sign ($) prepended to the name of the field,
like Perl’s scalar variables.
Fields are only available in an evaluation context which is triggered by a log message. For example, using a value
of a field in the Exec directive of a Schedule block will result in a run-time error because the scheduled execution
is not triggered by a log message.
Because it is through fields that the NXLog language accesses the contents of an event record, they are
frequently referenced. The following examples show some common ways that fields are used in NXLog
configurations.
184
Chapter 24. NXLog Language NXLog User Guide
This statement uses assignment to set the $Department field on log messages.
1 $Department = 'customer-service';
If the $Hostname field does not match, the message will be discarded with the drop() procedure.
This statement will generate an internal event if $SeverityValue integer field is greater than 2 (NXLog
INFO severity). The generated event will include the contents of the $Message field.
24.2.4. Operations
Like other programming languages and especially Perl, the NXLog language has unary operations, binary
operations, and the conditional ternary operation. These operations are expressions and evaluate to values.
Unary Operations
Unary operations work with a single operand and evaluate to a boolean value.
This statement uses the defined operator to log a message only if the $Hostname field is defined in the
event record.
Binary Operations
Binary operations work with two operands and evaluate to a value. The type of the evaluated value depends
on the type of the operands. Execution might result in a run-time error if the type of the operands are
unknown at compile time and then evaluate to types which are incompatible with the binary operation when
executed.
This statement uses the == operator to drop the event if the $Hostname field matches.
185
NXLog User Guide Chapter 24. NXLog Language
Ternary Operation
The conditional or ternary operation requires three operands. The first is an expression that evaluates to a
boolean. The second is an expression that is evaluated if the first expression is TRUE. The third is an
expression that is evaluated if the first expression is FALSE.
This statement sets the $Important field to TRUE if $SeverityValue is greater than 2, or FALSE
otherwise. The parentheses are optional and have been added here for clarity.
For a full list of supported operations, see the Reference Manual Operations section.
24.2.5. Functions
A function is an expression which always returns a value. A function cannot be used without using its return
value. Functions can be polymorphic: the same function can take different argument types.
Many NXLog language features are provided through functions. As with other types of expressions, and unlike
procedures, a function never modifies the state of the NXLog engine, the state of the module, or the current
event.
See the list of core functions. Modules can provide additional functions for use with the NXLog language.
These statements use the now() function (returning the current time) and the hostname() function
(returning the hostname of the system running NXLog) to set fields.
1 $EventTime = now();
2 $Relay = hostname();
Here, any event with a $Message field over 4096 bytes causes an internal log to be generated.
24.3. Statements
The evaluation of a statement will usually result in a change in the state of the NXLog engine, the state of a
module, or the log message.
Statements are used with the Exec module directive. A statement is terminated by a semicolon (;).
With this input configuration, an internal NXLog log message will be generated for each message received.
nxlog.conf
1 <Input in>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 Exec log_info("Message received on UDP port 514");
6 </Input>
186
Chapter 24. NXLog Language NXLog User Guide
Multiple statements can be specified, these will be evaluated and executed in order. Statements can also be
given on multiple lines by using line continuation or by enclosing the statements in an Exec block.
This configuration generates an internal log message and sets the $File field.
nxlog.conf
1 <Input in1>
2 Module im_file
3 File '/var/log/app.log'
4 Exec log_info("App message read from log"); $File = file_name();
5 </Input>
This is the same, but the backslash (\) is used to continue the Exec directive to the next line.
nxlog.conf
1 <Input in2>
2 Module im_file
3 File '/var/log/app.log'
4 Exec log_info("App message read from log"); \
5 $File = file_name();
6 </Input>
The following configuration is functionally equivalent to the previous configuration above. However, by
creating an Exec block, multiple statements can be specified without the need for a backslash (\) line
continuation at the end of each line.
nxlog.conf
1 <Input in3>
2 Module im_file
3 File '/var/log/app.log'
4 <Exec>
5 log_info("App message read from log");
6 $File = file_name();
7 </Exec>
8 </Input>
Statements can also be executed based on a schedule by using the Exec directive of a Schedule block. The Exec
directive is slightly different in this example. Because its execution depends solely on a schedule instead of any
incoming log events, there is no event record that can be associated with it. The $File field assignment in the
example above would be impossible.
187
NXLog User Guide Chapter 24. NXLog Language
nxlog.conf
1 <Input syslog_udp>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Schedule>
6 When @hourly
7 Exec log_info("The syslog_udp input module instance is active.");
8 </Schedule>
9 </Input>
24.3.1. Assignment
Each event record is made up of fields, and assignment is the primary way that a value is written to a field in the
NXLog language. The assignment operation is declared with an equal sign (=). This operation loads the value
from the expression evaluated on the right into an event record field on the left.
This input instance uses assignment operations to add two fields to each event record.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/var/log/messages'
4 <Exec>
5 $Department = 'processing';
6 $Tier = 1;
7 </Exec>
8 </Input>
24.3.2. Block
Statements can be declared inside a block by surrounding them with curly braces ({}). A statement block in the
configuration is parsed as if it were a single statement. Blocks are typically used with conditional statements.
188
Chapter 24. NXLog Language NXLog User Guide
This statement uses a block to execute two statements if the $Message field matches.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/var/log/messages'
4 <Exec>
5 if $Message =~ /^br0:/
6 {
7 log_warning('br0 interface state changed');
8 $Tag = 'network';
9 }
10 </Exec>
11 </Input>
24.3.3. Procedures
While functions are expressions that evaluate to values, procedures are statements that perform actions. Both
functions and procedures can take arguments. Unlike functions, procedures never return values. Instead, a
procedure modifies its argument, the state of the NXLog engine, the state of a module, or the current event.
Procedures can be polymorphic: the same procedure can take different argument types.
Many NXLog language features are provided through procedures. See the list of available procedures. Modules
can provide additional procedures for use with the NXLog language.
This example uses the parse_syslog() procedure, provided by the xm_syslog module, to parse each Syslog-
formatted event record received via UDP.
nxlog.conf
1 <Input in>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 Exec parse_syslog();
6 </Input>
24.3.4. If-Else
The if or conditional statement allows a statement to be executed based on the boolean value of an expression.
When the boolean is TRUE, the statement is executed. An optional else keyword can be followed by another
statement to be executed if the boolean is FALSE.
189
NXLog User Guide Chapter 24. NXLog Language
This example uses an if statement and the drop() procedure to discard any event that matches the regular
expression.
nxlog.conf
1 <Input in1>
2 Module im_file
3 File '/var/log/messages'
4 Exec if $raw_event =~ /junk/ drop();
5 </Input>
Here, any event not matching the regular expression will be dropped.
nxlog.conf
1 <Input in2>
2 Module im_file
3 File '/var/log/messages'
4 Exec if not ($raw_event =~ /important/) drop();
5 </Input>
Finally, this statement shows more extensive use of the if statement, with an else clause and blocks defined
by curly braces ({}).
nxlog.conf
1 <Input in3>
2 Module im_file
3 File '/var/log/messages'
4 <Exec>
5 if $raw_event =~ /alert/
6 {
7 log_warning('Detected alert message');
8 }
9 else
10 {
11 log_info('Discarding non-alert message');
12 drop();
13 }
14 </Exec>
15 </Input>
24.4. Variables
While NXLog provides fields for storing data during the processing of an event, they are only available for the
duration of that event record and can not be used to store a value across multiple events. For this purpose,
module variables can be used. A variable stores a value for the module instance where it is set. It can only be
accessed from the same module where it was created: a variable with the same name is a different variable
when referenced from another module.
Each module variable can be created with an expiry value or an infinite lifetime. If an expiry is used, the variable
will be destroyed automatically when the lifetime expires. This can be used as a garbage collection method or to
reset variable values automatically.
A module variable is referenced by a string value and can store a value of any type. Module variables are
supported by all modules. See the create_var(), delete_var(), set_var(), and get_var() procedures.
190
Chapter 24. NXLog Language NXLog User Guide
If the number of login failures exceeds 3 within 45 seconds, then an internal log message is generated.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/var/log/messages'
4 <Exec>
5 if $Message =~ /login failure/
6 {
7 if not defined get_var('login_failures')
8 { # create the variable if it doesn't exist
9 create_var('login_failures', 45);
10 set_var('login_failures', 1);
11 }
12 else
13 { # increase the variable and check if it is over the limit
14 set_var('login_failures', get_var('login_failures') + 1);
15 if get_var('login_failures') >= 3
16 log_warning(">= 3 login failures within 45 seconds");
17 }
18 }
19 </Exec>
20 </Input>
The pm_evcorr module is recommended instead for this case. This algorithm does not
reliably detect failures because the lifetime of the variable is not affected by set_var(). For
example, consider login failures at 0, 44, 46, and 47 seconds. The lifetime of the variable
will be set when the first failure occurs, causing the variable to be cleared at 45 seconds.
NOTE
The variable is created with a new expiry at 46 seconds, but then only two failures are
noticed. Also, this method can only work in real-time because the timing is not based on
values available in the log message (although the event time could be stored in another
variable).
A statistical counter can be created with the create_stat() procedure call. After it is created, it can be updated with
the add_stat() procedure call. The value of the counter can be read with the get_stat() function call. Note that the
value of the statistical counter is only recalculated during these calls, rather than happening automatically. This
can result in some slight distortion of the calculated value if the add and read operations are infrequent.
A time value can also be specified during creation, updating, and reading. This makes it possible for statistical
counters to be used with offline log processing.
191
NXLog User Guide Chapter 24. NXLog Language
This input configuration uses a Schedule block and a statistical counter with the RATEMAX algorithm to
calculate the maximum rate of events over a 1 hour period. An internal log message is generated if the rate
exceeds 500 events/second at any point during the 1 hour period.
nxlog.conf
1 <Input in>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 <Exec>
6 parse_syslog();
7 if defined get_stat('eps') add_stat('eps', 1, $EventReceivedTime);
8 </Exec>
9 <Schedule>
10 Every 1 hour
11 <Exec>
12 create_stat('eps', 'RATEMAX', 1, now(), 3600);
13 if get_stat('eps') > 500
14 log_info('Inbound TCP rate peaked at ' + get_stat('eps')
15 + ' events/second during the last hour');
16 </Exec>
17 </Schedule>
18 </Input>
192
Chapter 25. Reading and Receiving Logs NXLog User Guide
UDP
The im_udp module handles incoming messages over UDP.
This input module instance shows the im_udp module configured with the default options: localhost
only and port 514.
nxlog.conf
1 <Input udp>
2 Module im_udp
3 Host localhost
4 Port 514
5 </Input>
The UDP protocol does not guarantee reliable message delivery. It is recommended to use
the TCP or SSL transport modules instead if message loss is a concern.
NOTE
Though NXLog was designed to minimize message loss even in the case of UDP, adjusting
the kernel buffers may reduce the likelihood of UDP message loss on a system under heavy
load. The Priority directive in the Route block can also help.
TCP
The im_tcp module handles incoming messages over TCP. For TLS/SSL, use the im_ssl module.
This input module instance accepts TCP connections from any host on port 1514.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 </Input>
SSL/TLS
The im_ssl module handles incoming messages over TCP with SSL/TLS security.
193
NXLog User Guide Chapter 25. Reading and Receiving Logs
The following input module instance listens for SSL/TLS encrypted incoming logs on port 6514. The
certificate file paths are specified relative to a previously defined CERTDIR.
nxlog.conf
1 <Input in>
2 Module im_ssl
3 Host 0.0.0.0
4 Port 6514
5 CAFile %CERTDIR%/ca.pem
6 CertFile %CERTDIR%/client-cert.pem
7 CertKeyFile %CERTDIR%/client-key.pem
8 </Input>
Syslog
To receive Syslog over the network, use one of the network modules above, coupled with xm_syslog. Syslog
parsing is not required if you only need to forward or store the messages as they are. See also Accepting
Syslog via UDP, TCP, or TLS.
With this example configuration, NXLog listens for messages on TCP port 1514. The xm_syslog extension
module provides the Syslog_TLS InputType (for octet-framing) and the parse_syslog() procedure for
parsing Syslog messages.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 1514
9 # "Syslog_TLS" is for octet framing and may be used with TLS/SSL
10 InputType Syslog_TLS
11 Exec parse_syslog();
12 </Input>
194
Chapter 25. Reading and Receiving Logs NXLog User Guide
This example uses libdbi and the MySQL driver to read records from the logdb database.
nxlog.conf
1 <Input in>
2 Module im_dbi
3 Driver mysql
4 Option host 127.0.0.1
5 Option username mysql
6 Option password mysql
7 Option dbname logdb
8 SQL SELECT id, facility, severity, hostname, timestamp, application, \
9 message FROM log
10 </Input>
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString DSN=mssql;database=mydb;
4 SQL SELECT RecordNumber as id, DateOccured as EventTime, \
5 data as Message from logtable WHERE RecordNumber > ?
6 </Input>
This example reads from the specified file without performing any additional processing.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/var/log/messages"
4 </Input>
195
NXLog User Guide Chapter 25. Reading and Receiving Logs
With this configuration, NXLog will read messages from the /dev/log socket. NXLog’s flow control
feature must be disabled in this case (see the FlowControl directive in the Reference Manual).
nxlog.conf
1 <Input in>
2 Module im_uds
3 UDS /dev/log
4 FlowControl FALSE
5 </Input>
This example uses the tail command to read messages from a file.
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input in>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/log/messages
6 </Input>
196
Chapter 26. Processing Logs NXLog User Guide
The following sections provide configuration examples for parsing log formats commonly used by applications.
Field Description
authuser Username of the user accessing the document (not applicable for public documents)
197
NXLog User Guide Chapter 26. Processing Logs
This configuration uses a regular expression to parse the fields in each record. The parsedate() function is
used to convert the timestamp string into a datetime type for later processing or conversion as required.
nxlog.conf
<Input access_log>
Module im_file
File "/var/log/apache2/access.log"
<Exec>
if $raw_event =~ /(?x)^(\S+)\ \S+\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
\ HTTP\/\d\.\d\"\ (\S+)\ (\S+)/
{
$Hostname = $1;
if $2 != '-' $AccountName = $2;
$EventTime = parsedate($3);
$HTTPMethod = $4;
$HTTPURL = $5;
$HTTPResponseStatus = $6;
if $7 != '-' $FileSize = $7;
}
</Exec>
</Input>
198
Chapter 26. Processing Logs NXLog User Guide
This example is like the previous one, except it parses the two additional fields unique to the Combined Log
Format. An om_file instance is also shown here which has been configured to discard all events not related
to the user john and write the remaining events to a file in JSON format.
nxlog.conf
<Extension _json>
Module xm_json
</Extension>
<Input access_log>
Module im_file
File "/var/log/apache2/access.log"
<Exec>
if $raw_event =~ /(?x)^(\S+)\ \S+\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
\ HTTP\/\d\.\d\"\ (\S+)\ (\S+)\ \"([^\"]+)\"
\ \"([^\"]+)\"/
{
$Hostname = $1;
if $2 != '-' $AccountName = $2;
$EventTime = parsedate($3);
$HTTPMethod = $4;
$HTTPURL = $5;
$HTTPResponseStatus = $6;
if $7 != '-' $FileSize = $7;
if $8 != '-' $HTTPReferer = $8;
if $9 != '-' $HTTPUserAgent = $9;
}
</Exec>
</Input>
<Output out>
Module om_file
File '/var/log/john_access.log'
<Exec>
if not (defined($AccountName) and ($AccountName == 'john')) drop();
to_json();
</Exec>
</Output>
For information about using the Common and Combined Log Formats with the Apache HTTP Server, see Apache
HTTP Server.
199
NXLog User Guide Chapter 26. Processing Logs
This example shows a Syslog event as it is received via UDP and processed by the parse_syslog() procedure.
Syslog Message
<38>Nov 22 10:30:12 myhost sshd[8459]: Failed password for invalid user linda from 192.168.1.60
port 38176 ssh2↵
The following configuration loads the xm_syslog extension module and then uses the Exec directive to
execute the parse_syslog() procedure for each event.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 Exec parse_syslog();
10 </Input>
11
12 <Output out>
13 Module om_null
14 </Output>
This results in the following fields being added to the event record by parse_syslog().
Field Value
$Message Failed password for invalid user linda from 192.168.1.60 port 38176 ssh2
$SyslogSeverityValue 6
$SyslogSeverity INFO
$SeverityValue 2
$Severity INFO
$SyslogFacilityValue 4
$SyslogFacility AUTH
$Hostname myhost
$SourceName sshd
$ProcessID 8459
200
Chapter 26. Processing Logs NXLog User Guide
This example reads from the input file and parses it with the parse_csv() procedure from the csv1 instance
where the field names, types, and order within the record are defined. The $date field is then set to the
current time and the $number field is set to 0 if it is not already defined. Finally, the to_csv() procedure from
the csv2 instance is used to generate output with the additional date field, a different delimiter, and a
different field order.
nxlog.conf
1 <Extension csv1>
2 Module xm_csv
3 Fields $id, $name, $number
4 FieldTypes integer, string, integer
5 Delimiter ,
6 </Extension>
7
8 <Extension csv2>
9 Module xm_csv
10 Fields $id, $number, $name, $date
11 Delimiter ;
12 </Extension>
13
14 <Input filein>
15 Module im_file
16 File "/tmp/input"
17 <Exec>
18 csv1->parse_csv();
19 $date = now();
20 if not defined $number $number = 0;
21 csv2->to_csv();
22 </Exec>
23 </Input>
24
25 <Output fileout>
26 Module om_file
27 File "/tmp/output"
28 </Output>
Input Sample
1, "John K.", 42
2, "Joe F.", 43
Output Sample
1;42;"John K.";2011-01-15 23:45:20
2;43;"Joe F.";2011-01-15 23:45:20
26.1.4. JSON
The xm_json module provides procedures for generating and parsing log data in JSON format.
201
NXLog User Guide Chapter 26. Processing Logs
This example reads JSON-formatted data from file with the im_file module. Then the parse_json() procedure
is used to parse the data, setting each JSON field to a field in the event record.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/app.json"
8 Exec parse_json();
9 </Input>
Here, the to_json() procedure is used to write all the event record fields to $raw_event in JSON format. This
is then written to file using the om_file module.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File "/var/log/json.log"
8 Exec to_json();
9 </Output>
Log Sample
#Version: 1.0↵
#Date: 2011-07-01 00:00:00↵
#Fields: date time cs-method cs-uri↵
2011-07-01 00:34:23 GET /foo/bar1.html↵
2011-07-01 12:21:16 GET /foo/bar2.html↵
2011-07-01 12:45:52 GET /foo/bar3.html↵
2011-07-01 12:57:34 GET /foo/bar4.html↵
202
Chapter 26. Processing Logs NXLog User Guide
This configuration reads the W3C format log file and parses it with the xm_w3c module. The fields in the
event record are converted to JSON and the logs are forwarded via TCP.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension w3c_parser>
6 Module xm_w3c
7 </Extension>
8
9 <Input w3c>
10 Module im_file
11 File '/var/log/httpd-log'
12 InputType w3c_parser
13 </Input>
14
15 <Output tcp>
16 Module om_tcp
17 Host 192.168.12.1
18 Port 1514
19 Exec to_json();
20 </Output>
The W3C format can also be parsed with the xm_csv module if using NXLog Community Edition.
203
NXLog User Guide Chapter 26. Processing Logs
The following configuration reads a W3C file and tokenizes it with the CSV parser. Header lines starting with
a leading hash mark (#) are ignored. The $EventTime field is set from the parsed date and time fields.
The fields in the xm_csv module instance below must be updated to correspond with the
NOTE
fields in the W3C file to be parsed.
nxlog.conf
1 <Extension w3c_parser>
2 Module xm_csv
3 Fields $date, $time, $HTTPMethod, $HTTPURL
4 FieldTypes string, string, string, string
5 Delimiter ' '
6 EscapeChar '"'
7 QuoteChar '"'
8 EscapeControl FALSE
9 UndefValue -
10 </Extension>
11
12 <Extension _json>
13 Module xm_json
14 </Extension>
15
16 <Input w3c>
17 Module im_file
18 File '/var/log/httpd-log'
19 <Exec>
20 if $raw_event =~ /^#/ drop();
21 else
22 {
23 w3c_parser->parse_csv();
24 $EventTime = parsedate($date + " " + $time);
25 }
26 </Exec>
27 </Input>
26.1.6. XML
The xm_xml module can be used for generating and parsing structured data in XML format.
This configuration uses the im_file module to read from file. Then the parse_xml() procedure parses the
XML into fields in the event record.
nxlog.conf
1 <Extension _xml>
2 Module xm_xml
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/app.xml"
8 Exec parse_xml();
9 </Input>
204
Chapter 26. Processing Logs NXLog User Guide
Here, the fields in the event record are used by the to_xml() procedure to generate XML, which is then
written to file by the om_file module.
nxlog.conf
1 <Extension _xml>
2 Module xm_xml
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File "/var/log/logs.xml"
8 Exec to_xml();
9 </Output>
26.2. Alerting
NXLog can be configured to generate alerts when specific conditions are met. Here are some ways alerting could
be implemented.
In this example Output, all messages not matching the regular expression are dropped, and remaining
messages are piped to a custom alerter script.
nxlog.conf
1 <Output out>
2 Module om_exec
3 Command /usr/local/sbin/alerter
4 Arg -
5 Exec if not ($raw_event =~ /alertcondition/) drop();
6 </Output>
Without the Exec directive above, all messages received by the module would be passed to the alerter
script as defined by the Command directive. The optional Arg directive passes its value to the Command
script.
205
NXLog User Guide Chapter 26. Processing Logs
In this example Input, each message matching the regular expression is piped to a new instance of
alerter, which is executed asynchronously (does not block additional processing by the calling module).
nxlog.conf
1 <Extension _exec>
2 Module xm_exec
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 1514
9 <Exec>
10 if $raw_event =~ /alertcondition/
11 exec_async("/usr/local/sbin/alerter");
12 </Exec>
13 </Input>
In this example, an email is sent using exec_async() when the regular expression condition is met.
nxlog.conf
1 <Extension _exec>
2 Module xm_exec
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 1514
9 <Exec>
10 if $raw_event =~ /alertcondition/
11 {
12 exec_async("/bin/sh", "-c", 'echo "' + $Hostname + '\n\nRawEvent:\n' +
13 $raw_event + '"|/usr/bin/mail ' +
14 '-a "Content-Type: text/plain; charset=UTF-8" ' +
15 '-s "ALERT" user@domain.com');
16 }
17 </Exec>
18 </Input>
NOTE DEBUG level events are not generated by the im_internal module.
206
Chapter 26. Processing Logs NXLog User Guide
If a message matches the regular expression, an internal log event is generated with level WARNING.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/var/log/app.log"
4 Exec if $raw_event =~ /alertcondition/ log_warning("ALERT");
5 </Input>
This example shows the default read and write buffers used by NXLog for a simple route. Each buffer is
limited to 65,000 bytes.
nxlog.conf
1 <Input file>
2 Module im_file
3 File '/tmp/in.log'
4
5 # Set read buffer size, in bytes (default)
6 BufferSize 65000
7 </Input>
8
9 <Output tcp>
10 Module om_tcp
11 Host 192.168.1.1
12
13 # Set write buffer size, in bytes (default)
14 BufferSize 65000
15 </Output>
16
17 <Route r>
18 Path file => tcp
19 </Route>
207
NXLog User Guide Chapter 26. Processing Logs
The size of a module instance’s log queue can be configured with the LogqueueSize directive.
This example shows the default log queue used by NXLog in a simple route. Up to 100 events will be placed
in the queue to be processed by the om_batchcompress instance.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 </Input>
4
5 <Output batch>
6 Module om_batchcompress
7 Host 192.168.2.1
8
9 # Set log queue size, in events (default)
10 LogqueueSize 100
11 </Output>
12
13 <Route r>
14 Path eventlog => batch
15 </Route>
By default, log queues are stored in memory. NXLog can be configured to persist log queues to disk with the
PersistLogqueue directive. NXLog will further sync all writes to a disk-based queue with SyncLogqueue. These
directives can be used to prevent data loss in case of interrupted processing—at the expense of reduced
performance—and can be used both globally or for a particular module. For more information, see Reliable
Message Delivery.
Any events remaining in the log queue will be written to disk when NXLog is stopped, regardless
NOTE
of the value of PersistLogqueue.
208
Chapter 26. Processing Logs NXLog User Guide
In this example, the om_elasticsearch instance is configured with a persistent and synced log queue. Each
time an event is added to the log queue, the event will be written to disk and synced before processing
continues.
nxlog.conf
1 <Input acct>
2 Module im_acct
3 </Input>
4
5 <Output elasticsearch>
6 Module om_elasticsearch
7 URL http://192.168.2.2:9200/_bulk
8
9 # Set log queue size, in events (default)
10 LogqueueSize 100
11
12 # Use persistent and synced log queue
13 PersistLogqueue TRUE
14 SyncLogqueue TRUE
15 </Output>
16
17 <Route r>
18 Path acct => elasticsearch
19 </Route>
1. a processor or output module instance is not able to process log data at the incoming rate,
2. that module instance’s log queue becomes full, and
3. the input or processor module instance responsible for feeding the log queue has flow control enabled.
In this case, flow control will cause the input or processor module instance to suspend processing until the
succeeding module instance is ready to accept more log data.
209
NXLog User Guide Chapter 26. Processing Logs
This example shows the NXLog’s default flow control behavior with a basic route. Events are collected from
the Windows Event Log with im_msvistalog and forwarded with om_tcp. The om_tcp instance will be blocked
if the destination is unreachable or the network can not handle the events quickly enough.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3
4 # Flow control enabled (default)
5 FlowControl TRUE
6 </Input>
7
8 <Output tcp>
9 Module om_tcp
10 Host 192.168.1.1
11 </Output>
12
13 <Route r>
14 Path eventlog => tcp
15 </Route>
The om_tcp instance is unable to connect to the destination host and its log queue is full. Because the
im_msvistalog instance has flow control enabled and the next module in the route is blocked, it has been
paused. No events will be read from the Event Log until the tcp instance becomes unblocked.
Flow control is enabled by default, and can be set globally or for a particular module instance with the
FlowControl directive. Generally, flow control provides automatic, zero-configuration handling of cases where
buffering would otherwise be required. However, there are some situations where flow control should be
disabled and buffering should be explicitly configured as required.
210
Chapter 26. Processing Logs NXLog User Guide
In this example, Linux Audit messages are collected with im_linuxaudit and forwarded with om_http. Flow
control is disabled for im_linuxaudit to prevent processes from being blocked due to an Audit backlog. To
avoid loss of log data in this case, the LogqueueSize directive could be used as shown in Increasing the Log
Queue Size to Protect Against UDP Message Loss.
nxlog.conf
1 <Input audit>
2 Module im_linuxaudit
3 <Rules>
4 -D
5 -w /etc/passwd -p wa -k passwd
6 </Rules>
7
8 # Disable flow control to prevent Audit backlog
9 FlowControl FALSE
10 </Input>
11
12 <Output http>
13 Module om_http
14 URL http://192.168.2.1:8080/
15 </Output>
16
17 <Route r>
18 Path audit => http
19 </Route>
The om_http instance is unable to forward log data, and its log queue is full. Because it has flow control
disabled, the im_linuxaudit instance remains active and continues to process log data. However, all events
will be discarded until the om_http log queue is no longer full.
211
NXLog User Guide Chapter 26. Processing Logs
In a disk-based pm_buffer instance, events are not written to disk unless the log queue of the
succeeding module instance is full. For this reason, a disk-based pm_buffer instance does not
NOTE reduce peformance in the way that a persistent log queue does. Additionally, pm_buffer (and
other processor modules) should not be used if crash-safe processing is required; see Reliable
Message Delivery.
This example shows a route with a large disk-based buffer provided by the pm_buffer module. A warning
message will be generated when the buffer size crosses the threshold specified.
nxlog.conf
1 <Input udp>
2 Module im_udp
3 </Input>
4
5 <Processor buffer>
6 Module pm_buffer
7 Type Disk
8
9 # 40 MiB buffer
10 MaxSize 40960
11
12 # Generate warning message at 20 MiB
13 WarnLimit 20480
14 </Processor>
15
16 <Output ssl>
17 Module om_ssl
18 Host 10.8.0.2
19 CAFile %CERTDIR%/ca.pem
20 CertFile %CERTDIR%/client-cert.pem
21 CertKeyFile %CERTDIR%/client-key.pem
22 </Output>
23
24 <Route r>
25 Path udp => buffer => ssl
26 </Route>
• The UDP modules (im_udp, om_udp, and om_udpspoof) can be configured to set the socket buffer size
(SO_RCVBUF or SO_SNDBUF) with the respective SockBufSize directive.
212
Chapter 26. Processing Logs NXLog User Guide
• The external program and scripting support found in some modules (like im_exec, im_perl, im_python,
im_ruby, om_exec, om_perl, om_python, and om_ruby) can be used to implement custom buffering
solutions.
• Some modules (such as om_batchcompress, om_elasticsearch, and om_webhdfs) buffer events internally in
order to forward events in batches.
• The pm_blocker module can be used to programmatically block or unblock the log flow in a route, and in this
way control buffering. Or it can be used to test buffering.
• The om_blocker module can be used to test buffering behavior by simulating a blocked output.
The following diagram shows all buffers used in a simple im_udp => om_tcp route. The socket buffers are
only applicable to networking modules.
213
NXLog User Guide Chapter 26. Processing Logs
Example 80. Increasing the Log Queue Size to Protect Against UDP Message Loss
In this configuration, log messages are accepted with im_udp and forwarded with om_tcp. The log queue
size of the output module instance is increased to 5000 events to buffer messages in case the output
becomes blocked. To further reduce the risk of data loss, the socket buffer size is increased with the
SockBufSize directive and the route priority is increased with Priority.
nxlog.conf
1 <Input udp>
2 Module im_udp
3
4 # Raise socket buffer size
5 SockBufSize 150000000
6 </Input>
7
8 <Output tcp>
9 Module om_tcp
10 Host 192.168.1.1
11
12 # Keep up to 5000 events in the log queue
13 LogqueueSize 5000
14 </Output>
15
16 <Route udp_to_tcp>
17 Path udp => tcp
18
19 # Process events in this route first
20 Priority 1
21 </Route>
The output is blocked because the network is not able to handle the log data quickly enough.
214
Chapter 26. Processing Logs NXLog User Guide
Example 81. Using a pm_buffer Instance to Protect Against UDP Message Loss
Instead of raising the size of the log queue, this example uses a memory-based pm_buffer instance to
buffer events when the output becomes blocked. A warning message will be generated if the buffer size
exceeds the specified WarnLimit threshold.
nxlog.conf
1 <Input udp>
2 Module im_udp
3
4 # Raise socket buffer size
5 SockBufSize 150000000
6 </Input>
7
8 <Processor buffer>
9 Module pm_buffer
10 Type Mem
11
12 # 5 MiB buffer
13 MaxSize 5120
14
15 # Warn at 2 MiB
16 WarnLimit 2048
17 </Processor>
18
19 <Output http>
20 Module om_http
21 URL http://10.8.1.1:8080/
22 </Output>
23
24 <Route udp_to_http>
25 Path udp => buffer => http
26
27 # Process events in this route first
28 Priority 1
29 </Route>
The HTTP destination is unreachable, the http instance log queue is full, and the buffer instance is filling.
With flow control disabled, events will be discarded if the route becomes blocked and the route’s log queues
become full. To reduce the risk of lost log data, the log queue size of a succeeding module instance in the route
can be increased. Alternatively, a pm_buffer instance can be used as in the second UDP example above.
215
NXLog User Guide Chapter 26. Processing Logs
This configuration uses the im_uds module to collect Syslog messages from the /dev/log socket, and the
xm_syslog parse_syslog() procedure to parse them.
To prevent the syslog() system call from blocking as a result of the im_uds instance being suspended, the
FlowControl directive is set to FALSE. The LogqueueSize directive raises the log queue limit of the output
instance to 5000 events. The Priority directive indicates that this route’s events should be processed first.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input dev_log>
6 Module im_uds
7 UDS /dev/log
8 Exec parse_syslog();
9
10 # This module instance must never be suspended
11 FlowControl FALSE
12 </Input>
13
14 <Output elasticsearch>
15 Module om_elasticsearch
16 URL http://192.168.2.1:9022/_bulk
17
18 # Keep up to 5000 events in the log queue
19 LogqueueSize 5000
20 </Output>
21
22 <Route syslog_to_elasticsearch>
23 Path dev_log => elasticsearch
24
25 # Process events in this route first
26 Priority 1
27 </Route>
The Elasticsearch server is unreachable and the log queue is filling. If the log queue becomes full, events
will be discarded.
216
Chapter 26. Processing Logs NXLog User Guide
This configuration reads log messages from a file with im_file and forwards them with om_tcp. No extra
buffering is necessary because flow control is enabled.
nxlog.conf
1 <Input file>
2 Module im_file
3 File '/tmp/in.log'
4
5 # Enable flow control (default)
6 FlowControl TRUE
7
8 # Save file position on exit (default)
9 SavePos TRUE
10 </Input>
11
12 <Output tcp>
13 Module om_tcp
14 Host 10.8.0.2
15 </Output>
16
17 <Route r>
18 Path file => tcp
19 </Route>
The TCP destination is unreachable, and the im_file instance is paused. No messages will be read from the
source file until the om_tcp instance becomes unblocked.
Sometimes, however, there is a risk of the input log file becoming inaccessible while the im_file instance is
suspended (due to log rotation, for example). In this case, the tcp log queue size can be increased (or a
pm_buffer instance added) to buffer more events.
217
NXLog User Guide Chapter 26. Processing Logs
In this example, log messages are read from a file with im_file and forwarded with om_tcp. The om_tcp log
queue size has been increased in order to buffer more events because the source file may be rotated away.
nxlog.conf
1 <Input file>
2 Module im_file
3 File '/tmp/in.log'
4 </Input>
5
6 <Output tcp>
7 Module om_tcp
8 Host 192.168.1.1
9
10 # Keep up to 2000 events in the log queue
11 LogqueueSize 2000
12 </Output>
13
14 <Route r>
15 Path file => tcp
16 </Route>
The TCP destination is unreachable and the om_tcp instance is blocked. The im_file instance will continue to
read from the file (and events will accumulate) until the tcp log queue is full; then it will be paused.
218
Chapter 26. Processing Logs NXLog User Guide
This example sends UDP input to two outputs, a file and an HTTP destination. If the HTTP transmission is
slower than the rate of incoming UDP packets or the destination is unreachable, flow control would
normally pause the im_udp instance. This would result in dropped UDP packets. In this situation it is better
to selectively drop log messages in the HTTP route than to lose them entirely. This can be accomplished by
simply disabling flow control for the input module instance.
This configuration will also continue to send events to the HTTP destination in the unlikely
event that the om_file output blocks. In fact, the input will remain active even if both
NOTE
outputs block (though in this particular case, because UDP is lossy, messages will be lost
regardless of whether the im_udp instance is suspended).
nxlog.conf
1 <Input udp>
2 Module im_udp
3
4 # Never pause this instance
5 FlowControl FALSE
6 </Input>
7
8 <Output http>
9 Module om_http
10 URL http://10.0.0.3:8080/
11
12 # Increase the log queue size
13 LogqueueSize 2000
14 </Output>
15
16 <Output file>
17 Module om_file
18 File '/tmp/out.log'
19 </Output>
20
21 <Route udp_to_tcp>
22 Path udp => http, file
23 </Route>
The HTTP destination cannot accept events quickly enough. The om_http instance is blocked and its log
queue is full. New events are not being added to the HTTP output queue but are still being written to the
output file.
219
NXLog User Guide Chapter 26. Processing Logs
In this example, process accounting logs collected by im_acct are both forwarded via TCP and written to file.
A separate route is used for each output. A pm_buffer instance is used in the TCP route, and it is configured
to discard events with drop() if its size goes beyond a certain threshold. Thus, the pm_buffer instance will
never become full and will never cause the im_acct instance to pause—events will always be written to the
output file.
Because the im_acct instance has flow control enabled, it will be paused if the om_file
NOTE
output becomes blocked.
nxlog.conf
1 <Input acct>
2 Module im_acct
3
4 # Flow control enabled (default)
5 FlowControl TRUE
6 </Input>
7
8 <Processor buffer>
9 Module pm_buffer
10 Type Mem
11 MaxSize 1000
12 WarnLimit 800
13 Exec if buffer_size() >= 80k drop();
14 </Processor>
15
16 <Output tcp>
17 Module om_tcp
18 Host 192.168.1.1
19 </Output>
20
21 <Output file>
22 Module om_file
23 File '/tmp/out.log'
24 </Output>
25
26 <Route udp_to_tcp>
27 Path acct => buffer => tcp
28 </Route>
29
30 <Route udp_to_file>
31 Path acct => file
32 </Route>
The TCP destination is unreachable and the om_tcp log queue is full. Input accounting events will be added
to the buffer until it gets full, then they will be discarded. Input events will also be written to the output file,
regardless of whether the buffer is full.
220
Chapter 26. Processing Logs NXLog User Guide
221
NXLog User Guide Chapter 26. Processing Logs
This example collects log messages via UDP and forwards them to a remote NXLog agent. However, events
are buffered with pm_buffer during the week and only forwarded on weekends.
• During the week, the pm_blocker instance is blocked and events accumulate in the large on-disk buffer.
• During the weekend, the pm_blocker instance is unblocked and all events, including those that have
accumulated in the buffer, are forwarded.
nxlog.conf (truncated)
1 <Input udp>
2 Module im_udp
3 Host 0.0.0.0
4 </Input>
5
6 <Processor buffer>
7 Module pm_buffer
8
9 # 500 MiB disk buffer
10 Type Disk
11 MaxSize 512000
12 WarnLimit 409600
13 </Processor>
14
15 <Processor schedule>
16 Module pm_blocker
17 <Schedule>
18 # Start blocking Monday morning
19 When 0 0 * * 1
20 Exec schedule->block(TRUE);
21 </Schedule>
22 <Schedule>
23 # Stop blocking Saturday morning
24 When 0 0 * * 6
25 Exec schedule->block(FALSE);
26 </Schedule>
27 </Processor>
28 [...]
222
Chapter 26. Processing Logs NXLog User Guide
If it is possible to use flow control with the log sources, then it is not necessary to use extra buffering. Instead,
the inputs will be paused and read later when the route is unblocked.
223
NXLog User Guide Chapter 26. Processing Logs
This configuration reads events from the Windows Event Log and forwards them to a remote NXLog agent
in compressed batches with om_batchcompress. However, events are only forwarded during the night.
Because the im_msvistalog instance can be paused and events will still be available for collection later, it is
not necessary to configure any extra buffering.
• During the day, the pm_blocker instance is blocked, the output log queue becomes full, and the
eventlog instance is paused.
• During the night, the pm_blocker instance is unblocked. The events in the schedule log queue are
processed, the eventlog instance is resumed, and all pending events are read from the Event Log and
forwarded.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 </Input>
4
5 <Processor schedule>
6 Module pm_blocker
7 <Schedule>
8 # Start blocking at 7:00
9 When 0 7 * * *
10 Exec schedule->block(TRUE);
11 </Schedule>
12 <Schedule>
13 # Stop blocking at 19:00
14 When 0 19 * * *
15 Exec schedule->block(FALSE);
16 </Schedule>
17 </Processor>
18
19 <Output batch>
20 Module om_batchcompress
21 Host 10.3.0.211
22 </Output>
23
24 <Route scheduled_batches>
25 Path eventlog => schedule => batch
26 </Route>
The current time is within the specified "day" interval and pm_blocker is blocked.
224
Chapter 26. Processing Logs NXLog User Guide
This configuration shows an example of character set auto-detection. The input file may contain differently
encoded lines, but by invoking the convert_fields() procedure, each message will have the character set
encoding of its fields detected and then converted to UTF-8 as needed.
nxlog.conf
1 <Extension _charconv>
2 Module xm_charconv
3 AutodetectCharsets utf-8, euc-jp, utf-16, utf-32, iso8859-2
4 </Extension>
5
6 <Input filein>
7 Module im_file
8 File "tmp/input"
9 Exec convert_fields("auto", "utf-8");
10 </Input>
11
12 <Output fileout>
13 Module om_file
14 File "tmp/output"
15 </Output>
16
17 <Route r>
18 Path filein => fileout
19 </Route>
The im_mark module is designed as means of monitoring the health of the NXLog agent by
NOTE
generating "mark" messages every 30 minutes. The message text and interval are configurable.
The solution to this problem is the combined use of statistical counters and Scheduled checks. The input module
can update a statistical counter configured to calculate events per hour. In the same input module a Schedule
block checks the value of the statistical counter periodically. When the event rate is zero or drops below a certain
limit, an appropriate action can be executed such as sending out an alert email or generating an internal warning
message. Note that there are other ways to address this issue and this method may not be optimal for all
situations.
225
NXLog User Guide Chapter 26. Processing Logs
The following configuration example creates a statistical counter in the context of the im_tcp module to
calculate the number of events received per hour. The Schedule block within the context of the same
module checks the value of the msgrate statistical counter and generates an internal error message when
no logs have been received within the last hour.
nxlog.conf
1 <Input in>
2 Module im_tcp
3 Port 2345
4 <Exec>
5 create_stat("msgrate", "RATE", 3600);
6 add_stat("msgrate", 1);
7 </Exec>
8 <Schedule>
9 Every 3600 sec
10 <Exec>
11 create_stat("msgrate", "RATE", 10);
12 add_stat("msgrate", 0);
13 if defined get_stat("msgrate") and get_stat("msgrate") <= 1
14 log_error("No messages received from the source!");
15 </Exec>
16 </Schedule>
17 </Input>
A dedicated NXLog module, pm_evcorr, is available for advanced correlation requirements. It provides features
similar to those of SEC and greatly enhances the correlation capabilities of NXLog.
226
Chapter 26. Processing Logs NXLog User Guide
The following configuration provides samples for each type of rule: Absence, Pair, Simple, Suppressed, and
Thresholded.
nxlog.conf (truncated)
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4
5 <Simple>
6 Exec if $Message =~ /^simple/ $raw_event = "got simple";
7 </Simple>
8
9 <Suppressed>
10 # Match input event and execute an action list, but ignore the following
11 # matching events for the next t seconds.
12 Condition $Message =~ /^suppressed/
13 Interval 30
14 Exec $raw_event = "suppressing..";
15 </Suppressed>
16
17 <Pair>
18 # If TriggerCondition is true, wait Interval seconds for RequiredCondition
19 # to be true and then do the Exec. If Interval is 0, there is no window on
20 # matching.
21 TriggerCondition $Message =~ /^pair-first/
22 RequiredCondition $Message =~ /^pair-second/
23 Interval 30
24 Exec $raw_event = "got pair";
25 </Pair>
26
27 <Absence>
28 # If TriggerCondition is true, wait Interval seconds for RequiredCondition
29 [...]
Some log sources (like Windows EventLog collected via im_msvistalog) already contain structured data. In this
case, there is often no additional extraction required; see Message Classification.
227
NXLog User Guide Chapter 26. Processing Logs
Syslog Message
<38>Nov 22 10:30:12 myhost sshd[8459]: Failed password for invalid user linda from 192.168.1.60
port 38176 ssh2↵
With this configuration, the Syslog message shown above is first parsed with parse_syslog(). This results in a
$Message field created in the event record. Then, a regular expression is used to further parse the
$Message field and create additional fields if it matches.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 <Exec>
10 parse_syslog();
11 if $Message =~ /(?x)^Failed\ (\S+)\ for(?:\ invalid user)?\ (\S+)\ from
12 \ (\S+)\ port\ \d+\ ssh2$/
13 {
14 $AuthMethod = $1;
15 $AccountName = $2;
16 $SourceIPAddress = $3;
17 }
18 </Exec>
19 </Input>
Named capturing is supported also. Each captured group is automatically added to the event record as a
field with the same name.
nxlog.conf
1 <Input in>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 $Message =~ /(?x)^Failed\ (?<AuthMethod>\S+)\ for(?:\ invalid\ user)?
8 \ (?<AccountName>\S+)\ from\ (?<SourceIPAddress>\S+)\ port
9 \ \d+\ ssh2$/;
10 </Exec>
11 </Input>
Field Value
$AuthMethod password
$AccountName linda
$SourceIPAddress 192.168.1.60
228
Chapter 26. Processing Logs NXLog User Guide
The examples below demonstrate how to parse Apache messages using Grok patterns.
The above Apache message can be parsed using the Grok pattern below.
The above Apache message can be parsed using the Grok pattern below.
Lists of Grok patterns are available in various repositories. As an example, see the logstash-plugin section on
Github.
229
NXLog User Guide Chapter 26. Processing Logs
The following configuration reads messages from the apache_entries.log file using the im_file module
and stores the result in the $raw_event field.
The match_grok() function reads patterns from the patterns.txt file and attempts a series of matches on
the $raw_event field. If none of the patterns match, an internal message is logged.
nxlog.conf
1 <Extension grok>
2 Module xm_grok
3 Pattern patterns.txt
4 </Extension>
5
6 <Input messages>
7 Module im_file
8 File "apache_entries.log"
9 <Exec>
10 if not ( match_grok($raw_event, "%{ACCESS_LOG}") or
11 match_grok($raw_event, "%{ERROR_LOG}"))
12 {
13 log_info('Event did not match any pattern');
14 }
15 </Exec>
16 </Input>
This example uses the patterns.txt file, which contains all necessary Grok patterns.
patterns.txt
INT (?:[+-]?(?:[0-9]+))
YEAR (?>\d\d){1,2}
MONTH
\b(?:[Jj]an(?:uary|uar)?|[Ff]eb(?:ruary|ruar)?|[Mm](?:a|ä)?r(?:ch|z)?|[Aa]pr(?:il)?|[Mm]a(?:y|i
)?|[Jj]un(?:e|i)?|[Jj]ul(?:y)?|[Aa]ug(?:ust)?|[Ss]ep(?:tember)?|[Oo](?:c|k)?t(?:ober)?|[Nn]ov(?
:ember)?|[Dd]e(?:c|z)(?:ember)?)\b
DAY
(?:Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?)
HOUR (?:2[0123]|[01]?[0-9])
MINUTE (?:[0-5][0-9])
SECOND (?:(?:[0-5]?[0-9]|60)(?:[:.,][0-9]+)?)
UNIXPATH (/([\w_%!$@:.,+~-]+|\\.)*)+
GREEDYDATA .*
IP (?<![0-9])(?:(?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])[.](?:[0-1]?[0-9]{1,2}|2[0-4][0-
9]|25[0-5])[.](?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])[.](?:[0-1]?[0-9]{1,2}|2[0-4][0-9]|25[0-
5]))(?![0-9])
LOGLEVEL
([Aa]lert|ALERT|[Tt]race|TRACE|[Dd]ebug|DEBUG|[Nn]otice|NOTICE|[Ii]nfo|INFO|[Ww]arn?(?:ing)?|WA
RN?(?:ING)?|[Ee]rr?(?:or)?|ERR?(?:OR)?|[Cc]rit?(?:ical)?|CRIT?(?:ICAL)?|[Ff]atal|FATAL|[Ss]ever
e|SEVERE|EMERG(?:ENCY)?|[Ee]merg(?:ency)?)
TIMESTAMP_ACCESS %{INT}\/%{MONTH}\/%{YEAR}(:%{HOUR}:%{MINUTE}:%{SECOND} %{GREEDYDATA})?
TIMESTAMP_ERROR %{DAY} %{MONTH} %{INT} %{HOUR}:%{MINUTE}:%{SECOND} %{YEAR}
METHOD (GET|POST|PUT|DELETE|HEAD|TRACE|OPTIONS|CONNECT|PATCH){1}
HTTP_VERSION 1.(0|1)
230
Chapter 26. Processing Logs NXLog User Guide
231
NXLog User Guide Chapter 26. Processing Logs
Syslog Message
<38>Nov 22 10:30:12 myhost sshd[8459]: Failed password for invalid user linda from 192.168.1.60
port 38176 ssh2↵
With this configuration, the above Syslog message is first parsed with parse_syslog(). This results in a
$Message field created in the event record. Then, the pm_pattern module is used with a pattern XML file to
further parse the record.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 Exec parse_syslog();
10 </Input>
11
12 <Processor pattern>
13 Module pm_pattern
14 PatternFile /var/lib/nxlog/patterndb.xml
15 </Processor>
16
17 <Output out>
18 Module om_null
19 </Output>
20
21 <Route r>
22 Path in => pattern => out
23 </Route>
The patterns for the pm_pattern module instance above are declared in the following patterndb.xml file.
232
Chapter 26. Processing Logs NXLog User Guide
Field Value
$AuthMethod password
233
NXLog User Guide Chapter 26. Processing Logs
Field Value
$AccountName linda
$SourceIPAddress 192.168.1.60
$TaxonomyAction Authenticate
$TaxonomyStatus Failure
NXLog Manager provides an interface for writing pattern files, and will also test sample events to aid in
establishing the correct match patterns. The pattern functions can be accessed from the PATTERNS menu in the
page header.
234
Chapter 26. Processing Logs NXLog User Guide
The following instructions explain the steps required for creating the above pattern database with NXLog
Manager.
1. Open PATTERNS › CREATE GROUP. Enter a Name for the new pattern group, and optionally a
Description, in the Properties section. The name is used to refer to the pattern group later. The name
of the above pattern group is ssh.
2. Add a match field by clicking [Add Field] in the Match section. Only messages that match will be
further processed by this pattern group. In the above example, there is no reason to attempt any
matches if the $SourceName field does not equal sshd. The above pattern group uses Field name
=SourceName, Match=EXACT, and Value=sshd.
7. The Set section allows fields to be set if the match is successful. Click [Add Field] for each field. The
above example sets $TaxonomyStatus to Failure and $TaxonomyAction to Authenticate.
235
NXLog User Guide Chapter 26. Processing Logs
8. The Action section accepts NXLog language statements like would be specified in an Exec directive.
Click [Add action], type in the statement, and click [Verify] to make sure the statement is valid.
The above example does not include any NXLog language statements.
9. The final tabbed section allows test messages to be entered to verify that the match works as expected.
Click the [+] to add a test case. To test the above example, add a Value for the Message field: Failed
password for invalid user linda from 192.168.1.60 port 38176 ssh2. Click [Update Test
Cases] in the Match section to automatically fill the captured fields. Verify that the fields are set as
expected. Additional test cases can be added to test other events.
10. Save the new pattern. Then click [Export] to download the pattern.xml file or use the pattern to
configure a managed agent.
• A field or set of fields can be matched by string or regular expression to trigger alerts, perform filtering, or
further classify the event.
• Fields in the event record can be renamed, modified, or deleted.
• Event correlation can be used to execute statements or suppress messages based on matching events inside
a specified window.
• Some output formats can be used to preserve the full set of fields in the event record (such as JSON and the
236
Chapter 26. Processing Logs NXLog User Guide
In this example, any line that matches neither of the two regular expressions will be discarded with the
drop() procedure. Only lines that match at least one of the regular expressions will be kept.
nxlog.conf
1 <Input file>
2 Module im_file
3 File "/var/log/myapp/*.log"
4 Exec if not ($raw_event =~ /failed/ or $raw_event =~ /error/) drop();
5 </Input>
Example 99. Using drop() with $SourceName and $Message to Isolate Authentication Errors
In this example, events collected from multiple hosts and multiple sources by a centralized log server are
contained in an input file. By defining a list of targeted $SourceName values along with the presence of
certain keywords in the $Message field as criteria for authentication failures, the drop() procedure will
discard all non-matching events.
nxlog.conf
1 define AUTHSOURCES "su", "sudo", "sshd", "unix_chkpwd"
2
3 <Input combined>
4 Module im_file
5 File "tmp/central-logging"
6 <Exec>
7 if not (
8 defined($SourceName)
9 and $SourceName IN (%AUTHSOURCES%)
10 and (
11 $Message =~ /fail/
12 or $Message =~ /error/
13 or $Message =~ /illegal/
14 or $Message =~ /invalid/
15 )
16 ) drop();
17 </Exec>
18 </Input>
237
NXLog User Guide Chapter 26. Processing Logs
Example 100. Using drop() with $SourceName and $EventID to Collect all DNS Events
In this example events are to be collected from all DNS sources. Three of the four sources contain only
DNS-specific events which can be matched by their $SourceName value alone against the defined list, but
the Sysmon source can contain other non-DNS events as well. However, all Sysmon events with an Event ID
of 22 are DNS events. The conditional statement drops all events that do not have a $SourceName in the
defined list as well as those that match the Sysmon $SourceName but do not have a value of 22 for their
$EventID.
nxlog.conf
1 define DNSSOURCES "Microsoft-Windows-DNSServer", \
2 "Microsoft-Windows-DNS-Client", \
3 "systemd-resolved"
4
5 <Input combined>
6 Module im_file
7 File "tmp/central-logging"
8 <Exec>
9 if not (defined($SourceName)
10 and ($SourceName IN (%DNSSOURCES%)
11 or ($SourceName == "Microsoft-Windows-Sysmon"
12 and $EventID == 22)))
13 drop();
14 </Exec>
15 </Input>
238
Chapter 26. Processing Logs NXLog User Guide
Example 101. Filtering During the Output Phase to Create Multiple Event Logs from a Single Input
This example uses the same centralized log server events from the previous examples above as an input to
three outputs. Separate categories based on a single $SourceName are created and written to three
separate files. Each output instance defines a range of values for $EventID, the criteria for the
categorization into two groups: DNS Server Audit or DNS Server Analytical. The conditional statement in the
second instance uses $SeverityValue to keep only those audit events having a value greater than 2
(warnings or errors).
nxlog.conf (truncated)
1 <Input combined>
2 Module im_file
3 File "tmp/central-logging"
4 </Input>
5
6 <Output DNS_Audit>
7 Module om_file
8 File "tmp/DNS-Server-Audit"
9 <Exec>
10 if not (
11 defined($SourceName)
12 and $SourceName == "Microsoft-Windows-DNSServer"
13 and $EventID >= 513
14 and $EventID <= 582
15 ) drop();
16 </Exec>
17 </Output>
18
19 <Output DNS_Audit_Action_Required>
20 Module om_file
21 File "tmp/DNS-Server-Audit-Action-Required"
22 <Exec>
23 if not (
24 defined($SourceName)
25 and $SourceName == "Microsoft-Windows-DNSServer"
26 and $EventID >= 513
27 and $EventID <= 582
28 and $SeverityValue > 2 # Severity higher than INFO
29 [...]
For converting between CSV formats, see Complex CSV Format Conversion.
239
NXLog User Guide Chapter 26. Processing Logs
This configuration receives log messages in the BSD Syslog format over UDP and forwards the logs in the
IETF Syslog format over TCP.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input bsd>
6 Module im_udp
7 Port 514
8 Host 0.0.0.0
9 Exec parse_syslog_bsd(); to_syslog_ietf();
10 </Input>
11
12 <Output ietf>
13 Module om_tcp
14 Host 1.2.3.4
15 Port 1514
16 </Output>
17
18 <Route bsd_to_ietf>
19 Path bsd => ietf
20 </Route>
NXLog supports three main approaches to file rotation. In each case, policies should usually be implemented
using a Schedule block.
• Most policies are implemented within the scope of an om_file module instance, where output files are being
written.
• The im_file module can be configured to rotate log files after they have been fully read.
• Any log file on the system can be rotated under the scope of an xm_fileop module or any other module. This
includes the internal log file (specified by the LogFile directive).
240
Chapter 26. Processing Logs NXLog User Guide
Log files written by an om_file module often need to be rotated regularly. This example uses the om_file
file_name() function and xm_fileop file_cycle() procedure to rotate the output file daily, keeping a total of 7
old log files.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File '/var/log/out.log'
8 <Schedule>
9 When @daily
10 <Exec>
11 file_cycle(file_name(), 7);
12 reopen();
13 </Exec>
14 </Schedule>
15 </Output>
NXLog will write its own logs to a file specified by the LogFile directive. It is good practice to set up rotation
of this file. This configuration uses the xm_fileop file_size() function. The file_cycle() procedure rotates the file
if it is larger than 5 MB. The file is also rotated weekly. No more than 8 past log files are retained.
nxlog.conf
1 define LOGFILE /opt/nxlog/var/log/nxlog/nxlog.log
2 LogFile %LOGFILE%
3
4 <Extension _fileop>
5 Module xm_fileop
6
7 # Check the log file size every hour and rotate if larger than 5 MB
8 <Schedule>
9 Every 1 hour
10 <Exec>
11 if (file_exists('%LOGFILE%') and file_size('%LOGFILE%') >= 5M)
12 file_cycle('%LOGFILE%', 8);
13 </Exec>
14 </Schedule>
15
16 # Rotate log file every week on Sunday at midnight
17 <Schedule>
18 When @weekly
19 Exec if file_exists('%LOGFILE%') file_cycle('%LOGFILE%', 8);
20 </Schedule>
21 </Extension>
There are many other ways that rotation and retention can be implemented. See the following sections for more
details and examples.
241
NXLog User Guide Chapter 26. Processing Logs
If file_cycle() is used on a file that NXLog currently has open under the scope of an
om_file module instance, the reopen() procedure must be used to continue logging to
WARNING the file specified by the File directive. Otherwise, events will continue to be logged to
the rotated file ("file.1", for example). (This is not necessary if the rotated file is the
LogFile.)
This example uses the file_size() function to detect if a file has grown beyond a specified size. If it has, the
file_cycle() procedure is used to rotate it. The file size is checked hourly with the When directive.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File '/var/log/out.log'
8 <Schedule>
9 When @hourly
10 <Exec>
11 if file_size(file_name()) >= 1M
12 {
13 file_cycle(file_name());
14 reopen();
15 }
16 </Exec>
17 </Schedule>
18 </Output>
• The Every directive rotates log files according to a specific interval specified in seconds, minutes, days, or
weeks.
• The When directive provides crontab-style scheduling, including extensions like @hourly, @daily, and
@weekly.
242
Chapter 26. Processing Logs NXLog User Guide
This example shows the use of the Every and When directives. The output file is rotated daily using the
rotate_to() function. The name is generated in the YYYY-MM-DD format according to the current server time.
nxlog.conf
1 <Output out>
2 Module om_file
3 File '/var/log/out.log'
4 <Schedule>
5 # This can likewise be used for `@weekly` or `@monthly` time periods.
6 When @daily
7
8 # The following crontab-style is the same as `@daily` above.
9 # When "0 0 * * *"
10
11 # The `Every` directive could also be used in this case.
12 # Every 24 hour
13
14 Exec rotate_to(file_name() + strftime(now(), '_%Y-%m-%d'));
15 </Schedule>
16 </Output>
In this example, logs for each year and month are stored in separated sub-directories as shown below. The
log file is rotated daily.
.../logs/YEAR/MONTH/YYYY-MM-DD.log
This is accomplished with the xm_fileop dir_make() procedure, the core strftime() function, and the om_file
rotate_to() procedure.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Output out>
6 define OUT_DIR /srv/logs
7
8 Module om_file
9 File '%OUT_DIR%/out.log'
10 <Schedule>
11 When @daily
12 <Exec>
13 # Create year/month directories if necessary
14 dir_make('%OUT_DIR%/' + strftime(now(), '%Y/%m'));
15
16 # Rotate current file into the correct directory
17 rotate_to('%OUT_DIR%/' + strftime(now(), '%Y/%m/%Y-%m-%d.log'));
18 </Exec>
19 </Schedule>
20 </Output>
243
NXLog User Guide Chapter 26. Processing Logs
Because dynamic filenames result in events being written to multiple files with semi-arbitrary
NOTE names, they are not suitable for scenarios where a server or application expects events to be
written to a particular foo.log. In this case normal rotation should be used instead.
Often one of now(), $EventReceivedTime, and $EventTime are used for dynamic filenames. Consider the
following points.
• The now() function uses the current server time, not when the event was created or when it was received by
NXLog. If logs are delayed, they will be stored according to the time at which the NXLog output module
instance processes them. This will not work with nxlog-processor(8) (see Offline Log Processing).
• The $EventReceivedTime field timestamp is set by the input module instance when an event is received by
NXLog. This will usually be practically the same as using now(), except in cases where there are processing
delays in the NXLog route (such as when using buffering). This can be used with nxlog-processor(8) if the
$EventReceivedTime field was previously set in the logs.
• The $EventTime field is set from a timestamp in the event, so will result in correct value even if the event
was delayed before reaching NXLog. Note that some parsing may be required before this field is available
(for example, the parse_syslog() procedure sets the xm_syslog EventTime field). Note also that an incorrect
timestamp in an event record can cause the field to be unset or filled incorrectly resulting in data written into
the wrong file.
This example accepts Syslog formatted messages via UDP. Each message is parsed by the parse_syslog()
procedure. The EventTime field is set from the timestamp in the syslog header. This field is then used by
the expression in the File directive to generate an output filename for the event.
Even if messages received from clients over the network are out of order or delayed, they will still be placed
in the appropriate output files according to the timestamps.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_udp
7 Port 514
8 Host 0.0.0.0
9 Exec parse_syslog();
10 </Input>
11
12 <Output out>
13 Module om_file
14 File '/var/log/nxlog/out_' + strftime($EventTime, '%Y-%m-%d')
15 Exec to_syslog_ietf();
16 </Output>
244
Chapter 26. Processing Logs NXLog User Guide
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 Exec parse_syslog();
10 </Input>
11
12 <Output out>
13 Module om_file
14 File '/tmp/logs_by_host/' + $Hostname
15 </Output>
When using OnEOF for rotation, the rotated files must be named (or placed in a directory)
WARNING
such that they will not be detected as new files and re-read by the module instance.
If a logging service keeps a log file open for writing, the xm_exec exec() procedure should be used
NOTE
to restart the service or otherwise instruct it to re-open the log file.
245
NXLog User Guide Chapter 26. Processing Logs
In this example, files matching /var/log/app/*.log are read with an im_file module instance. When each
file has been fully read, it is rotated. The GraceTimeout directive will prevent NXLog from rotating the file
until after there have been no events for 10 seconds.
The input files are rotated by adding a timestamp suffix to the filename. For example, an input file named
/var/log/app/errors.log would be rotated to /var/log/app/errors.log_20180101T130100. The new
name does not match the wildcard specified by the File directive, so the file is not re-read.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Input app_logs_rotated>
6 Module im_file
7 File '/var/log/app/*.log'
8 <OnEOF>
9 <Exec>
10 file_rename(file_name(),
11 file_name() + strftime(now(), '_%Y%m%dT%H%M%S'));
12 </Exec>
13 GraceTimeout 10
14 </OnEOF>
15 </Input>
246
Chapter 26. Processing Logs NXLog User Guide
This example demonstrates the use of the xm_fileop file_cycle() procedure for keeping a total of 12 log files,
one for each month. Log files older than 1 year will be automatically deleted.
This policy creates following log file structure: /var/log/foo.log for the current
month,/var/log/foo.log.1 for the previous month, and so on up to the maximum of 12 files.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File '/var/logs/foo.log'
8 <Schedule>
9 When @monthly
10 <Exec>
11 file_cycle(file_name(), 12);
12 reopen();
13 </Exec>
14 </Schedule>
15 </Output>
Different policies for different events can be implemented in combination with dynamic filenames.
247
NXLog User Guide Chapter 26. Processing Logs
This example uses the $Severity field (such as $Severity set by parse_syslog()) to filter events to separate
files. Then different retention policies are applied according to severity. Here, one week of debug logs, 2
weeks of informational logs, and 4 weeks of higher severity logs are retained.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _fileop>
6 Module xm_fileop
7 </Extension>
8
9 <Input logs_in>
10 Module im_file
11 File "/var/log/messages"
12 Exec parse_syslog();
13 </Input>
14
15 <Output logs_out>
16 define OUT_DIR /opt/nxlog/var/log
17
18 Module om_file
19 File '%OUT_DIR%/' + $Severity + '.log'
20 <Schedule>
21 When @daily
22 <Exec>
23 file_cycle('%OUT_DIR%/DEBUG.log', 7);
24 file_cycle('%OUT_DIR%/INFO.log', 14);
25 file_cycle('%OUT_DIR%/WARNING.log', 28);
26 file_cycle('%OUT_DIR%/ERROR.log', 28);
27 file_cycle('%OUT_DIR%/CRITICAL.log', 28);
28 reopen();
29 </Exec>
30 </Schedule>
31 </Output>
248
Chapter 26. Processing Logs NXLog User Guide
In this example, the file size of the output file is checked hourly with the om_file file_size() function. If the
size is over the limit, then:
1. a newfile module variable is set to the name the current file will be rotated to,
2. the om_file rotate_to() procedure renames the current output file to the name set in newfile,
3. the module re-opens the original file specified by the File directive and continue logging, and
4. the xm_exec exec_async() procedure call bzip2 on the rotated-out file (without waiting for the command
to complete).
nxlog.conf (truncated)
1 <Input in>
2 Module im_null
3 </Input>
4
5 # tag::guide_include[]
6 <Extension _exec>
7 Module xm_exec
8 </Extension>
9
10 <Extension _fileop>
11 Module xm_fileop
12 </Extension>
13
14 <Output out>
15 Module om_file
16 File '/opt/nxlog/var/log/app.log'
17 <Schedule>
18 When @hourly
19 <Exec>
20 if out->file_size() > 15M
21 {
22 set_var('newfile', file_name() + strftime(now(), '_%Y%m%d%H%M%S'));
23 rotate_to(get_var('newfile'));
24 exec_async('/bin/bzip2', get_var('newfile'));
25 }
26 </Exec>
27 </Schedule>
28 [...]
249
NXLog User Guide Chapter 26. Processing Logs
This example uses file_remove() to remove any files older than 30 days.
nxlog.conf
1 <Input in>
2 Module im_null
3 </Input>
4
5 <Output logs_out>
6 Module om_file
7 File '/var/log/'+ strftime(now(),'%Y%m%d') + '.log'
8 <Schedule>
9 When @daily
10
11 # Delete logs older than 30 days (24x60x60x30)
12 Exec file_remove('/var/log/*.log', now() - 2592000);
13 </Schedule>
14 </Output>
See also Extracting Data, a closely related topic, for more examples of classification.
250
Chapter 26. Processing Logs NXLog User Guide
This example classifies Windows Security login failure events with Event ID 4625 (controlled by the "Audit
logon events" audit policy setting). If a received event has that ID, it is classified as a failed authentication
attempt and the $AccountName field is set to the value of $TargetUserName.
Field Value
$EventType AUDIT_FAILURE
$EventID 4625
$SourceName Microsoft-Windows-Security-Auditing
$Channel Security
$Category Logon
$TargetUserSid S-1-0-0
$TargetUserName linda
$TargetDomainName WINHOST
$Status 0xc000006d
$FailureReason %%2313
$SubStatus 0xc000006a
$LogonType 2
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <Exec>
4 if ($EventID == 4625) and
5 ($SourceName == 'Microsoft-Windows-Security-Auditing')
6 {
7 $TaxonomyAction = 'Authenticate';
8 $TaxonomyStatus = 'Failure';
9 $AccountName = $TargetUserName;
10 }
11 </Exec>
12 </Input>
Field Value
$TaxonomyAction Authenticate
$TaxonomyStatus Failure
$AccountName linda
251
NXLog User Guide Chapter 26. Processing Logs
When the contents of the $Message field match against the regular expression, the $AccountName and
$AccountID fields are filled with the appropriate values from the referenced captured sub-strings.
Additionally the value LoginEvent is stored in the $Action field.
252
Chapter 26. Processing Logs NXLog User Guide
The above pattern matching rule can be defined in the pm_pattern modules’s XML format in the following
way, which will accomplish the same result.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input uds>
6 Module im_uds
7 UDS /dev/log
8 Exec parse_syslog_bsd();
9 </Input>
10
11 <Processor pattern>
12 Module pm_pattern
13 PatternFile /var/lib/nxlog/patterndb.xml
14 </Processor>
15
16 <Output file>
17 Module om_file
18 File "/var/log/messages"
19 Exec to_syslog_bsd();
20 </Output>
21
22 <Route uds_to_file>
23 Path uds => pattern => file
24 </Route>
253
NXLog User Guide Chapter 26. Processing Logs
• a header in the first line (with timestamp and severity field, for example),
• a closing character sequence marking the end, and
• a fixed line count.
Based on this information, NXLog can be configured to reconstruct the original messages, creating a single event
for each multi-line message.
26.12.1. xm_multiline
NXLog provides xm_multiline for multi-line parsing; this dedicated extension module is the recommended way to
parse multi-line messages. It supports header lines, footer lines, and fixed line counts. Once configured, the
xm_multiline module instance can be used as a parser via the input module’s InputType directive.
This configuration creates a single event record with the matching HeaderLine and all successive lines until
an EndLine is received.
nxlog.conf
1 <Extension multiline_parser>
2 Module xm_multiline
3 HeaderLine "---------------"
4 EndLine "END------------"
5 </Extension>
6
7 <Input in>
8 Module im_file
9 File "/var/log/app-multiline.log"
10 InputType multiline_parser
11 </Input>
It is also possible to use regular expressions with the HeaderLine and EndLine directives.
254
Chapter 26. Processing Logs NXLog User Guide
Here, a new event record is created beginning with each line that matches the regular expression.
nxlog.conf
1 <Extension tomcat_parser>
2 Module xm_multiline
3 HeaderLine /^\d{4}\-\d{2}\-\d{2} \d{2}\:\d{2}\:\d{2},\d{3} \S+ \[\S+\] \- .*/
4 </Extension>
5
6 <Input log4j>
7 Module im_file
8 File "/var/log/tomcat6/catalina.out"
9 InputType tomcat_parser
10 </Input>
Because the EndLine directive is not specified in this configuration, the xm_multiline parser
cannot know that a log message is finished until it receives the HeaderLine of the next
NOTE message. The log message is kept in the buffers, waiting to be forwarded, until either a
new log message is read or the im_file module instance’s PollInterval has expired. See the
xm_multiline AutoFlush directive.
255
NXLog User Guide Chapter 26. Processing Logs
This example saves the matching line and successive lines in the saved variable. When another matching
line is read, an internal log message is generated with the contents of the saved variable.
nxlog.conf
1 <Input log4j>
2 Module im_file
3 File "/var/log/tomcat6/catalina.out"
4 <Exec>
5 if $raw_event =~ /(?x)^\d{4}\-\d{2}\-\d{2}\ \d{2}\:\d{2}\:\d{2},\d{3}\ \S+
6 \ \[\S+\]\ \-\ .*/
7 {
8 if defined(get_var('saved'))
9 {
10 $tmp = $raw_event;
11 $raw_event = get_var('saved');
12 set_var('saved', $tmp);
13 delete($tmp);
14 log_info($raw_event);
15 }
16 else
17 {
18 set_var('saved', $raw_event);
19 drop();
20 }
21 }
22 else
23 {
24 set_var('saved', get_var('saved') + "\n" + $raw_event);
25 drop();
26 }
27 </Exec>
28 </Input>
As with the previous example, a log message is kept in the saved variable, and not
NOTE
forwarded, until a new log message is read.
The poor man’s tool for rate limiting is the sleep() procedure.
256
Chapter 26. Processing Logs NXLog User Guide
In the following example, sleep() is invoked with 500 microseconds. This means that the input module will
be able to read at most 2000 messages per second.
nxlog.conf
1 <Input in>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 Exec sleep(500);
6 </Input>
This is not very precise because the module can do additional processing which can add to the total
execution time, but it gets fairly close.
WARNING It is not recommended to use rate limiting on a route that reads logs over UDP.
The traffic shaping script can be downloaded from the nxlog-public/contrib repository.
The script does not require configuring NXLog, but it needs to be configured to run at startup with tools like
crontab or rc.local.
To configure running the script with crontab, the @reboot task should be added to the /etc/crontab file.
/etc/crontab
1 @reboot /usr/local/sbin/traffic-shaper.sh
To configure running the script with rc.local, the script path should be added to the /etc/rc.local file.
/etc/rc.local
1 /usr/local/sbin/traffic-shaper.sh
The traffic shaper ties to the destination port on the network level and can shape traffic in accordance with
priorities. For example, high priority can be configured for a database server and low priority for a backup
system.
For more information about the Linux traffic control, see the Traffic Control HOWTO section on The Linux
Documentation Project website.
257
NXLog User Guide Chapter 26. Processing Logs
This statement, when used in an Exec directive, will apply the replacement directly to the $raw_event field.
In this case, a parsing procedure like parse_syslog() would not be used.
1 if $raw_event =~ /^(aaaa)(replaceME)(.+)/
2 $raw_event = $1 + 'replaceMENT' + $3;
This example will convert a timestamp field to a different format. Like the previous example, the goal is to
modify the $raw_event field directly, rather than use other fields and then a procedure like to_json() to
update $raw_event.
The input log format is line-based, with whitespace-separated fields. The first field is a timestamp
expressed as seconds since the epoch.
Input Sample
1301471167.225121 AChBVvgs1dfHjwhG8 141.143.210.102 5353 224.0.0.251 5353 udp dns - - - S0 - -
0 D 1 73 0 0 (empty)↵
In the output module instance Exec directive, the regular expression will match and capture the first field
from the line, and remove it. This captured portion is parsed with the parsedate() function and used to set
the $EventTime field. This field is then prepended to the $raw_event field to replace the previously
removed field.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "conn.log"
4 </Input>
5
6 <Output out>
7 Module om_tcp
8 Host 192.168.0.1
9 Port 1514
10 <Exec>
11 if $raw_event =~ s/^(\S+)//
12 {
13 $EventTime = parsedate($1);
14 $raw_event = strftime($EventTime, 'YYYY-MM-DDThh:mm:ss.sTZ') +
15 $raw_event;
16 }
17 </Exec>
18 </Output>
Output Sample
2011-03-30T00:46:07.225121-07:00 AChBVvgs1dfHjwhG8 141.143.210.102 5353 224.0.0.251 5353 udp
dns - - - S0 - - 0 D 1 73 0 0 (empty)↵
258
Chapter 26. Processing Logs NXLog User Guide
In this example, each Syslog message is received via UDP and parsed with parse_syslog_bsd(). Then, if the
$Message field matches the regular expression, the $SeverityValue field is modified. Finally, the
to_syslog_bsd() procedure generates $raw_event from the fields.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 Port 514
8 Host 0.0.0.0
9 Exec parse_syslog_bsd();
10 </Input>
11
12 <Output file>
13 Module om_file
14 File "/var/log/logmsg.txt"
15 <Exec>
16 if $Message =~ /error/ $SeverityValue = syslog_severity_value("error");
17 to_syslog_bsd();
18 </Exec>
19 </Output>
20
21 <Route syslog_to_file>
22 Path udp => file
23 </Route>
The simplest way is to use the NXLog language and the Exec directive.
This statement uses the rename_field() procedure to rename the $user field to $AccountName.
1 rename_field($user, $AccountName);
This statement uses the delete() procedure to delete the $Serial field.
1 delete($Serial);
Alternatively, the xm_rewrite extension module (available in NXLog Enterprise Edition) can be used to rename or
delete fields.
259
NXLog User Guide Chapter 26. Processing Logs
This example uses the parse_syslog() procedure to create a set of Syslog fields in the event record. It then
uses the Keep directive to whitelist a set of fields, deleting any field that is not in the list. Finally the Rename
directive is used to rename the $EventTime field to $Timestamp. The resulting event record is converted to
JSON and sent out via TCP.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension rewrite>
6 Module xm_rewrite
7 Keep EventTime, Severity, Hostname, SourceName, Message
8 Rename EventTime, Timestamp
9 </Extension>
10
11 <Input in>
12 Module im_file
13 File '/var/log/messages'
14 Exec parse_syslog(); rewrite->process();
15 </Input>
16
17 <Output out>
18 Module om_tcp
19 Host 10.0.0.1
20 Port 1514
21 Exec to_json();
22 </Output>
23
24 <Route r>
25 Path in => out
26 </Route>
Here is an example Extension block that uses the Delete directive to delete all the severity fields. This could
be used to prevent severity-based matching (during later processing) on an event source that does not set
severity values correctly.
nxlog.conf
1 <Extension rewrite>
2 Module xm_rewrite
3 Delete SyslogSeverityValue, SyslogSeverity, SeverityValue, Severity
4 </Extension>
26.15. Timestamps
The NXLog core provides functions for parsing timestamps that return datetime values, along with functions for
generating formatted timestamps from datetime values.
260
Chapter 26. Processing Logs NXLog User Guide
Consider the following line-based input sample. Each record begins with a timestamp followed by a tab.
Input Sample
2016-10-11T22:14:15.003Z ⇥ machine.example.com ⇥ An account failed to log on.↵
This example configuration uses a regular expression to capture the string up to the first tab. Then the
parsedate() function is used to parse the resulting string and set the $EventTime field to the corresponding
datetime value. This value can be converted to a timestamp string as required in later processing, either
explicitly or as defined by the global DateFormat directive (see Formatting Timestamps).
nxlog.conf
1 <Input in>
2 Module im_file
3 File 'in.log'
4 Exec if $raw_event =~ /^([^\t])\t/ $EventTime = parsedate($1);
5 </Input>
The parsedate() function is especially useful if the timestamp format varies within the events
being processed. A timestamp of any supported format will be parsed. In this example, the
TIP
timestamp must be at the beginning of the event and followed by a tab character to be
matched by the regular expression.
Sometimes a log source will contain a few events with invalid or unexpected formatting. If parsedate() fails to
parse the input string, it will return an undefined datetime value. This allows the user to configure a fallback
timestamp.
This example statement uses a vague regular expression that may in some cases match an invalid string. If
parsedate() fails to parse the timestamp, it will return an undefined datetime value. In this case, the final
line below will set $EventTime to the current time.
1 if $raw_event =~ /^(\S+)\s+(\S+)/
2 $EventTime = parsedate($1 + " " + $2);
3
4 # Make sure $EventTime is set
5 if not defined($EventTime) $EventTime = now();
For parsing more exotic formats, the strptime() function can be used.
261
NXLog User Guide Chapter 26. Processing Logs
In this input sample, the date and time are two distinct fields delimited by a tab. It also uses a non-standard
single digit format instead of fixed width with double digits.
Input Sample
2011-5-29 ⇥ 0:3:2 GMT ⇥ WINDOWSDC ⇥ An account failed to log on.↵
To parse this, a regular expression can be used to capture the timestamp string. This string is then parsed
with the strptime() function.
Reliably applying timezone offsets is difficult due to complications like daylight savings time
(DST) and networking and processing delays. For this reason, it is best to use clock
WARNING
synchronization (such as NTP) and timezone-aware timestamps at the log source when
possible.
The simplest solution for incorrect timestamps is to replace them with the time when the event was received by
NXLog. This is a good option for devices with untrusted clocks on the local network that send logs to NXLog in
real-time. The $EventReceivedTime field is automatically added to each event record by NXLog; this field can be
stored alongside the event’s own timestamp (normally $EventTime) if all fields are preserved when the event is
stored/forwarded. Alternatively, this field can be used as the event timestamp as shown below. This would have
the effect of influencing the timestamp used on most outputs, such as with the to_syslog_ietf() procedure.
This configuration accepts Syslog messages via UDP with the im_udp module. Events are parsed with the
parse_syslog() procedure, which adds an EventTime field from the Syslog header timestamp. The
$EventTime value, however, is replaced by the timestamp set by NXLog in the $EventReceivedTime field.
Any later processing that uses the $EventTime field will operate on the updated timestamp. For example, if
the to_syslog_ietf() procedure is used, the resulting IETF Syslog header will contain the
$EventReceivedTime timestamp.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input syslog>
6 Module im_udp
7 <Exec>
8 parse_syslog();
9 $EventTime = $EventReceivedTime;
10 </Exec>
11 </Input>
In some edge cases, a UTC timestamp that does not have the timezone specified is parsed as local time. This can
262
Chapter 26. Processing Logs NXLog User Guide
happen if BSD Syslog timestamps are in UTC, or when reading a non-timezone-aware ID timestamp with
im_odbc. In this case, it is necessary to either manually re-parse (see Parsing Timestamps) or apply a
corresponding reverse offset.
This statement uses the parsedate() and strftime() functions to apply a reverse offset after an incorrect
local-to-UTC timezone conversion. To reduce the likelihood of an incorrect offset during the daylight saving
time (DST) transition, this should be done in the Input module instance which is collecting the events (see
the warning above).
For the general case of adjusting timestamps, the plus (+) and minus (-) operators can be used to adjust a
timestamp by a specified number of seconds.
This simple method may not be suitable for correction of a timezone that uses
WARNING daylight saving time (DST). In that case the required offset may change based on
whether DST is in effect.
263
NXLog User Guide Chapter 26. Processing Logs
Consider an event record with an $EventTime field (as a datetime value) and a $Message field. Note that
the table below shows the $EventTime value as it is stored internally: as microseconds since the epoch.
Field Value
$EventTime 1493425133541851
The following output module instance uses the to_json() procedure without specifying the timestamp
format.
nxlog.conf
1 <Output out>
2 Module om_file
3 File 'out.log'
4 Exec to_json();
5 </Output>
The output of the $EventTime field in this case will depend on the DateFormat directive. The default
DateFormat is YYYY-MM-DD hh:mm:ss (local time).
Output Sample
{
"EventTime": "2017-01-02 15:19:22",
"Message": "EXT4-fs (dm-0): mounted filesystem with ordered data mode."
}
A different timestamp may be used in some cases, depending on the procedure used to
convert the field and the output module. The to_syslog_bsd() procedure, for example, will
NOTE
use the $EventTime value to generate a RFC 3164 format timestamp regardless of how the
DateFormat directive is set.
Alternatively, the strftime() function can be used to explicitly convert a datetime value to a string with the
required format.
264
Chapter 26. Processing Logs NXLog User Guide
Again, consider an event record with an $EventTime field (as a datetime value) and a $Message field. In this
example, the strftime() function is used with a format string (see the strftime(3) manual) to convert
$EventTime to a string in the local time zone. Then the to_json() procedure is used to set the $raw_event
field.
nxlog.conf
1 <Output out>
2 Module om_file
3 File 'out.log'
4 <Exec>
5 $EventTime = strftime($EventTime, '%Y-%m-%dT%H:%M:%S%z');
6 to_json();
7 </Exec>
8 </Output>
Output Sample
{
"EventTime": "2017-04-29T02:18:53+0200",
"Message": "EXT4-fs (dm-0): mounted filesystem with ordered data mode."
}
NXLog Enterprise Edition supports a few additional format strings for formats that the stock C strftime() does not
offer, including formats with fractional seconds and in UTC time. See the Reference Manual strftime()
documentation for the list.
The following statement will convert $EventTime to a timestamp format with fractional seconds and in UTC
(regardless of the current time zone).
265
NXLog User Guide Chapter 27. Forwarding and Storing Logs
Syslog
There are two Syslog formats, the older BSD Syslog (RFC 3164) and the newer IETF Syslog (RFC 5424). The
transport protocol in Syslog can be UDP, TCP, or SSL. The xm_syslog module provides procedures for
generating Syslog messages. For more information, see Generating Syslog.
This configuration uses the to_syslog_ietf() procedure to convert the corresponding fields in the event
record to a Syslog message in IETF format. The result is forwarded over TCP by the om_tcp module.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_tcp
7 Host 192.168.1.1
8 Port 1514
9 Exec to_syslog_ietf();
10 </Output>
Syslog Snare
The Snare agent format is a special format on top of BSD Syslog which is used and understood by several
tools and log analyzer frontends. This format is most useful when forwarding Windows EventLog data in
conjunction with im_mseventlog and/or im_msvistalog. The to_syslog_snare() procedure can construct Syslog
Snare formatted messages. For more information, see Generating Snare.
266
Chapter 27. Forwarding and Storing Logs NXLog User Guide
In this example, the to_syslog_snare() procedure converts the corresponding fields in the event record to
Snare format. The messages are then forwarded over UDP by the om_udp module.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_udp
7 Host 192.168.1.1
8 Port 514
9 Exec to_syslog_snare();
10 </Output>
This format is the recommended format when sending data between NXLog instances as it preserves type
information and all the fields. It is also possible to send data between NXLog instances in other formats, but
the characteristics of the chosen format needs to be considered. For example, JSON has no datetime type,
but it is more compliant to standards and a text based human readable format.
With this configuration, NXLog reads a JSON file, converts it to NXLog binary format using the OutputType
Binary and forwards over TCP using the om_tcp module. To accept a binary-formatted file, the receiver
NXLog module instance can be set to InputType Binary.
nxlog.conf
1 <Input from_file>
2 Module im_file
3 File "/tmp/input.json"
4 </Input>
5
6 <Output to_tcp>
7 Module om_tcp
8 Host 192.168.31.93
9 Port 10500
10 OutputType Binary
11 </Output>
267
NXLog User Guide Chapter 27. Forwarding and Storing Logs
With this configuration, NXLog sends the fields in the event record over UDP in GELF format.
nxlog.conf
1 <Extension _gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Output out>
6 Module om_udp
7 Host 127.0.0.1
8 Port 12201
9 OutputType GELF_UDP
10 </Output>
JSON
This is one of the most popular formats for interchanging data between various systems. The xm_json
module provides procedures for generating JSON messages by using data from the event record.
With this configuration, NXLog sends the fields of the event record over TCP in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Output out>
6 Module om_tcp
7 Host 192.168.1.1
8 Port 1514
9 Exec to_json();
10 </Output>
After parsing, Event Log data can be captured and processed by using any operating system.
268
Chapter 27. Forwarding and Storing Logs NXLog User Guide
Example 143. Generating Windows Event Log Messages and Sending Over UDP
With this configuration, NXLog reads Windows Event Log entries and selects only those entries which
contain IDs 4624 (an account was successfully logged on) and 4647 (user initiated logoff) using the
im_msvistalog module. Sending over UDP is carried out using the om_udp module.
nxlog.conf
1 <Input from_eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Security">
7 *[System[Level=0 and (EventID=4624 or EventID=4647)]]
8 </Select>
9 </Query>
10 </QueryList>
11 </QueryXML>
12 </Input>
13
14 <Output to_udp>
15 Module om_udp
16 Host 192.168.31.93
17 Port 10500
18 </Output>
UDP
To send logs as UDP datagrams, use the om_udp module.
UDP packets can be dropped by the operating system because the protocol does not
WARNING guarantee reliable message delivery. It is recommended to use TCP or TLS/SSL instead if
message loss is a concern.
269
NXLog User Guide Chapter 27. Forwarding and Storing Logs
This example provides configurations to forward data to the specified host via UDP.
The configuration below converts and forwards log messages in Graylog Extended Log Format (GELF).
nxlog.conf
1 <Extension gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/tmp/input"
8 </Input>
9
10 <Output out>
11 Module om_udp
12 Host 192.168.1.1
13 Port 514
14 OutputType GELF_UDP
15 </Output>
The below configuration sample forwards data via UDP in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/tmp/input"
8 </Input>
9
10 <Output out>
11 Module om_udp
12 Host 192.168.1.1
13 Port 514
14 Exec to_json();
15 </Output>
TCP
To send logs over TCP, use the om_tcp module.
270
Chapter 27. Forwarding and Storing Logs NXLog User Guide
In this example, log messages are forwarded to the specified host via TCP.
The configuration below provides forwarding data as a Syslog message in IETF format.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/tmp/input"
8 </Input>
9
10 <Output out>
11 Module om_tcp
12 Host 192.168.1.1
13 Port 1514
14 Exec to_syslog_ietf();
15 </Output>
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/tmp/input"
4 </Input>
5
6 <Output out>
7 Module om_tcp
8 Host 192.168.0.127
9 Port 10500
10 </Output>
SSL/TLS
To send logs over a trusted, secure SSL connection, use the om_ssl module.
271
NXLog User Guide Chapter 27. Forwarding and Storing Logs
This example provides nearly identical behavior to the TCP example above, but in this case SSL is used
to securely transmit the data.
The configuration below enables forwarding raw data over SSL/TLS using a self-signed certificate.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/tmp/input'
4 </Input>
5
6 <Output out>
7 Module om_ssl
8 Host 192.168.0.127
9 Port 10500
10 OutputType Binary
11 # Allows using self-signed certificates
12 AllowUntrusted TRUE
13 # Certificate from the peer host
14 CAFile /tmp/peer_cert.pem
15 # Certificate file
16 CertFile /tmp/cert.pem
17 # Keypair file
18 CertKeyFile /tmp/key.pem
19 </Output>
The below configuration sample forwards data over SSL/TLS in JSON format using a trusted CA
certificate.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/tmp/input'
4 </Input>
5
6 <Extension json>
7 Module xm_json
8 </Extension>
9
10 <Output out>
11 Module om_ssl
12 Host 192.168.0.127
13 Port 10500
14 # Allows using self-signed certificates
15 AllowUntrusted FALSE
16 # Certificate from the peer host
17 CAFile /tmp/peer_cert.pem
18 # Certificate file
19 CertFile /tmp/cert.pem
20 # Keypair file
21 CertKeyFile /tmp/key.pem
22 Exec to_json();
23 </Output>
272
Chapter 27. Forwarding and Storing Logs NXLog User Guide
HTTP(S)
To send logs over an HTTP or HTTPS connection, use the om_http module.
This example provides configurations for forwarding data via HTTP to the specified HTTP address.
Using the below configuration sample, NXLog will send raw data in text form using a POST request for
each log message.
nxlog.conf
1 <Input in>
2 Module im_file
3 File '/tmp/input'
4 </Input>
5
6 <Output out>
7 Module om_http
8 URL http://server:8080/
9 </Output>
The configuration below will forward data in Graylog Extended Log Format (GELF) over HTTPS using a
trusted certificate.
nxlog.conf
1 <Extension gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/tmp/input"
8 </Input>
9
10 <Output out>
11 Module om_http
12 URL https://server:8080/
13 # Allows using self-signed certificates
14 HTTPSAllowUntrusted FALSE
15 # Certificate from the peer host
16 HTTPSCAFile /tmp/peer_cert.pem
17 # Certificate file
18 HTTPSCertFile /tmp/cert.pem
19 # Keypair file
20 HTTPSCertKeyFile /tmp/key.pem
21 </Output>
273
NXLog User Guide Chapter 27. Forwarding and Storing Logs
This configuration writes log messages to the specified file. No additional processing is performed by
the output module instance.
nxlog.conf
1 <Output out>
2 Module om_file
3 File "/var/log/out.log"
4 </Output>
With this configuration, log messages are written to the specified socket without any additional
processing.
nxlog.conf
1 <Output out>
2 Module om_uds
3 UDS /dev/log
4 </Output>
This configuration uses libdbi and the pgsql driver to insert events into the specified database. The SQL
statement references fields in the event record to be added to the database.
nxlog.conf
1 <Output out>
2 Module om_dbi
3 SQL INSERT INTO log (facility, severity, hostname, timestamp, application, \
4 message) \
5 VALUES ($SyslogFacility, $SyslogSeverity, $Hostname, '$EventTime', \
6 $SourceName, $Message)
7 Driver pgsql
8 Option host 127.0.0.1
9 Option username dbuser
10 Option password secret
11 Option dbname logdb
12 </Output>
274
Chapter 27. Forwarding and Storing Logs NXLog User Guide
This example inserts events into the database specified by the ODBC connection string. In this case, the
sql_exec() and sql_fetch() functions are used to interact with the database.
nxlog.conf
1 <Output out>
2 Module om_odbc
3 ConnectionString DSN=mysql_ds;username=mysql;password=mysql;database=logdb;
4 <Exec>
5 if ( sql_exec("INSERT INTO log (facility, severity, hostname, timestamp,
6 application, message) VALUES (?, ?, ?, ?, ?, ?)",
7 1, 2, "host", now(), "app", $raw_event) == TRUE )
8 {
9 if ( sql_fetch("SELECT max(id) as id from log") == TRUE )
10 {
11 log_info("ID: " + $id);
12 if ( sql_fetch("SELECT message from log WHERE id=?", $id) == TRUE )
13 log_info($message);
14 }
15 }
16 </Exec>
17 </Output>
This configuration executes the specified command and writes log messages to its standard input.
nxlog.conf
1 <Output out>
2 Module om_exec
3 Command /usr/bin/someprog
4 Arg -
5 </Output>
275
NXLog User Guide Chapter 28. Centralized Log Collection
• Event data can be accessed even if the originating server is offline, compromised, or decommissioned.
• Data can be analyzed and correlated across more than one system.
• It is more difficult for malicious actors to remove evidence from logs that have already been forwarded.
• Incident investigation and auditing is easier because all event data is collected in a single location.
• Scalable, high-availability, and redundancy solutions are easier to implement and maintain since they can be
implemented at the point of the collection server.
• Compliance with internal and external standards for log data retention only need to be to managed at a
single point.
28.1. Architecture
The following diagram depicts an example of centralized log collection architecture. The single, central server
collects logs from other servers, applications, and network devices. After collection, the logs can be forwarded as
required for further analysis or storage.
In practice, network topology and other requirements may dictate that additional servers such as relays be
added for log handling. For those cases, other functionality may be necessary than what is covered here (such as
buffering).
The following diagram depicts an example of a log collection architecture where NXLog is also used as a relay
which can then forward logs to any destination such as a SIEM or a log collection server. This can be especially
important when separating networks is a necessity.
276
Chapter 28. Centralized Log Collection NXLog User Guide
This chapter is concerned with the system displayed in the first diagram; collecting logs from clients to a central
server.
Agent-based log collection requires that an NXLog agent be installed on the client. With a local agent, collection is
much more flexible, providing features such as filtering on the source system to send only the required data,
format conversion, compression, encryption, and delivery reliability, among others. It is generally recommended
that NXLog be deployed as an agent wherever possible.
277
NXLog User Guide Chapter 28. Centralized Log Collection
With agent-based log collection, NXLog agents are installed on both the client and the central server. Here,
the im_batchcompress and om_batchcompress modules are used to transport logs both compressed and
encrypted. These modules preserve all the fields in the event record.
nxlog.conf (Client)
1 <Output batch>
2 Module om_batchcompress
3 Host 192.168.56.101
4 Port 2514
5 UseSSL TRUE
6 CAFile /opt/openssl_rootca/rootCA.pem
7 CertFile /opt/openssl_server/server.crt
8 CertKeyFile /opt/openssl_server/server.key
9 </Output>
In agent-less mode, there is no NXLog agent installed on the client. Instead, the client forwards events to the
central server in a native format. On the central server, NXLog accepts and parses the logs received. Often there
is limited control over the log format used, and it may not be possible to implement encryption, compression,
delivery reliability, or other features.
With agent-less collection, NXLog is installed on the central server but not on the client. Clients can be
configured to send UDP Syslog messages to the central server using their native logging functionality. The
im_udp module below could be replaced with im_tcp or im_ssl according to what protocol is supported by
the clients.
UDP transport does not provide any guarantee of delivery. Network congestion or
WARNING
other issues may result in lost log data.
It is common for logs to be collected using both modes among the various clients, network devices, relays, and
log servers in a network. For example, an NXLog relay may be configured to collect logs from both agents and
278
Chapter 28. Centralized Log Collection NXLog User Guide
agent-less sources and perform filtering and processing before forwarding the data to a central server.
28.3. Requirements
Various logging requirements may dictate particular details about the chosen logging architecture. The following
are important considerations when deciding how to set up centralized log collection. In some cases, these
requirements can only be met by using agent-based collection.
Reliability
UDP does not guarantee message delivery, and should be avoided if data loss is unacceptable. Instead, TCP
(and therefore TLS as well) offers guaranteed packet delivery. Furthermore, with agent-based collection
NXLog can provide application-level, guaranteed delivery. See Reliable Network Delivery for more
information.
Structured data
Correlating data across multiple log sources requires parsing event data into a common set of fields. Event
fields are a core part of NXLog processing, and an NXLog agent can be configured to parse events at any point
along their path to the central server. Often, parsing is done as early as possible (at the source, for agent-
based collection) to simplify later categorization and to reduce processing load on log servers as logs are
received. See Parsing Various Formats and Message Classification.
Encryption
To maintain confidentiality of log data, TLS can be used during transport.
Compression
If bandwidth is a concern, log data compression may be desirable. Most event data is highly compressible,
allowing bandwidth requirements to be reduced significantly. The im_batchcompress and om_batchcompress
modules provide batched, compressed transport of log data between NXLog agents.
Storage format
Normally, data should be converted to, and stored in, a common format when dealing with heterogeneous
logs sources.
JSON
JSON is easy to generate and parse and has become a de facto standard for logging as well. It has some
limitations, such as the missing datetime format. See the JSON section.
Agent-less collection is restricted to formats supported by the clients. The following are a few common formats,
but many more are supported. See also the OS Support chapters.
Syslog
Using Syslog has become a common practice and many SIEM vendors and products support (or even require)
Syslog. See the Syslog chapter for more details. Syslog contains free form message data that typically needs
to be parsed to extract more information for further analysis. Syslog often uses UDP, TCP, or TLS for
279
NXLog User Guide Chapter 28. Centralized Log Collection
transport.
Snare
The Snare format is commonly used to transport Windows Event Log, with or without Syslog headers.
280
Chapter 29. NXLog Failover Mode NXLog User Guide
• Configuration of which nodes comprise the cluster and which node is the default active node
• Detection of a fault within the active node
• Selection of the next passive node to be promoted to active status when a fault is detected
29.2.1. Self-Managed
The most common implementation of failover provides same-tier failover and is managed within the cluster
itself. It’s main advantage is that a cluster can be deployed without any need for management from external
hosts. This type of failover is typically only practical for large organizations that need to provide HA for client-
server applications dependent on session continuity. Due to the technical complexity of this approach,
configuring and deploying such clusters usually requires significant planning and resources.
An externally managed failover cluster is unaware of its peers and none of the nodes contain any configuration
details defining themselves as part of a cluster. It relies entirely on the external hosts that will be accessing it to
define which node is active and which nodes will be considered viable passive peers. If the active node fails, each
external host’s failover-enabled agent, in this case NXLog v5, will actively try to connect to the next available
passive node and promote it to be the active node for its own use. Each external host performs this task
independently.
281
NXLog User Guide Chapter 29. NXLog Failover Mode
Figure 5. NXLog Relay Cluster used in failover mode for centralized logging
282
Chapter 29. NXLog Failover Mode NXLog User Guide
The following configuration example can be used to create the architecture seen in the diagram. When
implemented, only the first node will be actively receiving events. The other two nodes will sit idle unless
the first node fails.
To implement this architecture, the following to_relay output instance needs to be included in the
configuration file for both Linux servers, both Windows DNS Servers, and both Windows hosts collecting
Sysmon events.
This completes the definition of the cluster and its nodes and as well as the sending side of the
architecture.
nxlog.conf (Configuration for each log source sending to the failover cluster)
1 # External Failover Cluster - Active-Passive
2 <Output to_relay>
3 Module om_tcp
4
5 # Node 1 ACTIVE
6 Host 192.168.1.51:1514
7
8 # Node 2 passive
9 Host 192.168.1.52:1514
10
11 # Node 3 passive
12 Host 192.168.1.53:1514
13
14 </Output>
For the receiving side, the following from_log_sources input instance needs to be included in the
configuration file for all nodes in the cluster. The output and relay instances complete the relay path
depicted in the diagram for sending the events to their final destination, the SIEM Log Collection Server.
nxlog.conf (Configuration for each log source sending to the failover cluster)
1 # Receiving Events as a Node in a Failover Cluster
2 <Input from_log_sources>
3 Module im_tcp
4 ListenAddr 0.0.0.0:1514
5 </Input>
6
7 # Relay the Events to the SIEM
8 <Output to_siem>
9 Module om_tcp
10 Host siem.example.com:1514
11 </Output>
12
13 <Route relay>
14 Path from_log_sources => to_siem
15 </Route>
283
NXLog User Guide Chapter 29. NXLog Failover Mode
Figure 6. NXLog Relay Cluster used in hybrid load balancing / failover mode for centralized logging
284
Chapter 29. NXLog Failover Mode NXLog User Guide
As depicted in the diagram above, each agent can be configured to have a different active node from that of
other agents configured to use the same NXLog Relay Cluster. This enables the creation of a hybrid failover
/ load balancing configuration.
From each individual agent’s perceptive, it is communicating with an active-passive cluster, but in reality the
cluster will be operating as an active-active load balancer (albeit a static one). This technique prevents the
other passive nodes from sitting completely idle, and depending on the number of nodes, can dramatically
increase performance.
The following output instance is used by both Linux servers. The first relay node has been set as the default
active node for their failover setup.
The following output instance is used by both Windows DNS servers. The second relay node has been set
as the default active node for their failover setup.
The following output instance is used by both Windows servers collecting Sysmon events. The third relay
node has been set as the default active node for their failover setup.
285
NXLog User Guide Chapter 29. NXLog Failover Mode
For the receiving side, the following from_log_sources input instance needs to be included in the
configuration file for all nodes in the cluster. The output and relay instances complete the relay path
depicted in the diagram for sending the events to their final destination, the SIEM Log Collection Server.
nxlog.conf (Configuration for each log source sending to the failover cluster)
1 # Receiving Events as a Node in a Failover Cluster
2 <Input from_log_sources>
3 Module im_tcp
4 ListenAddr 0.0.0.0:1514
5 </Input>
6
7 # Relay the Events to the SIEM
8 <Output to_siem>
9 Module om_tcp
10 Host siem.example.com:1514
11 </Output>
12
13 <Route relay>
14 Path from_log_sources => to_siem
15 </Route>
286
Chapter 30. High Availability NXLog User Guide
30.1. Failover
Configuring a cluster of redundant, multiple systems able to provide identical functionality is the first
prerequisite for implementing failover. Such a cluster is also known as an active-passive cluster. See NXLog
Failover Mode for a detailed guide on configuring NXLog externally managed active-passive clusters.
Figure 7. NXLog Relay Cluster used in failover mode for centralized logging
The architecture exhibited above includes a Raijin Server Cluster comprised of two nodes. It too will operate in
the same manner as the NXLog Relay Cluster, failing over to the next passive node if the active node fails.
To summarize, the failover for the NXLog Relay Cluster is configured in the om_tcp instance of each agent in the
Log Sources group. The failover for the Raijin Server Cluster is configured in the om_raijin output instance of
each agent in the NXLog Relay Cluster.
287
NXLog User Guide Chapter 30. High Availability
For NXLog deployments that have not yet been upgraded to v5, see the next diagram.
The following sample configurations are based on the architecture depicted above. For failover to function
as depicted, each of the NXLog relay nodes should have identical module instances (input, out, relay, etc.),
exception for their ListenAddr directive.
The configurations for sending events to Amazon S3 and SIEMs like Microsoft Azure
Sentinel or Splunk require additional setup that is beyond the scope of this chapter.
Should you opt to include them in your HA Centralized Log Collection architecture, please
NOTE
visit their respective integration chapters for details on how to prepare and configure the
NXLog Relay Cluster nodes for forwarding events to these third-party log analytics and/or
long-term archival solutions: Amazon S3, Microsoft Azure Sentinel, and Splunk.
30.1.2.2. Using a third-party solution to provide failover within the NXLog relay
cluster
For NXLog EE deployments that have not yet been upgraded to v5.0, failover needs to be managed by using a
third-party load balancing solution that can be configured to operate in active-passive mode, such as HAProxy or
Nginx.
288
Chapter 30. High Availability NXLog User Guide
Figure 8. Using a third-party solution to provide failover within the NXLog relay cluster
289
NXLog User Guide Chapter 30. High Availability
In the following examples, either HAProxy or Nginx can be configured to automatically select the next
available NXLog node in the relay cluster if the current node becomes unresponsive. Using this approach,
all log sources will have their output instances configured to send events to the third-party failover provider
as depicted in the diagram above.
nxlog.conf (Configuration for each Log Source sending to the failover server)
1 <Output to_3rd_party_failover>
2 Module om_tcp
3 OutputType Binary
4 Host 192.168.1.50:1514
5 </Output>
Each of the NXLog nodes in the NXLog Relay Cluster are configured to receive events from the third-party
failover provider.
290
Chapter 30. High Availability NXLog User Guide
Example 158. Using HAProxy to provide failover for an NXLog Relay Cluster
In this example HAProxy is configured for active-passive mode. The frontend section defines the listening IP
and port (0.0.0.0:1514) of the host where HAProxy is running.
The backend section defines the members of the NXLog cluster, assigns them labels (nxlog_1, nxlog_2,
nxlog_3), along with their listening IP addresses and ports. The second and third servers (nxlog_2 and
nxlog_3) are flagged with backup to indicate they should remain passive as long as nxlog_1 is accepting
connections and can relay events. The roundrobin algorithm means each server in the cluster will tested in
order, cycling back to the first server again if the last one in the list fails while serving as the primary due to
previous failures of the ones before it.
/etc/haproxy/haproxy.cfg
frontend tcp_front
bind *:1514
stats uri /haproxy?stats
default_backend tcp_back
backend tcp_back
balance roundrobin
server nxlog_1 192.168.1.51:1514 check
server nxlog_2 192.168.1.52:1514 check backup
server nxlog_3 192.168.1.53:1514 check backup
Example 159. Using Nginx to provide failover for an NXLog Relay Cluster
In this example Nginx is configured for active-passive mode within the context of a stream block. This is
important because HTTP connections are handled differently than TCP (stream) connections.
Within the server block, the listen directive defines only the port (effectively 0.0.0.0:1514) that the
Nginx host will be accepting connections on. The proxy_pass directive defines the name of the upstream
block, nxlog_relay_cluster, to which TCP traffic will be directed.
The named (nxlog_relay_cluster) upsteam block defines each server member of the NXLog cluster by
its hostname or IP address and port number. The second and third servers (192.168.1.52:1514 and
192.168.1.53:1514) are flagged with backup to indicate they should remain passive as long as
192.168.1.51:1514 is accepting connections and can relay events. Should the first server fail to accept
connections and relay events, each susequent server in the cluster will tested in order, cycling back to the
first server again if the last one in the list fails while serving as the primary due to previous failures of the
ones before it.
/etc/nginx/nginx.conf
stream {
upstream nxlog_relay_cluster {
server 192.168.1.51:1514;
server 192.168.1.52:1514 backup;
server 192.168.1.53:1514 backup;
}
server {
listen 1514;
proxy_pass nxlog_relay_cluster;
}
}
291
NXLog User Guide Chapter 30. High Availability
• Sudden spikes in workload that would otherwise overwhelm a non-distributed computing environment that
can easily slow the entire computing environment down to a crawl or even a halt.
• In an unmanaged cluster, some compute resources will inevitably be working at peak capacity while others
sit idle due the random nature of tasks and network traffic. A load balancer can efficiently distribute network
traffic and mete out compute tasks across multiple nodes. This optimizes resource utilization and maximizes
throughput.
Load balancing can also be used to scale out your application and increase its performance and redundancy.
30.2.1. Architecture
The active-active mode of managing a load balanced cluster of nodes provides the most cost effective use of a
cluster and the highest performance attainable. When comparing the architecture depicted in the following
diagram with the previous one for Failover, two major differences are apparent:
1. An additional Load Balancing tier has been inserted as a mediator between the Log Sources tier and the
NXLog Relay Cluster tier.
2. All nodes in the NXLog Relay Cluster are now active; none are sitting idle waiting for a failure to occur.
For this reason, load balancers are associated first and foremost with performance rather than fault tolerance.
Figure 9. Using Load Balancing with a NXLog Relay Cluster for Centralized Logging
292
Chapter 30. High Availability NXLog User Guide
Since neither pre-v5 NXLog Enterprise Edition nor HAProxy nor Nginx (Open Source) ship with
NOTE built-in failover capabilities, only a single load balancer can be used in standalone mode when
configuring pre-v5 log sources.
nxlog.conf (Configuration for each Log Source sending to the Load Balancer Cluster)
1 <Output to_relay>
2 Module om_tcp
3 OutputType Binary
4
5 # Load Balancer 1 - ACTIVE
6 Host 192.168.1.50:1514
7
8 # Load Balancer 2 - passive
9 Host 192.168.1.60:1514
10
11 </Output>
Each of the NXLog nodes in the NXLog Relay Cluster are configured to receive events from the third-party
failover provider.
293
NXLog User Guide Chapter 30. High Availability
Example 161. Using HAProxy to provide load balancing for an NXLog Relay Cluster
In this example HAProxy is configured for active-active mode. The leastconn load balancing algorithm is
recommended for TCP connections that are long-lived.
/etc/haproxy/haproxy.cfg
frontend tcp_front
bind *:1514
default_backend tcp_back
backend tcp_back
balance leastconn
mode tcp
server nxlog_1 192.168.1.51:1514 check
server nxlog_2 192.168.1.52:1514 check
server nxlog_3 192.168.1.53:1514 check
server nxlog_4 192.168.1.54:1514 check
server nxlog_5 192.168.1.55:1514 check
Example 162. Using Nginx to provide load balancing for an NXLog Relay Cluster
In this example Nginx is configured for active-active mode. The least_conn load balancing algorithm is
recommended for TCP connections that are long-lived.
/etc/nginx/nginx.conf
stream {
upstream nxlog_relay_cluster {
least_conn;
server 192.168.1.51:1514;
server 192.168.1.52:1514;
server 192.168.1.53:1514;
server 192.168.1.54:1514;
server 192.168.1.55:1514;
}
server {
listen 1514;
proxy_pass nxlog_relay_cluster;
}
}
294
Chapter 31. Encrypted Transfer NXLog User Guide
• strong authentication,
• message integrity (assures that the logs are not changed), and
• message confidentiality (assures that the logs cannot be viewed by an unauthorized party).
There are several modules in NXLog Enterprise Edition that support SSL/TLS encryption:
When using the SSL/TLS, there are two ways to handle authentication.
• With mutual authentication, both client and log server agents are authenticated, and certificates/keys must
be deployed for both agents. This is the most secure and prevents log collection if the client’s certificate is
untrusted or has expired.
• With server-side authentication only, authentication takes place only via a certificate/key deployed on the
server. On the log server, the im_ssl AllowUntrusted directive (or corresponding directive for im_http or
im_batchcompress) must be set to TRUE. The client is prevented from sending logs to an untrusted server
but the server accepts logs from untrusted clients.
295
NXLog User Guide Chapter 31. Encrypted Transfer
With the following configurations, a client reads logs from all log files under the /var/log directory, parses
the events with parse_syslog(), converts to JSON with to_json(), and forwards them over a secure connection
to the central server.
These configurations use mutual authentication: both agents are authenticated and certificates must be
created for both agents.
nxlog.conf (Client)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input messages>
10 Module im_file
11 File "/var/log/*"
12 Exec parse_syslog();
13 </Input>
14
15 <Output central_ssl>
16 Module om_ssl
17 Host 192.168.56.103
18 Port 516
19 CAFile /opt/ssl/rootCA.pem
20 CertFile /opt/ssl/client.crt
21 CertKeyFile /opt/ssl/client.key
22 KeyPass password
23 Exec to_json();
24 </Output>
The server receives the logs on port 516 and writes them to /var/log/logmsg.log.
296
Chapter 31. Encrypted Transfer NXLog User Guide
1. Generate the private root key for your Certification Authority (CA).
$ openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 730 -out rootCA.pem
b. Generate the certificate signing request for the CA. When prompted for the Common Name, enter the
server’s name or IP address.
297
NXLog User Guide Chapter 32. Reducing Bandwidth and Data Size
The three main strategies for achieving this goal are covered in the following sections:
• Filtering Events by removing unnecessary or duplicate events at the source so that less data needs to be
transported and stored—reducing the data size during all subsequent stages of processing.
• Trimming Events by removing extra content or fields from event records which can reduce the total volume
of log data.
• Compressing During Transport can drastically reduce bandwidth requirements for events being forwarded.
To achieve the best results, it is important to understand how fields work in NXLog and which fields are being
transferred or stored. For example, removing or modifying fields without modifying $raw_event will not reduce
data requirements at all for an output module instance that uses only $raw_event. See Event Records and Fields
for details, as well as the explanation in Compressing During Transport below.
In this example, an NXLog agent is configured to collect Syslog messages from devices on the local network.
Events are parsed with the xm_syslog parse_syslog() procedure, which sets the SeverityValue field. Any event
with a normalized severity lower than 3 (warning) is discarded.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input syslog>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 Exec parse_syslog(); if $SeverityValue < 3 drop();
10 </Input>
Similarly, the pm_norepeat module can be used to detect, count, and discard duplicate events. In their place,
pm_norepeat generates a single event with a last message repeated n times message.
298
Chapter 32. Reducing Bandwidth and Data Size NXLog User Guide
With this configuration, NXLog collects Syslog messages from hosts on the local network with im_udp and
parses them with the xm_syslog parse_syslog() procedure. Events are then routed through a pm_norepeat
module instance, where the $Hostname, $Message, and $SourceName fields are checked to detect duplicate
messages. Last, events are sent to a remote host with om_batchcompress.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input syslog_udp>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 Exec parse_syslog();
10 </Input>
11
12 <Processor norepeat>
13 Module pm_norepeat
14 CheckFields Hostname, Message, SourceName
15 </Processor>
16
17 <Output out>
18 Module om_batchcompress
19 Host 10.2.0.2
20 Port 2514
21 </Output>
22
23 <Route r>
24 Path syslog_udp => norepeat => out
25 </Route>
299
NXLog User Guide Chapter 32. Reducing Bandwidth and Data Size
This configuration reads from the Windows Event Log with im_msvistalog and uses an xm_rewrite module
instance to discard any fields in the event record that are not included in the whitelist. The xm_rewrite
instance below could be used with multiple sources; for example, the whitelist would also be suitable for
the xm_syslog fields.
NOTE The xm_rewrite module does not remove the $raw_event field.
nxlog.conf
1 <Extension whitelist>
2 Module xm_rewrite
3 Keep AccountName, Channel, EventID, EventReceivedTime, EventTime, Hostname, \
4 Severity, SeverityValue, SourceName
5 </Extension>
6
7 <Input eventlog>
8 Module im_msvistalog
9 <QueryXML>
10 <QueryList>
11 <Query Id='0'>
12 <Select Path='Security'>*[System/Level<=4]</Select>
13 </Query>
14 </QueryList>
15 </QueryXML>
16 Exec whitelist->process();
17 </Input>
In some cases, event messages contain a lot of extra data that is duplicated across multiple events of the same
time. One example of this is the "descriptive event data" which has been introduced by Microsoft for the
Windows Event Log. By removing this verbose text from common events, event sizes can be reduced significantly
while still preserving all the forensic details of the event.
300
Chapter 32. Reducing Bandwidth and Data Size NXLog User Guide
The following configuration collects events from the Application, Security, and System channels. Rules are
included for truncating the messages of Security events with IDs 4688 and 4769.
In this example, the $Message field is truncated. However, the $raw_event field is not. For
most input modules, $raw_event will include the contents of $Message and other fields
NOTE (see the im_msvistalog $raw_event field). To update the $raw_event field, include a
statement for this (see the comment in the configuration example). See also Compressing
During Transport below for more details.
Account Information:
Account Name: WINAD$@TEST.COM
Account Domain: TEST.COM
Logon GUID: {55a7f67c-a32c-150a-29f1-7e173ff130a7}
Service Information:
Service Name: WINAD$
Service ID: TEST\WINAD$
Network Information:
Client Address: ::1
Client Port: 0
Additional Information:
Ticket Options: 0x40810000
Ticket Encryption Type: 0x12
Failure Code: 0x0
Transited Services: -
This event is generated every time access is requested to a resource such as a computer or a
Windows service. The service name indicates the resource to which access was requested.
This event can be correlated with Windows logon events by comparing the Logon GUID fields in
each event. The logon event occurs on the machine that was accessed, which is often a
different machine than the domain controller which issued the service ticket.
Ticket options, encryption types, and failure codes are defined in RFC 4120.
301
NXLog User Guide Chapter 32. Reducing Bandwidth and Data Size
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Application">
7 *[System[(Level<=4)]]</Select>
8 <Select Path="Security">
9 *[System[(Level<=4)]]</Select>
10 <Select Path="System">
11 *[System[(Level<=4)]]</Select>
12 </Query>
13 </QueryList>
14 </QueryXML>
15 <Exec>
16 if ($Channel == 'Security') and ($EventID == 4688)
17 $Message =~ s/\s*Token Elevation Type indicates the type of .*$//s;
18 else if $(Channel == 'Security') and ($EventID == 4769)
19 $Message =~ s/\s*This event is generated every time access is .*$//s;
20 # Additional rules can be added here
21 # ...
22 # Optionally, update the $raw_event field
23 #$raw_event = $EventTime + ' ' + $Message;
24 </Exec>
25 </Input>
Output Sample
A Kerberos service ticket was requested.
Account Information:
Account Name: WINAD$@TEST.COM
Account Domain: TEST.COM
Logon GUID: {55a7f67c-a32c-150a-29f1-7e173ff130a7}
Service Information:
Service Name: WINAD$
Service ID: TEST\WINAD$
Network Information:
Client Address: ::1
Client Port: 0
Additional Information:
Ticket Options: 0x40810000
Ticket Encryption Type: 0x12
Failure Code: 0x0
Transited Services: -
There are cases when large events may cause a problem during transport or for processing by the receiving end.
Such a case may be packet fragmentation when using UDP. To prevent this issue, the event may be truncated to
make sure that it does not exceed a specific size.
302
Chapter 32. Reducing Bandwidth and Data Size NXLog User Guide
The following configuration reads from the Windows Event Log with im_msvistalog and truncates the event
to 1000 bytes by using the substr() function. This function accepts an input string and returns a sub-string
with the starting and ending positions as byte offsets from the beginning of the string.
This method will cause data after the specified position to be discarded. It should only
WARNING
be used in rare cases when the packet size must not be larger than a set limit.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id='0'>
6 <Select Path='Security'>*[System/Level=4]</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 Exec $raw_event = substr($raw_event, 0, 1000);
11 </Input>
The following chart compares the data requirements for the *m_tcp, *m_ssl (with TLSv1.2), and *m_batchcompress
module pairs. It is based on a sample of BSD Syslog records parsed with parse_syslog(). The values shown reflect
the total bi-directional bytes transferred at the packet level. Of course, ratios will vary from this in practice based
on network conditions and the compressibility of the event data.
Note that the om_tcp and om_ssl modules (among others) transfer only the $raw_event field by default, but can
be configured to transfer all fields with OutputType Binary. The om_batchcompress module transfers all fields
in the event record, but it is possible to send only the $raw_event field by first removing the other fields (see
Generating $raw_event and Removing Other Fields below).
303
NXLog User Guide Chapter 32. Reducing Bandwidth and Data Size
Simply configuring the *m_batchcompress modules for the transfer of event data between NXLog agents can
significantly reduce the bandwidth requirements for that part of the log path.
The table below displays the comparison of sending the same data set using different methods and modules:
Compressio Modules Event size Diff vs Sender CPU Receiver EPS sender EPS
n method used baseline usage CPU usage receiver
Compression ratios show that enabling SSLCompression yields only a minimal improvement in message size.
Batch compression fares much better, because it compresses data in batches leading to better compression
ratios.
304
Chapter 32. Reducing Bandwidth and Data Size NXLog User Guide
With the following configuration, an NXLog agent uses om_batchcompress to send events in compressed
batches to a remote NXLog agent.
The *m_batchcompress modules also support SSL/TLS encryption; see the im_batchcompress
TIP
and om_batchcompress configuration details.
The remote NXLog agent receives and decompresses the received batches with im_batchcompress. All
fields in an event are available to the receiving agent.
To further reduce the size of the batches transferred by the *m_batchcompress modules, and if only the
$raw_event field will be needed later in the log path, the extra fields can be removed from the event record prior
to transfer. This can be done with an xm_rewrite instance for multiple fields or with the delete() procedure (see
Renaming and Deleting Fields).
305
NXLog User Guide Chapter 32. Reducing Bandwidth and Data Size
In this configuration, events are collected from the Windows Event Log with im_msvistalog, which sets the
$raw_event and many other fields. To reduce the size of the events, only the $raw_event field is retained;
all the other fields in the event record are removed by the xm_rewrite module instance (called by clean-
>process()).
Rather than using the default im_msvistalog $raw_event field, it would also be possible to
NOTE customize it with something like $raw_event = $EventTime + ' ' + $Message or
to_json().
nxlog.conf
1 <Extension clean>
2 Module xm_rewrite
3 Keep raw_event
4 </Extension>
5
6 <Input eventlog>
7 Module im_msvistalog
8 <QueryXML>
9 <QueryList>
10 <Query Id='0'>
11 <Select Path='Security'>*[System/Level<=4]</Select>
12 </Query>
13 </QueryList>
14 </QueryXML>
15 </Input>
16
17 <Output out>
18 Module om_batchcompress
19 Host 10.2.0.2
20 Exec clean->process();
21 </Output>
Alternatively, if the various fields in the event record will be handled later in the log path, the $raw_event field
can be set to an empty string (but see the warning below).
306
Chapter 32. Reducing Bandwidth and Data Size NXLog User Guide
This configuration collects events from the Windows Event Log with im_msvistalog, which writes multiple
fields to the event record. In this case, the $raw_event field contains the same data as other fields. Because
the om_batchcompress module instance will send all the fields in the event record, the $raw_event field
can be emptied.
Many output modules operate on the $raw_event field only. It should not be set to
an empty string unless the output module sends all the event fields
(om_batchcompress or a module using the Binary OutputType) and so on for all
WARNING
subsequent agents and modules. Otherwise, a module instance will encounter an
empty $raw_event. For this reason, the following example is in general not
recommended.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id='1'>
6 <Select Path='Security'>*[System/Level<=4]</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 </Input>
11
12 <Output out>
13 Module om_batchcompress
14 Host 10.2.0.2
15 Exec $raw_event = '';
16 </Output>
307
NXLog User Guide Chapter 33. Reliable Message Delivery
• Log messages are buffered in various places in NXLog, and buffered messages can be lost in the case of a
crash. Persistent module message queues can be enabled so that these messages are stored on disk instead
of in memory. Each log message is removed from the queue only after successful delivery. See the
PersistLogqueue and SyncLogqueue global configuration directives, and the PersistLogqueue and
SyncLogqueue module directives.
Log message removal from queues in processor modules happens before delivery. This
WARNING can result in potential data loss. Do not use processor modules when high reliability
operation is required.
• Input positions (for im_file and other modules) are saved in the cache file, and by default this file is only
saved to disk on shutdown. In case of a crash some events may be duplicated or lost depending on the value
of the ReadFromLast directive. This data can be periodically flushed and synced to disk using the
CacheFlushInterval and CacheSync directives.
In this example, the log queues are synced to disk after each successful delivery. The cache file containing
the current event ID is also flushed and synced to disk after each event is read from the database. Note that
these reliability features, when enabled, significantly reduce the processing speed.
nxlog.conf
1 PersistLogqueue TRUE
2 SyncLogqueue TRUE
3 CacheFlushInterval always
4 CacheSync TRUE
5
6 <Input in>
7 Module im_file
8 File 'input.log'
9 </Input>
10
11 <Output out>
12 Module om_tcp
13 Host 10.0.0.1
14 Port 1514
15 </Output>
308
Chapter 33. Reliable Message Delivery NXLog User Guide
The solution to this unreliability in the TCP protocol is application-level acknowledgment. NXLog provides two
pairs of modules for this purpose.
• NXLog can use the HTTP/HTTPS protocol to provide guaranteed message delivery over the network,
optionally with TLS/SSL. The client (om_http) sends the event in a HTTP POST request. The server (im_http,
only available in NXLog Enterprise Edition) responds with a status code indicating successful message
reception.
In the following configuration example, a client reads logs from a file and transmits the logs over an
SSL-secured HTTP connection.
nxlog.conf (Client/Sending)
1 <Input in>
2 Module im_file
3 File 'input.log'
4 </Input>
5
6 <Output out>
7 Module om_http
8 URL https://10.0.0.1:8080/
9 HTTPSCertFile %CERTDIR%/client-cert.pem
10 HTTPSCertKeyFile %CERTDIR%/client-key.pem
11 HTTPSCAFile %CERTDIR%/ca.pem
12 </Output>
The remote NXLog agent accepts the HTTPS connections and stores the received messages in a file. The
contents of input.log will be replicated in output.log.
nxlog.conf (Server/Receiving)
1 <Input in>
2 Module im_http
3 ListenAddr 0.0.0.0
4 Port 8080
5 HTTPSCertFile %CERTDIR%/server-cert.pem
6 HTTPSCertKeyFile %CERTDIR%/server-key.pem
7 HTTPSCAFile %CERTDIR%/ca.pem
8 </Input>
9
10 <Output out>
11 Module om_file
12 File 'output.log'
13 </Output>
• The om_batchcompress and im_batchcompress modules, available in NXLog Enterprise Edition, also provide
acknowledgment as part of the batchcompress protocol.
309
NXLog User Guide Chapter 33. Reliable Message Delivery
With the following configuration, a client reads logs from a file and transmits the logs in compressed
batches to a remote NXLog agent.
nxlog.conf (Client/Sending)
1 <Input in>
2 Module im_file
3 File 'input.log'
4 </Input>
5
6 <Output out>
7 Module om_batchcompress
8 Host 10.0.0.1
9 UseSSL true
10 CertFile %CERTDIR%/client-cert.pem
11 CertKeyFile %CERTDIR%/client-key.pem
12 CAFile %CERTDIR%/ca.pem
13 </Output>
The remote NXLog agent receives and decompresses the received message batches and stores the
individual messages in a file. The contents of input.log will be replicated in output.log.
nxlog.conf (Server/Receiving)
1 <Input in>
2 Module im_batchcompress
3 ListenAddr 0.0.0.0
4 CertFile %CERTDIR%/server-cert.pem
5 CertKeyFile %CERTDIR%/server-key.pem
6 CAFile %CERTDIR%/ca.pem
7 </Input>
8
9 <Output out>
10 Module om_file
11 File 'output.log'
12 </Output>
In some cases it may be very important that a log message is not duplicated. For example, a duplicated message
may trigger the same alarm a second time or cause an extra entry in a financial transaction log. NXLog Enterprise
Edition can be configured to prevent duplicate messages from occurring.
The best way to prevent duplicated messages is by using serial numbers, as it is only possible to detect
duplicates at the receiver. The receiver can keep track of what has been received by storing the serial number of
the last message. If a message is received with the same or a lower serial number from the same source, the
message is simply discarded.
• Each module that receives a message directly from an input source or from another module in the route
assigns a field named $__SERIAL__$ with a monotonically increasing serial number. The serial number is
310
Chapter 33. Reliable Message Delivery NXLog User Guide
taken from a global generator and is increased after each fetch so that two messages received at two
modules simultaneously will not have the same serial number. The serial number is initialized to the seconds
elapsed since the UNIX epoch when NXLog is started. This way it can provide 1,000,000 serial numbers per
second without problems in case it is stopped and restarted. Otherwise the value would need to be saved
and synced to disk as after each serial number fetch which would adversely affect performance. When a
module receives a message it checks the value of the field named $__SERIAL__$ against the last saved
value.
• The im_http module keeps the value of the last $__SERIAL__$ for each client. It is only possible to know and
identify the client (om_http sender) in HTTPS mode. The Common Name (CN) in the certificate subject is
used and is assumed to uniquely identify the client.
The remote IP and port number cannot be used to identify the remote sender because the
remote port is assigned dynamically and changes for every connection. Thus if a client
sends a message, disconnects, reconnects, and then sends the same message again, it is
NOTE impossible to know if this is the same client or another. For this reason it is not possible to
protect against message duplication with plain TCP or HTTP when multiple clients connect
from the same IP. The im_ssl and im_batchcompress modules do not have the certificate
subject extraction implemented at this time.
• All other non-network modules use the value of $SourceModuleName which is automatically set to the name
of the module instance generating the log message. This value is assumed to uniquely identify the source.
The value of $SourceModuleName is not overwritten if it already exists. Note that this may present problems
in some complex setups.
• The algorithm is implemented in one procedure call named duplicate_guard(), which can be used in modules
to prevent message duplication. The dropped() function can be then used to test whether the current log
message has been dropped.
311
NXLog User Guide Chapter 33. Reliable Message Delivery
The following client and server configuration examples extend the earlier HTTPS example to provide an
ultra-reliable operation where messages cannot be lost locally due to a crash, lost over the network, or
duplicated.
nxlog.conf (Client/Sending)
1 PersistLogqueue TRUE
2 SyncLogqueue TRUE
3 CacheFlushInterval always
4 CacheSync TRUE
5
6 <Input in>
7 Module im_file
8 File 'input.log'
9 </Input>
10
11 <Output out>
12 Module om_http
13 URL https://10.0.0.1:8080/
14 HTTPSCertFile %CERTDIR%/client-cert.pem
15 HTTPSCertKeyFile %CERTDIR%/client-key.pem
16 HTTPSCAFile %CERTDIR%/ca.pem
17 Exec duplicate_guard();
18 </Output>
The server accepts the HTTPS connections and stores the received messages in a file. The contents of
input.log will be replicated in output.log
nxlog.conf (Server/Receiving)
1 PersistLogqueue TRUE
2 SyncLogqueue TRUE
3 CacheFlushInterval always
4 CacheSync TRUE
5
6 <Input in>
7 Module im_http
8 ListenAddr 0.0.0.0
9 Port 8080
10 HTTPSCertFile %CERTDIR%/server-cert.pem
11 HTTPSCertKeyFile %CERTDIR%/server-key.pem
12 HTTPSCAFile %CERTDIR%/ca.pem
13 Exec duplicate_guard();
14 </Input>
15
16 <Output out>
17 Module om_file
18 File 'output.log'
19 Exec duplicate_guard();
20 </Output>
312
Chapter 34. Compression and Encryption NXLog User Guide
To address the first question, compressing logs can help reduce the size of the data that needs to be stored, thus
allowing these resources to be reallocated for other purposes. This is true for both log entries that are large in
size, such as Windows Event Logs, as well as for log sources that generate many events within a short period of
time, even those that are small in size.
Log encryption offers security by concealing sensitive information that may be required by compliance
mandates.
Both operations, compression and encryption of data, imply that their inverse operations, decompression and
decryption, can be performed to facilitate the reading and processing of the original data.
The following sections demonstrate the various ways NXLog’s compression and encryption capabilities can be
used in different situations using sample configurations:
The data converters used with the InputType and OutputType directives of their respective
input/output stream-based modules are invoked using dot notation:
<InstanceName>.<DataConverterName>
NOTE
For the sake of consistency in these examples, all xm_zlib instances will be named zlib and all
xm_crypto instances will be named crypto. For more details about using data converters with
these directives, see the documentation on InputType data converters and OutputType data
converters.
To learn more about compression and encryption, see the documentation for the Compression
TIP
(xm_zlib) and Encryption (xm_crypto) extension modules.
The following table shows the order of operations for compressing and decompressing log data comprised of
single-line events.
313
NXLog User Guide Chapter 34. Compression and Encryption
Log data can be compressed and saved to file using the om_file module. To successfully read the compressed
logs, decompression needs to be performed on input and can be specified using the im_file module.
The example below shows how to compress Windows Event Log data using the NXLog xm_zlib extension module.
This configuration reads Windows Event Log messages with Event ID 4688 using the im_msvistalog input
module. The collected events are formatted as JSON using the to_json() procedure of the xm_json module.
Following the sequence of operations listed in the table above for compression, the OutputType directive in
the to_file output instance formats the data as LineBased events, then it invokes the compress data
converter using the zlib instance of the xm_zlib module to compress the log data.
Finally, the compressed output is saved as a file specified by the mandatory File directive.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension zlib>
6 Module xm_zlib
7 </Extension>
8
9 <Input from_eventlog>
10 Module im_msvistalog
11 <QueryXML>
12 <QueryList>
13 <Query Id="0">
14 <Select Path="Security">
15 *[System[Level=0 and (EventID=4688)]]
16 </Select>
17 </Query>
18 </QueryList>
19 </QueryXML>
20 Exec to_json();
21 </Input>
22
23 <Output to_file>
24 Module om_file
25 File 'C:\outputfile.txt.gz'
26 OutputType LineBased, zlib.compress
27 </Output>
The decompression procedure can be performed using the xm_zlib module as well, as shown below.
314
Chapter 34. Compression and Encryption NXLog User Guide
In this configuration, decompression is performed by the from_file input instance of the im_file module
when files are read.
Following the sequence of operations listed in the table above for decompression, the InputType directive
in the from_file input instance invokes the decompress data converter using the zlib instance of the
xm_zlib module to decompress the log data, then it reads the data as LineBased events.
After successful decompression and reading, log messages can be processed as usual. In this case, the log
data is forwarded over the network with UDP using the om_udp module.
nxlog.conf
1 <Extension zlib>
2 Module xm_zlib
3 </Extension>
4
5 <Input from_file>
6 Module im_file
7 File 'C:\inputtfile.txt.gz'
8 InputType zlib.decompress, LineBased
9 </Input>
10
11 <Output to_udp>
12 Module om_udp
13 Host 192.168.31.11:10500
14 </Output>
Log data can be encrypted and saved to file using the om_file module. Decryption can be performed using the
im_file module.
The examples below demonstrate how to configure NXLog to successfully encrypt and decrypt log data.
The following table shows the order of operations for encrypting and decrypting log data comprised of single-line
events.
315
NXLog User Guide Chapter 34. Compression and Encryption
In this example NXLog receives data via the network using the im_tcp module. The received data is
formatted as JSON using the to_json() procedure of the xm_json module.
Following the sequence of operations listed in the table above for encryption, the OutputType directive in
the to_file output instance formats the data as LineBased events, then it invokes the aes_encrypt data
converter using the crypto instance of the xm_crypto module to encrypt the log data. Since the optional
Password directive is specified in the crypto instance along with a password, it will be applied during the
encryption process.
Finally, the encrypted output is saved as a file specified by the mandatory File directive.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension crypto>
6 Module xm_crypto
7 Password <PASSWORD_TO_ENCRYPT>
8 </Extension>
9
10 <Input from_tcp>
11 Module im_tcp
12 ListenAddr 192.168.31.25:10500
13 Exec to_json();
14 </Input>
15
16 <Output to_file>
17 Module om_file
18 File '/tmp/output'
19 OutputType LineBased, crypto.aes_encrypt
20 </Output>
Decryption of logs is merely the inverse procedure of encrypting logs, which NXLog can perform as well. This
example shows how to decrypt log data.
316
Chapter 34. Compression and Encryption NXLog User Guide
Following the sequence of operations listed in the table above for decryption, the InputType directive in the
from_file input instance invokes the aes_decrypt data converter using the crypto instance of the
xm_crypto module to decrypt the log data. Since this data was encrypted with a password, the optional
Password directive is specified in the crypto instance along with the required password. Once the data has
been decrypted, it then reads the data as LineBased events.
Once the operations specified by the InputType directive have been completed, the data can be processed
as usual. In this case, the log data is sent over UDP using the om_udp module.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension crypto>
6 Module xm_crypto
7 Password <PASSWORD_TO_DECRYPT>
8 </Extension>
9
10 <Input from_file>
11 Module im_file
12 File '/tmp/input'
13 InputType crypto.aes_decrypt, LineBased
14 </Input>
15
16 <Output to_udp>
17 Module om_udp
18 Host 192.168.11.31:10500
19 </Output>
The following table shows the order of operations for compressing and encrypting log data comprised of single-
line events.
Compression + OutputTy
Encryption LineBased compress aes_encrypt
pe
Below is an example of the NXLog configuration to compress and encrypt the log data.
317
NXLog User Guide Chapter 34. Compression and Encryption
This example contains configuration to accept incoming UDP datagrams using the im_udp module. The logs
formatted as JSON using the to_json() procedure of the xm_json module.
Following the sequence of operations listed in the table above for compression and encryption, the
OutputType directive in the to_file output instance formats the data as LineBased events, then it invokes
the compress data converter using the zlib instance of the xm_zlib module to compress the log data.
Once the log data is compressed, it invokes the aes_encrypt data converter using the crypto instance of
the xm_crypto module to encrypt the log data. Since the optional Password directive is specified in the
crypto instance along with a password, it will be applied during the encryption process.
Finally, the encrypted output is saved as a file specified by the mandatory File directive.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension crypto>
6 Module xm_crypto
7 Password <PASSWORD_TO_ENCRYPT>
8 </Extension>
9
10 <Extension zlib>
11 Module xm_zlib
12 </Extension>
13
14 <Input from_udp>
15 Module im_udp
16 ListenAddr 192.168.31.25:10500
17 Exec to_json();
18 </Input>
19
20 <Output to_file>
21 Module om_file
22 File '/tmp/output'
23 OutputType LineBased, zlib.compress, crypto.aes_encrypt
24 </Output>
The following table shows the order of operations for decompressing and decrypting log data comprised of
single-line events.
Decompressio
n + Decryption InputType aes_decrypt decompress LineBased
318
Chapter 34. Compression and Encryption NXLog User Guide
Following the sequence of operations listed in the table above for decryption, the InputType directive in the
from_file input instance invokes the aes_decrypt data converter using the crypto instance of the
xm_crypto module to decrypt the log data. Since this data was encrypted with a password, the optional
Password directive is specified in the crypto instance along with the required password.
After the data has been decrypted, it invokes the decompress data converter using the zlib instance of the
xm_zlib module to decompress the log data and then reads it as LineBased events.
Finally, after restoring the log events to their original state, they are transmitted over TCP using the om_tcp
module to a remote host.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension crypto>
6 Module xm_crypto
7 Password <PASSWORD_TO_DECRYPT>
8 </Extension>
9
10 <Extension zlib>
11 Module xm_zlib
12 </Extension>
13
14 <Input from_file>
15 Module im_file
16 File '/tmp/input'
17 InputType crypto.aes_decrypt, zlib.decompress, LineBased
18 </Input>
19
20 <Output to_tcp>
21 Module om_tcp
22 Host 192.168.31.11:10500
23 </Output>
The following table shows the order of operations for compressing/encrypting, and decompressing/decrypting
log data comprised of single-line events.
Compression + OutputTy
Encryption LineBased compress aes_encrypt
pe
319
NXLog User Guide Chapter 34. Compression and Encryption
Decompressio
n + Decryption InputType aes_decrypt decompress LineBased
320
Chapter 34. Compression and Encryption NXLog User Guide
In this example, it is assumed that the input data is log data comprised of single-line events that have been
compressed and encrypted with a password.
Following the sequence of operations listed in the table above for decompression and decryption, the
InputType directive in the from_file input instance invokes the aes_decrypt data converter using the
crypto instance of the xm_crypto module to decrypt the log data. Since this data was encrypted with a
password, the optional Password directive is specified in the crypto instance along with the required
password.
After the data has been decrypted, it invokes the decompress data converter using the zlib instance of the
xm_zlib module to decompress the log data and then reads it as LineBased events.
At this stage, the log events are now ready for further processing or filtering as needed. In this case, the
Exec block of the from_file input instance instructs NXLog to discard messages which do not contain the
error string by using the drop() procedure. Events that are not dropped are then ready for output where
they will be compressed and encrypted.
Following the sequence of operations listed in the table above for compression and encryption, the
OutputType directive in the to_file output instance formats the data as LineBased events, then it invokes
the compress data converter using the zlib instance of the xm_zlib module to compress the log data.
Once the log data is compressed, it invokes the aes_encrypt data converter using the crypto instance of
the xm_crypto module to encrypt the log data. Since the optional Password directive is specified in the
crypto instance along with a password, it will be applied during the encryption process.
Finally, the filtered, compressed, and encrypted output is saved as a file specified by the mandatory File
directive.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension crypto>
6 Module xm_crypto
7 Password <PASSWORD_TO_DECRYPT>
8 </Extension>
9
10 <Extension zlib>
11 Module xm_zlib
12 </Extension>
13
14 <Input from_file>
15 Module im_file
16 File '/tmp/input_all'
17 InputType crypto.aes_decrypt, zlib.decompress, LineBased
18 Exec if not ($raw_event =~ /error/) drop();
19 </Input>
20
21 <Output to_file>
22 Module om_file
23 File '/tmp/output_error'
24 OutputType LineBased, zlib.compress, crypto.aes_encrypt
25 </Output>
321
NXLog User Guide
OS Support
Each of the following chapters lists some of the common log sources that can be collected on the corresponding
platform. See also Supported Platforms.
322
Chapter 35. IBM AIX NXLog User Guide
AIX Audit
The im_aixaudit module natively collects logs generated by the AIX Audit system, without depending on
auditstream or any other process.
This example reads AIX audit logs from the /dev/audit device file.
nxlog.conf
1 <Input in>
2 Module im_aixaudit
3 DeviceFile /dev/audit
4 </Input>
Custom Programs
The im_exec module allows log data to be collected from custom external programs.
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input exec>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/adm/ras/errlog
6 </Input>
DNS Monitoring
Logs can be collected from BIND 9.
323
NXLog User Guide Chapter 35. IBM AIX
This example monitors files in the /etc and /srv directories, generating events when files are modified
or deleted. Files ending in .bak are excluded from the watch list.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/etc/*"
4 File "/srv/*"
5 Exclude "*.bak"
6 Digest sha1
7 ScanInterval 3600
8 Recursive TRUE
9 </Input>
Local Syslog
Messages written to /dev/log can be collected with the im_uds module. Events written to file in Syslog
format can be collected with im_file. In both cases, the xm_syslog module can be used to parse the events.
See Collecting and Parsing Syslog for more information.
This example reads Syslog messages from /var/log/messages and parses them with the parse_syslog()
procedure.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 Exec parse_syslog();
9 </Input>
Log Files
The im_file module can be used to collect events from log files.
This configuration reads messages from the /opt/test/input.log file. No parsing is performed; each
line is available in the $raw_event field.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/opt/test/input.log"
4 </Input>
Process Accounting
The im_acct module can be used to gather details about which owner (user and group) runs what processes.
324
Chapter 35. IBM AIX NXLog User Guide
This configuration turns on process accounting (using /tmp/nxlog.acct as the log file) and watches for
messages.
nxlog.conf
1 <Input acct>
2 Module im_acct
3 AcctOn TRUE
4 File "/tmp/nxlog.acct"
5 </Input>
325
NXLog User Guide Chapter 36. FreeBSD
This example reads BSM audit logs from the /dev/auditpipe device file.
nxlog.conf
1 <Input bsm>
2 Module im_bsm
3 DeviceFile /dev/auditpipe
4 </Input>
Custom Programs
The im_exec module allows log data to be collected from custom external programs.
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input exec>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/log/messages
6 </Input>
DNS Monitoring
Logs can be collected from BIND 9.
326
Chapter 36. FreeBSD NXLog User Guide
This example monitors files in the /etc and /srv directories, generating events when files are modified
or deleted. Files ending in .bak are excluded from the watch list.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/etc/*"
4 File "/srv/*"
5 Exclude "*.bak"
6 Digest sha1
7 ScanInterval 3600
8 Recursive TRUE
9 </Input>
Kernel
Logs from the kernel can be collected directly with the im_kernel module.
The system logger may need to be disabled or reconfigured to collect logs with im_kernel. To
NOTE completely disable syslogd on FreeBSD, run service syslogd onestop and sysrc
syslogd_enable=NO.
nxlog.conf
1 <Input kernel>
2 Module im_kernel
3 </Input>
Local Syslog
Messages written to /dev/log can be collected with the im_uds module. Events written to file in Syslog
format can be collected with im_file. In both cases, the xm_syslog module can be used to parse the events.
See the Linux System Logs and Collecting and Parsing Syslog sections for more information.
This example reads Syslog messages from /var/log/messages and parses them with the parse_syslog()
procedure.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 Exec parse_syslog();
9 </Input>
327
NXLog User Guide Chapter 36. FreeBSD
Log Files
The im_file module can be used to collect events from log files.
This configuration reads messages from the /opt/test/input.log file. No parsing is performed; each
line is available in the $raw_event field.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/opt/test/input.log"
4 </Input>
Process Accounting
The im_acct module can be used to gather details about which owner (user and group) runs what processes.
This configuration turns on process accounting (using /var/account/acct as the log file) and watches
for messages.
nxlog.conf
1 <Input acct>
2 Module im_acct
3 AcctOn TRUE
4 File "/var/account/acct"
5 </Input>
328
Chapter 37. OpenBSD NXLog User Guide
This example reads BSM audit logs from the /dev/auditpipe device file.
nxlog.conf
1 <Input bsm>
2 Module im_bsm
3 DeviceFile /dev/auditpipe
4 </Input>
Custom Programs
The im_exec module allows log data to be collected from custom external programs.
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input exec>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/log/messages
6 </Input>
DNS Monitoring
Logs can be collected from BIND 9.
329
NXLog User Guide Chapter 37. OpenBSD
This example monitors files in the /etc and /srv directories, generating events when files are modified
or deleted. Files ending in .bak are excluded from the watch list.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/etc/*"
4 File "/srv/*"
5 Exclude "*.bak"
6 Digest sha1
7 ScanInterval 3600
8 Recursive TRUE
9 </Input>
Kernel
Logs from the kernel can be collected directly with the im_kernel module. See Linux System Logs.
The system logger may need to be disabled or reconfigured to collect logs with im_kernel. To
NOTE completely disable syslogd on OpenBSD, run rcctl stop syslogd and rcctl disable
syslogd.
nxlog.conf
1 <Input kernel>
2 Module im_kernel
3 </Input>
Local Syslog
Messages written to /dev/log can be collected with the im_uds module. Events written to file in Syslog
format can be collected with im_file. In both cases, the xm_syslog module can be used to parse the events.
See the Linux System Logs and Collecting and Parsing Syslog sections for more information.
This example reads Syslog messages from /var/log/messages and parses them with the parse_syslog()
procedure.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 Exec parse_syslog();
9 </Input>
330
Chapter 37. OpenBSD NXLog User Guide
Log Files
The im_file module can be used to collect events from log files.
This configuration reads messages from the /opt/test/input.log file. No parsing is performed; each
line is available in the $raw_event field.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/opt/test/input.log"
4 </Input>
Process Accounting
The im_acct module can be used to gather details about which owner (user and group) runs what processes.
This configuration turns on process accounting (using /var/account/acct as the log file) and watches
for messages.
nxlog.conf
1 <Input acct>
2 Module im_acct
3 AcctOn TRUE
4 File "/var/account/acct"
5 </Input>
331
NXLog User Guide Chapter 38. GNU/Linux
The perlfcount add-on can be used to collect system information and statistics on Linux platforms.
DNS Monitoring
Logs can be collected from BIND 9 on Linux.
Kernel
The im_kernel module reads logs directly from the kernel log buffer. These logs can be parsed with
xm_syslog. See the Linux System Logs section.
Local Syslog
Messages written to /dev/log can be collected with the im_uds module. Events written to file in Syslog
format can be collected with im_file. In each case, the xm_syslog module can be used to parse the events. See
the Linux System Logs and Collecting and Parsing Syslog sections for more information.
Log Databases
Events can be read from databases with the im_dbi and im_odbc modules.
Log Files
The im_file module can be used to collect events from log files.
Process Accounting
The im_acct module can be used to gather details about which owner (user and group) runs what processes.
This overlaps with Audit System logging.
332
Chapter 39. Apple macOS NXLog User Guide
This example reads events from input.asl and parses them with the xm_asl parser.
nxlog.conf
1 <Extension asl_parser>
2 Module xm_asl
3 </Extension>
4
5 <Input in>
6 Module im_file
7 # Example: "/var/log/asl/*"
8 File "foo/input.asl"
9 InputType asl_parser
10 Exec delete($EventReceivedTime);
11 </Input>
This configuration reads BSM audit logs directly from the kernel with the im_bsm module.
nxlog.conf
1 Group wheel
2
3 <Input bsm>
4 Module im_bsm
5 DeviceFile /dev/auditpipe
6 </Input>
333
NXLog User Guide Chapter 39. Apple macOS
This configuration reads from the BSM audit log files with im_file and parses the events with xm_bsm.
nxlog.conf
1 Group wheel
2
3 <Extension bsm_parser>
4 Module xm_bsm
5 </Extension>
6
7 <Input bsm>
8 Module im_file
9 File '/var/audit/*'
10 InputType bsm_parser
11 </Input>
Custom Programs
The im_exec module allows log data to be collected from custom external programs.
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input systemlog>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/log/system.log
6 </Input>
This configuration watches for changes to files and directories under /bin and /usr/bin/.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/bin/*"
4 File "/usr/bin/*"
5 ScanInterval 3600
6 Recursive TRUE
7 </Input>
334
Chapter 39. Apple macOS NXLog User Guide
Kernel
Logs from the kernel can be collected directly with the im_kernel module or via the local log file with im_file.
For log collection details, see macOS Kernel.
Local Syslog
Events written to file in Syslog format can be collected with im_file. The xm_syslog module can be used to
parse the events. See the Syslog section for more information.
This configuration file collects system logs from /var/log/system.log. This method does not read
from /dev/klog directly, so it is not necessary to disable syslogd.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/system.log"
8 Exec parse_syslog();
9 </Input>
Log Files
The im_file module can be used to collect events from log files.
This configuration uses the im_file module to read events from the specified log file.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/foo/in.log"
4 </Input>
Process Accounting
The im_acct module can be used to gather details about which owner (user and group) runs what processes.
With this configuration file, NXLog will enable process accounting to the specified file and reads events
from it.
nxlog.conf
1 Group wheel
2
3 <Input acct>
4 Module im_acct
5 File '/var/log/acct'
6 AcctOn TRUE
7 </Input>
335
NXLog User Guide Chapter 40. Oracle Solaris
This example configuration reads from files in /var/audit with im_file. The InputType provided by
xm_bsm is used to parse the binary format.
nxlog.conf
1 <Extension bsm_parser>
2 Module xm_bsm
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File '/var/audit/*'
8 InputType bsm_parser
9 </Input>
Custom Programs
The im_exec module allows log data to be collected from custom external programs.
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input systemlog>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/log/syslog
6 </Input>
DNS Monitoring
Logs can be collected from BIND 9.
336
Chapter 40. Oracle Solaris NXLog User Guide
This configuration watches for changes to files and directories under /usr/bin/.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/usr/bin/*"
4 Digest SHA1
5 ScanInterval 3600
6 Recursive TRUE
7 </Input>
Local Syslog
Events written to file in Syslog format can be collected with the im_file module and parsed with the xm_syslog
module. See Collecting and Parsing Syslog for more information.
This example uses the im_file module to read messages from /var/log/messages and the xm_syslog
parse_syslog() procedure to parse them.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 Exec parse_syslog();
9 </Input>
Log Files
The im_file module can be used to collect events from log files.
This configuration uses the im_file module to read events from the specified log file.
nxlog.conf
1 <Input in>
2 Module im_file
3 File "/foo/input.log"
4 </Input>
Process Accounting
The im_acct module can be used to gather details about which owner (user and group) runs what processes.
337
NXLog User Guide Chapter 40. Oracle Solaris
With this configuration file, NXLog will enable process accounting to the specified file and read events
from it.
nxlog.conf
1 <Input acct>
2 Module im_acct
3 AcctOn TRUE
4 File '/tmp/nxlog.acct'
5 </Input>
338
Chapter 41. Microsoft Windows NXLog User Guide
Custom Programs
The im_exec module allows log data to be collected from custom external programs.
DHCP Monitoring
DHCP logging can be set up for Windows DHCP server using the im_file module by reading DHCP audit logs
directly from CSV files. Alternatively, the im_msvistalog module can be used to collect DHCP Server or Client
event logs from the built-in channels in Windows Event Log.
DNS Monitoring
DNS logging can be set up for Windows DNS Server using either ETW tracing or debug logging.
Log Databases
Events can be read from databases with the im_odbc module. Some products write logs to SQL Server
databases; see the Microsoft System Center Operations Manager section for an example.
Log Files
The im_file module can be used to collect events from log files.
Microsoft Exchange
Logs generated by Microsoft Exchange can be used as a source for log collection with many log types
supported.
Microsoft IIS
IIS can be configured to write logs in W3C format, which can be read with im_file and parsed with xm_w3c or
xm_csv. Other formats can be parsed with other methods. See Microsoft IIS.
Microsoft SharePoint
Collect the various types of logs generated by Microsoft SharePoint, parse the ULS into another format, and
send.
339
NXLog User Guide Chapter 41. Microsoft Windows
Registry Monitoring
The Windows Registry can be monitored for changes; see the im_regmon module. For an example ruleset,
see the regmon-rules add-on.
Snare
Windows Event Log data can be converted to Snare format as needed for some third-party integrations.
Sysmon
Many additional audit events can be generated with the Sysmon utility, including process creation, system
driver loading, network connections, and modification of file creation timestamps. These events are written to
the Event Log. See the Sysmon section for more information.
Windows Applocker
Collecting event logs from Windows AppLocker is supported by using the im_msvistalog or the other Windows
Event Log modules.
Windows Firewall
Windows Firewall logs can be collected with the im_file module from the Advanced Security log. Alternatively,
the im_msvistalog module can be used to collect Windows Firewall events from Windows Event Log.
Windows Powershell
PowerShell scripts can be integrated for log processing tasks and configuration generation (for example,
Azure SQL database); see Using PowerShell Scripts. It is also possible to collect Powershell activity logs.
340
NXLog User Guide
Integration
341
NXLog User Guide Chapter 42. Amazon Web Services (AWS)
NXLog can be set up to retrieve CloudWatch log streams in either of two ways:
• NXLog can connect to the CloudWatch API using the Boto 3 client and poll for logs at regular intervals. This is
suitable when a short delay in log collection is acceptable.
• Or, AWS Lambda can be set up to push log data to NXLog via HTTP. This method offers low latency log
collection.
4. Choose to Attach existing policies directly and select the CloudWatchLogsReadOnly policy. Click Next:
Review and then Create user.
342
Chapter 42. Amazon Web Services (AWS) NXLog User Guide
343
NXLog User Guide Chapter 42. Amazon Web Services (AWS)
This example NXLog configuration uses im_python to execute the CloudWatch add-on script. The xm_json
parse_json() procedure is then used to parse the JSON log data into fields.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input py>
6 Module im_python
7 PythonCode cloudwatch.py
8 Exec parse_json();
9 </Input>
cloudwatch.py (truncated)
import nxlog, boto3, json, time
class LogReader:
def __init__(self, time_interval):
client = boto3.client('logs', region_name='eu-central-1')
self.lines = ""
all_streams = []
group_name = '<ENTER GROUP NAME HERE>'
1. In the AWS web interface, go to Services › Lambda and click the Create function button.
344
Chapter 42. Amazon Web Services (AWS) NXLog User Guide
4. Under Function code select Upload a .ZIP file for Code entry type, select Python under Runtime, and
change the Handler name to lambda_function.lambda_handler.
5. Set the correct host and port in lambda_function.py, then upload a ZIP archive with that file (and
certificates, if needed). Click Save.
6. From the Configuration tab, change to the Triggers tab. Click + Add trigger.
7. Choose CloudWatch Logs as a trigger for the Lambda function. Select the log group that should be
forwarded and provide a Filter Name, then click Submit.
345
NXLog User Guide Chapter 42. Amazon Web Services (AWS)
346
Chapter 42. Amazon Web Services (AWS) NXLog User Guide
In this example, the im_http module listens for connections from the Lambda script via HTTP. The xm_json
parse_json() procedure is then used to parse the JSON log data into fields.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input http>
6 Module im_http
7 ListenAddr 127.0.0.1
8 Port 8080
9 HTTPSCertFile %CERTDIR%/server-cert.pem
10 HTTPSCertKeyFile %CERTDIR%/server-key.pem
11 HTTPSCAFile %CERTDIR%/ca.pem
12 HTTPSRequireCert TRUE
13 HTTPSAllowUntrusted FALSE
14 Exec parse_json();
15 </Input>
lambda_function.py
import json, base64, zlib, ssl, http.client
print('Loading function')
When running NXLog in EC2 instances, it may be helpful to include the current instance ID in the collected logs.
For more information about retrieving EC2 instance metadata and adding it to event data, see the Amazon Web
Services section of the Cloud Instance Metadata chapter.
347
NXLog User Guide Chapter 42. Amazon Web Services (AWS)
NXLog can be set up to send log data to S3 storage or read log data from S3 storage. For more information, see
the Amazon S3 add-on documentation.
348
Chapter 43. Apache HTTP Server NXLog User Guide
349
NXLog User Guide Chapter 43. Apache HTTP Server
The following directives enable error logging of all messages at or above the "informational" severity level,
in the specified format, to the specified file. The ErrorLogFormat defined below is equivalent to the
default, which includes the timestamp, the module producing the message, the event severity, the process
ID, the thread ID, the client address, and the detailed error message.
apache2.conf
LogLevel info
ErrorLogFormat "[%{u}t] [%-m:%l] [pid %P:tid %T] [client %a] %M"
ErrorLog /var/log/apache2/error.log
The following is a typical log message generated by the Apache HTTP Server, an NXLog configuration for
parsing it, and the resulting JSON.
Log Sample
[Tue Aug 01 07:17:44.496832 2017] [core:info] [pid 15019:tid 140080326108928] [client
192.168.56.1:60154] AH00128: File does not exist: /var/www/html/notafile.html↵
nxlog.conf
1 <Input apache_error>
2 Module im_file
3 File '/var/log/apache2/error.log'
4 <Exec>
5 if $raw_event =~ /(?x)^\[\S+\ ([^\]]+)\]\ \[(\S+):(\S+)\]\ \[pid\ (\d+):
6 tid\ (\d+)\]\ (\[client\ (\S+)\]\ )?(.+)$/
7 {
8 $EventTime = parsedate($1);
9 $ApacheModule = $2;
10 $ApacheLogLevel = $3;
11 $ApachePID = $4;
12 $ApacheTID = $5;
13 if $7 != '' $ClientAddress = $7;
14 $Message = $8;
15 }
16 </Exec>
17 </Input>
Output Sample
{
"EventReceivedTime": "2017-08-01T07:17:45.641190+02:00",
"SourceModuleName": "apache_error",
"SourceModuleType": "im_file",
"EventTime": "2017-08-01T07:17:44.496832+02:00",
"ApacheModule": "core",
"ApacheLogLevel": "info",
"ApachePID": "15019",
"ApacheTID": "140080317716224",
"ClientAddress": "192.168.56.1:60026",
"Message": "AH00128: File does not exist: /var/www/html/notafile.html"
}
350
Chapter 43. Apache HTTP Server NXLog User Guide
There are several options for handling logging when using virtual hosts. The examples below, when specified in
the main server context (not in a <VirtualHost> section) will log all requests exactly as with a single-host server.
The %v format string can be added, if desired, to log the name of the virtual server responding to the request.
Alternatively, the CustomLog directive can be specified inside a <VirtualHost> section, in which case only the
requests served by that virtual server will be logged to the file.
Pre-defined format strings for the Common Log and Combined Log Formats may be included by
NOTE default. These pre-defined formats may use %O (the total sent including headers) instead of the
standard %b (the size of the requested file) in order to allow detection of partial requests.
Example 220. Using the Common Log Format for the Access Log
The LogFormat directive below creates a format named common that corresponds to the Common Log
Format. The second directive configures the Apache HTTP Server to write entries to the access_log file in
the common format.
apache2.conf
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog /var/log/apache2/access_log common
Example 221. Using the Combined Log Format for the Access Log
The following directives will configure the Apache HTTP Server to write entries to the access_log file in the
Combined Log Format.
apache2.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog /var/log/apache2/access_log combined
NXLog configuration examples for parsing these access log formats can be found in the Common & Combined
Log Formats section.
351
NXLog User Guide Chapter 44. Apache Tomcat
Here is a log sample consisting of three events. The log message of the second event spans multiple lines.
Log Sample
2001-01-25 17:31:42,136 INFO [org.nxlog.somepackage.Class] - single line↵
2001-01-25 17:41:16,268 ERROR [org.nxlog.somepackage.Class] - Error retrieving names: ; nested
exception is:↵
java.net.ConnectException: Connection refused↵
AxisFault↵
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException↵
faultSubcode:↵
faultString: java.net.ConnectException: Connection refused↵
faultActor:↵
faultNode:↵
faultDetail:↵
{http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection refused↵
2001-01-25 17:57:38,469 INFO [org.nxlog.somepackage.Class] - third log message↵
In order to parse and process multiple line log messages, the xm_multiline module can be used. In this
example, a regular expression match determines the beginning of a log message.
nxlog.conf
1 define REGEX /(?x)^(?<EventTime>\d{4}\-\d{2}\-\d{2}\ \d{2}\:\d{2}\:\d{2}),\d{3}\ \
2 (?<Severity>\S+)\ \[(?<Class>\S+)\]\ \-\ (?<Message>[\s\S]+)/
3
4 <Extension multiline>
5 Module xm_multiline
6 HeaderLine %REGEX%
7 </Extension>
8
9 <Input log4j>
10 Module im_file
11 File "/var/log/tomcat6/catalina.out"
12 InputType multiline
13 Exec if $raw_event =~ %REGEX% $EventTime = parsedate($EventTime);
14 </Input>
352
Chapter 45. APC Automatic Transfer Switch NXLog User Guide
Log Sample
Date Time Event↵
------------------------------------------------------------------------↵
03/26/2017 16:20:55 Automatic Transfer Switch: Communication↵
established.↵
03/26/2017 16:20:45 System: Warmstart.↵
03/26/2017 16:19:13 System: Detected an unauthorized user attempting↵
to access the SNMP interface from 192.168.15.11.↵
The ATS is an independent device, so if there more than one installed in a particular environment the
configuration below must be applied to each device individually. For more details about configuring APC ATS
logging, go to the APC Support Site and select the product name or part number.
The steps below have been tested on AP7700 series devices and should work for other ATS
NOTE
models also.
1. Configure NXLog for receiving log entries via UDP (see the example below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from the device.
3. Configure Syslog logging on the ATS using either the web interface or the command line. See the following
sections.
353
NXLog User Guide Chapter 45. APC Automatic Transfer Switch
The following examples shows the ATS logs as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/apc.log"
19 Exec to_json();
20 </Output>
Logs like the example at the beginning of the chapter will produce output as follows.
354
Chapter 45. APC Automatic Transfer Switch NXLog User Guide
Output Sample
{
"MessageSourceAddress": "192.168.15.22",
"EventReceivedTime": "2017-03-26 17:03:27",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 23,
"SyslogFacility": "LOCAL7",
"SyslogSeverityValue": 7,
"SyslogSeverity": "DEBUG",
"SeverityValue": 1,
"Severity": "DEBUG",
"Hostname": "192.168.15.22",
"EventTime": "2017-03-26 16:04:18",
"SourceName": "System",
"Message": "Detected an unauthorized user attempting to access the SNMP interface from
192.168.15.11. 0x0004"
}
{
"MessageSourceAddress": "192.168.15.22",
"EventReceivedTime": "2017-03-26 17:20:04",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 23,
"SyslogFacility": "LOCAL7",
"SyslogSeverityValue": 7,
"SyslogSeverity": "DEBUG",
"SeverityValue": 1,
"Severity": "DEBUG",
"Hostname": "192.168.15.22",
"EventTime": "2017-03-26 16:20:54",
"SourceName": "System",
"Message": "Warmstart. 0x0002"
}
{
"MessageSourceAddress": "192.168.15.22",
"EventReceivedTime": "2017-03-26 17:20:04",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 23,
"SyslogFacility": "LOCAL7",
"SyslogSeverityValue": 7,
"SyslogSeverity": "DEBUG",
"SeverityValue": 1,
"Severity": "DEBUG",
"Hostname": "192.168.15.22",
"EventTime": "2017-03-26 16:20:55",
"Message": "Automatic Transfer Switch: Communication established. 0x0C05"
}
3. Enable Syslog.
4. Select the Facility.
355
NXLog User Guide Chapter 45. APC Automatic Transfer Switch
7. Click [Apply].
356
Chapter 45. APC Automatic Transfer Switch NXLog User Guide
The following shows the Syslog settings screen, which is shown after completing step 2 above.
1- Settings
2- Server 1
3- Server 2
4- Server 3
5- Server 4
6- Severity Mapping
357
NXLog User Guide Chapter 46. Apple macOS Kernel
• Collect directly with the im_kernel module, which requires disabling syslogd.
• Collect via the local log file with im_file; see Local Syslog below.
This configuration uses the im_kernel module to read events directly from the kernel (via /dev/klog).
This requires that syslogd be disabled as follows:
2. Rename plist to keep syslogd from starting again at the next reboot.
$ sudo mv /System/Library/LaunchDaemons/com.apple.syslogd.plist \
/System/Library/LaunchDaemons/com.apple.syslogd.plist.disabled
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input kernel>
6 Module im_kernel
7 Exec parse_syslog_bsd();
8 </Input>
Newer versions of Apple macOS use ULS (Unified Logging System) with SIP (System Integrity Protection) and
users are unable to easily disable syslogd while keeping SIP enabled. For this setup, you can leverage the
im_exec module to collect from /usr/bin/log stream --style=json --type=log.
358
Chapter 46. Apple macOS Kernel NXLog User Guide
This configuration uses the im_exec module to read events from the kernel (via /usr/bin/log) and
parses the data with the xm_json module.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension multiline>
6 Module xm_multiline
7 HeaderLine /^\[{|^},{/
8 </Extension>
9
10 <Input in>
11 Module im_exec
12 Command /usr/bin/log
13 Arg stream
14 Arg --style=json
15 Arg --type=log
16 InputType multiline
17 <Exec>
18 $raw_event =~ s/^\[{|^},{/{/;
19 $raw_event =~ s/\}]$//;
20 $raw_event = $raw_event + "\n}";
21 parse_json();
22 </Exec>
23 </Input>
359
NXLog User Guide Chapter 47. ArcSight Common Event Format (CEF)
CEF is a text-based log format developed by ArcSight™ and used by HP ArcSight™ products. It uses Syslog as
transport. The full format includes a Syslog header or "prefix", a CEF "header", and a CEF "extension". The
extension contains a list of key-value pairs. Standard key names are provided, and user-defined extensions can
be used for additional key names. In some cases, CEF is used with the Syslog header omitted.
CEF Syntax
Jan 11 10:25:39 host CEF:Version|Device Vendor|Device Product|Device Version|Device Event Class
ID|Name|Severity|[Extension]↵
Log Sample
Oct 12 04:16:11 localhost CEF:0|nxlog.org|nxlog|2.7.1243|Executable Code was Detected|Advanced
exploit detected|100|src=192.168.255.110 spt=46117 dst=172.25.212.204 dpt=80↵
The ArcSight™ Logger can be configured to send CEF logs via TCP with the following steps.
5. Click Save.
360
Chapter 47. ArcSight Common Event Format (CEF) NXLog User Guide
With this configuration, NXLog will collect CEF logs via TCP, convert to plain JSON format, and save to file.
nxlog.conf
1 <Extension _cef>
2 Module xm_cef
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Extension _syslog>
10 Module xm_syslog
11 </Extension>
12
13 <Input logger_tcp>
14 Module im_tcp
15 Host 0.0.0.0
16 Port 1514
17 Exec parse_syslog(); parse_cef($Message);
18 </Input>
19
20 <Output json_file>
21 Module om_file
22 File '/var/log/json'
23 Exec to_json();
24 </Output>
25
26 <Route r>
27 Path logger_tcp => json_file
28 </Route>
The ArcSight™ Logger can be configured to receive CEF logs via TCP with the following steps.
◦ Encoding: UTF-8
5. Click Save.
361
NXLog User Guide Chapter 47. ArcSight Common Event Format (CEF)
With this configuration, NXLog will read Syslog logs from file, convert them to CEF, and forward them to the
ArcSight Logger via TCP. Default values will be used for the CEF header unless corresponding fields are
defined in the event record (see the to_cef() procedure in the Reference Manual for a list of fields).
nxlog.conf
1 <Extension _cef>
2 Module xm_cef
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input messages_file>
10 Module im_file
11 File '/var/log/messages'
12 Exec parse_syslog();
13 </Input>
14
15 <Output logger_tcp>
16 Module om_tcp
17 Host 192.168.1.1
18 Port 574
19 Exec $Message = to_cef(); to_syslog_bsd();
20 </Output>
21
22 <Route r>
23 Path messages_file => logger_tcp
24 </Route>
WARNING The xm_csv and xm_kvp modules may not always correctly parse or generate CEF logs.
362
Chapter 47. ArcSight Common Event Format (CEF) NXLog User Guide
Here, the xm_csv module is used to parse the pipe-delimited CEF header, while the xm_kvp module is used
to parse the space-delimited key-value pairs in the CEF extension. The required extension configurations
are shown below.
nxlog.conf Extensions
1 <Extension cef_header>
2 Module xm_csv
3 Fields $Version, $Device_Vendor, $Device_Product, $Device_Version, \
4 $Signature_ID, $Name, $Severity, $_Extension
5 Delimiter |
6 QuoteMethod None
7 </Extension>
8
9 <Extension cef_extension>
10 Module xm_kvp
11 KVDelimiter '='
12 KVPDelimiter ' '
13 QuoteMethod None
14 </Extension>
15
16 <Extension syslog>
17 Module xm_syslog
18 </Extension>
nxlog.conf Input
1 <Input in>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 <Exec>
6 parse_syslog();
7 cef_header->parse_csv($Message);
8 cef_extension->parse_kvp($_Extension);
9 </Exec>
10 </Input>
363
NXLog User Guide Chapter 47. ArcSight Common Event Format (CEF)
nxlog.conf Output
1 <Output out>
2 Module om_tcp
3 Host 192.168.1.1
4 Port 574
5 <Exec>
6 $_Extension = cef_extension->to_kvp();
7 $Version = 'CEF:0';
8 $Device_Vendor = 'NXLog';
9 $Device_Product = 'NXLog';
10 $Device_Version = '';
11 $Signature_ID = '0';
12 $Name = '-';
13 $Severity = '';
14 $Message = cef_header->to_csv();
15 to_syslog_bsd();
16 </Exec>
17 </Output>
364
Chapter 48. Box NXLog User Guide
NXLog can be set up to pull events from Box using their REST API. For more information, see the Box add-on.
365
NXLog User Guide Chapter 49. Brocade Switches
Log Sample
2017/03/22-23:05:12, [SEC-1203], 113962, FID 128, INFO, fcsw1, Login information: Login successful
via TELNET/SSH/RSH. IP Addr: admin2↵
The best way to configure a Brocade switch is with the command line interface. In the case of multiple switches
running in redundancy mode, each device must be configured separately.
More details on configuring Brocade switches can be found in the Brocade Document Library: search for a
particular switch model and select Installation & Configuration Guides from the Filter list.
The steps below have been tested with Brocade 4100 series switches and OS v6. Newer
NOTE
software versions may have additional capabilities, such as sending logs over TLS.
1. Configure NXLog for receiving Syslog entries via UDP (see the example below), then restart NXLog.
2. Make sure the NXLog agent is accessible from the switch.
3. Log in to the switch via SSH.
4. Run the following commands. Replace LEVEL with an integer corresponding to the desired Syslog local facility
(see the example). Replace IP_ADDRESS with the address of the NXLog agent.
# syslogdfacility -l LEVEL
# syslogdIpAdd IP_ADDRESS
The following commands query the current Syslog facility and then set up Syslog logging to
192.168.6.143 with Syslog facility local5.
fcsw1:admin> syslogdfacility
Syslog facility: LOG_LOCAL7
fcsw1:admin> syslogdfacility -l 5
Syslog facility changed to LOG_LOCAL5
fcsw1:admin> syslogdIpAdd 192.168.6.143
Syslog IP address 192.168.6.143 added
366
Chapter 49. Brocade Switches NXLog User Guide
This example shows Brocade switch logs as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/brocade.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.5.15",
"EventReceivedTime": "2017-03-22 20:23:58",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 21,
"SyslogFacility": "LOCAL5",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-03-22 20:23:58",
"Hostname": "192.168.5.15",
"SourceName": "raslogd",
"Message": "2017/03/22-23:05:12, [SEC-1203], 113962, WWN 10:00:00:05:1e:02:8e:fc | FID 128,
INFO, fcsw1, Login information: Login successful via TELNET/SSH/RSH. IP Addr: admin2"
}
367
NXLog User Guide Chapter 50. Browser History Logs
Most popular browsers keep a log of the browsing history in an SQLite database. Information in this database
includes the URL that was accessed, the title of the page, the time when the page was visited, and the number of
times it was accessed. This data can be collected and processed with NXLog using the im_odbc module.
Linux/Unix
/home/<username>/.config/google-chrome/Default
macOS
/Users/<username>/Library/Application Support/Google/Chrome/Default
The tables containing the browsing history in the History database are named urls and visits. Data from these
tables can be joined together to retrieve the URL, page title, and time it was accessed.
368
Chapter 50. Browser History Logs NXLog User Guide
Table 77. Example data from joined visits and urls tables
Linux/Unix
/home/<username>/.mozilla/firefox/<profile folder>
macOS
/Users/<username>/Library/Application Support/Firefox/Profiles/<profile folder>
The tables containing the browsing history in the places database are named moz_places and moz_historyvisits.
Data from these tables can be joined together to retrieve the URL, page title, and time it was accessed.
369
NXLog User Guide Chapter 50. Browser History Logs
Table 80. Example data from joined moz_historyvisits and moz_places tables
The tables containing the browsing history in the History database are named urls and visits. Data from these
tables can be joined together to retrieve the URL, page title, and the time it was accessed.
Table 83. Example data from joined visits and urls tables
370
Chapter 50. Browser History Logs NXLog User Guide
371
NXLog User Guide Chapter 50. Browser History Logs
This example configuration uses the xm_exec module to periodically run a batch script which copies the
History database to a new location. This is done to avoid cases when the the database is locked by Google
Chrome. The copied database is then processed by the im_odbc module.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension exec>
6 Module xm_exec
7 <Schedule>
8 Every 30 min
9 <Exec>
10 odbc->module_stop();
11 sleep(5000000);
12 exec("C:\scripts\copy_chrome_db.cmd");
13 odbc->module_start();
14 </Exec>
15 </Schedule>
16 </Extension>
17
18 <Input odbc>
19 Module im_odbc
20 ConnectionString DRIVER=SQLite3 ODBC Driver; \
21 Database=C:\logs\History_Chrome;Version=3;
22 SQL SELECT visits.id AS id, \
23 DATETIME(ROUND(visits.visit_time / 1000000-11644473600), \
24 'unixepoch', 'localtime') AS EventTime, \
25 urls.url AS URL, \
26 urls.title AS Title \
27 FROM visits \
28 INNER JOIN urls ON visits.url = urls.id \
29 WHERE visits.id > ?
30 PollInterval 1200
31 Exec to_json();
32 </Input>
Google Chrome saves the visit_time as a timestamp in nanoseconds. In this example the
NOTE
SQL DATETIME function is used to convert it to local time.
copy_chrome_db.cmd
@echo off
copy "%LOCALAPPDATA%\Google\Chrome\User Data\Default\History" C:\logs\History_Chrome /Y >nul
The cmd file needs to be saved in the path specified in the Exec block of the schedule in
NOTE the configuration file. The user running NXLog needs to have permission to execute the
file.
The same configuration may be used for Microsoft Edge by changing the location of the
NOTE
original browser history database.
372
Chapter 50. Browser History Logs NXLog User Guide
Output Sample
{
"id": 100,
"EventTime": "2020-11-17 08:32:27",
"URL": "https://nxlog.co",
"Title": "High Performance Log Management Solutions",
"EventReceivedTime": "2020-11-17T09:30:23.811555+01:00",
"SourceModuleName": "odbc",
"SourceModuleType": "im_odbc"
}
373
NXLog User Guide Chapter 50. Browser History Logs
Example 233. Collecting browsing history from Mozilla Firefox on Linux Ubuntu
This example configuration uses the xm_exec module to periodically copy the places.sqlite database to
a new location. This is done to avoid cases when the the database is locked by Mozilla Firefox. The copied
database is then processed by the im_odbc module.
nxlog.conf (truncated)
1 define FDBPATH /home/<user>/.mozilla/firefox/<profile_folder>/places.sqlite
2 define FDBCOPY /var/log/browser/places.sqlite
3
4 <Extension json>
5 Module xm_json
6 </Extension>
7
8 <Extension exec>
9 Module xm_exec
10 <Schedule>
11 Every 30 min
12 <Exec>
13 odbc->module_stop();
14 sleep(5000000);
15 exec("/bin/sh", "-c", "cp %FDBPATH% %FDBCOPY%");
16 odbc->module_start();
17 </Exec>
18 </Schedule>
19 </Extension>
20
21 <Input odbc>
22 Module im_odbc
23 ConnectionString DRIVER=SQLite3;Database=%FDBCOPY%;
24 SQL SELECT moz_historyvisits.id AS id, \
25 DATETIME(ROUND(moz_historyvisits.visit_date / 1000000), \
26 'unixepoch', 'localtime') AS EventTime, \
27 moz_places.url AS URL, \
28 moz_places.title AS Title \
29 [...]
Mozilla Firefox saves the visit_date as a timestamp in microseconds. In this example the
NOTE
SQL DATETIME function is used to convert it to local time.
Output Sample
{
"id": 100,
"EventTime": "2020-11-09 14:30:43",
"URL": "https://nxlog.co",
"Title": "High Performance Log Management Solutions",
"EventReceivedTime": "2020-11-09T15:32:51.811555+01:00",
"SourceModuleName": "odbc",
"SourceModuleType": "im_odbc"
}
374
Chapter 51. Check Point NXLog User Guide
With the following configuration, NXLog will collect logs from Check Point devices over the LEA protocol and
write them to file in JSON format.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input checkpoint>
6 Module im_checkpoint
7 Command /opt/nxlog/bin/nx-im-checkpoint
8 LEAConfigFile /opt/nxlog/etc/lea.conf
9 </Input>
10
11 <Output file>
12 Module om_file
13 File 'tmp/output'
14 Exec $raw_event = to_json();
15 </Output>
16
17 <Route checkpoint_to_file>
18 Path checkpoint => file
19 </Route>
375
NXLog User Guide Chapter 52. Cisco ACS
Log Sample
<38>Oct 16 21:01:29 10.0.1.1 CisACS_02_FailedAuth 1k1fg93nk 1 0 Message-Type=Authen failed,User-
Name=John,NAS-IP-Address=10.0.1.2,AAA Server=acs01↵
The following configuration file instructs NXLog to accept Syslog messages on UDP port 1514. The payload
is parsed as Syslog and then the ACS specific fields are extracted. The output is written to file in JSON
format.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_udp
11 Host 0.0.0.0
12 Port 1514
13 <Exec>
14 parse_syslog_bsd();
15 if ( $Message =~ /^CisACS_(\d\d)_(\S+) (\S+) (\d+) (\d+) (.*)$/ )
16 {
17 $ACSCategoryNumber = $1;
18 $ACSCategoryName = $2;
19 $ACSMessageId = $3;
20 $ACSTotalSegments = $4;
21 $ACSSegmentNumber = $5;
22 $ACSMessage = $6;
23 if ( $ACSMessage =~ /Message-Type=([^\,]+)/ ) $ACSMessageType = $1;
24 if ( $ACSMessage =~ /User-Name=([^\,]+)/ ) $AccountName = $1;
25 if ( $ACSMessage =~ /NAS-IP-Address=([^\,]+)/ ) $ACSNASIPAddress = $1;
26 if ( $ACSMessage =~ /AAA Server=([^\,]+)/ ) $ACSAAAServer = $1;
27 }
28 else log_warning("Does not match: " + $raw_event);
29 [...]
376
Chapter 53. Cisco ASA NXLog User Guide
Log Sample
Apr 15 2017 00:21:14 192.168.12.1 : %ASA-5-111010: User 'john', running 'CLI' from IP 0.0.0.0,
executed 'dir disk0:/dap.xml'↵
Apr 15 2017 00:22:27 192.168.12.1 : %ASA-4-313005: No matching connection for ICMP error message:
icmp src outside:81.24.28.226 dst inside:72.142.17.10 (type 3, code 0) on outside interface.
Original IP payload: udp src 72.142.17.10/40998 dst 194.153.237.66/53.↵
Apr 15 2017 00:22:42 192.168.12.1 : %ASA-3-710003: TCP access denied by ACL from
179.236.133.160/8949 to outside:72.142.18.38/23↵
For more details about configuring Syslog on Cisco ASA, see the Cisco configuration guide for the ASA or
Adaptive Security Device Manager (ASDM) version in use.
The steps below have been tested with ASA 9.x and ASDM 7.x, but should also work with other
NOTE
versions.
377
NXLog User Guide Chapter 53. Cisco ASA
This example shows Cisco ASA logs as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_tcp>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/asa.log"
19 Exec to_json();
20 </Output>
The following output log sample resulted from the input at the beginning of the chapter being processed by
this configuration.
378
Chapter 53. Cisco ASA NXLog User Guide
Output Sample
{
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-04-15 00:19:53",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 20,
"SyslogFacility": "LOCAL4",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "192.168.12.1",
"EventTime": "2017-04-15 00:21:14",
"Message": "%ASA-5-111010: User 'john', running 'CLI' from IP 0.0.0.0, executed 'dir
disk0:/dap.xml'"
}
{
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-04-15 00:21:06",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 20,
"SyslogFacility": "LOCAL4",
"SyslogSeverityValue": 4,
"SyslogSeverity": "WARNING",
"SeverityValue": 3,
"Severity": "WARNING",
"Hostname": "192.168.12.1",
"EventTime": "2017-04-15 00:22:27",
"Message": "%ASA-4-313005: No matching connection for ICMP error message: icmp src
outside:81.24.28.226 dst inside:72.142.17.10 (type 3, code 0) on outside interface. Original IP
payload: udp src 72.142.17.10/40998 dst 194.153.237.66/53."
}
{
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-04-15 00:21:21",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 20,
"SyslogFacility": "LOCAL4",
"SyslogSeverityValue": 3,
"SyslogSeverity": "ERR",
"SeverityValue": 4,
"Severity": "ERROR",
"Hostname": "192.168.12.1",
"EventTime": "2017-04-15 00:22:42",
"Message": "%ASA-3-710003: TCP access denied by ACL from 179.236.133.160/8949 to
outside:72.142.18.38/23"
}
379
NXLog User Guide Chapter 53. Cisco ASA
The following configuration uses regular expressions to parse additional key-value pairs from substrings
embedded in the string value of $Message field. Once they have been parsed and added as new fields, a
copy of the $Message field is made, given the name $ASAMessage, and assigned the remaining string value
after the parsed substrings have been removed.
nxlog.conf
1 <Input in_syslog_tcp>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /^%(ASA)-(\d)-(\d{6}): (.*)$/
8 {
9 $ASASeverityNumber = $2;
10 $ASAMessageID = $3;
11 $ASAMessage = $4;
12 }
13 </Exec>
14 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-04-15 14:27:04",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 20,
"SyslogFacility": "LOCAL4",
"SyslogSeverityValue": 3,
"SyslogSeverity": "ERR",
"SeverityValue": 4,
"Severity": "ERROR",
"Hostname": " 192.168.12.1",
"EventTime": "2017-04-15 14:28:26",
"Message": "%ASA-3-710003: TCP access denied by ACL from 117.247.81.21/52569 to
outside:72.142.18.38/23",
"ASASeverityNumber": "3",
"ASAMessageID": "710003",
"ASAMessage": "TCP access denied by ACL from 117.247.81.21/52569 to outside:72.142.18.38/23"
}
Further field extraction can be done based on message ID. Detailed information on existing IDs and their formats
can be found in the Cisco ASA Series Syslog Messages book.
380
Chapter 53. Cisco ASA NXLog User Guide
The following NXLog configuration parses a very common firewall message: "TCP access denied by ACL".
The regular expressions have been enhanced with pattern matching for parsing out the IP address/port
for both the source and the destination.
nxlog.conf
1 <Input in_syslog_tcp>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /(?x)^%ASA-3-710003:\ TCP\ access\ denied\ by\ ACL\ from
8 \ ([0-9.]*)\/([0-9]*)\ to\ outside:([0-9.]*)\/([0-9]*)/
9 {
10 $ASASeverityNumber = "3";
11 $ASAMessageID = "710003";
12 $ASAMessage = "TCP access denied by ACL";
13 $ASASrcIP = $1;
14 $ASASrcPort = $2;
15 $ASADstIP = $3;
16 $ASADstPort = $4;
17 }
18 </Exec>
19 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-04-15 15:10:20",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 20,
"SyslogFacility": "LOCAL4",
"SyslogSeverityValue": 3,
"SyslogSeverity": "ERR",
"SeverityValue": 4,
"Severity": "ERROR",
"Hostname": "192.168.12.1",
"EventTime": "2017-04-15 15:11:43",
"Message": "%ASA-3-710003: TCP access denied by ACL from 119.80.179.109/2083 to
outside:72.142.18.38/23",
"ASASeverityNumber": "3",
"ASAMessageID": "710003",
"ASAMessage": "TCP access denied by ACL",
"ASASrcIP": "119.80.179.109",
"ASASrcPort": "2083",
"ASADstIP": "72.142.18.38",
"ASADstPort": "23"
}
381
NXLog User Guide Chapter 53. Cisco ASA
2. Enable logging.
# logging enable
3. In case of a High Availability (HA) pair, enable logging on the standby unit.
# logging standby
4. Specify the Syslog facility. Replace FACILITY with a number from 16 to 23, corresponding to local0 through
local7 (the default is 20, or local4).
5. Specify the severity level. Replace LEVEL with a number from 0 to 7. Use the maximum level for which
messages should be generated (severity level 3 will produce messages for levels 3, 2, 1, and 0). The levels
correspond to the Syslog severities.
6. Allow ASA to pass traffic when the Syslog server is not available.
# logging permit-hostdown
If logs are being sent via TCP and this setting is not configured, ASA will stop passing traffic
NOTE
when the Syslog server is unavailable.
7. Configure the Syslog host. Replace IP_ADDRESS and PORT with the remote IP address and port that NXLog is
listening on.
To enable SSL/TLS for connections to the NXLog agent, add secure at the end of the above
NOTE
command. The im_ssl module will need to be used when configuring NXLog.
This command configures 192.168.6.143 as the Syslog host, with TCP port 1514.
# write memory
382
Chapter 53. Cisco ASA NXLog User Guide
3. Go to Syslog Setup and specify the Facility Code (the default is 20). Click [Apply].
4. Go to Logging Filters, select Syslog Servers, click [Edit] and specify the severity level. Click [OK] and then
[Apply].
383
NXLog User Guide Chapter 53. Cisco ASA
5. Go to Syslog Servers and select Allow user traffic to pass when TCP syslog server is down. Click
[Apply].
This setting is important to avoid downtime during TCP logging in case the Syslog server is
NOTE
unavailable.
6. Under Syslog Servers, click [Add] and specify the interface, remote IP address, protocol and port. Click
[OK] and then [Apply].
To enable SSL/TLS for connections to the NXLog agent, select the Enable secure syslog
NOTE
using SSL/TLS option. The im_ssl module will need to be used when configuring NXLog.
384
Chapter 53. Cisco ASA NXLog User Guide
1. Configure NXLog for receiving NetFlow via UDP/2162 (see the example below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from each of the ASA devices being configured.
3. Set up NetFlow logging on Cisco ASA, using either the command line or ASDM. See the following sections.
The steps below have been tested with ASA 9.x and ASDM 7.x, but should work for other
NOTE
versions also.
385
NXLog User Guide Chapter 53. Cisco ASA
nxlog.conf
1 <Extension netflow>
2 Module xm_netflow
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_netflow_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 2162
13 InputType netflow
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/netflow.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"Version": 9,
"SysUpTimeMilisec": 2374222958,
"ExportTime": "2017-05-17 18:39:05",
"TimeMsecStart": "2017-05-17 18:38:04",
"Protocol": 6,
"SourcePort": 64394,
"DestPort": 443,
"SourceIpV4Address": "192.168.13.37",
"DestIpV4Address": "172.217.3.135",
"inputSNMPIface": 4,
"outputSNMPIface": 3,
"ASAeventTime": "2017-05-17 18:39:05",
"ASAconnID": 41834207,
"FNF_ICMPCode": 0,
"FNF_ICMPType": 0,
"ASAevent": 1,
"ASAextEvent": 0,
"ASA_XlateSourcePort": 64394,
"ASA_XlateDestPort": 443,
"ASA_V4XlateSourceAddr": "72.142.18.38",
"ASA_V4XlateDestAddr": "172.217.3.135",
"ASA_IngressACL": "433a1af1a925365e00000000",
"ASA_EgressACL": "000000000000000000000000",
"ASA_UserName20": "",
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-05-17 18:36:32",
"SourceModuleName": "udpin",
"SourceModuleType": "im_udp"
}
{
"Version": 9,
386
Chapter 53. Cisco ASA NXLog User Guide
"SysUpTimeMilisec": 2374222958,
"ExportTime": "2017-05-17 18:39:05",
"TimeMsecStart": "2017-05-17 18:38:04",
"Protocol": 17,
"SourcePort": 65080,
"DestPort": 443,
"SourceIpV4Address": "192.168.13.37",
"DestIpV4Address": "216.58.216.206",
"inputSNMPIface": 4,
"outputSNMPIface": 3,
"ASAeventTime": "2017-05-17 18:39:05",
"ASAconnID": 41834203,
"FNF_ICMPCode": 0,
"FNF_ICMPType": 0,
"ASAevent": 1,
"ASAextEvent": 0,
"ASA_XlateSourcePort": 65080,
"ASA_XlateDestPort": 443,
"ASA_V4XlateSourceAddr": "72.142.18.38",
"ASA_V4XlateDestAddr": "216.58.216.206",
"ASA_IngressACL": "433a1af1a925365e00000000",
"ASA_EgressACL": "000000000000000000000000",
"ASA_UserName20": "",
"MessageSourceAddress": "192.168.12.1",
"EventReceivedTime": "2017-05-17 18:36:32",
"SourceModuleName": "udpin",
"SourceModuleType": "im_udp"
}
3. Create an access list matching the traffic that needs to be logged. Replace ACL_NAME with a name for the
access list. Replace PROTOCOL, SOURCE_IP, and DESTINATION_IP with appropriate values corresponding to
the traffic to be matched.
4. Create a class map with the access list. Replace ACL_NAME with the access list name used in the previous
step.
# class-map global-class
# match access-list ACL_NAME
5. Add NetFlow destination to global policy. Replace IP_ADDRESS with the address that the NXLog agent is
listening on.
# policy-map global_policy
# class global-class
# flow-export event-type all destination IP_ADDRESS
387
NXLog User Guide Chapter 53. Cisco ASA
These commands enable NetFlow logging of all traffic to 192.168.6.143 via UDP port 2162.
3. Click [Add] and specify the interface, remote IP address, and port that the NXLog agent is listening on.
388
Chapter 53. Cisco ASA NXLog User Guide
6. Select Source and Destination IP Address (uses ACL) and click [Next].
7. Specify the source and destination criteria. The example below matches all traffic.
389
NXLog User Guide Chapter 53. Cisco ASA
8. Go to the NetFlow tab and add the NetFlow destination created during the first step. Make sure the Send
option is selected.
390
Chapter 54. Cisco FireSIGHT NXLog User Guide
NXLog can be set up to collect Cisco FireSIGHT events using the Cisco Event Streamer (eStreamer) API. This
functionality is implemented as an add-on; for more information, see the Cisco FireSIGHT eStreamer add-on
documentation.
391
NXLog User Guide Chapter 55. Cisco IPS
NXLog can be set up to collect Cisco IPS alerts with the Security Device Event Exchange (SDEE) API. This
functionality is implemented as an add-on; for more information, see the Cisco Intrusion Prevention Systems
(CIDEE) add-on documentation.
392
Chapter 56. Cloud Instance Metadata NXLog User Guide
The examples below use the xm_python module and Python scripts for this purpose. Each of the scripts depends
on the requests module which can be installed by running pip install requests or with the system’s
package manager (for example, apt install python-requests on Debian-based systems).
In this example, NXLog reads from a generic file with im_file. In the Output block, the xm_python
python_call() procedure is used to execute the get_attribute() Python function, which adds one or more
metadata fields to the event record. The output is then converted to JSON format and written to a file.
This configuration is applicable for each of cloud providers listed in the following sections, with the
corresponding Python code which differs according to the provider.
nxlog.conf
1 <Extension python>
2 Module xm_python
3 PythonCode metadata.py
4 </Extension>
5
6 <Extension json>
7 Module xm_json
8 </Extension>
9
10 <Input in>
11 Module im_file
12 File '/var/log/input'
13 </Input>
14
15 <Output out>
16 Module om_file
17 File '/tmp/output'
18 <Exec>
19 # Call Python function; this will add one or more fields to the event
20 python_call('get_attribute');
21
22 # Save contents of $raw_event field in $Message prior to JSON conversion
23 $Message = $raw_event;
24
25 # Save all fields in event record to $raw_event field in JSON format
26 $raw_event = to_json();
27 </Exec>
28 </Output>
$ curl http://169.254.169.254/
See the Instance Metadata and User Data documentation for more information about retrieving metadata from
the AWS EC2 service.
393
NXLog User Guide Chapter 56. Cloud Instance Metadata
The following Python script, which can be used with the xm_python module, collects the instance ID from
the EC2 metadata service and adds a field to the event record.
metadata.py (truncated)
import nxlog, requests
def request_metadata(item):
"""Gets value of metadata attribute 'item', returns text string"""
# Set metadata URL
metaurl = 'http://169.254.169.254/latest/meta-data/{0}'.format(item)
$ curl -H "Metadata:true" \
"http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"
See the Azure Instance Metadata service for more information about retrieving the metadata of an Azure
instance.
394
Chapter 56. Cloud Instance Metadata NXLog User Guide
The following Python script, which can be used with the xm_python module, collects the metadata
attributes from the Azure Instance Metadata Service API and adds a field to the event record for each.
metadata.py (truncated)
import json, nxlog, requests
def request_metadata():
"""Gets all metadata values for compute instance, returns dict"""
# Set metadata URL
metaurl = 'http://169.254.169.254/metadata/instance/compute?api-version=2017-08-01'
# Set header required to retrieve metadata
metaheader = {'Metadata':'true'}
See Storing and Retrieving Instance Metadata for more information about retrieving metadata from the Google
Compute Engine.
395
NXLog User Guide Chapter 56. Cloud Instance Metadata
The following Python script, which can be used with the xm_python module, collects the instance ID from
the GCE metadata server and adds a field to the event record.
metadata.py (truncated)
import nxlog, requests
def request_metadata(item):
"""Gets value of metadata attribute 'item', returns text string"""
# Set metadata URL
metaurl = 'http://metadata.google.internal/computeMetadata/v1/instance/{0}'.format(item)
# Set header require to retrieve metadata
metaheader = {'Metadata-Flavor':'Google'}
396
Chapter 57. Common Event Expression (CEE) NXLog User Guide
Log Sample
Dec 20 12:42:20 syslog-relay serveapp[1335]: @cee:
{"pri":10,"id":121,"appname":"serveapp","pid":1335,"host":"syslog-relay","time":"2011-12-
20T12:38:05.123456-05:00","action":"login","domain":"app","object":"account","status":"success"}↵
397
NXLog User Guide Chapter 57. Common Event Expression (CEE)
With the following configuration, NXLog accepts CEE logs via TCP, parses the CEE-formatted $Message field,
and writes the logs to file in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 <Exec>
14 parse_syslog();
15 if $Message =~ /^@cee: ({.+})$/
16 {
17 $raw_event = $1;
18 parse_json();
19 }
20 </Exec>
21 </Input>
22
23 <Output out>
24 Module om_file
25 File '/var/log/json'
26 Exec to_json();
27 </Output>
Input Sample
Oct 13 14:23:11 myserver @cee: { "purpose": "test" }↵
Output Sample
{
"EventReceivedTime": "2016-09-13 14:23:12",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "myserver",
"EventTime": "2016-09-13 14:23:11",
"Message": "@cee: { \"purpose\": \"test\" }",
"purpose": "test"
}
398
Chapter 57. Common Event Expression (CEE) NXLog User Guide
With this configuration, NXLog parses IETF Syslog input from file. The logs are then converted to CEE format
and forwarded via TCP. The Syslog header data and IETF Syslog Structured-Data key/value list from the
input are also included.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/log/ietf'
12 Exec parse_syslog();
13 </Input>
14
15 <Output out>
16 Module om_tcp
17 Host 192.168.1.1
18 Port 1514
19 Exec $Message = '@cee: ' + to_json(); to_syslog_bsd();
20 </Output>
Input Sample
<13>1 2016-10-13T14:23:11.000000-06:00 myserver - - - [NXLOG@14506 Purpose="test"] This is a
test message.↵
Output Sample
<13>Oct 13 14:23:11 myserver @cee: {"EventReceivedTime":"2016-10-13
14:23:12","SourceModuleName":"in","SourceModuleType":"im_file","SyslogFacilityValue":1,"SyslogF
acility":"USER","SyslogSeverityValue":5,"SyslogSeverity":"NOTICE","SeverityValue":2,"Severity":
"INFO","EventTime":"2016-10-13 14:23:11","Hostname":"myserver","Purpose":"test","Message":"This
is a test message."}↵
399
NXLog User Guide Chapter 58. Dell EqualLogic
In most environments, two or more EqualLogic units are configured as a single group. This allows storage
capacity to be utilized from all devices, and the configuration of RAID levels across multiple drives and hardware
platforms. In this case, Syslog configuration is performed from Group Manager and applies to all members.
For more details about configuring logging on Dell EqualLogic PS series SANs, check the "Dell PS Series
Configuration Guide" which can be downloaded from the Dell EqualLogic Support Site (a valid account is
required).
NOTE The steps below have been tested with a Dell EqualLogic PS6000 series SAN.
1. Configure NXLog for receiving Syslog messages via UDP (see the examples below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from all devices in the group.
3. Proceed with the logging configuration on EqualLogic, using either the Group Manager or the command line.
See the following sections.
400
Chapter 58. Dell EqualLogic NXLog User Guide
The following example shows EqualLogic logs as received and processed by NXLog with the im_udp and
xm_syslog modules.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/equallogic.log"
19 Exec to_json();
20 </Output>
401
NXLog User Guide Chapter 58. Dell EqualLogic
Output Sample
{
"MessageSourceAddress": "192.168.10.43",
"EventReceivedTime": "2017-03-18 21:12:58",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 16,
"SyslogFacility": "LOCAL0",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-03-18 21:12:58",
"Hostname": "192.168.10.43",
"SourceName": "11517",
"Message": "380:netmgtd:18-Mar-2017
21:13:19.415464:rcc_util.c:1032:AUDIT:grpadmin:25.7.0:CLI: Login to account grpadmin succeeded,
using local authentication. User privilege is group-admin."
}
{
"MessageSourceAddress": "192.168.10.43",
"EventReceivedTime": "2017-03-18 20:35:31",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 16,
"SyslogFacility": "LOCAL0",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-03-18 20:35:31",
"Hostname": "192.168.10.43",
"SourceName": "11470",
"Message": "88:agent:18-Mar-2017 20:35:51.833836:echoCli.c:10611:AUDIT:grpadmin:22.7.0:User
action:volume select volume1 schedule create test type once start-time 06:30PM read-write max-
keep 10 start-date 03/18/17 enable"
}
{
"MessageSourceAddress": "192.168.10.43",
"EventReceivedTime": "2017-03-18 20:38:51",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 16,
"SyslogFacility": "LOCAL0",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-03-18 20:38:51",
"Hostname": "192.168.10.43",
"SourceName": "11502",
"Message": "103:agent:18-Mar-2017 20:39:12.124329:echoCli.c:10611:AUDIT:grpadmin:22.7.0:User
action:volume select volume1 snapshot delete volume1-2017-03-18-20:38:00.3.1 "
}
402
Chapter 58. Dell EqualLogic NXLog User Guide
This configuration uses a regular expression to extract additional fields from each message.
nxlog.conf
1 <Input in_syslog_udp>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /(?x)^([0-9]*):([a-z]*):\d{2}-[a-zA-Z]{3}-\d{4}
8 \ \d{2}:\d{2}:\d{2}.\d{6}:([a-zA-Z.]*):[0-9]*:([a-zA-Z]*):
9 ([a-z]*):([0-9.]*):([a-zA-Z. ]*):(.*)$/
10 {
11 $EQLMsgSeq = $1;
12 $EQLMsgSrc = $2;
13 $EQLFile = $3;
14 $EQLMsgType = $4;
15 $EQLAccount = $5;
16 $EQLMsgID = $6;
17 $EQLEvent = $7;
18 $EQLMessage = $8;
19 }
20 </Exec>
21 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.10.43",
"EventReceivedTime": "2017-04-15 16:55:48",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 16,
"SyslogFacility": "LOCAL0",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-04-15 16:55:48",
"Hostname": "192.168.10.43",
"SourceName": "12048",
"Message": "113:agent:15-Apr-2017 16:57:09.744470:echoCli.c:10611:AUDIT:grpadmin:22.7.0:User
action:alerts select syslog priority fatal,error,warning,audit",
"EQLMsgSeq": "113",
"EQLMsgSrc": "agent",
"EQLFile": "echoCli.c",
"EQLMsgType": "AUDIT",
"EQLAccount": "grpadmin",
"EQLMsgID": "22.7.0",
"EQLEvent": "User action",
"EQLMessage": "alerts select syslog priority fatal,error,warning,audit"
}
403
NXLog User Guide Chapter 58. Dell EqualLogic
3. Under the Event Logs section, make sure the Send events to syslog servers option is checked.
4. Select the required Event priorities.
5. Click [Add], enter the IP address of the NXLog agent, and click [OK].
6. Click the [Save all changes] button in the top left corner.
These commands will send all logs, except for Informational level, to 192.168.6.143 via the default UDP
port 514.
404
Chapter 59. Dell iDRAC NXLog User Guide
Different server generations come with different versions of iDRAC. For example, PowerEdge R520, R620, or R720
servers have iDRAC7, while older models such as PowerEdge 1850 or 1950 come with iDRAC5. Remote Syslog via
UDP is an option starting from iDRAC6.
NOTE An iDRAC Enterprise license is required to redirect logs to a remote Syslog destination.
For more details regarding iDRAC configuration, go to Dell Support and search for the server model or iDRAC
version.
NOTE The steps below were tested with iDRAC7 but should work for newer versions as well.
1. Configure NXLog for receiving Syslog entries via UDP (see the examples below), then restart NXLog.
2. Make sure the NXLog agent is accessible from the management interface.
3. Configure iDRAC remote Syslog logging, using the web interface or the command line. See the following
sections.
405
NXLog User Guide Chapter 59. Dell iDRAC
This example shows iDRAC logs as received and processed by NXLog, with the im_udp and xm_syslog
modules.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/idrac.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.5.50",
"EventReceivedTime": "2017-03-26 13:52:48",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 21,
"SyslogFacility": "LOCAL5",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-03-26 13:52:48",
"Hostname": "192.168.5.50",
"SourceName": "Severity",
"Message": "Informational, Category: Audit, MessageID: USR0030, Message: Successfully logged
in using john, from 192.168.0.106 and GUI."
}
406
Chapter 59. Dell iDRAC NXLog User Guide
The following configuration uses a regular expression to extract additional fields from each message.
nxlog.conf
1 <Input in_syslog_udp>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /(?x)^([a-zA-Z]*),\ Category:\ ([a-zA-Z]*),
8 \ MessageID:\ ([a-zA-Z0-9]*),\ Message:\ (.*)$/
9 {
10 $DracMsgLevel = $1;
11 $DracMscCategory = $2;
12 $DracMscID = $3;
13 $DracMessage = $4;
14 }
15 </Exec>
16 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.5.50",
"EventReceivedTime": "2017-04-15 17:32:47",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 21,
"SyslogFacility": "LOCAL5",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-04-15 17:32:47",
"Hostname": "192.168.5.50",
"SourceName": "Severity",
"Message": "Informational, Category: Audit, MessageID: USR0030, Message: Successfully logged
in using john, from 192.168.0.106 and GUI.",
"DracMsgLevel": "Informational",
"DracMscCategory": "Audit",
"DracMscID": "USR0030",
"DracMessage": "Successfully logged in using john, from 192.168.0.106 and GUI."
}
3. Select the Remote System Log option for all required alert types.
407
NXLog User Guide Chapter 59. Dell iDRAC
4. Click [Apply].
5. Go to Overview › Server › Logs › Settings.
408
Chapter 59. Dell iDRAC NXLog User Guide
Available categories are all, system, storage, updates, audit, config, and worknotes. Valid severity
values are critical, warning, and info.
◦ ACTION: an action for this alert. Possible values are none, powercycle, poweroff, and systemreset.
◦ NOTIFICATION: required notifications for the alert. Valid values are all or none, or a comma-separated
list including one or more of snmp, ipmi, lcd, email, and remotesyslog.
◦ NUMBER: the Syslog server number—1, 2 or 3.
The following commands disable all alert actions, enable Syslog notifications for all alerts (disabling
other notifications), and enable Syslog logging to 192.168.6.143 (UDP port 514).
409
NXLog User Guide Chapter 60. Dell PowerVault MD Series
Log Sample
Date/Time: 4/5/17 2:43:00 PM↵
Sequence number: 418209↵
Event type: 4011↵
Description: Virtual disk not on preferred path due to failover↵
Event specific codes: 0/0/0↵
Event category: Error↵
Component type: RAID Controller Module↵
Component location: Enclosure 0, Slot 0↵
Logged by: RAID Controller Module in slot 0↵
↵
Date/Time: 4/5/17 4:06:21 PM↵
Sequence number: 418233↵
Event type: 104↵
Description: Needs attention condition resolved↵
Event specific codes: 0/0/0↵
Event category: Internal↵
Component type: RAID Controller Module↵
Component location: Enclosure 0, Slot 0↵
Logged by: RAID Controller Module in slot 0↵
For more details about configuring PowerVault alerts and using MD Storage Manager, see Dell Support.
The steps below have been tested with the PowerVault MD3200 Series SAN and should work
NOTE
with any MD unit managed by MD Storage Manager Enterprise.
1. Configure NXLog for receiving log entries via UDP (see the examples below), then restart NXLog.
2. Confirm that the NXLog agent is accessible from the server where MD Storage Manager is installed.
3. Locate the PMServer.properties file. By default, the file can be found in C:\Program Files
(x86)\Dell\MD Storage Software\MD Storage Manager\client\data.
4. Edit the file. Set enable_local_logger to true, specify the Syslog server address, and set the facility.
410
Chapter 60. Dell PowerVault MD Series NXLog User Guide
With the following directives, the MD Storage Manager will send events to 192.168.15.223 via UDP port
514.
PMServer.properties
Time_format(12/24)=12
syslog_facilty=3
DBM_files_maximum_key=20
DBM_files_minimum_key=5
syslog_receivers=192.168.15.223
DBM_recovery_interval_key=120
DBM_recovery_debounce_key=5
DBM_files_maintain_timeperiod_key=14
eventlog_source_name=StorageArray
enable_local_logger=true
syslog_tag=StorageArray
411
NXLog User Guide Chapter 60. Dell PowerVault MD Series
This example shows PowerVault logs as received and processed by NXLog with the im_udp and xm_syslog
modules.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/mdsan.log"
19 Exec to_json();
20 </Output>
412
Chapter 60. Dell PowerVault MD Series NXLog User Guide
Output Sample
{
"MessageSourceAddress": "192.168.15.231",
"EventReceivedTime": "2017-04-05 14:43:45",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 4,
"SyslogSeverity": "WARNING",
"SeverityValue": 3,
"Severity": "WARNING",
"Hostname": "192.168.5.18",
"EventTime": "2017-04-05 14:43:00",
"SourceName": "StorageArray",
"Message": "MD3620f1;4011;Warning;Virtual disk not on preferred path due to failover"
}
{
"MessageSourceAddress": "192.168.15.231",
"EventReceivedTime": "2017-04-05 16:07:01",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "192.168.5.18",
"EventTime": "2017-04-05 16:06:21",
"SourceName": "StorageArray",
"Message": "MD3620f1;104;Informational;Needs attention condition resolved"
}
413
NXLog User Guide Chapter 60. Dell PowerVault MD Series
The following configuration uses a regular expression to extract additional fields from each message.
nxlog.conf
1 <Input in_syslog_udp>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /^([a-zA-Z0-9]*);([0-9]*);([a-zA-Z]*);(.*)$/
8 {
9 $MDArray = $1;
10 $MDMsgID = $2;
11 $MDMsgLevel = $3;
12 $MDMessage = $4;
13 }
14 </Exec>
15 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.15.231",
"EventReceivedTime": "2017-04-05 14:43:45",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 4,
"SyslogSeverity": "WARNING",
"SeverityValue": 3,
"Severity": "WARNING",
"Hostname": "192.168.5.18",
"EventTime": "2017-04-05 14:43:00",
"SourceName": "StorageArray",
"Message": "MD3620f1;4011;Warning;Virtual disk not on preferred path due to failover",
"MDArray": "MD3620f1",
"MDMsgID": "4011",
"MDMsgLevel": "Warning",
"MDMessage": "Virtual disk not on preferred path due to failover"
}
414
Chapter 61. Devo NXLog User Guide
All events arriving to the Devo Cloud must have an associated tag that is recognized by Devo. Read more about
devo tags in the Devo documentation.
• The address of the central relay of Devo Cloud is available on the Administration > Relays page. This needs
to be used as the value for the Host directive in NXLog.
• The certificates for the CAFile, CertFile, and CertKeyFile directives can be downloaded by browsing to
the Administration > Credentials page and selecting X.509 Certificates on the top.
• The password for the KeyPass directive can be found next to the certificates.
When sending logs directly to the Devo Cloud, the predefined tag can be added either in the input instance or
the output instance of the NXLog configuration.
415
NXLog User Guide Chapter 61. Devo
Using the im_msvistalog module, the configuration below reads Windows Event Log entries and selects only
those entries which contain EventIDs 4624 and 4625. The selected logs are then sent to the Devo Cloud
using the om_ssl module. It is required that the "box.win_nxlog."+lc($Channel) tag is added to the data
in the output. Read more about the box.win_nxlog tag in the Devo documentation.
The box.win_nxlog tag is a special tag that can only be used with NXLog collecting
NOTE
Windows Event Log with the im_msvistalog module.
For the Host directive, the xx string in the hostname should be replaced with the actual Devo Cloud region.
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_msvistalog
11 <QueryXML>
12 <QueryList>
13 <Query Id="0">
14 <Select Path="Security">
15 *[System[Level=0 and (EventID=4624 or EventID=4625)]]
16 </Select>
17 </Query>
18 </QueryList>
19 </QueryXML>
20 </Input>
21
22 <Output direct_ssl_devo>
23 Module om_ssl
24 Host xx.elb.relay.logtrust.net:443
25 CAFile C:\Program Files\nxlog\cert\chain.crt
26 CertFile C:\Program Files\nxlog\cert\nxlog.crt
27 CertKeyFile C:\Program Files\nxlog\cert\nxlog.key
28 KeyPass topsecret
29 AllowUntrusted TRUE
30 <Exec>
31 $Message = to_json();
32 $SourceName="box.win_nxlog."+lc($Channel);
33 to_syslog_bsd();
34 </Exec>
35 </Output>
Below is the header line including the corresponding Devo tag that is added to the beginning of the JSON
message.
Below is the event sample of a log message in JSON, which is sent to the Devo Cloud.
416
Chapter 61. Devo NXLog User Guide
{
"EventTime": "2020-07-28 05:49:42",
"Hostname": "NXLOGTEST",
"Keywords": "9232379236109516800",
"EventType": "AUDIT_SUCCESS",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 4624,
"SourceName": "box.win_nxlog.security",
"ProviderGuid": "{54849625-5478-4994-A5BA-3E3B0328C30D}",
"Version": 2,
"TaskValue": 12544,
"OpcodeValue": 0,
"RecordNumber": 2747,
"ActivityID": "{D3963786-6526-0000-8939-96D32665D601}",
"ExecutionProcessID": 576,
"ExecutionThreadID": 2816,
"Channel": "Security",
"Category": "Logon",
"Opcode": "Info",
"SubjectUserSid": "S-1-5-18",
"SubjectUserName": "NXLOGTEST$",
"SubjectDomainName": "WORKGROUP",
"SubjectLogonId": "0x3e7",
"TargetUserSid": "S-1-5-18",
"TargetUserName": "SYSTEM",
"TargetDomainName": "NT AUTHORITY",
"TargetLogonId": "0x3e7",
"LogonType": "5",
"LogonProcessName": "Advapi ",
"AuthenticationPackageName": "Negotiate",
"WorkstationName": "-",
"LogonGuid": "{00000000-0000-0000-0000-000000000000}",
"TransmittedServices": "-",
"LmPackageName": "-",
"KeyLength": "0",
"ProcessId": "0x238",
"ProcessName": "C:\\Windows\\System32\\services.exe",
"IpAddress": "-",
"IpPort": "-",
"ImpersonationLevel": "%%1833",
"RestrictedAdminMode": "-",
"TargetOutboundUserName": "-",
"TargetOutboundDomainName": "-",
"VirtualAccount": "%%1843",
"TargetLinkedLogonId": "0x0",
"ElevatedToken": "%%1842",
"EventReceivedTime": "2020-07-28 05:50:47",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog"
}
When forwarding logs to Devo Cloud via the relay, it is best to apply the Devo tags at the input module stage, so
417
NXLog User Guide Chapter 61. Devo
data can be identified based on their source. When the events are tagged in their input module, it is only
necessary to define the Host and Port directives for the Devo relay.
418
Chapter 61. Devo NXLog User Guide
The configuration below reads file-based system logs from a Linux machine using the im_kernel and im_uds
modules. The tags are applied at the input stage. The entries are sent to the Devo relay on the local
network, which automatically relays them to the Devo Cloud.
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input kernel>
10 Module im_kernel
11 <Exec>
12 $Message = to_json();
13 $SourceName="box.unix.nxlog.kernel";
14 to_syslog_bsd();
15 </Exec>
16 </Input>
17
18 <Input journal>
19 Module im_uds
20 UDS /run/systemd/journal/syslog
21 <Exec>
22 $Message = to_json();
23 $SourceName="box.unix.nxlog.journal";
24 to_syslog_bsd();
25 </Exec>
26 </Input>
27
28 <Input devlog>
29 Module im_uds
30 UDS /dev/log
31 FlowControl FALSE
32 <Exec>
33 $raw_event =~ s/\s+$//;
34 $Message = to_json();
35 $SourceName="box.unix.nxlog.devlog";
36 to_syslog_bsd();
37 </Exec>
38 </Input>
39
40 <Output devo_relay>
41 Module om_tcp
42 Host 192.168.1.55
43 Port 13000
44 </Output>
Below is the header line including the corresponding Devo tag that is added to the beginning of the JSON
message.
Below is the event sample of a log message which is sent over TCP to the Devo relay.
419
NXLog User Guide Chapter 61. Devo
{
"EventReceivedTime": "2020-07-28 10:08:59",
"SourceModuleName": "devlog",
"SourceModuleType": "im_uds",
"SyslogFacilityValue": 10,
"SyslogFacility": "AUTHPRIV",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "ubuntu",
"EventTime": "2020-07-28 10:08:59",
"SourceName": "box.unix.nxlog.devlog",
"Message": "pam_unix(sudo:session): session opened for user root by root(uid=0)"
}
In the Devo Cloud platform, the received data is represented in tables. Devo provides various ways for filtering
received logs. For example, the predefined tag box.win_nxlog.security allows searching for Windows Event
Log events from the security channel. These events were sent directly to the Devo Cloud over SSL/TLS. Read
more about searching data in the Devo documentation.
420
Chapter 61. Devo NXLog User Guide
The image below demonstrates the events which are forwarded from a Linux machine via the Devo In-House
Relay.
421
NXLog User Guide Chapter 61. Devo
In addition to the above, tables can be downloaded as CSV, TSV, XLSX, JSON Object Array, JSON Matrix, or as
Source files.
Below is an event sample of a log message that has been downloaded from the Devo website in JSON format.
The message was sent to the Devo Cloud via the In-House Relay.
422
Chapter 61. Devo NXLog User Guide
{
"eventdate": "2020-07-28T09:17:43.271Z",
"machine": "relayinhouse",
"facility": "authpriv",
"level": "info",
"application": "CRON[669]",
"appName": "CRON",
"processId": "669",
"message": " pam_unix(cron:session): session opened for user root by (uid=0)",
"user": "root",
"srcUser": null,
"srcIp": "null",
"srcPort": null,
"obj": null,
"uid": 0,
"tty": null,
"pwd": null,
"cmd": null,
"attempt": null,
"device": null
}
423
NXLog User Guide Chapter 62. DHCP logs
By default, DHCPd logs to the daemon Syslog facility. If desired, the DHCPd log-facility configuration
statement can be used in /etc/dhcp/dhcpd.conf to write logs to a different facility. The system logger could
then be configured to handle that facility’s logs as required. Otherwise, something like the following example
should work with the default settings.
This configuration uses the im_file module to read DHCPd messages from one of the Syslog log files, and
the xm_syslog parse_syslog() procedure to parse them. Only events from the dhcpd source are kept; others
are discarded with drop().
This method will most likely not preserve severity information. See Reading Syslog Log
WARNING Files for more information and the other sections in Collecting and Parsing Syslog for
alternative ways to collect Syslog messages.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input dhcp_server>
6 Module im_file
7 # Debian writes `daemon` facility logs to `/var/log/daemon.log` by default
8 File '/var/log/daemon.log'
9 # RHEL writes `daemon` facility logs to `/var/log/messages` by default
10 #File '/var/log/messages'
11 <Exec>
12 parse_syslog();
13 if $SourceName != 'dhcpd' drop();
14 </Exec>
15 </Input>
424
Chapter 62. DHCP logs NXLog User Guide
This configuration uses the im_file module to read dhclient messages from one of the Syslog log files, and
the xm_syslog parse_syslog() procedure to parse them. Only events from the dhclient source are kept;
others are discarded with drop().
This method will most likely not preserve severity information. See Reading Syslog Log
WARNING Files for more information and the other sections in Collecting and Parsing Syslog for
alternative ways to collect Syslog messages.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input dhcp_client>
6 Module im_file
7 # Debian writes `daemon` facility logs to `/var/log/daemon.log` by default
8 File '/var/log/daemon.log'
9 # RHEL writes `daemon` facility logs to `/var/log/messages` by default
10 #File '/var/log/messages'
11 <Exec>
12 parse_syslog();
13 if $SourceName != 'dhclient' drop();
14 </Exec>
15 </Input>
NOTE The following sections have been tested on Windows Server 2016.
The log files are named DhcpSrvLog-<DAY>.log for IPv4 and DhcpV6SrvLog-<DAY>.log for IPv6. For example,
Thursday’s log files are DhcpSrvLog-Thu.log and DhcpV6SrvLog-Thu.log.
425
NXLog User Guide Chapter 62. DHCP logs
The DHCP audit log can be configured with PowerShell or the DHCP Management MMC snap-in.
> Get-DhcpServerAuditLog
Path : C:\Windows\system32\dhcp
Enable : True
MaxMBFileSize : 70
DiskCheckInterval : 50
MinMBDiskSpace : 20
2. To set the audit log configuration, run this command (see Set-DhcpServerAuditLog on Microsoft Docs).
3. The DHCP server must be restarted for the configuration changes to take effect.
1. Run the DHCP MMC snap-in (dhcpmgmt.msc), expand the server for which to configure logging, and click on
IPv4.
2. Right-click on IPv4 and click Properties. Note that the context menu is not fully populated until after the
IPv4 menu has been expanded at least once.
426
Chapter 62. DHCP logs NXLog User Guide
5. Restart the DHCP server by right-clicking the server and clicking All Tasks › Restart.
427
NXLog User Guide Chapter 62. DHCP logs
This configuration uses a short batch/PowerShell polyglot script with the include_stdout directive to fetch
the DHCP audit log location. The im_file module reads from the files and the xm_csv module parses the
lines into fields. Any line that does not match the /^\d+,/ regular expression is discarded with the drop()
procedure (all the header lines are dropped). The event ID and QResult codes are resolved automatically,
with corresponding $Message and $QMessage fields added where applicable.
If DHCP audit logging is disabled, the script will print an error and NXLog will abort during
NOTE
the configuration check.
nxlog.conf (truncated)
1 <Extension dhcp_csv_parser>
2 Module xm_csv
3 Fields ID, Date, Time, Description, IPAddress, Hostname, MACAddress, \
4 UserName, TransactionID, QResult, ProbationTime, CorrelationID, \
5 DHCID, VendorClassHex, VendorClassASCII, UserClassHex, \
6 UserClassASCII, RelayAgentInformation, DnsRegError
7 </Extension>
8
9 <Extension dhcpv6_csv_parser>
10 Module xm_csv
11 Fields ID, Date, Time, Description, IPv6Address, Hostname, ErrorCode, \
12 DuidLength, DuidBytesHex, UserName, Dhcid, SubnetPrefix
13 </Extension>
14
15 <Input dhcp_server_audit>
16 Module im_file
17 include_stdout %CONFDIR%\dhcp_server_audit_include.cmd
18 <Exec>
19 # Only process lines that begin with an event ID
20 if $raw_event =~ /^\d+,/
21 {
22 $FileName = file_name();
23 if $FileName =~ /DhcpSrvLog-/
24 {
25 dhcp_csv_parser->parse_csv();
26 $QResult = integer($QResult);
27 if $QResult == 0 $QMessage = "NoQuarantine";
28 else if $QResult == 1 $QMessage = "Quarantine";
29 [...]
428
Chapter 62. DHCP logs NXLog User Guide
dhcp_server_audit_include.cmd
@( Set "_= (
REM " ) <#
)
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
powershell.exe -ExecutionPolicy Bypass -NoProfile ^
-Command "iex ((gc '%~f0') -join [char]10)"
EndLocal & Exit /B %ErrorLevel%
#>
$AuditLog = Get-DhcpServerAuditLog
if ($AuditLog.Enable) {
Write-Output "File '$($AuditLog.Path)\Dhcp*SrvLog-*.log'"
}
else {
[Console]::Error.WriteLine(@"
DHCP audit logging is disabled. To enable, run in PowerShell:
> Set-DhcpServerAuditLog -Enable $True
"@)
exit 1
}
Alternatively, the following PowerShell script will check all three logs, enabling if necessary.
429
NXLog User Guide Chapter 62. DHCP logs
$LogNames = @("DhcpAdminEvents",
"Microsoft-Windows-Dhcp-Server/FilterNotifications",
"Microsoft-Windows-Dhcp-Server/Operational")
ForEach ($LogName in $LogNames) {
$EventLog = Get-WinEvent -ListLog $LogName
if ($EventLog.IsEnabled) {
Write-Host "Already enabled: $LogName"
}
else {
Write-Host "Enabling: $LogName"
$EventLog.IsEnabled = $true
$EventLog.SaveChanges()
}
}
Example 262. Collecting DHCP server events from Windows Event Log
This configuration uses the im_msvistalog module to collect DHCP Server events from the Windows Event
Log DhcpAdminEvents, FilterNotifications, and Operational logs.
nxlog.conf
1 <Input dhcp_server_eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="DhcpAdminEvents">*</Select>
7 <Select Path="Microsoft-Windows-Dhcp-Server/FilterNotifications">
8 *</Select>
9 <Select Path="Microsoft-Windows-Dhcp-Server/Operational">*</Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 </Input>
430
Chapter 62. DHCP logs NXLog User Guide
Alternatively, the following PowerShell script will check all four logs, enabling if necessary.
$LogNames = @("Microsoft-Windows-Dhcp-Client/Admin",
"Microsoft-Windows-Dhcp-Client/Operational",
"Microsoft-Windows-Dhcpv6-Client/Admin",
"Microsoft-Windows-Dhcpv6-Client/Operational")
ForEach ($LogName in $LogNames) {
$EventLog = Get-WinEvent -ListLog $LogName
if ($EventLog.IsEnabled) {
Write-Host "Already enabled: $LogName"
}
else {
Write-Host "Enabling: $LogName"
$EventLog.IsEnabled = $true
$EventLog.SaveChanges()
}
}
This configuration collects events from the IPv4 and IPv6 Admin and Operational DHCP client logs using
the im_msvistalog module.
nxlog.conf
1 <Input dhcp_client_eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Dhcp-Client/Admin">*</Select>
7 <Select Path="Microsoft-Windows-Dhcp-Client/Operational">*</Select>
8 <Select Path="Microsoft-Windows-Dhcpv6-Client/Admin">*</Select>
9 <Select Path="Microsoft-Windows-Dhcpv6-Client/Operational">*</Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 </Input>
431
NXLog User Guide Chapter 63. DNS Monitoring
DNS traffic can quickly become overwhelming. To save resources, consider discarding any fields
TIP
that will not be required for analysis.
According to RFC 7626 there are no specific privacy laws for DNS data collection, in any country. However, it is
not clear if data protection directive 95/46/EC of the European Union includes DNS traffic collection.
DNS events are available from a number of sources. DNS queries and responses are commonly sent and
received in the form of packets over UDP. These packets and the ability to passively capture them is basically the
same across all operating systems.
Another common source is the DNS server itself as it receives queries from clients, processes them and returns
the results. Although the DNS protocol is a common standard, the logging facilities implemented in each DNS
server can vary greatly across different operating systems. Bind 9 generates flat log files while Windows DNS
Server employs Event Tracing for Windows (ETW) for managing its DNS events.
Although Windows DNS Server has two event tracing channels named Audit and Analytical, the advantage gained
from classifying DNS events into these two categories, and treating them separately, is by no means proprietary
and can be applied to other DNS server environments.
A DNS server is basically a highly specialized database server, yet it still retains the same low-level CRUD (Create,
Read, Update, Delete) functionality of any other database. Analytical logging is focused primarily on client
queries, the read operations, while DNS Audit Logging is focused on the remaining CRUD operations: creating,
updating, and deleting DNS zone information. These are the most important operations to monitor from a
security perspective since unauthorized access to them can lead to interruption of network services, data loss,
and outages of other infrastructure services.
The goal of DNS Audit logging is to maintain an audit trail of any changes to the DNS Server’s configuration,
mainly for security purposes, while providing timely notification and easy access to any high severity events. By
logging changes to any of the more than 40 DNS resource record (RR) types in zone files, security analysts will
have the forensic information they need, should DNS records be maliciously or accidentally modified.
The realm of DNS Analytical Logging is completely different. The volume of data collected can be huge and the
events being analyzed are typically not time- sensitive. The bulk of these DNS queries can be useful for producing
metrics on user and application network traffic to various internal and external sites and services.
In the following two sections, the methods used to collect audit and analytical log data may differ greatly, but the
goal of managing them separately remains the same.
432
Chapter 63. DNS Monitoring NXLog User Guide
63.2. BIND 9
The BIND 9 DNS server is commonly used on Unix-like operating systems. It can act as both an authoritative
name server and a recursive resolver.
In addition to collecting BIND 9 logs, consider implementing File Integrity Monitoring or DNS Audit Logging for
the BIND 9 configuration files.
This configuration logs all messages, of info severity or greater, to the local Syslog daemon. The queries
category is specified explicitly, because query logging is otherwise disabled by default. The print-* options
enable the inclusion of various metadata in the log messages—this metadata can later be parsed by NXLog.
named.conf
logging {
Log Format
<syslog-header> <date> <time> <category>: <severity>: <message>
Log Sample
<30>Apr 29 22:30:15 debian named[16373]: 29-Apr-2019 22:30:15.371 general: info: managed-keys-
zone: Key 20326 for zone . acceptance timer complete: key now trusted↵
<30>Apr 29 22:30:15 debian named[16373]: 29-Apr-2019 22:30:15.372 resolver: info: resolver
priming query complete↵
<30>Apr 29 22:30:20 debian named[16373]: 29-Apr-2019 22:30:20.770 queries: info: client
@0x7f9b6810ed50 10.80.0.1#44663 (google.com): query: google.com IN A +E(0) (10.80.1.88)↵
433
NXLog User Guide Chapter 63. DNS Monitoring
BIND can be configured to write log messages to a file. This configuration also shows how a particular
category can be disabled.
named.conf
logging {
The resulting log format is the same as in the previous example, but without the Syslog header.
Log Sample
01-May-2019 00:26:56.579 general: info: managed-keys-zone: Key 20326 for zone . acceptance
timer complete: key now trusted↵
01-May-2019 00:26:56.617 resolver: info: resolver priming query complete↵
01-May-2019 00:27:48.084 queries: info: client @0x7f82bc11d4e0 10.80.0.1#53995 (google.com):
query: google.com IN A +E(0) (10.80.1.88)↵
3. any category-specific syntax (such as for the queries category below)—additional parsing can be
implemented, if required, for any other category that uses a consistent format.
NOTE The following examples have been tested with BIND 9.10 and 9.11.
434
Chapter 63. DNS Monitoring NXLog User Guide
This configuration uses the im_uds module to accept local Syslog messages. BIND 9 should be configured
to log messages via Syslog as shown in Logging All Categories via Syslog above.
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input syslog>
6 Module im_uds
7 UDS /dev/log
8 <Exec>
9 # 1. Parse Syslog header
10 parse_syslog_bsd();
11
12 # 2. Parse BIND 9 metadata
13 if $Message =~ /(?x)^(?<EventTime>\S+\s\S+)\s(?<Category>\S+):\s
14 (?<BINDSeverity>[^:]+):\s(?<Message>.+)$/i
15 {
16 $EventTime = parsedate($EventTime);
17
18 # 3. Parse messages from the queries category
19 if $Category == "queries"
20 {
21 $Message =~ /(?x)^client\s((?<ClientID>\S+)\s)?(?<Client>\S+)\s
22 \((?<OriginalQuery>\S+)\):\squery:\s
23 (?<QueryName>\S+)\s(?<QueryClass>\S+)\s
24 (?<QueryType>\S+)\s(?<QueryFlags>\S+)\s
25 \((?<LocalAddress>\S+)\)$/;
26 }
27
28 # Parse messages from another category
29 [...]
435
NXLog User Guide Chapter 63. DNS Monitoring
Event Sample
{
"EventReceivedTime": "2019-04-29T22:30:20.856069+01:00",
"SourceModuleName": "syslog",
"SourceModuleType": "im_uds",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "debian",
"EventTime": "2019-04-29T22:30:20.770000+01:00",
"SourceName": "named",
"ProcessID": "16373",
"Message": "client @0x7f9b6810ed50 10.80.0.1#44663 (google.com): query: google.com IN A +E(0)
(10.80.1.88)",
"BINDSeverity": "info",
"Category": "queries",
"Client": "10.80.0.1#44663",
"ClientID": "@0x7f9b6810ed50",
"LocalAddress": "10.80.1.88",
"OriginalQuery": "google.com",
"QueryClass": "IN",
"QueryFlags": "+E(0)",
"QueryName": "google.com",
"QueryType": "A"
}
This configuration uses the im_file module to read messages from the BIND 9 log file. BIND 9 should be
configured as shown in Logging to File above. The parsing here is very similar to the previous example, but
without Syslog header parsing.
nxlog.conf
1 <Input file>
2 Module im_file
3 File '/var/log/bind.log'
4 <Exec>
5 if $raw_event =~ /(?x)^(?<EventTime>\S+\s\S+)\s(?<Category>\S+):\s
6 (?<Severity>[^:]+):\s(?<Message>.+)$/i
7 {
8 $EventTime = parsedate($EventTime);
9 if $Category == "queries"
10 {
11 $Message =~ /(?x)^client\s((?<ClientID>\S+)\s)?(?<Client>\S+)\s
12 \((?<OriginalQuery>\S+)\):\squery:\s
13 (?<QueryName>\S+)\s(?<QueryClass>\S+)\s
14 (?<QueryType>\S+)\s(?<QueryFlags>\S+)\s
15 \((?<LocalAddress>\S+)\)$/;
16 }
17 }
18 </Exec>
19 </Input>
436
Chapter 63. DNS Monitoring NXLog User Guide
437
NXLog User Guide Chapter 63. DNS Monitoring
This configuration uses the im_linuxaudit module to watch the the BIND 9 configuration file
/etc/bind/named.conf for modifications and tags the events with conf-change-bind. Read more about
Audit Rules.
nxlog.conf
1 <Input audit>
2 Module im_linuxaudit
3 FlowControl FALSE
4 <Rules>
5 # Delete all rules (This rule has no affect; it is performed
6 # automatically by im_linuxaudit)
7 -D
8
9 # Watch /etc/bind/named.conf for modifications and tag 'conf-change-bind'
10 -w /etc/bind/named.conf -p wa -k conf-change-bind
11
12 # Generate a log entry when the system time is changed
13 -a always,exit -F arch=b64 -S adjtimex -S settimeofday -k system_time
14
15 # Lock Audit rules until reboot
16 -e 2
17 </Rules>
18 </Input>
438
Chapter 63. DNS Monitoring NXLog User Guide
The following table maps some of the key features and attributes unique to each NXLog logging facility available
for Windows DNS monitoring.
439
NXLog User Guide Chapter 63. DNS Monitoring
1. Windows DNS Server Audit Events are enabled by default. An audit event is logged whenever the DNS
server settings, zones, or resource records are changed. Such DNS events are of utmost importance for
security audits. Each of the 53 types of audit events are identified by a unique EventID which is documented
in the Audit events table of Microsoft’s documentation. The Type column in this table contains a short
description of the event; however, it is not included in the actual logged event. For example, if a new zone is
created, it will not be possible to search for an event containing Record create, instead only EventID: 515 is
available for identifying this type of event.
2. Windows DNS Server Analytical Events must be specifically enabled. They represent the bulk of DNS
events—primarily lookups and other queries—and can be quite large in volume. The Analytic events table of
Microsoft’s documentation lists each of the 23 types of events that are monitored. Just like with Audit Events,
Windows logs the EventID, but not the more descriptive Type field. According to the Audit and analytic event
logging section of Microsoft’s documentation, when processing 100,000 queries per second (QPS) on modern
hardware the expected reduction in performance is around 5% if Analytical Event logging is enabled.
Event tracing offers significant advantages over DNS Debug Logging in terms of architecture, flexibility,
440
Chapter 63. DNS Monitoring NXLog User Guide
configurability, and performance. ETW events can be read directly without requiring events to be first written to
disk. However, ETW is not available on older Windows systems. To maintain its performance it is by design a
"best effort" framework and consequently does not guarantee that all events will be captured.
For more information, see the Installing and enabling DNS diagnostic logging section on Microsoft Docs.
With Analytical Logging enabled, NXLog can use the im_etw module to collect DNS logs from the Microsoft-
Windows-DNSServer ETW provider. This is the preferred method for collecting logs from Windows Server versions
2012 R2 and later.
NOTE On Windows Server 2012 R2, this feature is provided by hotfix 2956577.
63.3.2.1. Examples
441
NXLog User Guide Chapter 63. DNS Monitoring
The following configuration collects DNS logs via ETW from the Microsoft-Windows-DNSServer provider,
using the im_etw module. The collected logs are converted to JSON and saved to a file.
nxlog.conf
1 <Input etw>
2 Module im_etw
3 Provider Microsoft-Windows-DNSServer
4 </Input>
In this example, an Audit event has been logged. EventID: 515 identifies this as a Record create for this zone.
{
"SourceName": "Microsoft-Windows-DNSServer",
"ProviderGuid": "{EB79061A-A566-4698-9119-3ED2807060E7}",
"EventID": 515,
"Version": 0,
"ChannelID": 17,
"OpcodeValue": 0,
"TaskValue": 5,
"Keywords": "4611686018428436480",
"EventTime": "2020-03-10T09:42:39.788511-07:00",
"ExecutionProcessID": 4752,
"ExecutionThreadID": 1732,
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Domain": "WIN-R4QHULN6KLH",
"AccountName": "Administrator",
"UserID": "S-1-5-21-915329490-2962477901-227355065-500",
"AccountType": "User",
"Flags": "EXTENDED_INFO|IS_64_BIT_HEADER|PROCESSOR_INDEX (577)",
"Type": "1",
"NAME": "www.example.com",
"TTL": "3600",
"BufferSize": "4",
"RDATA": "0x0A00020F",
"Zone": "example.com",
"ZoneScope": "Default",
"VirtualizationID": ".",
"EventReceivedTime": "2020-03-10T09:42:40.801598-07:00",
"SourceModuleName": "etw",
"SourceModuleType": "im_etw"
}
442
Chapter 63. DNS Monitoring NXLog User Guide
2. Right-click on the DNS server and choose Properties from the context menu.
3. Under the Debug Logging tab, enable Log packets for debugging.
4. Mark the check boxes corresponding to the data that should be logged.
The Details option will produce multi-line logs. To parse this detailed format, refer to
NOTE
Parsing Detailed DNS Logs With Regular Expressions below.
5. Set the File path and name to the desired log file location.
The Windows DNS service may not recreate the debug log file after a rollover. If you
WARNING encounter this issue, be sure to use the C: drive for the debug log path. See the post,
The disappearing Windows DNS debug log, on the NXLog website.
See the following sections for information about parsing the logs.
This module does not support parsing of logs from DNS Debug Logging generated with the
WARNING
Details option enabled.
443
NXLog User Guide Chapter 63. DNS Monitoring
NOTE This module has been tested on Windows Server versions 2008 R2, 2012 R2, and 2016.
This configuration uses the im_file and xm_msdns modules to read and parse the log file. Output is written
to file in JSON format for this example.
nxlog.conf
1 <Extension dns_parser>
2 Module xm_msdns
3 EventLine TRUE
4 PacketLine TRUE
5 NoteLine TRUE
6 </Extension>
7
8 <Input in>
9 Module im_file
10 File 'C:\Server\dns.log'
11 InputType dns_parser
12 </Input>
Event Sample
{
"EventTime": "2017-04-21 07:52:03",
"ThreadId": "06B0",
"Context": "PACKET",
"InternalPacketIdentifier": "00000000028657F0",
"Protocol": "UDP",
"SendReceiveIndicator": "Snd",
"RemoteIP": "10.2.0.1",
"Xid": "6590",
"QueryResponseIndicator": "Response",
"Opcode": "Standard Query",
"FlagsHex": "8081",
"RecursionDesired": true,
"RecursionAvailable": true,
"ResponseCode": "NOERROR",
"QuestionType": "A",
"QuestionName": "example.com",
"EventReceivedTime": "2017-04-21 7:52:03",
"SourceModuleName": "in",
"SourceModuleType": "im_file"
}
This example does not parse logs from DNS Debug Logging generated with the Details
WARNING
option enabled.
NOTE This has been tested on Windows Server versions 2008 R2, 2012 R2, and 2016.
444
Chapter 63. DNS Monitoring NXLog User Guide
This example parses the log files generated by DNS Debug Logging and then writes the output to file in
JSON format.
nxlog.conf (truncated)
1 define EVENT_REGEX /(?x)(?<Date>\d+(?:\/\d+){2})\s \
2 (?<Time>\d+(?:\:\d+){2}\s\w+)\s \
3 (?<ThreadId>\w+)\s+ \
4 (?<Context>\w+)\s+ \
5 (?<InternalPacketIdentifier>[[:xdigit:]]+)\s+ \
6 (?<Protocol>\w+)\s+ \
7 (?<SendReceiveIndicator>\w+)\s \
8 (?<RemoteIP>[[:xdigit:].:]+)\s+ \
9 (?<Xid>[[:xdigit:]]+)\s \
10 (?<QueryType>\s|R)\s \
11 (?<Opcode>[A-Z]|\?)\s \
12 (?<QFlags>\[(.*?)\])\s+ \
13 (?<QuestionType>\w)\s+ \
14 (?<QuestionName>.*)/
15 define EMPTY_EVENT_REGEX /(^$|^\s+$)/
16 define DOMAIN_REGEX /\(\d+\)([\w-]+)\(\d+\)([\w-]+)/
17 define SUBDOMAIN_REGEX /\(\d+\)([\w-]+)\(\d+\)([\w-]+)\(\d+\)(\w+)/
18 define NOT_STARTING_WITH_DATE_REGEX /^(?!\d+\/\d+\/\d+).+/
19 define QFLAGS_REGEX /(?x)(?<FlagsHex>\d+)\s+ \
20 (?<FlagsCharCodes>\s+|([A-Z]{2}|[A-Z]))\s+ \
21 (?<ResponseCode>\w+)/
22
23 <Extension _json>
24 Module xm_json
25 </Extension>
26
27 <Input in>
28 Module im_file
29 [...]
445
NXLog User Guide Chapter 63. DNS Monitoring
Output Sample
{
"EventReceivedTime": "2017-04-21 07:52:16",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"Context": "PACKET",
"InternalPacketIdentifier": "00000000028657F0",
"Opcode": "Q",
"Protocol": "UDP",
"QueryType": "response",
"QuestionName": "notabilus.com",
"QuestionType": "A",
"RemoteIP": "10.2.0.1",
"SendReceiveIndicator": "Snd",
"ThreadId": "06B0",
"Xid": "6590",
"Regular": true,
"EventTime": "2017-04-21 07:52:03",
"Raw": "4/21/2017 7:52:03 AM 06B0 PACKET 00000000028657F0 UDP Snd 10.2.0.1 6590 R Q
[8081 DR NOERROR] A (9)notabilus(3)com(0)",
"FlagsCharCodes": "DR",
"FlagsHex": "8081",
"ResponseCode": "NOERROR"
}
446
Chapter 63. DNS Monitoring NXLog User Guide
In this example, the xm_multiline module joins lines that belong to the same event, by using a regular
expression to match the header line. Then a regular expression is used to parse the content into fields.
Input Sample
6/1/2017 8:33:36 PM 09B8 PACKET 0000022041EED460 UDP Rcv 192.168.56.1 edaa Q [2001 D
NOERROR] A (6)google(3)com(0)↵
UDP question info at 0000022041EED460↵
Socket = 680↵
Remote addr 192.168.56.1, port 48210↵
Time Query=6941, Queued=0, Expire=0↵
Buf length = 0x0fa0 (4000)↵
Msg length = 0x0027 (39)↵
Message:↵
XID 0xedaa↵
Flags 0x0120↵
QR 0 (QUESTION)↵
OPCODE 0 (QUERY)↵
AA 0↵
TC 0↵
RD 1↵
RA 0↵
Z 0↵
CD 0↵
AD 1↵
RCODE 0 (NOERROR)↵
nxlog.conf (truncated)
1 define EVENT_REGEX /(?x)(?<Date>\d+(?:\/\d+){2})\s \
2 (?<Time>\d+(?:\:\d+){2}\s\w+)\s \
3 (?<ThreadId>\w+)\s+ \
4 (?<Context>\w+)\s+ \
5 (?<InternalPacketIdentifier>[[:xdigit:]]+)\s+ \
6 (?<Protocol>\w+)\s+ \
7 (?<SendReceiveIndicator>\w+)\s \
8 (?<RemoteIP>[[:xdigit:].:]+)\s+ \
9 (?<Xid>[[:xdigit:]]+)\s \
10 (?<QueryType>\s|R)\s \
11 (?<Opcode>[A-Z]|\?)\s \
12 (?<QFlags>\[(.*?)\])\s+ \
13 (?<QuestionType>\w+)\s+ \
14 (?<QuestionName>.*)\s+ \
15 (?<LogInfo>.+)\s+.+=\s \
16 (?<Socket>\d+)\s+ Remote\s+ addr\s \
17 (?<RemoteAddr>.+),\sport\s \
18 (?<PortNum>\d+)\s+Time\sQuery= \
19 (?<TimeQuery>\d+),\sQueued= \
20 (?<Queued>\d+),\sExpire= \
21 (?<Expire>\d+)\s+.+\( \
22 (?<BufLen>\d+)\)\s+.+\( \
23 (?<MsgLen>\d+)\)\s+Message:\s+ \
24 (?<Message>(?s).*)/
25
26 define HEADER_REGEX /(?x)(?<Date>\d+(?:\/\d+){2})\s \
27 (?<Time>\d+(?:\:\d+){2}\s\w+)\s \
28 (?<ThreadId>\w+)\s+ \
29 [...]
447
NXLog User Guide Chapter 63. DNS Monitoring
Output Sample
{
"EventReceivedTime": "2018-11-30T04:33:38.660127+01:00",
"SourceModuleName": "filein",
"SourceModuleType": "im_file",
"BufLen": "512",
"Context": "PACKET",
"Expire": "0",
"InternalPacketIdentifier": "000000D58F45A560",
"LogInfo": "UDP response info at 000000D58F45A560",
"Message": "XID 0x000d\r\n Flags 0x8180\r\n QR 1 (RESPONSE)\r\n
OPCODE 0 (QUERY)\r\n AA 0\r\n TC 0\r\n RD 1\r\n RA
1\r\n Z 0\r\n CD 0\r\n AD 0\r\n RCODE 0
(NOERROR)\r\n QCOUNT 1\r\n ACOUNT 1\r\n NSCOUNT 0\r\n ARCOUNT 0\r\n
QUESTION SECTION:\r\n Offset = 0x000c, RR count = 0\r\n Name \"
(6)google(3)com(0)\"\r\n QTYPE AAAA (28)\r\n QCLASS 1\r\n ANSWER SECTION:\r\n
Offset = 0x001c, RR count = 0\r\n Name \"[C00C](6)google(3)com(0)\"\r\n TYPE
AAAA (28)\r\n CLASS 1\r\n TTL 26\r\n DLEN 16\r\n DATA
2a00:1450:400d:805::200e\r\n AUTHORITY SECTION:\r\n empty\r\n ADDITIONAL
SECTION:\r\n empty\r\n",
"MsgLen": "56",
"Opcode": "Q",
"PortNum": "60010",
"Protocol": "UDP",
"QFlags": "[8081 DR NOERROR]",
"QueryType": "R",
"QuestionName": "(6)google(3)com(0)",
"QuestionType": "AAAA",
"Queued": "0",
"RemoteAddr": "::1",
"RemoteIP": "::1",
"SendReceiveIndicator": "Snd",
"Socket": "512",
"ThreadId": "044C",
"TimeQuery": "12131",
"Xid": "000d",
"EventTime": "2018-11-30T04:32:43.000000+01:00"
}
The DNS event log collection supported by Sysmon is not comparable to other types of DNS monitoring like DNS
Server Audit and Analytical logging or DNS Server Debug Logging. In fact, Sysmon DNS Query logging provides
only DNS client query logging, but the information it provides compliments the information from DNS Server
Analytical logs by adding the name and path of the application which is querying the DNS Server. It can monitor
the DNS queries executed by practically any Windows client software that is network-enabled, for instance web
browsers, FileZilla, WinSCP, ping, tracert, etc. It should be noted that direct DNS lookups using nslookup are
not logged by Sysmon’s DNS Query logging.
448
Chapter 63. DNS Monitoring NXLog User Guide
config-dnsquery.xml
<Sysmon schemaversion="4.22">
<EventFiltering>
<DnsQuery onmatch="exclude"/>
</EventFiltering>
</Sysmon>
With the XML configuration file confg-dnsquery.xml located in the same directory as Sysmon.exe, running the
following command will apply the new configuration:
Once the configuration file has been applied, it can be confirmed by issuing the same command with the -c
option, but without any file specified:
A good resource for configuring Sysmon to perform DNS monitoring can be found in this
document on GitHub: sysmonconfig-export.xml. Despite being in XML, the DNS section starting
NOTE at line 835 is quite readable. Lines 871-1063 provide a complete RuleGroup example of how to
filter 180 domains to reduce noise from ads and other common sources of DNS traffic that can
generate a large number of events but are benign.
The last few lines of output returned from Sysmon should produce the following confirmation that DNS Query
logging is active.
Once Sysmon is active and running as a service, it will be logging various events in addition to DNS queries.
These events are visible in the Windows Event Viewer under Applications and Services Log > Microsoft >
Windows > Sysmon > Operational. Each event has an EventID. Sysmon Event ID 22, DNSEvent (DNS query), is
generated when a process executes a DNS query, whether the result is successful or fails, cached or not. The
telemetry for this event was added for Windows 8.1 so it is not available on Windows 7 and earlier. See the
Sysmon section for more information.
To collect DNS events, Sysmon creates an ETW trace session and writes the data into the
Windows Event Log which can then be collected with the im_msvistalog module. To avoid
WARNING
this performance overhead, it is recommended to use the im_etw module to collect event
data directly from the DNS ETW providers for greater efficiency.
449
NXLog User Guide Chapter 63. DNS Monitoring
Environments that already utilize Sysmon monitoring (v10.0 or later) only need to use the im_msvistalog
module and add the relevant Sysmon filtering rules for DNS Query monitoring. In this example, the
im_msvistalog module will collect DnsQuery logs.
nxlog.conf
1 <Input sysmon>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Sysmon/Operational">
7 *[System[(EventID='22')]]
8 </Select>
9 </Query>
10 </QueryList>
11 </QueryXML>
12 </Input>
450
Chapter 63. DNS Monitoring NXLog User Guide
The Message field usually contains a long string of information, most of which is parsed out into the following
fields:
• ProcessGuid
• ProcessId
• QueryStatus
• QueryResults
• Image (the full path and file name of the client application’s executable which performed the DNS query)
451
NXLog User Guide Chapter 63. DNS Monitoring
Using the im_msvistalog module for collecting DNS client events from this source is similar to the
configuration for getting events from Sysmon. A QueryXML block is used to select the source, some fields
are used to filter out unwanted events, while other fields are used to select only the events of interest. In
this configuration example, only four Event IDs are of interest, queries for "wpad" are not needed, and any
QueryType other than "1" will be dropped.
nxlog.conf
1 <Input DNS_Client>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-DNS-Client/Operational">
7 *[System[(EventID=3006 or EventID=3008 or
8 EventID=3010 or EventID=3018)]]
9 </Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 Exec if ($QueryName == 'wpad') OR \
14 ($QueryType != '1') drop();
15 </Input>
452
Chapter 63. DNS Monitoring NXLog User Guide
Output Sample
{
"EventTime": "2020-03-12T14:40:08.809107-07:00",
"Hostname": "WIN-R4QHULN6KLH",
"Keywords": "9223372036854775808",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 3006,
"SourceName": "Microsoft-Windows-DNS-Client",
"ProviderGuid": "{1C95126E-7EEA-49A9-A3FE-A378B03DDB4D}",
"Version": 0,
"TaskValue": 0,
"OpcodeValue": 0,
"RecordNumber": 42095,
"ExecutionProcessID": 2224,
"ExecutionThreadID": 4672,
"Channel": "Microsoft-Windows-DNS-Client/Operational",
"Domain": "WIN-R4QHULN6KLH",
"AccountName": "Administrator",
"UserID": "S-1-5-21-915329490-2962477901-227355065-500",
"AccountType": "User",
"Message": "DNS query is called for the name ntp.msn.com, type 1, query options
140738562228224, Server List , isNetwork query 0, network index 0, interface index 0, is
asynchronous query 0",
"Opcode": "Info",
"QueryName": "ntp.msn.com",
"QueryType": "1",
"QueryOptions": "140738562228224",
"IsNetworkQuery": "0",
"NetworkQueryIndex": "0",
"InterfaceIndex": "0",
"IsAsyncQuery": "0",
"EventReceivedTime": "2020-03-12T14:40:10.674875-07:00",
"SourceModuleName": "DNS_Client",
"SourceModuleType": "im_msvistalog"
}
453
NXLog User Guide Chapter 63. DNS Monitoring
No filtering is used in this configuration since most audit events are important and audit logs tend to be
much lower in volume than analytical or debug logs.
nxlog.conf
1 <Input DNS_Audit>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-DNSServer/Audit">*</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 </Input>
Output Sample
{
"EventTime": "2020-03-12T14:56:07.622472-07:00",
"Hostname": "WIN-R4QHULN6KLH",
"Keywords": "4611686018428436480",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 516,
"SourceName": "Microsoft-Windows-DNSServer",
"ProviderGuid": "{EB79061A-A566-4698-9119-3ED2807060E7}",
"Version": 0,
"TaskValue": 5,
"OpcodeValue": 0,
"RecordNumber": 98,
"ExecutionProcessID": 2000,
"ExecutionThreadID": 4652,
"Channel": "Microsoft-Windows-DNSServer/Audit",
"Domain": "WIN-R4QHULN6KLH",
"AccountName": "Administrator",
"UserID": "S-1-5-21-915329490-2962477901-227355065-500",
"AccountType": "User",
"Message": "A resource record of type 1, name ns2.example.com and RDATA 0x0A000210 was
deleted from scope Default of zone example.com.",
"Category": "ZONE_OP",
"Opcode": "Info",
"Type": "1",
"NAME": "ns2.example.com",
"TTL": "0",
"BufferSize": "4",
"RDATA": "0A000210",
"Zone": "example.com",
"ZoneScope": "Default",
"VirtualizationID": ".",
"EventReceivedTime": "2020-03-12T14:56:09.343045-07:00",
"SourceModuleName": "DNS_Audit",
"SourceModuleType": "im_msvistalog"
}
454
Chapter 63. DNS Monitoring NXLog User Guide
%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-DNSServer%4Analytical.etl
455
NXLog User Guide Chapter 63. DNS Monitoring
Analytical log sources, like debug log sources, tend to generate a high volume of events that are not always
useful. In this configuration example, an analysis of the log file determined that frequent lookups on 10
specific hosts were responsible for a sizable portion of the log file. Since none of these hosts are of interest
for security monitoring, they are being filtered out to reduce noise. The polling interval for reading the log
file is set to 60 seconds to reduce disk I/O in a low traffic environment.
nxlog.conf
1 <Input DNS_Analytical>
2 Module im_msvistalog
3 File C:\Windows\System32\winevt\Logs\Microsoft-Windows-
4 DNSServer%4Analytical.etl
5 PollInterval 60
6 Exec if ($QNAME == 'americas1.notify.windows.com.akadns.net.') OR \
7 ($QNAME == 'cy2.vortex.data.microsoft.com.akadns.net.') OR \
8 ($QNAME == 'dm3p.wns.notify.windows.com.akadns.net.') OR \
9 ($QNAME == 'geo.vortex.data.microsoft.com.akadns.net.') OR \
10 ($QNAME == 'v10-win.vortex.data.microsoft.com.akadns.net.') OR \
11 ($QNAME == 'v10-win.vortex.data.microsoft.com.akadns.NET.') OR \
12 ($QNAME == 'v10.vortex-win.data.microsoft.com.') OR \
13 ($QNAME == 'wns.notify.windows.com.akadns.net.') OR \
14 ($QNAME == 'wns.notify.windows.com.akadns.NET.') OR \
15 ($QNAME == 'client.wns.windows.com.') OR \
16 ($QTYPE == '15') \
17 drop();
18 </Input>
456
Chapter 63. DNS Monitoring NXLog User Guide
Output Sample
{
"EventTime": "2020-03-12T19:21:47.052133-07:00",
"Hostname": "WIN-R4QHULN6KLH",
"Keywords": "9223372071214514176",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 279,
"SourceName": "Microsoft-Windows-DNSServer",
"ProviderGuid": "{EB79061A-A566-4698-9119-3ED2807060E7}",
"Version": 0,
"TaskValue": 1,
"OpcodeValue": 0,
"RecordNumber": 60,
"ExecutionProcessID": 2000,
"ExecutionThreadID": 4188,
"Domain": "NT AUTHORITY",
"AccountName": "SYSTEM",
"UserID": "S-1-5-18",
"AccountType": "User",
"Message": "INTERNAL_LOOKUP_CNAME: TCP=0; InterfaceIP=10.0.2.15; Source=10.0.2.15; RD=1;
QNAME=ns1.example.com.; QTYPE=1; Port=54171; Flags=34176; XID=2;
PacketData=0x00028580000100010000000003777777076578616D706C6503636F6D0000010001",
"Category": "LOOK_UP",
"Opcode": "Info",
"TCP": "0",
"InterfaceIP": "10.0.2.15",
"Source": "10.0.2.15",
"RD": "1",
"QNAME": "ns1.example.com.",
"QTYPE": "1",
"Port": "54171",
"Flags": "34176",
"XID": "2",
"BufferSize": "33",
"PacketData": "00028580000100010000000003777777076578616D706C6503636F6D0000010001",
"EventReceivedTime": "2020-03-12T19:28:51.560303-07:00",
"SourceModuleName": "DNS_Analytical",
"SourceModuleType": "im_msvistalog"
}
The packet capture module im_pcap provides capabilities for monitoring all common network protocols,
including network traffic that is specific to DNS clients and servers.
457
NXLog User Guide Chapter 63. DNS Monitoring
via the extended field name pattern, $dns.additional.*, needed to store the various additional attributes of
DNS traffic.
458
Chapter 63. DNS Monitoring NXLog User Guide
This configuration uses the im_pcap module to capture DNS, IPv4, IPv6, TCP, and UDP packets which are
then formatted to JSON while writing to a local file. Each protocol and its fields are defined within its own
Protocol block.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input pcap>
6 Module im_pcap
7 Dev enp0s3
8 <Protocol>
9 Type dns
10 Field dns.opcode
11 Field dns.id
12 Field dns.flags.authoritative
13 Field dns.flags.recursion_available
14 Field dns.flags.recursion_desired
15 Field dns.flags.authentic_data
16 Field dns.flags.checking_disabled
17 Field dns.flags.truncated_response
18 Field dns.response
19 Field dns.response.code
20 Field dns.query
21 Field dns.additional
22 Field dns.answer
23 Field dns.authority
24 </Protocol>
25 <Protocol>
26 Type ipv4
27 Field ipv4.src
28 Field ipv4.dst
29 [...]
459
NXLog User Guide Chapter 63. DNS Monitoring
"dns.id": "18321",
"dns.opcode": "Query",
"dns.query.class": "IN",
"dns.query.count": "1",
"dns.query.name": "www.example.com",
"dns.response.code": "NOERROR",
"ipv4.dst": "192.168.1.7",
"ipv4.src": "192.168.1.24",
"udp.dst_port": "36486",
"udp.src_port": "53",
"EventTime": "2020-05-18T12:15:34.033655-05:00",
"EventReceivedTime": "2020-05-18T12:15:34.301402-05:00",
"SourceModuleName": "pcap",
"SourceModuleType": "im_pcap"
}
{
"dns.additional.count": "0",
"dns.answer.count": "0",
"dns.authority.count": "0",
"dns.flags.authentic_data": "false",
"dns.flags.authoritative": "false",
"dns.flags.checking_disabled": "false",
"dns.flags.recursion_available": "false",
"dns.flags.recursion_desired": "false",
"dns.flags.truncated_response": "false",
"dns.id": "0",
"dns.opcode": "Query",
"dns.query.class": "IN",
"dns.query.count": "1",
"dns.query.name": "wpad.local",
"dns.response.code": "NOERROR",
"ipv6.dst": "ff02::fb",
"ipv6.src": "fe80::3c3c:c860:df55:fd89",
"udp.dst_port": "5353",
"udp.src_port": "5353",
"EventTime": "2020-05-18T12:22:48.291661-05:00",
"EventReceivedTime": "2020-05-18T12:22:48.487235-05:00",
"SourceModuleName": "pcap",
"SourceModuleType": "im_pcap"
}
460
Chapter 64. Docker NXLog User Guide
By concept, Docker images should be lightweight; usually only one application is present and running in the
container. Therefore, logs are written to the standard out and standard error streams and logging must be
performed from outside the image.
• The default logging driver can be set in the daemon.json configuration file. This file is located in
/etc/docker/ on Linux hosts or C:\ProgramData\docker\config\ on Windows Server hosts. The default
logging driver is json-file.
• The default logging driver can be overridden at the container level. To accomplish this, the log driver and its
configuration options must be provided as parameters at container startup with the help of the docker run
command. The configuration options are the same as setting up logging options for the Docker daemon. See
the docker run command reference on Docker.com for more information.
To find the current logging driver for a running container, run the following docker inspect command,
substituting the container name or ID for <CONTAINER>.
64.2.1. JSON
With the json-file log driver, Docker produces a line-based log file in JSON format for each container. See the
JSON File logging driver guide on Docker.com for more information.
Because im_file recursively watches for log files in the containers directory, this may cause
NOTE
reduced performance in very large installations.
461
NXLog User Guide Chapter 64. Docker
This example configuration reads from the JSON log files of all containers. The JSON fields are parsed and
added to the event record with the xm_json parse_json() procedure. A $HostID field, with the container ID, is
also added.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/lib/docker/containers/*/*-json.log'
12 <Exec>
13 parse_json();
14 $HostID = file_basename(file_name());
15 $HostID =~ s/-json.log//;
16 </Exec>
17 </Input>
64.2.2. GELF
The gelf logging driver is a convenient format that is understood by a number of tools such as NXLog. In GELF,
every log message is a dictionary with fields such as version, host, timestamp, short and long version of the
message, and any custom fields that have been configured. See the Graylog Extended Format logging driver
guide on Docker.com for more information.
In this example, NXLog accepts and parses logs in GELF format on TCP port 12201 with the im_tcp and
xm_gelf modules.
nxlog.conf
1 <Extension _gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 12201
9 InputType GELF_TCP
10 </Input>
64.2.3. Syslog
The syslog logging driver routes logs to a Syslog server, such as NXLog, via UDP, TCP, SSL/TLS, or a Unix domain
socket. See the Syslog logging driver guide on Docker.com for more information.
462
Chapter 64. Docker NXLog User Guide
Here, NXLog accepts logs on TCP port 1514 with the im_tcp module and parses the logs with the xm_syslog
parse_syslog() procedure.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 1514
9 Exec parse_syslog();
10 </Input>
64.2.4. ETW
On Windows-based systems, the etwlogs logging driver forwards container logs to the Event Tracing for
Windows (ETW) system. Each ETW event contains a message with both the log and its context information. See
the ETW logging driver guide on Docker.com for more information.
This example collects logs from the DockerContainerLogs Event Tracing provider using the im_etw
module.
nxlog.conf
1 <Input in>
2 Module im_etw
3 Provider DockerContainerLogs
4 </Input>
463
NXLog User Guide Chapter 65. Elasticsearch and Kibana
However, Logstash is not actually required to load data into Elasticsearch. NXLog can do this as well, and offers
several advantages over Logstash—this is the KEN stack (Kibana, Elasticsearch, and NXLog).
• Because Logstash is written in Ruby and requires Java, it has high system resource requirements. NXLog has
a small resource footprint and is recommended by many ELK users as the log collector of choice for
Windows and Linux.
• Due to the Java dependency, Logstash requires system administrators to deploy the Java runtime onto their
production servers and keep up with Java security updates. NXLog does not require Java.
• The EventLog plugin in Logstash uses the Windows WMI interface to retrieve the EventLog data. This method
incurs a significant performance penalty. NXLog uses the Windows EventLog API natively in order to
efficiently collect EventLog data.
1. Configure NXLog.
The om_elasticsearch module is only available in NXLog Enterprise Edition. Because it sends data in
batches, it reduces the effect of the latency inherent in HTTP responses, allowing the Elasticsearch
server to process the data much more quickly (10,000 EPS or more on low-end hardware).
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Output out>
6 Module om_elasticsearch
7 URL http://localhost:9200/_bulk
8 FlushInterval 2
9 FlushLimit 100
10
11 # Create an index daily
12 Index strftime($EventTime, "nxlog-%Y%m%d")
13
14 # Use the following if you do not have $EventTime set
15 #Index strftime($EventReceivedTime, "nxlog-%Y%m%d")
16 </Output>
464
Chapter 65. Elasticsearch and Kibana NXLog User Guide
For NXLog Community Edition, the om_http module can be used instead to send logs to Elasticsearch.
Because it sends a request to the Elasticsearch HTTP REST API for each event, the maximum logging
throughput is limited by HTTP request and response latency. Therefore this method is suitable only for
low-volume logging scenarios.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Output out>
6 Module om_http
7 URL http://localhost:9200
8 ContentType application/json
9 <Exec>
10 set_http_request_path(strftime($EventTime, "/nxlog-%Y%m%d/" +
11 $SourceModuleName));
12 rename_field("timestamp", "@timestamp");
13 to_json();
14 </Exec>
15 </Output>
2. Restart NXLog, and make sure the event sources are sending data. This can be checked with curl -X GET
'localhost:9200/_cat/indices?v&pretty'. There should be an index matching nxlog* and its
docs.count counter should be increasing.
465
NXLog User Guide Chapter 65. Elasticsearch and Kibana
c. Set the Time Filter field name selector to EventTime (or EventReceivedTime if the $EventTime field is
not set by the input module). Click [Create index pattern].
4. Test that the NXLog and Elasticsearch/Kibana configuration is working by opening Discover on the left panel.
466
Chapter 65. Elasticsearch and Kibana NXLog User Guide
1. Set up a configuration on the Logstash server to process incoming event data from NXLog.
logstash.conf
input {
tcp {
codec => json_lines { charset => CP1252 }
port => "3515"
tags => [ "tcpjson" ]
}
}
filter {
date {
locale => "en"
timezone => "Etc/GMT"
match => [ "EventTime", "YYYY-MM-dd HH:mm:ss" ]
}
}
output {
elasticsearch {
host => localhost
}
stdout { codec => rubydebug }
}
467
NXLog User Guide Chapter 65. Elasticsearch and Kibana
The json codec in Logstash sometimes fails to properly parse JSON—it will concatenate
more than one JSON record into one event. Use the json_lines codec instead.
NOTE
Although the im_msvistalog module converts data to UTF-8, Logstash seems to have trouble
parsing that data. The charset => CP1252 seems to help.
2. Configure NXLog.
nxlog.conf
1 <Output out>
2 Module om_tcp
3 Host 10.1.1.1
4 Port 3515
5 Exec to_json();
6 </Output>
3. Restart NXLog.
468
Chapter 66. F5 BIG-IP NXLog User Guide
There are multiple sub-systems that write logs to different files. Below is an example of Local Traffic
Management (LTM) logs reporting pool members being up or down.
For more details on BIG-IP log files and how to view them, please refer to the K16197 knowledge base article.
Additional information on configuring logging options on BIG-IP devices can be found in the F5 Knowledge
Center. Select the appropriate software version and look for the "Log Files" section in the TMOS Operations
Guide.
NOTE The steps below have been tested with BIG-IP v11 but should also work for other versions.
1. Configure NXLog to receive log entries via TCP and process them as Syslog (see the examples below). Then
restart NXLog.
2. Make sure the NXLog agent is accessible from all BIG-IP devices being configured. A new route or default
gateway may need to be configured depending on the current setup.
3. Connect via SSH to the BIG-IP device. In case of a High Availability (HA) group, make sure you are logged into
the active unit. You should see (Active) in the command prompt.
4. Review the existing Syslog configuration on BIG-IP and remove it.
5. Configure a remote Syslog destination on BIG-IP. Replace IP_SYSLOG and PORT with the IP address and port
that the NXLog agent is listening on. Replace LEVEL with the required logging level.
469
NXLog User Guide Chapter 66. F5 BIG-IP
This command forwards all appliance logs to the remote destination, so nothing will be
NOTE
logged locally as soon as it is executed.
This command redirects logs at the informational level (from info to emerg) to an NXLog agent at
192.168.6.43, via TCP port 1514.
6. In case of a High Availability (HA) group, synchronize the configuration changes to the other units.
Once the configuration has been synchronized to all members of the group, each member
NOTE will be sending logs, inserting its own hostname and IP address. In the event of failover,
logging will continue from both units regardless of which one is currently active.
470
Chapter 66. F5 BIG-IP NXLog User Guide
This configuration uses the im_tcp module to collect the BIG-IP logs. A JSON output sample shows the
resulting logs as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 Exec parse_syslog();
14 </Input>
15
16 <Output out>
17 Module om_file
18 File "/var/log/f5.log"
19 Exec to_json();
20 </Output>
471
NXLog User Guide Chapter 66. F5 BIG-IP
Output Sample
{
"MessageSourceAddress": "192.168.6.161",
"EventReceivedTime": "2017-03-14 17:03:16",
"SourceModuleName": "in",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 16,
"SyslogFacility": "LOCAL0",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "l-lb2",
"EventTime": "2017-03-14 17:03:53",
"SourceName": "mcpd",
"ProcessID": "7233",
"Message": "notice httpd[5150]: 01070639:5: Pool /Common/q-qa-pool member /Common/q-qa1:25
session status enabled."
}
{
"MessageSourceAddress": "192.168.6.91",
"EventReceivedTime": "2017-03-14 17:10:18",
"SourceModuleName": "in",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 16,
"SyslogFacility": "LOCAL0",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "l-lb1",
"EventTime": "2017-03-14 17:10:33",
"SourceName": "httpd",
"ProcessID": "1181",
"Message": "notice httpd[5150]: 01070417:5: AUDIT - user john - RAW: httpd(mod_auth_pam):
user=john(john) partition=[All] level=Administrator tty=/usr/bin/tmsh host=192.168.9.78
attempts=1 start=\"Tue Mar 14 16:43:41 2017\" end=\"Tue Mar 14 17:10:33 2017\"."
}
NXLog can also be configured to extract additional fields from the messages, including those that contain key-
value pairs.
472
Chapter 66. F5 BIG-IP NXLog User Guide
This configuration uses the xm_syslog parse_syslog() procedure to parse Syslog messages and the xm_kvp
module to extract additional fields.
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Extension kvp>
10 Module xm_kvp
11 KVPDelimiter " "
12 KVDelimiter =
13 EscapeChar \\
14 </Extension>
15
16 <Input in>
17 Module im_tcp
18 Host 0.0.0.0
19 Port 1514
20 <Exec>
21 parse_syslog();
22 if $Message =~ /^([a-z]*) ([a-zA-Z]*)(.*)$/
23 {
24 $F5MsgLevel = $1;
25 $F5Proc = $2;
26 $F5Message = $3;
27 if $F5Message =~ /^\[[0-9]*\]: ([0-9]*):([0-9]+): (.*)$/
28 {
29 [...]
473
NXLog User Guide Chapter 66. F5 BIG-IP
Output Sample
{
"MessageSourceAddress": "192.168.6.91",
"EventReceivedTime": "2017-04-16 00:06:43",
"SourceModuleName": "in",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 10,
"SyslogFacility": "AUTHPRIV",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "l-lb1",
"EventTime": "2017-04-16 00:07:59",
"Message": "notice httpd[5320]: 01070417:5: AUDIT - user john - RAW: httpd(mod_auth_pam):
user=john(john) partition=[All] level=Administrator tty=/usr/bin/tmsh host=192.168.9.78
attempts=1 start=\"Sun Apr 16 00:07:59 2017\".",
"F5MsgLevel": "notice",
"F5Proc": "httpd",
"F5Message": "[5320]: 01070417:5: AUDIT - user john - RAW: httpd(mod_auth_pam):
user=john(john) partition=[All] level=Administrator tty=/usr/bin/tmsh host=192.168.9.78
attempts=1 start=\"Sun Apr 16 00:07:59 2017\".",
"F5MsgID": "01070417",
"F5MsgSev": "5",
"F5Msg": "AUDIT - user john - RAW: httpd(mod_auth_pam): user=john(john) partition=[All]
level=Administrator tty=/usr/bin/tmsh host=192.168.9.78 attempts=1 start=\"Sun Apr 16 00:07:59
2017\".",
"F5Process": "httpd",
"F5Module": "mod_auth_pam",
"user": "john(john)",
"partition": "[All]",
"level": "Administrator",
"tty": "/usr/bin/tmsh",
"host": "192.168.9.78",
"attempts": "1",
"start": "Sun Apr 16 00:19:55 2017"
}
1. Configure NXLog to receive log entries via UDP and process them as Syslog (see the example below). Then
restart the agent.
2. Make sure the NXLog agent is accessible from all BIG-IP devices being configured. A new route or default
gateway may need to be configured, depending on the current setup.
3. Proceed with the Syslog configuration on BIG-IP, using either the command line or the web interface. See the
following sections.
474
Chapter 66. F5 BIG-IP NXLog User Guide
This configuration uses the im_udp module to collect the BIG-IP logs.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in_syslog_udp>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 Exec parse_syslog();
10 </Input>
This command redirects Informational Logs to an NXLog agent at 192.168.6.143, via UDP port 514.
3. In case of a High Availability (HA) group, synchronize configuration changes to the other units:
Once the configuration has been synchronized to all members of the group, each member
NOTE will be sending logs, inserting its own hostname and IP address. In the event of failover,
logging will continue from both units regardless of which one is currently active.
3. Type in the Remote IP and Remote Port, then click [Add] and [Update].
475
NXLog User Guide Chapter 66. F5 BIG-IP
4. In case of a High Availability (HA) group, synchronize the configuration changes to the other units:
a. Click on the yellow Changes Pending in the top left corner.
b. Select Active unit which should be marked as (Self).
c. Make sure Sync Device to Group option is chosen and click [Sync].
476
Chapter 66. F5 BIG-IP NXLog User Guide
Once the configuration has been synchronized to all members of the group, each member will
NOTE be sending logs, inserting its own hostname and IP address. In the event of failover, logging will
continue from both units regardless of which one is currently active.
BIG-IP systems also come with Management Information Base (MIB) files stored on the device itself. Additional
information on that is available in K13322.
1. Configure NXLog with the xm_snmp module. See the example below.
2. Make sure the NXLog agent is accessible from all BIG-IP devices being configured. A new route or default
gateway may need to be configured, depending on the current setup.
3. Proceed with the SNMP configuration on BIG-IP, using either the command line or the web interface. See the
following sections.
477
NXLog User Guide Chapter 66. F5 BIG-IP
This example NXLog configuration uses the im_udp and xm_snmp modules to receive SNMP traps. The
corresponding JSON-formatted output is shown below.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension snmp>
6 Module xm_snmp
7 MIBDir /usr/share/mibs/bigip
8 # The following <User> section is required for SNMPv3
9 #<User snmp_user>
10 # AuthProto sha1
11 # AuthPasswd q1w2e3r4
12 # EncryptPasswd q1w2e3r4
13 # EncryptProto aes
14 #</User>
15 </Extension>
16
17 <Input in>
18 Module im_udp
19 Host 0.0.0.0
20 Port 162
21 InputType snmp
22 </Input>
23
24 <Output out>
25 Module om_file
26 File "/var/log/f5.log"
27 Exec to_json();
28 </Output>
Output Sample
{
"SNMP.CommunityString": "nxlog",
"SNMP.RequestID": 449377444,
"EventTime": "2017-03-18 16:37:41",
"SeverityValue": 2,
"Severity": "INFO",
"OID.1.3.6.1.2.1.1.3.0": 1277437018,
"OID.1.3.6.1.6.3.1.1.4.1.0": "1.3.6.1.4.1.3375.2.4.0.3",
"OID.1.3.6.1.6.3.1.1.4.3.0": "1.3.6.1.4.1.3375.2.4",
"MessageSourceAddress": "192.168.6.91",
"EventReceivedTime": "2017-03-18 16:37:41",
"SourceModuleName": "in",
"SourceModuleType": "im_udp"
}
478
Chapter 66. F5 BIG-IP NXLog User Guide
4. Configure the remote SNMP destination on BIG-IP. Replace NAME, COMMUNITY, IP_ADDRESS, and PORT with
appropriate values. Replace NETWORK with other unless traps are going out the management interface, when
management should be specified instead.
In case of SNMPv3, this command needs additional parameters, including security-level, auth-protocol, auth-
password, privacy-protocol, and privacy-password.
This command enables sending SNMPv3 traps to 192.168.6.143, using SHA and AES.
479
NXLog User Guide Chapter 66. F5 BIG-IP
If the BIG-IP configuration has been previously migrated or cloned, SNMPv3 may not work
NOTE
because the EngineID is not unique. In this case it must be reset as described in K6821.
5. In case of a High Availability (HA) group, synchronize the configuration changes to the other units.
3. Create an SNMP user (SNMPv3 only). Go to System › SNMP › Agent › Access (v3). Click [Create] and
specify the user name, authentication type and password, privacy protocol and password, and access type.
Specify an OID value to limit access to certain OIDs, or use .1 to allow full access.
4. Go to System › SNMP › Traps › Destination and click [Create]. Specify the SNMP version, community
480
Chapter 66. F5 BIG-IP NXLog User Guide
name, destination IP address, destination port, and network to send traffic to. Then click [Finished].
SNMPv3 requires additional parameters. This example matches the settings shown in the NXLog
configuration above.
5. In case of a High Availability (HA) group, synchronize the configuration changes to the other units.
a. Click on the yellow Changes Pending in the top left corner.
b. Select the Active unit which should be marked as (Self).
c. Make sure the Sync Device to Group option is chosen and click [Sync].
481
NXLog User Guide Chapter 66. F5 BIG-IP
Once the configuration has been synchronized to all members of the group, each
NOTE member will be sending logs, inserting its own hostname and IP address. In the event of
failover, logging will continue from both units regardless of which one is currently active.
BIG-IP is able to send its own logs via HSL in addition to logs for traffic passing through the device. Because the
load balancer is usually on the edge of the network and all web traffic passes through it, logging traffic on BIG-IP
itself may be an easier and faster solution than processing web server logs on each server separately.
When configuring HSL on BIG-IP, the administrator will have to choose between sending logs via TCP or UDP. TCP
can guarantee reliable delivery. However when load balancing traffic between multiple nodes, BIG-IP will reuse
existing TCP connections to each node in order to reduce overhead related to creating new connections. This
may result in less perfect load balancing between members.
NOTE The steps below have been tested with BIG-IP v12.
In order to configure HSL on BIG-IP, a node for each NXLog server must be created and then added to a pool.
Follow these steps.
482
Chapter 66. F5 BIG-IP NXLog User Guide
These commands create a pool named nxlog with one NXLog node.
Adaptive
Sends traffic to one of the pool members until this member is either unable to process logs at the
required rate or the connection is lost.
Balanced
Uses the load balancing method configured on the pool and selects a new member each time it sends
data.
Replicated
Sends each log to all members of the pool.
3. Create a log publisher. Replace NAME with a name for the publisher and DESTINATION with the destination
name used in the previous step.
4. Create a log filter. Replace NAME with a name for the filter, LEVEL with the required logging level between
Emergency and Debugging, PUBLISHER with the name used in the previous step, and SOURCE with a
particular process running on BIG-IP (or all, which sends all logs).
483
NXLog User Guide Chapter 66. F5 BIG-IP
The following commands will send all logs to the NXLog pool via the TCP protocol.
3. Assign the logging profile to a virtual server. Replace NAME with the virtual server name and
LOGGING_PROFILE with the profile name used in the previous step. A logging profile can be assigned to
multiple virtual servers.
The following commands configure traffic logging to the NXLog pool via TCP.
484
Chapter 66. F5 BIG-IP NXLog User Guide
This example shows BIG-IP traffic logs as received and processed by NXLog using im_tcp and xm_syslog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_tcp>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 Exec parse_syslog();
14 </Input>
15
16 <Output out>
17 Module om_file
18 File "/var/log/f5.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.6.91",
"EventReceivedTime": "2017-05-10 19:16:43",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-05-10 19:16:43",
"Hostname": "192.168.6.91",
"Message": "client 192.168.9.78:63717 request GET /cmedia/img/icons/mime/mime-
unknown.png?v170509919 HTTP/1.1 server 192.168.6.101:80 status "
}
485
NXLog User Guide Chapter 66. F5 BIG-IP
Further field extraction can be done with NXLog according to the sequence of fields specified in the
template. For the template string shown above, the following configuration extracts the four fields with a
regular expression.
nxlog.conf
1 <Input in_syslog_tcp>
2 Module im_tcp
3 Host 0.0.0.0
4 Port 1514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /^client (.*) request (.*) server (.*) status (.*)$/
8 {
9 $HTTP_Client = $1;
10 $HTTP_Request = $2;
11 $HTTP_Server = $3;
12 $HTTP_Status = $4;
13 }
14 </Exec>
15 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.6.91",
"EventReceivedTime": "2017-05-10 20:06:24",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2017-05-10 20:06:24",
"Hostname": "192.168.6.91",
"Message": "client 192.168.9.78:65275 request GET /?disabledcookies=true HTTP/1.1 server
192.168.6.100:80 status ",
"HTTP_Client": "192.168.9.78:65275",
"HTTP_Request": "GET /?disabledcookies=true HTTP/1.1",
"HTTP_Server": "192.168.6.100:80",
"HTTP_Status": ""
}
486
Chapter 66. F5 BIG-IP NXLog User Guide
Example 298. Creating a Virtual Server Forwarding Logs to the NXLog Pool
This example creates a virtual server listening on TCP port 1514 that forwards logs to the nxlog pool.
Once this has been set up, log producers can be configured to forward Syslog logs to 192.168.6.93.
487
NXLog User Guide Chapter 67. File Integrity Monitoring
• PCI-DSS compliance - Payment Card Industry Data Security Standard (Requirement 11.5)
• SOX compliance - Sarbanes-Oxley Act (Section 404)
• NERC CIP compliance - NERC CIP Standard (CIP-010-2)
• FISMA compliance - Federal Information Security Management Act (NIST SP800-53 Rev3)
• HIPAA compliance - Health Insurance Portability and Accountability Act of 1996 (NIST Publication 800-66)
• SANS compliance - SANS Critical Security Controls (Control 3)
NXLog can be configured to provide file (or Windows Registry) integrity monitoring. An event is generated for
each detected modification. These events can then be used to generate alerts or be forwarded for storage and
auditing.
There are various ways that monitoring can be implemented; these fall into two categories.
Checksum Monitoring
The im_fim and im_regmon modules (available with NXLog Enterprise Edition only) provide monitoring based
on a cryptographic checksums. On the first run (when a file set or the registry is in a known secure state), a
database of checksums is created. Subsequent scans are performed at regular intervals, and the checksums
are compared. When a change is detected, an event is generated.
• The im_fim module is platform independent, available on all platforms supported by NXLog, and has no
external dependencies. Similarly, the im_regmon module requires no configuration outside of NXLog to
monitor the Windows Registry.
• If there are multiple changes between two scans, only the cumulative effect is logged. For example, if a
file is deleted and a new file is created in its place before the next scan occurs, a single modification event
will be generated.
• It is not possible to detect which user made a change because the filesystem/registry does not provide
that information, and there may be multiple changes by different users between scans.
Real-Time Monitoring
Files (and the Windows Registry) can also be monitored in real-time with the help of kernel-level auditing,
which does not require periodic scanning. This type of monitoring is platform specific.
• Kernel-level monitoring usually provides improved performance, especially for large file sets.
• All events are logged; the granularity of reporting is not limited by the scan interval (because there is no
scanning involved).
• Reported events may be very detailed, and usually include information about which user made the
change.
See the following sections for details about setting up file integrity monitoring on various platforms.
NXLog must have permission to read the files that are to be monitored. Run NXLog as root, make sure the nxlog
user or group has permission to read the files, or change the user/group under which NXLog runs. See the User
and Group directives.
488
Chapter 67. File Integrity Monitoring NXLog User Guide
This configuration uses im_fim to monitor a common set of system directories containing configuration,
executables, and libraries. The RIPEMD-160 hash function is selected and the scan interval is set to 3,600
seconds (1 hour).
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/bin/*"
4 File "/etc/*"
5 File "/lib/*"
6 File "/opt/nxlog/bin/*"
7 File "/opt/nxlog/lib/*"
8 File "/sbin/*"
9 File "/usr/bin/*"
10 File "/usr/sbin/*"
11 Exclude "/etc/hosts.deny"
12 Exclude "/etc/mtab"
13 Digest rmd160
14 Recursive TRUE
15 ScanInterval 3600
16 </Input>
Internal Log
2017-06-14 11:44:53 INFO Module 'fim': FIM scan started↵
2017-06-14 11:45:00 INFO Module 'fim': FIM scan finished in 7.24 seconds. Scanned folders: 833
Scanned files: 5081 Read file bytes: 379166339↵
Output Sample
{
"EventTime": "2017-06-14 11:57:33",
"Hostname": "ubuntu-xenial",
"EventType": "CHANGE",
"Object": "FILE",
"PrevFileName": "/etc/ld.so.cache",
"PrevModificationTime": "2017-06-14 11:20:47",
"FileName": "/etc/ld.so.cache",
"ModificationTime": "2017-06-14 11:56:55",
"PrevFileSize": 46298,
"FileSize": 46971,
"DigestName": "rmd160",
"PrevDigest": "1dbe24a108c044153d8499f073274b7ad5507119",
"Digest": "ec0bc108b7c9e5d9eafde9cb1407b91e618d24c4",
"EventReceivedTime": "2017-06-14 11:57:33",
"SourceModuleName": "fim",
"SourceModuleType": "im_fim"
}
See the Linux Audit System chapter for details about setting up kernel-level auditing. It is even possible to
combine the im_fim and im_linuxaudit modules for redundant monitoring.
489
NXLog User Guide Chapter 67. File Integrity Monitoring
This configuration monitors the program directories for changes. The scan interval is set to 1,800 seconds
(30 minutes). The events generated by NXLog are similar to those shown in Using im_fim on Linux.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File 'C:\Program Files\*'
4 File 'C:\Program Files (x86)\*'
5 Exclude 'C:\Program Files\nxlog\data\*'
6 Recursive TRUE
7 ScanInterval 1800
8 </Input>
The Windows Registry can be monitored with the im_regmon module. This configuration monitors all
registry keys in the specified path. The keys are scanned every 60 seconds.
nxlog.conf
1 <Input registry>
2 Module im_regmon
3 RegValue 'HKLM\Software\Policies\*'
4 Recursive TRUE
5 ScanInterval 60
6 </Input>
Internal Log
2020-02-26 22:08:32 INFO Module 'in': Registry scan finished in 0.08 seconds. Scanned registry
keys: 337 Scanned registry values: 1250 Read value bytes: 106866↵
Output Sample
{
"EventTime": "2018-01-31 04:01:12",
"Hostname": "WINAD",
"EventType": "CHANGE",
"RegistryValueName": "HKLM\\Software\\Policies\\Microsoft\\TPM\\OSManagedAuthLevel",
"PrevValueSize": 4,
"ValueSize": 4,
"DigestName": "SHA1",
"PrevDigest": "0aaf76f425c6e0f43a36197de768e67d9e035abb",
"Digest": "3c585604e87f855973731fea83e21fab9392d2fc",
"Severity": "WARNING",
"SeverityValue": 3,
"EventReceivedTime": "2018-01-31 04:01:12",
"SourceModuleName": "registry",
"SourceModuleType": "im_regmon",
"MessageSourceAddress": "10.8.0.121"
}
490
Chapter 67. File Integrity Monitoring NXLog User Guide
The following example uses the im_regmon module to monitor a list of hive key paths listed in documents
such as the MITRE ATT&CK framework and the JP/CERT Lateral Movements. This list can be modified as and
when needed.
When running a custom list, make sure to double check the internal log for the appropriate number of keys
and values that are being scanned.
nxlog.conf
1 <Input extend_regmon_rules>
2 Module im_regmon
3 Recursive TRUE
4 ScanInterval 30
5
6 RegValue "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\*"
7 RegValue "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image
8 File Execution Options\*"
9 RegValue "HKLM\SYSTEM\CurrentControlSet\Control\WMI\Security\*"
10 RegValue "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\*"
11 RegValue "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute"
12 RegValue "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Control
13 Panel\NameSpace\*"
14 RegValue "HKLM\SYSTEM\ControlSet001\Enum\STORAGE\VolumeSnapshot"
15 RegValue "HKLM\SYSTEM\ControlSet001\Services\VSS\*"
16 RegValue "HKLM\Software\Microsoft\Windows\CurrentVersion\Runonce"
17 RegValue "HKLM\Software\Microsoft\Windows\CurrentVersion\policies\Explorer\*"
18 RegValue "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\*"
19 RegValue "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\*"
20 RegValue "HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce"
21 RegValue "HKLM\Software\Policies\*"
22 </Input>
491
NXLog User Guide Chapter 68. FreeRADIUS
NXLog can be configured to process FreeRADIUS authentication and accounting logs. For processing RADIUSs
NPS, see RADIUS NPS (xm_nps).
492
Chapter 68. FreeRADIUS NXLog User Guide
The configuration below uses the im_file module to read FreeRADIUS authentication log entries and
separate fields with regular expressions. The result is converted to JSON after fields EventReceivedTime,
SourceModuleName, and SourceModuleType are deleted from the $raw_event.
nxlog.conf
1 <Input freeradius>
2 Module im_file
3 File '/tmp/input'
4 <Exec>
5 if $raw_event =~ /^(?<DateTime>\w{3} \w{3} \d{2} \d{2}:\d{2}:\d{2} \d{4}) :
(?<EventType>\w+): (?<Message>.+)/
6 {
7 $raw_event = $DateTime + ' ' + $EventType + ' ' + $Message;
8 }
9 else drop();
10 </Exec>
11 </Input>
12
13 <Output out>
14 Module om_file
15 File '/tmp/output'
16 <Exec>
17 delete($EventReceivedTime);
18 delete($SourceModuleName);
19 delete($SourceModuleType);
20 to_json();
21 </Exec>
22 </Output>
Event Sample
Thu Dec 20 07:50:44 2018 : Info: Loaded virtual server inner-tunnel↵
Thu Dec 20 07:50:44 2018 : Info: Ready to process requests↵
Thu Dec 20 07:50:46 2018 : Auth: (0) Login OK: [testing/testing123] (from client localhost port
0)↵
Thu Dec 20 07:50:46 2018 : Auth: (1) Login OK: [testing/testing123] (from client localhost port
0)↵
Thu Dec 20 07:50:47 2018 : Auth: (2) Login OK: [testing/testing123] (from client localhost port
0)↵
Thu Dec 20 07:50:49 2018 : Auth: (3) Login incorrect (pap: Cleartext password does not match
"known good" password): [testing/testing] (from client localhost port 0)↵
493
NXLog User Guide Chapter 68. FreeRADIUS
Output Sample
{
"DateTime": "Thu Dec 20 07:50:44 2018",
"EventType": "Info",
"Message": "Loaded virtual server inner-tunnel"
}
{
"DateTime": "Thu Dec 20 07:50:44 2018",
"EventType": "Info",
"Message": "Ready to process requests"
}
{
"DateTime": "Thu Dec 20 07:50:46 2018",
"EventType": "Auth",
"Message": "(0) Login OK: [testing/testing123] (from client localhost port 0)"
}
{
"DateTime": "Thu Dec 20 07:50:46 2018",
"EventType": "Auth",
"Message": "(1) Login OK: [testing/testing123] (from client localhost port 0)"
}
{
"DateTime": "Thu Dec 20 07:50:47 2018",
"EventType": "Auth",
"Message": "(2) Login OK: [testing/testing123] (from client localhost port 0)"
}
{
"DateTime": "Thu Dec 20 07:50:49 2018",
"EventType": "Auth",
"Message": "(3) Login incorrect (pap: Cleartext password does not match \"known good\"
password): [testing/testing] (from client localhost port 0)"
}
494
Chapter 68. FreeRADIUS NXLog User Guide
The configuration below utilizes the im_file module to read FreeRADIUS accounting logs and the
xm_multiline module to match the start and end of a log entry. Each string is processed and converted to
key-value pairs using the xm_kvp and to JSON using the xm_json modules. The EventReceivedTime,
SourceModuleName, and SourceModuleType fields are deleted from the entry.
nxlog.conf
1 <Extension radius>
2 Module xm_multiline
3 HeaderLine /^\s\S\S\S\s+\S\S\S\s+\d{1,2}\s+\d{1,2}\:\d{1,2}\: \
4 \d{1,2}\s+\d{4}/
5 EndLine /^\s+Timestamp = \d*/
6 </Extension>
7
8 <Extension kvp>
9 Module xm_kvp
10 KVDelimiter =
11 KVPDelimiter \n
12 </Extension>
13
14 <Input in>
15 Module im_file
16 File "/tmp/input"
17 ReadFromLast FALSE
18 SavePos FALSE
19 InputType radius
20 <Exec>
21 if $raw_event =~ /^(.+)\s*([\s\S]+)/
22 {
23 $EventTime = parsedate($1);
24 kvp->parse_kvp($2);
25 $Timestamp = datetime(integer($Timestamp) * 1000000);
26 }
27 else log_info("no match for " + $raw_event);
28 delete($EventReceivedTime);
29 delete($SourceModuleName);
30 delete($SourceModuleType);
31 </Exec>
32
33 </Input>
495
NXLog User Guide Chapter 68. FreeRADIUS
Event Sample
Tue May 21 00:00:03 2013↵
Acct-Session-Id = "1/3/0/3_00FA2701"↵
Framed-Protocol = PPP↵
Framed-IP-Address = 1.2.3.4↵
Cisco-AVPair = "ppp-disconnect-cause=Received LCP TERMREQ from peer"↵
User-Name = "user"↵
Acct-Authentic = RADIUS↵
Cisco-AVPair = "connect-progress=LAN Ses Up"↵
Cisco-AVPair = "nas-tx-speed=1410065408"↵
Cisco-AVPair = "nas-rx-speed=1410065408"↵
Acct-Session-Time = 384↵
Acct-Input-Octets = 4497↵
Acct-Output-Octets = 7951↵
Acct-Input-Packets = 64↵
Acct-Output-Packets = 64↵
Acct-Terminate-Cause = User-Request↵
Cisco-AVPair = "disc-cause-ext=PPP Receive Term"↵
Acct-Status-Type = Stop↵
NAS-Port-Type = Ethernet↵
NAS-Port = 402653187↵
NAS-Port-Id = "1/3/0/3"↵
Cisco-AVPair = "client-mac-address=fe00.5104.01ae"↵
Service-Type = Framed-User↵
NAS-IP-Address = 1.2.3.4↵
X-Ascend-Session-Svr-Key = "DCCE87A5"↵
Acct-Delay-Time = 0↵
Proxy-State = 0x313133↵
Proxy-State = 0x323339↵
Client-IP-Address = 1.2.3.4↵
Acct-Unique-Session-Id = "3ff5a50a3cea9cba"↵
Timestamp = 1369087203↵
↵
496
Chapter 68. FreeRADIUS NXLog User Guide
Output Sample
{
"EventTime": "2013-05-21T00:00:03.000000+00:00",
"Acct-Session-Id": "1/3/0/3_00FA2701",
"Framed-Protocol": "PPP",
"Framed-IP-Address": "1.2.3.4",
"Cisco-AVPair": "client-mac-address=fe00.5104.01ae",
"User-Name": "user",
"Acct-Authentic": "RADIUS",
"Acct-Session-Time": 384,
"Acct-Input-Octets": 4497,
"Acct-Output-Octets": 7951,
"Acct-Input-Packets": 64,
"Acct-Output-Packets": 64,
"Acct-Terminate-Cause": "User-Request",
"Acct-Status-Type": "Stop",
"NAS-Port-Type": "Ethernet",
"NAS-Port": 402653187,
"NAS-Port-Id": "1/3/0/3",
"Service-Type": "Framed-User",
"NAS-IP-Address": "1.2.3.4",
"X-Ascend-Session-Svr-Key": "DCCE87A5",
"Acct-Delay-Time": 0,
"Proxy-State": 3289913,
"Client-IP-Address": "1.2.3.4",
"Acct-Unique-Session-Id": "3ff5a50a3cea9cba",
"Timestamp": "2013-05-20T22:00:03.000000+00:00"
}
497
NXLog User Guide Chapter 69. Graylog
See the Graylog documentation for more information about configuring and using Graylog.
2. Select input type GELF UDP and click the [Launch new input] button.
3. Select the Graylog node for your input or make it global. Provide a name for the input in the Title textbox.
Change the default port if needed. Use the Bind address option to limit the input to a specific network
interface.
498
Chapter 69. Graylog NXLog User Guide
This configuration loads the xm_gelf extension module and uses the GELF_UDP output writer to send GELF
messages via UDP.
nxlog.conf
1 <Extension _gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 </Input>
9
10 <Output out>
11 Module om_udp
12 Host 127.0.0.1
13 Port 12201
14 OutputType GELF
15 </Output>
2. Select input type GELF TCP and click the [Launch new input] button.
3. Select the Graylog node for your input or make it global. Provide a name for the input in the Title textbox.
Change the default port if needed. Use the Bind address option to limit the input to a specific network
interface.
499
NXLog User Guide Chapter 69. Graylog
4. To use TLS configuration, provide the TLS cert file and the TLS private key file (a password is required if the
private key is encrypted). Check Enable TLS.
500
Chapter 69. Graylog NXLog User Guide
This configuration loads the xm_gelf extension module and uses the GELF_TCP output writer to send GELF
messages via TCP.
nxlog.conf
1 <Extension _gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 </Input>
9
10 <Output out>
11 Module om_tcp
12 Host 127.0.0.1
13 Port 12201
14 OutputType GELF_TCP
15 </Output>
501
NXLog User Guide Chapter 69. Graylog
This configuration loads the xm_gelf extension module and uses the GELF_TCP output writer with the
om_ssl module to send GELF messages via TLS encrypted connection.
nxlog.conf
1 <Extension _gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "/var/log/messages"
8 </Input>
9
10 <Output out>
11 Module om_ssl
12 Host 127.0.0.1
13 Port 12201
14 CertFile %CERTDIR%/graylog.crt
15 AllowUntrusted TRUE
16 OutputType GELF_TCP
17 </Output>
1. Stop and disable the NXLog system service, as the NXLog process will be managed by Graylog. Install and
configure the collector sidecar for the target system. The details can found in the Graylog Collector Sidecar
documentation.
collector_sidecar.yml
server_url: http://10.0.2.2:9000/api/
update_interval: 30
tls_skip_verify: true
send_status: true
list_log_files:
- /var/log
node_id: graylog-collector-sidecar
collector_id: file:/etc/graylog/collector-sidecar/collector-id
log_path: /var/log/graylog/collector-sidecar
log_rotation_time: 86400
log_max_age: 604800
tags:
- linux
- apache
- redis
backends:
- name: nxlog
enabled: true
binary_path: /usr/bin/nxlog
configuration_path: /etc/graylog/collector-sidecar/generated/nxlog.conf
2. Go to System › Collectors. After a successful sidecar installation, a new collector should appear.
502
Chapter 69. Graylog NXLog User Guide
5. Create a new output of the required type. See the Configuring GELF UDP Collection and Configuring GELF
TCP or TCP/TLS Collection sections above.
6. Create an input for NXLog (for example, a file input).
503
NXLog User Guide Chapter 69. Graylog
7. Go back to System › Collectors to verify the setup. If everything is fine the collector should be in the
Running state.
504
Chapter 70. HP ProCurve NXLog User Guide
The HP ProCurve web interface does not provide a way to configure an external Syslog server, so this must be
done via the command line (see the following sections). For more details on configuring logging for HP ProCurve
switches, refer to the HP ProCurve Management and Configuration Guide available from HP Enterprise Support.
The actual document depends on the model and firmware version in use.
In case of multiple switches running in redundancy mode (such as VRRP or similar), each
WARNING device must be configured separately as failover happens per VLAN and logging
configuration is not synchronized.
The steps below have been tested with HP 4000 series switches but should also work for 2000,
NOTE
6000, and 8000 series devices.
1. Configure NXLog to receive log entries over the network and process them as Syslog (see Accepting Syslog
via UDP, TCP, or TLS and the TCP example below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from the switch.
3. Connect to the switch via SSH or Telnet.
4. Run the following commands to configure Syslog logging. Replace LEVEL with the logging level (debug, major,
error, warning, or info). Replace FACILITY with the Syslog facility to be used for the logs. Replace
IP_ADDRESS with the address of the NXLog agent; PROTOCOL with udp, tcp, or tls; and PORT with the
required port. If PORT is omitted, the default will be used (514 for UDP, 1470 for TCP, or 6514 for TLS).
# configure
(config)# logging severity LEVEL
(config)# logging facility FACILITY
(config)# logging IP_ADDRESS PROTOCOL PORT
(config)# write memory
The following commands configure the switch to send logs to 192.168.6.143 via the default TCP port.
Only logs with info severity level and higher will be sent, and the local5 Syslog facility will be used.
# configure
(config)# logging severity info
(config)# logging facility local5
(config)# logging 192.168.6.143 tcp
(config)# write memory
505
NXLog User Guide Chapter 70. HP ProCurve
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_tcp>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1470
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/hp.log"
19 Exec to_json();
20 </Output>
Events like those at the beginning of the chapter will result in the following output.
Output Sample
{
"MessageSourceAddress": "192.168.10.3",
"EventReceivedTime": "2017-03-18 19:32:02",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 21,
"SyslogFacility": "LOCAL5",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "192.168.10.3",
"EventTime": "2017-03-19 00:27:27",
"SourceName": "mgr",
"Message": " SME TELNET from 192.168.9.78 - MANAGER Mode"
}
506
Chapter 71. IBM QRadar SIEM NXLog User Guide
NXLog can be configured to collect events and forward them to QRadar SIEM. This chapter provides information
about setting up this integration, both for generic structured logs and for several specific log types. The last
section shows output examples for forwarding the processed logs to QRadar.
NOTE The instructions and examples in this chapter were tested with QRadar 7.3.1.
• Some events may exceed QRadar’s default Syslog payload length. Consider setting the maximum payload
length to 8,192 bytes. For instructions, see QRadar: How to increase the maximum TCP payload size for event
data on IBM Support.
• The QRadar appliance should be fully updated with recent patches and fixes.
This log source will act as a gateway, passing each event on to another matching log source. Only one TLS listener
is required per port; see Configuring multiple log sources over TLS syslog on IBM Knowledge Center.
First, prepare the TLS certificate and key files (for more information, see OpenSSL Certificate Creation):
1. Locate a certificate authority (CA) certificate and private key, or generate and sign a new one. The CA
certificate (for example, rootCA.pem) will be used by the NXLog agent to authenticate the QRadar receiver in
Forwarding Logs below.
2. Create a certificate and private key for QRadar TLS Syslog (for example, server.crt and server.key).
3. Convert the QRadar private key to a DER-encoded PKCS8 key (see QRadar: TLS Syslog support of DER-
encoded PKCS8 custom certificates):
4. Copy the private key and certificate files to QRadar (the steps below assume the files are copied to
/root/server.*).
507
NXLog User Guide Chapter 71. IBM QRadar SIEM
1. In the QRadar web interface, go to Menu > Admin > Data Sources > Events > Log Sources.
2. Click Add to add a new log source. The Add a log source window appears.
9. Set Provided Private Key Path to the path of the DER-encoded server key (for example,
/root/server.key.der).
10. Select the Target Event Collector. Use this to poll for and process events using the specified event collector,
rather than on the Console appliance.
11. Make any other changes required, and then click Save.
508
Chapter 71. IBM QRadar SIEM NXLog User Guide
12. Go to Menu > Admin and click Advanced > Deploy Full Configuration after making all required log source
changes.
1. In the QRadar web interface, go to Menu > Admin > Data Sources > Events > Log Sources.
2. Click Add to add a new log source. The Add a log source window appears.
The Syslog hostname field is used by QRadar as the log source identifier to associate events
with a particular log source when received. This value can be adjusted by changing the
NOTE $Hostname = host_ip(); line in the examples below: keep the line as-is to use the
system’s first non-loopback IP address, remove the line to use the system hostname, or set
the line to a custom value (for example, $Hostname = "myhostname";).
509
NXLog User Guide Chapter 71. IBM QRadar SIEM
7. Select the Target Event Collector. Use this to poll for and process events using the specified event collector,
rather than on the Console appliance.
8. Make any other changes required, and then click Save.
9. Go to Menu > Admin and click Advanced > Deploy Full Configuration after making all required log source
changes.
LEEF has several predefined event attributes that should be used where applicable—see LEEF event components
and Predefined LEEF event attributes on IBM Knowledge Center. These fields can be set during parsing, set to
static values manually ($usrName = "john";), renamed using the rename_field() directive, or renamed using the
xm_rewrite Rename directive (NXLog Enterprise Edition only). Additionally, to_leef() will set several predefined
attributes automatically.
Use Universal LEEF as QRadar’s Log Source Type. Once LEEF events have been received by QRadar, specific
fields can be selected for extraction as described in Writing an expression for structured data in LEEF format (in
the QRadar Security Intelligence Platform documentation). LEEF events can also be mapped to QRadar Identifiers
(QIDs). For more information, see the Universal LEEF section in the QRadar DSM Guide.
510
Chapter 71. IBM QRadar SIEM NXLog User Guide
This example reads Syslog messages from file, parses them, and sets some additional fields. Then the
xm_leef to_leef() procedure is used to convert the event to LEEF (and write it to the $raw_event field).
Because the event is converted in the scope of this input instance, it is not necessary to do additional
processing in the corresponding output instance—see Forwarding Logs for output examples that could be
used to send the events to QRadar.
This example is intended as a starting point for a configuration that provides a specific set
NOTE of fields to QRadar. For logs that are already structured, it may only be necessary to
rename a few fields according to the predefined LEEF attribute names.
nxlog.conf (truncated)
1 <Extension _leef>
2 Module xm_leef
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input auth>
10 Module im_file
11 File '/var/log/auth.log'
12 <Exec>
13 # Parse Syslog event and set fields in the event record
14 parse_syslog();
15
16 # Set event category and event ID (for QID mapping)
17 if $Message =~ /^Invalid/
18 {
19 $Category = "Failed";
20 $EventID = "Logon Failure";
21 }
22 else
23 {
24 $Category = "Success";
25 $EventID = "Logon Success";
26 }
27
28 # Extract user name for "usrName" event attribute
29 [...]
511
NXLog User Guide Chapter 71. IBM QRadar SIEM
Output Sample
<13>Jul 31 07:17:01 10.80.1.49 CRON[968]: LEEF:1.0|NXLog|CRON|4.4.4347|Logon
Success|EventReceivedTime=2019-08-11 22:48:59 ⇥ SourceModuleName=file ⇥
SourceModuleType=im_file ⇥ SyslogFacilityValue=1 ⇥ SyslogFacility=USER ⇥ SyslogSeverityValue=5
⇥ SyslogSeverity=NOTICE ⇥ sev=2 ⇥ Severity=INFO ⇥ identHostName=debian ⇥ devTime=2019-07-31
07:17:01 ⇥ vSrcName=CRON ⇥ ProcessID=968 ⇥ Message=pam_unix(cron:session): session opened for
user root by (uid=0) ⇥ cat=Success ⇥ EventID=Logon Success ⇥ usrName=root ⇥ role=Administrator
⇥ devTimeFormat=yyyy-MM-dd HH:mm:ss↵
<13>Aug 11 22:43:26 10.80.1.49 sshd[5584]: LEEF:1.0|NXLog|sshd|4.4.4347|Logon
Failure|EventReceivedTime=2019-08-11 22:48:59 ⇥ SourceModuleName=file ⇥
SourceModuleType=im_file ⇥ SyslogFacilityValue=1 ⇥ SyslogFacility=USER ⇥ SyslogSeverityValue=5
⇥ SyslogSeverity=NOTICE ⇥ sev=2 ⇥ Severity=INFO ⇥ identHostName=debian ⇥ devTime=2019-08-11
22:43:26 ⇥ vSrcName=sshd ⇥ ProcessID=5584 ⇥ Message=Invalid user baduser from 10.80.0.1 port
33122 ⇥ cat=Failed ⇥ EventID=Logon Failure ⇥ usrName=baduser ⇥ role=User ⇥
devTimeFormat=yyyy-MM-dd HH:mm:ss↵
For more information, see DHCP server audit logging and the Microsoft DHCP Server page in the QRadar DSM
Guide.
512
Chapter 71. IBM QRadar SIEM NXLog User Guide
In this example, NXLog is configured to read logs from the following paths:
• C:\Windows\System32\dhcp\DhcpSrvLog-*.log
• C:\Windows\System32\dhcp\DhcpV6SrvLog-*.log
NXLog parses the events and converts the structured data for forwarding to QRadar.
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension dhcp_csv_parser>
6 Module xm_csv
7 Fields ID, Date, Time, Description, IPAddress, LogHostname, MACAddress, \
8 UserName, TransactionID, QResult, ProbationTime, CorrelationID, \
9 DHCID, VendorClassHex, VendorClassASCII, UserClassHex, \
10 UserClassASCII, RelayAgentInformation, DnsRegError
11 </Extension>
12
13 <Extension dhcpv6_csv_parser>
14 Module xm_csv
15 Fields ID, Date, Time, Description, IPAddress, LogHostname, MACAddress, \
16 UserName, TransactionID, QResult, ProbationTime, CorrelationID, \
17 DHCID, VendorClassHex
18 </Extension>
19
20 <Input dhcp>
21 Module im_file
22 File 'C:\Windows\System32\dhcp\DhcpSrvLog-*.log'
23 File 'C:\Windows\System32\dhcp\DhcpV6SrvLog-*.log'
24 <Exec>
25 # Only process lines that begin with an event ID
26 if $raw_event =~ /^\d+,/
27 {
28 if file_name() =~ /^.*\\(.*)$/ $FileName = $1;
29 [...]
513
NXLog User Guide Chapter 71. IBM QRadar SIEM
WARNING Do not enable Details in the DNS Server Debug Logging dialog.
If QRadar does not auto-discover the log source, add one manually. The Log Source Type should be set to
Microsoft DNS Debug and the Protocol Configuration should be set to Syslog—see Adding a QRadar Log
Source. If the Microsoft DNS Debug log source type is not available, see Setting up the QRadar Appliance above.
For more information, see Windows DNS Server and the Microsoft DNS Debug page in the QRadar DSM Guide.
This configuration uses the xm_msdns extension module to parse the Windows DNS debug log.
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension dns_parser>
6 Module xm_msdns
7 </Extension>
8
9 <Input dns>
10 Module im_file
11 File 'C:\logs\dns.log'
12 InputType dns_parser
13 <Exec>
14 $raw_event =~ /(?x)^(?<Date>\d+\/\d+\/\d+)\s(?<Time>\d+:\d+:\d+\s+\w{2})/;
15 if file_name() =~ /^.*\\(.*)$/ $FileName = $1;
16 $Message = "AgentDevice=WindowsDNS" +
17 "\tAgentLogFile=" + $FileName +
18 "\tDate=" + $Date +
19 "\tTime=" + $Time +
20 "\tThread ID=" + $ThreadID;
21 if $Context == "EVENT"
22 {
23 $EventDescription =~ s/,//g;
24 $Message = $Message +
25 "\tContext=EVENT" +
26 "\tMessage=" + $EventDescription;
27 }
28 else if $Context == "Note"
29 [...]
Output Sample
<13>Jul 20 08:42:07 10.80.1.49 AgentDevice=WindowsDNS ⇥ AgentLogFile=debug.log ⇥
Date=7/20/2019 ⇥ Time=8:42:07 AM ⇥ Thread ID=0710 ⇥ Context=EVENT ⇥ Message=The DNS server has
finished the background loading of zones. All zones are now available for DNS updates and zone
transfers as allowed by their individual zone configuration.↵
514
Chapter 71. IBM QRadar SIEM NXLog User Guide
QRadar does not support auto-discovery for Exchange Server logs, so it is necessary to add a log source
manually. The Log Source Type should be set to Microsoft Exchange Server and the Protocol Configuration
should be set to Syslog—see Adding a QRadar Log Source.
For more information, see the Microsoft Exchange chapter and the Microsoft Exchange Server pages in the
QRadar DSM Guide.
The following configuration uses the im_file module to read message tracking, Outlook web access (OWA),
and SMTP logs from various paths. The logs are parsed and converted for forwarding to QRadar.
Make sure to use the correct ID for the Exchange Back End site. This can be verified using
NOTE the Internet Information Services (IIS) Manager. The following example collects logs from
the site with ID 2 (W3SVC2/).
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension w3c_parser>
6 Module xm_w3c
7 </Extension>
8
9 <Extension w3c_comma_parser>
10 Module xm_w3c
11 Delimiter ,
12 </Extension>
13
14 <Input exchange_OWA>
15 Module im_file
16 File 'C:\inetpub\logs\LogFiles\W3SVC2\u_ex*.log'
17 InputType w3c_parser
18 <Exec>
19 if file_name() =~ /^.*\\(.*)$/ $FileName = $1;
20 if ${cs-uri-query} == undef ${cs-uri-query} = "-";
21 if ${cs-username} == undef ${cs-username} = "-";
22 if ${cs(Referer)} == undef ${cs(Referer)} = "-";
23 $Message = "AgentDevice=MicrosoftExchange" +
24 "\tAgentLogFile=" + $FileName +
25 "\tAgentLogFormat=W3C" +
26 "\tAgentLogProtocol=OWA" +
27 "\tdate=" + $date +
28 "\ttime=" + $time +
29 [...]
515
NXLog User Guide Chapter 71. IBM QRadar SIEM
NOTE For NXLog Community Edition, the xm_csv module can be used instead of xm_w3c.
If QRadar does not auto-discover the log source, add one manually. The Log Source Type should be set to
Microsoft IIS and the Protocol Configuration should be set to Syslog—see Adding a QRadar Log Source.
For more information, see the Microsoft IIS chapter and the QRadar DSM Guide Microsoft IIS Server pages.
516
Chapter 71. IBM QRadar SIEM NXLog User Guide
This configuration uses the xm_w3c extension module to parse the IIS log, and converts the events to a tab-
delimited format for QRadar.
Input Sample
2019-07-24 09:21:55 127.0.0.1 POST /OWA/auth.owa &CorrelationID=<empty>;&cafeReqId=4b9353b7-
e17b-4bc5-9e54-bc6b4733d6dd;&encoding=; 443
HealthMailboxa733ff32a90d44bb970f7a147fb3f328@nxlog.org 127.0.0.1 AMProbe/Local/ClientAccess -
302 0 0 10171↵
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension w3c_parser>
6 Module xm_w3c
7 </Extension>
8
9 <Input iis>
10 Module im_file
11 File 'C:\inetpub\logs\LogFiles\W3SVC1\u_ex*.log'
12 InputType w3c_parser
13 <Exec>
14 if file_name() =~ /^.*\\(.*)$/ $FileName = $1;
15 if ${cs-uri-query} == undef ${cs-uri-query} = "-";
16 if ${cs-username} == undef ${cs-username} = "-";
17 if ${cs(Referer)} == undef ${cs(Referer)} = "-";
18 $Message = "AgentDevice=MSIIS" +
19 "\tAgentLogFile=" + $FileName +
20 "\tAgentLogFormat=W3C" +
21 "\tAgentLogProtocol=W3C" +
22 "\tdate=" + $date +
23 "\ttime=" + $time +
24 "\ts-ip=" + ${s-ip} +
25 "\tcs-method=" + ${cs-method} +
26 "\tcs-uri-stem=" + ${cs-uri-stem} +
27 "\tcs-uri-query=" + ${cs-uri-query} +
28 "\ts-port=" + ${s-port} +
29 [...]
Output Sample
<13>Jul 24 09:21:55 10.80.1.49 AgentDevice=MSIIS ⇥ AgentLogFile=u_ex190724.log ⇥
AgentLogFormat=W3C ⇥ AgentLogProtocol=W3C ⇥ date=2019-07-24 ⇥ time=09:21:55 ⇥ s-ip=127.0.0.1
⇥ cs-method=POST ⇥ cs-uri-stem=/OWA/auth.owa ⇥ cs-uri-
query=&CorrelationID=<empty>;&cafeReqId=4b9353b7-e17b-4bc5-9e54-bc6b4733d6dd;&encoding=; ⇥ s-
port=443 ⇥ cs-username=HealthMailboxa733ff32a90d44bb970f7a147fb3f328@nxlog.org ⇥ c-
ip=127.0.0.1 ⇥ cs(User-Agent)=AMProbe/Local/ClientAccess ⇥ cs(Referer)=- ⇥ sc-status=302 ⇥ sc-
substatus=0 ⇥ sc-win32-status=0 ⇥ time-taken=10171↵
If QRadar does not auto-discover the log source, add one manually. The Log Source Type should be set to
Microsoft SQL Server and the Protocol Configuration should be set to Syslog—see Adding a QRadar Log
Source.
517
NXLog User Guide Chapter 71. IBM QRadar SIEM
For configuration information, see the Microsoft SQL Server section in the QRadar DSM Guide.
This example reads and parses events from the SQL Server log file, then converts the events to a tab-
delimited format for QRadar.
nxlog.conf (truncated)
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension charconv>
6 Module xm_charconv
7 LineReader UTF-16LE
8 </Extension>
9
10 define ERRORLOG_EVENT /(?x)(?<Date>\d+-\d+-\d+)\s \
11 (?<Time>\d+:\d+:\d+.\d+)\s \
12 (?<Source>\S+)\s+ \
13 (?<Payload>.+)$/s
14
15 <Input sql>
16 Module im_file
17 File 'C:\Program Files\Microsoft SQL Server\' + \
18 'MSSQL14.MSSQLSERVER\MSSQL\Log\ERRORLOG'
19 InputType charconv
20 <Exec>
21 # Attempt to match regular expression
22 if $raw_event =~ %ERRORLOG_EVENT%
23 {
24 # Check if previous lines were saved
25 if defined(get_var('saved'))
26 {
27 $tmp = $raw_event;
28 $raw_event = get_var('saved');
29 [...]
Output Sample
<13>Aug 21 22:55:36 10.80.1.49 AgentDevice=MSSQL ⇥ AgentLogFile=ERRORLOG ⇥ Date=2019-08-21 ⇥
Time=22:55:36.23 ⇥ Source=spid16s ⇥ Message=The Service Broker endpoint is in disabled or
stopped state.↵
This format is recommended instead of Snare or Log Event Extended Format (LEEF) in order to
NOTE take full advantage of the parsing provided by the QRadar DSM. Otherwise additional parsing
and/or mappings would be required to translate Windows EventLog fields to QRadar fields.
If QRadar does not auto-discover the log source, add one manually. The Log Source Type should be set to
Microsoft Windows Security Event Log and the Protocol Configuration should be set to Syslog—see Adding a
QRadar Log Source.
For more information, see the Windows Event Log chapter and the Microsoft Windows Security Event Log section
518
Chapter 71. IBM QRadar SIEM NXLog User Guide
This configuration will collect from the Windows EventLog using im_msvistalog, convert the $Message field
to a specific tab-delimited format, and add a BSD Syslog header with xm_syslog.
This example does not filter events, but forwards all events to QRadar. Only a subset of
NOTE those events will be recognized and parsed by the QRadar DSM. For more information
about using EventLog queries to limit collected events, see Windows Event Log.
nxlog.conf (truncated)
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input eventlog>
6 Module im_msvistalog
7 <Exec>
8 if $Category == undef $Category = 0;
9 $EventTimeStr = strftime($EventTime, "YYYY-MM-DDThh:mm:ss.sUTC");
10 if $EventType == 'CRITICAL'
11 {
12 $EventTypeNum = 1;
13 $EventTypeStr = "Critical";
14 }
15 else if $EventType == 'ERROR'
16 {
17 $EventTypeNum = 2;
18 $EventTypeStr = "Error";
19 }
20 else if $EventType == 'INFO'
21 {
22 $EventTypeNum = 4;
23 $EventTypeStr = "Informational";
24 }
25 else if $EventType == 'WARNING'
26 {
27 $EventTypeNum = 3;
28 $EventTypeStr = "Warning";
29 [...]
Output Sample
<13>Jul 15 20:24:43 10.80.1.49 AgentDevice=WindowsLog ⇥ AgentLogFile=System ⇥ Source=Service
Control Manager ⇥ Computer=QRW.nxlog.org ⇥ OriginatingComputer=10.80.1.49 ⇥ User= ⇥ Domain= ⇥
EventIDCode=7036 ⇥ EventType=4 ⇥ EventCategory=0 ⇥ RecordNumber=9830 ⇥ TimeGenerated=2019-07-
15T20:24:43.296533Z ⇥ TimeWritten=2019-07-15T20:24:43.296533Z ⇥ Level=Informational ⇥
Keywords=9259400833873739776 ⇥ Task=None ⇥ Opcode=Info ⇥ Message=The WinCollect service
entered the stopped state.↵
519
NXLog User Guide Chapter 71. IBM QRadar SIEM
This om_tcp instance sends logs to QRadar via TCP. In this example, events are sent from the Microsoft IIS
and Windows EventLog sources.
nxlog.conf
1 <Output qradar>
2 Module om_tcp
3 Host 10.0.0.2
4 Port 514
5 </Output>
6
7 <Route r>
8 Path iis, eventlog => qradar
9 </Route>
Forwarding logs with TLS requires adding a TLS Syslog listener, as described in Adding a TLS Syslog Log Source
above. The root certificate authority (CA) certificate, which is used to verify the authenticity of the QRadar
receiver’s certificate, should be provided to om_ssl with either CADir or CAFile.
In this example, the om_ssl module is used to send logs to QRadar securely, with TLS encryption.
nxlog.conf
1 <Output qradar>
2 Module om_ssl
3 Host 10.0.0.2
4 Port 6514
5 CAFile C:\Program Files\cert\rootCA.pem
6 </Output>
520
Chapter 72. Industrial Control Systems NXLog User Guide
Depending on the specific industry, each ICS system may function differently, however they all built to
electronically manage tasks in the most efficient way possible. The protocols and the devices used in these
systems are probably used in almost every industrial sector and critically important infrastructure. Common
places where ICS is used are: transportation, manufacturing, energy, and water treatment industries.
There are a number of major companies provides/manufactures ICS solutions for various industries. The topics
below describe how to collect logs from these systems with NXLog.
This document was written in accordance with Citect SCADA 2018 Version 8.10[0]. All examples listed in this
document are tested in this version.
Citect SCADA produces two types of Windows Event Log entries in the Application event channel with EventID 0:
• Schneider Electric SUT Service (System Under Test) for Schneider Electric software updates
• Citect Runtime Manager logs
The im_msvistalog module can be used to process logs based on their EventID and source.
521
NXLog User Guide Chapter 72. Industrial Control Systems
Example 319. Processing Windows Event Log Entries From Citect SCADA
In this example, the im_msvistalog module reads data from the Application channel in Windows Event Log
with Xpath filtering, which is defined in the query XML. Finally, by calling the to_json() procedure, the
xm_json extension module formats the event as JSON prior to being routed to any output instances.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_eventlog>
6 Module im_msvistalog
7 # An XML query that reads Windows Event Logs
8 # based on their EventID
9 <QueryXML>
10 <QueryList>
11 <Query Id="0" Path="Application">
12 <Select Path="Application">*[System[(EventID=0)]]</Select>
13 </Query>
14 </QueryList>
15 </QueryXML>
16 # Formats the result as JSON
17 Exec to_json();
18 </Input>
In the following example, the im_msvistalog module reads data from the Application channel in Windows
Event Log, but instead of an EventID, the configuration reads the Schneider Electric SUT Service
source which is created by Citect SCADA. As in the previous example, the input instance calls the to_json()
procedure from the xm_json extension module which formats the event as JSON prior to being routed to
any output instances.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_eventlog>
6 Module im_msvistalog
7 # An XML query that reads Windows Event Logs
8 # based on their source
9 <QueryXML>
10 <QueryList>
11 <Query Id="0" Path="Application">
12 <Select Path="Application">
13 *[System[Provider[@Name='Schneider Electric SUT Service']]]
14 </Select>
15 </Query>
16 </QueryList>
17 </QueryXML>
18 # Formats the result as JSON
19 Exec to_json();
20 </Input>
This output sample displays an event that was captured using the first configuration example, where logs
are collected based on EventID 0 and processed by NXLog.
522
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventTime": "2020-05-12T08:12:57.737403+02:00",
"Hostname": "NXLog-Computer",
"Keywords": "36028797018963968",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 0,
"SourceName": "Schneider Electric SUT Service",
"TaskValue": 0,
"RecordNumber": 912,
"ExecutionProcessID": 0,
"ExecutionThreadID": 0,
"Channel": "Application",
"Message": "Service started successfully.",
"Opcode": "Info",
"Data": "Service started successfully.",
"EventReceivedTime": "2020-09-14T13:14:26.675310+02:00",
"SourceModuleName": "from_eventlog",
"SourceModuleType": "im_msvistalog"
}
Citect SCADA log files contain time-stamped system data and are stored in the the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs directory. The Drivers\ subdirectory directly beneath this directory
contains driver log files which are named according to their respective drivers. Logs related to licensing are
stored in the C:\Users\<WindowsUser>\AppData\Local\Temp directory. The Citect SCADA 2018 Log Files Table
lists the exact location of all log files. If the system uses a separate processes, a log file is appended with the
name of the component. For example, the filename syslog.IOServer.Cluster1.dat illustrates how the server
name, IOServer and the cluster name, Cluster1, are appended to the syslog log type.
The citect.ini file also stores values for a comprehensive set of operating parameters
that are used to configure the operational settings for each computer in the Citect SCADA
IMPORTANT
system. These values are read by Citect SCADA on startup to determine how the
application should operate.
For more detailed information on how to configure logging, consult the Schneider Citect SCADA documentation
in the Citect Studio application.
523
NXLog User Guide Chapter 72. Industrial Control Systems
Change Log .log C:\ProgramData\Schneider Electric\Citect SCADA A log file, containing a time
2018\Logs\ChangeLogs\* stamp and the last unsaved
changes. It is created after
saving the project.
tracelog .dat C:\ProgramData\Schneider Electric\Citect SCADA Managed code logs which are
2018\Logs\* related to data subscription and
updates.
- File mask is
*PROTOCOL.[ClusterName].[IOServerName].dat
524
Chapter 72. Industrial Control Systems NXLog User Guide
Because these logs do not contain structured data, regular expressions are used in all of the configurations to
accommodate the parsing needed to create the individual schema that best suits each log type. This ensures that
all important data is collected and structured for any future data analysis. The flexibility of NXLog allows the use
of named capturing when using regular expressions, so the resulting fields are automatically added to the
output.
The term Syslog used here is not the same as the well known Syslog protocol. The name Syslog
NOTE
is only used in this case as Schneider Electric decided to name this particular file Syslog.
The syslog.dat file is the primary log file for Citect SCADA. It contains system information about low-level driver
traffic, Kernel messages, user-defined messages, and trace options (except some CTAPI traces).
• Level
• Category
• Thread Id
• Driver Name
• Unit
• Function
• File
• Line
• Message
There is a separate SysLog file per IOServer process for both the Drivers and the IOServer (in earlier versions of
Citect SCADA there was one file for the IOServer and one file for the Drivers).
As indicated by the file-based logs table, Syslog logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs directory. The following NXLog example applies to all logs having names
that begin with syslog..
525
NXLog User Guide Chapter 72. Industrial Control Systems
In this example, only two fields will be parsed from the syslog.dat log file: the date and time the event
was logged and a message. However, certain messages will be dropped that start with four or more
asterisks (*), since they contain only asterisks. Two different regular expressions are used to achieve this.
In order to make the Exec directive block of the from_file input instance more readable, the first regular
expression is defined as the constant SYSLOG_REGEX. It parses the datetime and message values. The
named capture feature, in this case (?<Message>.*), will cause a new $Message field containing the value
that has been captured to be created. The other, shorter regular expression is used with the drop()
procedure in this input instance to filter out the unwanted messages flagged with asterisks.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
nxlog.conf
1 # A regular expression defined as a constant to read the content of the logs
2 define SYSLOG_REGEX /(?x)^(\d+.\d+.\d+.)(\d+.\d+.\d+.\d+)\s([+]\d+.\d*)\
3 \s(?<Message>.*)/
4 # Part of the log path defined as a constant
5 define SYSLOG_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input from_file>
12 Module im_file
13 File '%SYSLOG_PATH%\syslog.dat'
14 <Exec>
15 # A regular expression to drop event messages
16 # that starts with more than four asterisks
17 if $raw_event =~ /.*[*]{4,}.*/ drop();
18 # Matches the events with the regular expression
19 if $raw_event =~ %SYSLOG_REGEX%
20 {
21 # Creates the timestamp
22 $EventTime = parsedate($1 + $2 + $3);
23 # Formats the result as JSON
24 to_json();
25 }
26 </Exec>
27 </Input>
526
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-10-06T09:35:17.597817+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "*** Citect process is starting up ***",
"EventTime": "2020-05-12T11:59:38.112000+02:00"
}
The tracelog.dat file contains managed code logging, mainly in relation to data subscriptions and updates.
In the PSIClient and CSAToPSI categories, Sent and Received notations (indicated with ⇐ and ⇒) will be added to
indicate tag data flow on the client side.
As indicated by the file-based logs table, tracelog logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs directory. The following NXLog example applies to all logs having names
that begin with tracelog., except the tracelog.RuntimeManager logs which are discussed separately.
• Process ID (PID)
• Severity
• Process Name
• Message
527
NXLog User Guide Chapter 72. Industrial Control Systems
In this example, the IDEtracelog.dat log file provides four fields of interest in addition to each event’s
timestamp: PID, process name, severity, and a message. Since no filters are required for filtering unwanted
events, only one regular expression is needed to parse these fields.
By defining the regular expression as the constant TRACELOG_REGEX, as well as the absolute path to the log
file as the constant TRACELOG_PATH, the from_file input instance will be more readable without such long
strings.
The input instance uses TRACELOG_REGEX to capture the first three matches for constructing a string that
parsedate() returns as a datetime value. This value is then assigned to the $EventTime field.
Using the named capturing groups feature, the remaining fields captured by their respective patterns are
defined using the names contained within angle brackets (< >). These names will determine the actual field
names which are then automatically added to the event record.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields,
along with the core fields, are added to the event record and formatted as JSON prior to being routed to
any output instances.
528
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # A regular expression defined as a constant to read the content of the logs
2 define TRACELOG_REGEX /(?x)^(\d+.\d+.\d+.)(\d+.\d+.\d+.\d+.)\s([+]\d+.\d*)\
3 \s(?<PID>\d+)\s{3}\d\s(?<Severity>\w+)\s*(?<ProcessName>\
4 \w+)\s*(?<Message>.*)/
5 # Part of the log path defined as a constant
6 define TRACELOG_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
7
8 <Extension json>
9 Module xm_json
10 </Extension>
11
12 <Input from_file>
13 Module im_file
14 File '%TRACELOG_PATH%\IDEtracelog.dat'
15 <Exec>
16 # Matches the events with the regular expression
17 if $raw_event =~ %TRACELOG_REGEX%
18 {
19 # Creates the timestamp
20 $EventTime = parsedate($1 + $2 + $3);
21 # Saves the PID field as an integer
22 $PID = integer ($PID);
23 # Formats the result as JSON
24 to_json();
25 }
26 </Exec>
27 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-05T18:43:13.609841+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "HttpResponseException Response: Forbidden (403)",
"PID": 1744,
"ProcessName": "Deployment",
"Severity": "Error",
"EventTime": "2020-05-15T07:11:58.720000+02:00"
}
This debug.log file contains information about crashes and other serious internal issues. If a crash occurs, it
identifies the version and path of each DLL being used at the time of the crash. It can be used to confirm the
validity of file versions.
As indicated by the file-based logs table, Debug logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs directory. The following NXLog example applies to all logs having names
that begin with debug..
Aside from the timestamp, the only field of interest in this log file is the message field.
529
NXLog User Guide Chapter 72. Industrial Control Systems
In this example the configuration only extract a single field of interest from the debug.log file in addition to
the default fields added by NXLog. In this case, all events lines are of interest, so all lines are read and
processed by NXLog, nothing is dropped.
There are two regular expression defined as a constant, DEBUGLOG_REGEX the regular expression to process
the events and DEBUGLOG_PATH as the absolute path to the log file. This helps with the readability of the file
path in the from_file input instance.
The input instance uses DEBUGLOG_REGEX to capture the first three matches of the regular expression to
construct a string that parsedate() returns as a datetime value for. This value is then assigned to the
$EventTime field. Because named capturing is used in the regular expression, the $Message field is
automatically created.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
nxlog.conf
1 # A regular expression defined as a constant to read the content of the logs
2 define DEBUGLOG_REGEX /(?x)^(\d+.\d+.\d+.)(\d+.\d+.\d+.\d+.\d+.)([+]\
3 \d+.\d+.)\s(?<Message>.*)/
4 # Part of the log path defined as a constant
5 define DEBUGLOG_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input from_file>
12 Module im_file
13 File '%DEBUGLOG_PATH%\debug.log'
14 <Exec>
15 # Matches the events with the regular expression
16 if $raw_event =~ %DEBUGLOG_REGEX%
17 {
18 # Creates the timestamp
19 $EventTime = parsedate($1 + $2 + $3);
20 # Formats the result as JSON
21 to_json();
22 }
23 </Exec>
24 </Input>
530
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-10-06T09:44:18.656718+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "BufPoolClose: non fatal, freed 12 inuse buffers in Code.String",
"EventTime": "2020-05-12T13:02:40.254000+02:00"
}
As indicated by the file-based logs table, ipc logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs directory. Some of the IPC logs are multiline logs, which means a single
event spans multiple lines, while other IPC logs are comprised of single-line events.
• Process
• Message
531
NXLog User Guide Chapter 72. Industrial Control Systems
In this configuration two constants are defined. The first is IPCLOG_REGEX which is the regular expression to
parse the fields in the events and IPCLOG_PATH which defines the absolute path to the log file.
There is another regular expression in this configuration which plays an important role in this case. This is
not a predefined constant, but included in the HeaderLine directive of the xm_multiline extension module
and is used in the InputType directive of the from_file input instance. This regular expression is utilized
to convert the multiline logs to single-line logs, so they can be further processed by the predefined regular
expression mentioned in the previous paragraph. Each log message has a header (TIMESTAMP) which is
found by the regular expression and used as the message boundary, so each log message is appended with
the additional lines until the next header line is read.
Once the messages are on a single line, the first Exec directive block in the from_file input instance
replaces the \r and \n characters, then the second Exec directive block parses the event using the
previously defined regular expression. The original event time is processed with the parsedate() procedure
using the $1 and $2 groups.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
532
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf (truncated)
1 # A regular expression defined as a constant to read the content of the logs
2 define IPCLOG_REGEX /(?x)^(\d+.\d+.\d+\d+.\d+.\d+.\d+.\d+)\s+([+]\d+.\d+)\
3 \s+(?<Process>\S+)\s+(?<Message>.*)/
4 # Part of the log path defined as a constant
5 define IPCLOG_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Extension multiline>
12 Module xm_multiline
13 # Regular expression to look for the header of the message
14 HeaderLine /(\d+.\d+.\d+)\s(\d+.\d+.\d+.\d+.\d+)\s([+]\d+.\d+)\s(.*)/
15 </Extension>
16
17 <Input from_file>
18 Module im_file
19 File '%IPCLOG_PATH%\ipc.log'
20 # Defines that the input has to be first paresd with the regular
21 # expression in the multiline extension module
22 InputType multiline
23 <Exec>
24 # Replaces unwanted characters
25 $raw_event = replace($raw_event, "\r", "");
26 $raw_event = replace($raw_event, "\n", " ");
27 </Exec>
28 <Exec>
29 [...]
Output Sample
{
"EventReceivedTime": "2020-10-09T10:44:38.390139+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "_ctConnect: connection is established, sending login information.",
"Process": "CtApi:",
"EventTime": "2020-05-20T21:12:13.047000+02:00"
}
[driver] logs contain information about the operation of a particular driver and are named accordingly. For
example, the TCP/IP driver is logged in TCPIP.*.DAT.
As indicated by the file-based logs table, [driver] logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs\Drivers\ directory. Some of the [driver] logs are single-line logs, but
some have events that span multiple lines. The following NXLog example applies to all logs having names that
begin with the name of a driver.
• SourceType
• Message
533
NXLog User Guide Chapter 72. Industrial Control Systems
This example processes the TCPIP.*.DAT log file. For easier readability a regular expression is defined as
TCPIPDRIVER_REGEX. Using this same method, the absolute path to the log file is defined as
TCPIPDRIVER_PATH.
The TCPIP.*.DAT multi-line logs are first processed with the xm_multiline module to make each log entry
consist of only a single line. To achieve this, a regular expression is used in the HeaderLine directive of the
multiline extension instance. Each log message has a header, in this case a timestamp which is used as the
message boundary. Each log message is appended with the additional lines until the next header line is
read. Once the messages are on a single line, the first Exec directive block of the from_file input instance
replaces the \r, \t and \n characters, then the second Exec directive block parses the event using the
previously defined regular expression. The original event time is processed with the strptime() function
from the $1 capture group.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields
$SourceType and $Message along with the core fields are formatted as JSON prior to being routed to an
output instance.
nxlog.conf (truncated)
1 # A regular expression defined as a constant to read the content of the logs
2 define TCPIPDRIVER_REGEX /(?x)^(\d+.[\/]\d+.[\/]\d+\d+.\d+.\d+.\d+.\d*)\
3 \s+(?<SourceType>\S+)\s+(?<Message>.*)/
4 # Part of the log path defined as a constant
5 define TCPIPDRIVER_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Extension multiline>
12 Module xm_multiline
13 # Regular expression to look for the header of the message
14 HeaderLine /(\d+.[\/]\d+.[\/]\d+)\s(\d+.\d+.\d+.\d+.\d*)/
15 </Extension>
16
17 <Input from_file>
18 Module im_file
19 File '%TCPIPDRIVER_PATH%\Drivers\TCPIP.Cluster1.IOServer1.DAT'
20 # Defines that the input has to be first paresd with the regular
21 # expression in the multiline extension module
22 InputType multiline
23 <Exec>
24 # Replaces unwanted characters
25 $raw_event = replace($raw_event, "\r", "");
26 $raw_event = replace($raw_event, "\n", " ");
27 $raw_event = replace($raw_event, "\t", " ");
28 </Exec>
29 [...]
534
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-10-09T12:37:51.259840+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "Port1 connection OK",
"SourceType": "Port",
"EventTime": "2020-05-20T22:59:57.000000+02:00"
}
The Params.dat log file contains historical record of non-default SCADA parameters.
As indicated by the file-based logs table, the Params logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs\ directory. The following NXLog example applies to all logs having names
that begin with Params..
• Category
• Message
535
NXLog User Guide Chapter 72. Industrial Control Systems
In this example, besides the core fields added by NXLog, two fields are parsed from the Params.dat log file:
$Category and the $Message field.
To be able to parse the above mentioned fields, a regular expression is used, which is defined as a constant
named PARAMS_REGEX in the first line of the configuration. The absolute path to the log file is defined by the
constant PARAMS_PATH.
The first Exec directive of the from_file input instance replaces the \r and \n characters, then the second
Exec directive block parses the event using the previously defined regular expression. The original event
time is processed with the parsedate() procedure using the $1 capture group. Because name capturing is
used in the regular expression, the $Category and $Message fields are automatically added to the result.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
nxlog.conf
1 # A regular expression defined as a constant to read the content of the logs
2 define PARAMS_REGEX /(?x)^(\d+.\d+.\d+\s\d+.\d+.\d+.\d+.\d+\s[+]\d+.\d+).\
3 \s(?<Category>\[\w+\]|\[\w+.\w+.\w+\])\s+(?<Message>.*)/
4 # Part of the log path defined as a constant
5 define PARAMS_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input from_file>
12 Module im_file
13 File '%PARAMS_PATH%\Params.dat'
14 # Replaces unwanted characters
15 Exec $raw_event = replace($raw_event, "\t", " ");
16 <Exec>
17 # Matches the events with the regular expression
18 if $raw_event =~ %PARAMS_REGEX%
19 {
20 # Creates the timestamp
21 $EventTime = parsedate($1);
22 # Formats the result as JSON
23 to_json();
24 }
25 </Exec>
26 </Input>
536
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-10-06T13:11:37.529135+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Category": "[SA_Library.Meter]",
"Message": "UseDefaultPLCLimits= TRUE Default= FALSE",
"EventTime": "2020-09-18T13:18:19.890000+02:00"
}
As indicated by the file-based logs table, the reloadlog logs are located in the C:\ProgramData\Schneider
Electric\Citect SCADA 2018\Logs\ directory. The following NXLog example applies to all logs having names
that begin with reloadlog..
• ServerName
• Message
537
NXLog User Guide Chapter 72. Industrial Control Systems
This example parses two fields of interest, the $ServerName and $Message fields in addition to the fields
created automatically by NXLog.
In the first part of the configuration, two constants are defined: RELOADLOG_REGEX, the regular expression
for parsing fields and their values, as well as RELOADLOG_PATH, which stores the absolute path to the log
file.
The Exec block in the from_file input instance parses the message based on the regular expression
defined in RELOADLOG_REGEX, then the parsedate() function parses the original event time based on
capture group $1.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
nxlog.conf
1 # A regular expression defined as a constant to read the content of the logs
2 define RELOADLOG_REGEX /(?x)^(\d+.\d+.\d+\s\d+.\d+.\d+.\d+.\d+\s[+]\d+.\d+)\
3 \s(?<ServerName>\w+\s\w+:)\s(?<Message>.*)/
4 # Part of the log path defined as a constant
5 define RELOADLOG_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input from_file>
12 Module im_file
13 File '%RELOADLOG_PATH%\reloadlog.dat'
14 <Exec>
15 # Matches the events with the regular expression
16 if $raw_event =~ %RELOADLOG_REGEX%
17 {
18 # Creates the timestamp
19 $EventTime = parsedate($1);
20 # Formats the result as JSON
21 to_json();
22 }
23 </Exec>
24 </Input>
538
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-09-29T15:23:26.050139+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "Server: Alarm added: PMP02_Fault (0).",
"ServerName": "Alarm",
"EventTime": "2020-05-13T09:04:40.306000+02:00"
}
As indicated by the file-based logs table, the tracelog.RuntimeManager logs are located in the
C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs\ directory. The following NXLog example
applies to all logs having names that begin with tracelog.RuntimeManager.
• EventID
• Severity
• Type
• Message
539
NXLog User Guide Chapter 72. Industrial Control Systems
This example processes the tracelog.RuntimeManager.UI.dat log file. In this case, the configuration
parses four fields in addition to the core fields added by NXLog.
At the beginning of the configuration two constants are defined, TRACELOGRM_REGEX and
TRACELOGRM_PATH. The former is the regular expression used for parsing the messages and the latter is the
absolute path to the log file.
The Exec block of the from_file input instance first parses the input with the predefined regular expression,
then parses the original datetime with the parsedate() function from capture group $1. In the next step, the
string value captured for the EventID field is converted to an integer. This can be helpful if further analysis
is required, for instance, for querying a range of EventIDs.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
nxlog.conf
1 # A regular expression defined as a constant to read the content of the logs
2 define TRACELOGRM_REGEX /(?x)^(\d+.\d+.\d+\s\d+.\d+.\d+.\d+.\d+\s[+]\d+.\d+)\
3 \s(?<EventID>\w+)\s+\d\s(?<Severity>\w+)\s+(?<Type>\w+)\
4 \s+(?<Message>.*)/
5 # Part of the log path defined as a constant
6 define TRACELOGRM_PATH C:\ProgramData\Schneider Electric\Citect SCADA 2018\Logs
7
8 <Extension json>
9 Module xm_json
10 </Extension>
11
12 <Input from_file>
13 Module im_file
14 File '%TRACELOGRM_PATH%\tracelog.RuntimeManager.UI.dat'
15 <Exec>
16 # Matches the events with a regular expression
17 if $raw_event =~ %TRACELOGRM_REGEX%
18 {
19 # Creates the timestamp
20 $EventTime = parsedate($1);
21 # Specifies the EventID filed to be saved as an integer
22 $EventID = integer ($EventID);
23 # Formats the result as JSON
24 to_json();
25 }
26 </Exec>
27 </Input>
540
Chapter 72. Industrial Control Systems NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-10-09T13:55:39.129810+02:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"EventID": 412,
"Message": "The Citect process (Client) is not responding.",
"Severity": "Warning",
"Type": "RuntimeManager",
"EventTime": "2020-05-20T22:43:13.949000+02:00"
}
The Floating License Manager_reg.log log contains information related to the operation of the Floating
License Manager.
As indicated by the file-based logs table, the Floating License Manager Reg logs are located in the
C:\Users\%USERNAME%\AppData\Local\Temp directory. These logs are multiline logs containing a set of system
information that spans multiple lines, which is only valuable when correctly grouped together as an
interdependent set of attributes. In this example, the fields are parsed, extracted, and structured as a single JSON
object.
• EventTime
• ServerName
• Severity
• EvetGroupID
• InfoType
• ComputerName
• UserName
• OSVersion
• Hypervisor
• Product
• LogLevel
• FNPAPIVersion
• LicensingServiceVersion
• SrvActBrickdllVersion
• SrvActBrickXdllVersion
• FnpCommsSoapdllVersion
• Message1
• Message2
In addition, most of the above parameters contain an additional Line ID. They are named with the word LineID
appended to the name of the entry. For example the corresponding Line ID for Product is ProductLineID.
These IDs are collected as well since they can be useful for event data analysis later on, when searching for
patterns.
541
NXLog User Guide Chapter 72. Industrial Control Systems
This example processes the Floating_License_Manager_reg.log log file. In this example all together,
there are 33 fields that are of interest and parsed.
To achieve the parsing of the above mentioned fields, a regular expression is used, which is defined as a
constant with the name FLMRG_REGEX in the first line of the configuration. The absolute path to the
directory of the log file is also defined in the same way as FLMRG_PATH.
Since each log message spans multiple lines, they are first processed with the xm_multiline module to make
each log entry consist of only a single line. To achieve this, a regular expression is used in the HeaderLine
directive of the multiline extension instance. Each log message has a header, in this case a LineID (150)
which is used as the message boundary. Every log message is appended with the additional lines until the
next header line is read.
Once the messages are on a single line, the first Exec directive block of the from_file input instance replaces
the \r, \t and \n characters, then the second Exec directive block parses the event using the previously
defined regular expression, FLMRG_REGEX, which leverages the named capturing groups feature. This allows
captured values to be automatically assigned to event field names defined by the names contained within
angle brackets (< >) of the regular expression.
To preserve the desired data types of certain fields, additional processing is required for all fields which
should not contain string values. The original event time is processed with the strptime() function from the
$EventTime capture group which converts the string to a datetime value. Likewise the fields having names
ending in LineID, for instance, ComputernameLineID, EventGroupLineID, etc., should contain integer
values. The integer() function is used for converting their string values to integers. This will facilitate any
further processing or queries that might need to employ conditional statements requiring numeric
comparison operators.
Finally, by calling the to_json() procedure from the xm_json extension module, the newly parsed fields along
with the core fields are formatted as JSON prior to being routed to any output instances.
542
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf (truncated)
1 # A regular expression defined as a constant to read the content of the logs
2 define FLMRG_REGEX /(?x)^(?<EventTime>\d+-\d+-\d+,\d+:\d+:\d+:\d+),\
3 (?<ServerName>\w+),(?<Severity>\w+),\
4 \s(?<EventGroupLineID>150),\s(?<EvetGroupID>\d+),\-+\s\d+.\
5 \d+.\d+\d+.\d+.\d+.\d+.\d*,\w+,\w+,\s+(?<InfoTypeLineID>\d+)\
6 ,\s+\d+,(?<InfoType>\w+\s+\w+):\s+\d+.\d+.\d+\d+.\d+.\d+.\d+.\
7 \d*,\w+,\w+,\s+(?<ComputernameLineID>\d+),\s+\d+,\w+\s+\w+:\
8 \s+(?<ComputerName>\w+.+)\s\d+.\d+.\d+\d+.\d+.\d+.\d+.\d*,\
9 \w+,\w+,\s+(?<UserNameLineID>\d+),\s+\d+,\w+\s+\w+:\
10 \s+(?<UserName>\w+)\s+\d+.\d+.\d+\d+.\d+.\d+.\d+.\d*,\w+,\w+,\
11 \s+(?<OSVersionLineID>\d+),\s\d+,\w+:\s+(?<OSVersion>\w+\s+\
12 \(\w+\s\d+\),\s\d+-\w+)\s\d+.\d+.\d+\d+.\d+.\d+.\d+.\d*,\w+,\
13 \w+,\s+(?<HypervisorLineID>\d+),\s+\d+,\w+:\s+(?<Hypervisor>\
14 \w+.\w+|\w+)\s\d+.\d+.\d+\d+.\d+.\d+.\d+.\d*,\w+,\w+,\
15 \s+(?<ProductLineID>\d+),\s+\d+,\w+:\s+(?<Product>\w+\s\w+\s\
16 \w+\s\d+.\d+)\s\d+.\d+.\d+\d+.\d+.\d+.\d+.\d*,\w+,\w+,\
17 \s(?<LogLevelLineID>\d+),\s\d+,\w+\s\w+:\s+(?<LogLevel>\d+)\s+\
18 \d+.\d+.\d+\d+.\d+.\d+.\d+.\d+,\w+,\w+,\
19 \s+(?<FNPAPIVersionLineID>\d+),\s+\d+,\w+.\w+.\w+:\
20 \s+(?<FNPAPIVersion>v\d+.\d+.\d+.\d+\s\w+\s\d+\s\w+)\s\d+.\d+.\
21 \d+\d+.\d+.\d+.\d+.\d*,\w+,\w+,\
22 \s+(?<LicensingServiceVersionLineID>\d+),\s+\d+,\w+.\w+.\w+:\
23 \s+(?<LicensingServiceVersion>v\d+.\d+.\d+.\d+\s\w+\s\d+\s\d+\
24 \/\d+\/\d+)\s+\d+.\d+.\d+\d+.\d+.\d+.\d+.\d*,\w+,\w+,\
25 \s(?<SrvActBrickdllVersionLineID>\d+),\s\d+,\w+.\w+\s+\w+:\
26 \s+(?<SrvActBrickdllVersion>\d+.\d+.\d+.\d+)\s+\d+.\d+.\d+\d+.\
27 \d+.\d+.\d+.\d*,\w+,\w+,\s(?<SrvActBrickXdllVersionLineID>\
28 \d+),\s\d+,\w+.\w+\s+\w+:\s+(?<SrvActBrickXdllVersion>\d+.\
29 [...]
543
NXLog User Guide Chapter 72. Industrial Control Systems
Output Sample
{
"EventReceivedTime": "2020-10-05T14: 06: 54.146916+02: 00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"ComputerName": "DESKTOP-VCF8F0G",
"ComputernameLineID": 153,
"EventGroupLineID": 150,
"EventTime": "2020-05-15T08: 34: 07.000000+02: 00",
"EvetGroupID": 8944,
"FNPAPIVersion": "v11.16.4.0 build 252457 i86_n3",
"FNPAPIVersionLineID": 176,
"FnpCommsSoapdllVersion": "11.16.4.0 build 252457",
"FnpCommsSoapdllVersionLineID": 236,
"Hypervisor": "Oracle VirtualBox",
"HypervisorLineID": 164,
"InfoType": "GENERAL INFORMATION",
"InfoTypeLineID": 151,
"LicensingServiceVersion": "v11.16.4.0 build 252457 2019/07/09",
"LicensingServiceVersionLineID": 187,
"LogLevel": "1",
"LogLevelLineID": 172,
"Message1": "No stored composite transaction requests found",
"Message1LineID": 2695,
"Message2": "Found 0 fulfillments in Trusted Storage",
"Message2LineID": 628,
"OSVersion": "Microsoft (build 14393), 64-bit",
"OSVersionLineID": 157,
"Product": "Floating License Manager 02.04",
"ProductLineID": 169,
"ServerName": "SrvActBr",
"Severity": "INF",
"SrvActBrickXdllVersion": "11.16.4.0 build 252457",
"SrvActBrickXdllVersionLineID": 232,
"SrvActBrickdllVersion": "2.4.0.0",
"SrvActBrickdllVersionLineID": 213,
"UserName": "Engineer",
"UserNameLineID": 155
}
72.1.3.3.10. Processing All the Citect SCADA log Files with a Single Configuration
This configuration combines the configuration files in the Collecting File-based Logs section. It provides the same
functionality as the individual configurations, but performed automatically, on demand, using a single
configuration. Using this technique, any other source or output can be combined together.
In this case, an output module is also displayed sending the collected logs to Microsoft Azure Event Hubs using
the om_kafka module. For more information on configuring NXLog to send data to Microsoft Azure Event Hubs
see the Microsoft Azure Event Hubs integration guide in the NXLog documentation.
Although this configuration contains three routes, all of which define the same output destination, it was written
this way to enhance the readability of the configuration file. Combining all nine input instances as a list of inputs
in a single route would achieve the same functionality.
The example below combines the processing of all the files listed in this topic.
544
Chapter 72. Industrial Control Systems NXLog User Guide
Example 329. Processing All Citect SCADA log Files with a Single Configuration
This example is structured with extra headers for easier readability. Each main section is separated with
comments.
nxlog.conf (truncated)
1 # ----------- REGULAR EXPRESSIONS FOR PARSING DATA -------------------
2
3 define SYSLOG_REGEX /(?x)^(\d+.\d+.\d+.)(\d+.\d+.\d+.\d+.)\s([+]\d+.\
4 \d*)\s(?<Message>.*)/
5
6 define TRACELOG_REGEX /(?x)^(\d+.\d+.\d+.)(\d+.\d+.\d+.\d+.)\s([+]\d+.\d*)\
7 \s(?<PID>\d+)\s{3}\d\s(?<Severity>\w+)\s*(?<ProcessName>\
8 \w+)\s*(?<Message>.*)/
9
10 define DEBUGLOG_REGEX /(?x)^(\d+.\d+.\d+.)(\d+.\d+.\d+.\d+.\d+.)([+]\
11 \d+.\d+.)\s(?<Message>.*)/
12
13 define IPCLOG_REGEX /(?x)^(\d+.\d+.\d+\d+.\d+.\d+.\d+.\d+)\s+([+]\d+.\d+)\
14 \s+(?<Process>\S+)\s+(?<Message>.*)/
15
16 define TCPIPDRIVER_REGEX /(?x)^(\d+.[\/]\d+.[\/]\d+\d+.\d+.\d+.\d+.\d*)\
17 \s+(?<SourceType>\S+)\s+(?<Message>.*)/
18
19 define PARAMS_REGEX /(?x)^(\d+.\d+.\d+\s\d+.\d+.\d+.\d+.\d+\s[+]\d+.\d+).\
20 \s(?<Category>\[\w+\]|\[\w+.\w+.\w+\])\s+(?<Message>.*)/
21
22 define RELOADLOG_REGEX /(?x)^(\d+.\d+.\d+\s\d+.\d+.\d+.\d+.\d+\s[+]\d+.\d+)\
23 \s(?<ServerName>\w+\s\w+:)\s(?<Message>.*)/
24
25 define TRACELOGRM_REGEX /(?x)^(\d+.\d+.\d+\s\d+.\d+.\d+.\d+.\d+\s[+]\d+.\d+)\
26 \s(?<EventID>\w+)\s+\d\s(?<Severity>\w+)\s+(?<Type>\w+)\
27 \s+(?<Message>.*)/
28 [...]
NXLog can be configured to read and process all kinds of logs which are produced by Siemens SIMATIC PCS 7.
545
NXLog User Guide Chapter 72. Industrial Control Systems
This example contains NXLog configuration for reading and processing Windows Event logs generated by
WinCC. Log filtering is based on the values of the Event ID field.
A sample list of values for Event ID is provided in the table below. This is only a small subset of events
generated by WinCC since it is impractical to include all possible events.
The following log sample with Event ID 4096 was copied from the Windows Event Viewer.
Event Sample
Log Name: Application
Source: SIMATIC NET Station Manager
Date: 16.06.2020 14:09:51
Event ID: 4096
Task Category: None
Level: Information
Keywords: Classic
User: N/A
Computer: WINSRV99
Description:
The service SIMATIC NET Station Manager was started
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="SIMATIC NET Station Manager" />
<EventID Qualifiers="16386">4096</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2020-06-16T11:09:51.480603800Z" />
<EventRecordID>20030</EventRecordID>
<Channel>Application</Channel>
<Computer>WINSRV99</Computer>
<Security />
</System>
<EventData>
<Data>SIMATIC NET Station Manager</Data>
</EventData>
</Event>
Using the im_msvistalog module, the configuration below instructs NXLog to read data from the log sources
listed in the table above. To facilitate more convenient post-processing, the xm_json module enables all
messages to be converted to JSON as specified in the Exec directive.
546
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_eventlog>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id="0">
10 <Select Path="Application">
11 *[System[(EventID=256 or EventID=1005 or
12 EventID=1026 or EventID=1027 or
13 EventID=4096 or EventID=4132)]]
14 </Select>
15 </Query>
16 </QueryList>
17 </QueryXML>
18 Exec to_json();
19 </Input>
Below is the message with Event ID 4096 after it has been processed by NXLog and converted to JSON.
Output
{
"EventTime": "2020-06-16T14:09:51.480603+03:00",
"Hostname": "WINSRV99",
"Keywords": "36028797018963968",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 4096,
"SourceName": "SIMATIC NET Station Manager",
"TaskValue": 0,
"RecordNumber": 20030,
"ExecutionProcessID": 0,
"ExecutionThreadID": 0,
"Channel": "Application",
"Message": "The service SIMATIC NET Station Manager was started",
"EventData": "<Data>SIMATIC NET Station Manager</Data>",
"EventReceivedTime": "2020-06-16T14:09:51.666231+03:00",
"SourceModuleName": "from_eventlog",
"SourceModuleType": "im_msvistalog"
}
The following table lists the WinCC services which generate log data in the Windows Event Log, along with their
display names and the path to their executables.
547
NXLog User Guide Chapter 72. Industrial Control Systems
548
Chapter 72. Industrial Control Systems NXLog User Guide
549
NXLog User Guide Chapter 72. Industrial Control Systems
550
Chapter 72. Industrial Control Systems NXLog User Guide
551
NXLog User Guide Chapter 72. Industrial Control Systems
This example demonstrates how to apply NXLog to parse and process WinCC log sources listed in the table
above.
The following log sample of the SIMATIC Management Agent event source was copied from the Windows
Event Viewer.
Event Sample
Log Name: Application
Source: SIMATIC Management Agent
Date: 19.06.2020 17:15:53
Event ID: 0
Task Category: None
Level: Information
Keywords: Classic
User: N/A
Computer: WINSRV99
Description:
Service started/resumed
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="SIMATIC Management Agent" />
<EventID Qualifiers="0">0</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2020-06-19T14:15:53.966166700Z" />
<EventRecordID>20534</EventRecordID>
<Channel>Application</Channel>
<Computer>WINSRV99</Computer>
<Security />
</System>
<EventData>
<Data>Service started/resumed</Data>
</EventData>
</Event>
Using im_msvistalog module, the configuration below instructs NXLog to process only those events
generated by the following four SIMATIC WinCC event sources:
To facilitate more convenient post-processing, the xm_json module enables all messages to be converted to
JSON as specified in the Exec directive.
552
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_eventlog>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id="0" Path="Application">
10 <Select Path="Application">*
11 [System[Provider[@Name='S7 PC Adapter USB A2 Service Plugin'
12 or @Name='SIMATIC Management Agent'
13 or @Name='SIMATIC NET PnP Manager'
14 or @Name='SIMATIC NET RouteManager']]]
15 </Select>
16 </Query>
17 </QueryList>
18 </QueryXML>
19 Exec to_json();
20 </Input>
Below is the message from the SIMATIC Management Agent event source after it has been processed by
NXLog and converted to JSON.
Output
{
"EventTime": "2020-06-19T17:15:53.966166+03:00",
"Hostname": "WINSRV99",
"Keywords": "36028797018963968",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 0,
"SourceName": "SIMATIC Management Agent",
"TaskValue": 0,
"RecordNumber": 20534,
"ExecutionProcessID": 0,
"ExecutionThreadID": 0,
"Channel": "Application",
"Message": "Service started/resumed",
"Category": "%1",
"Opcode": "Info",
"EventData": "<Data>Service started/resumed</Data>",
"EventReceivedTime": "2020-06-19T17:15:54.078372+03:00",
"SourceModuleName": "from_eventlog",
"SourceModuleType": "im_msvistalog"
}
File-based logs are created by the Automation, Engineering, and Operator stations, and in most of the cases do
not follow a unified formatting scheme. To tackle the inconsistent formatting of these logs, NXLog can be
configured to use regular expressions that is specific to each messaging structure.
File-based logs of PCS7 in this section are grouped into the following categories:
553
NXLog User Guide Chapter 72. Industrial Control Systems
C:\Program
Files(x86)\Siemens\WinCC\diagnose\SIMATIC_S7-
1200_S7-1500_Channel_xx.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\System_Info
.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\SIMATIC_S5_
PROFIBUS_FDL_xx.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\OPC.log
554
Chapter 72. Industrial Control Systems NXLog User Guide
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMAutostart
.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMDeactivat
e.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMDiagnose
.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMProjectFil
e.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMService.l
og
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMStart.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMStop.log
C:\Program
Files(x86)\Siemens\WinCC\diagnose\PMTrace.log
555
NXLog User Guide Chapter 72. Industrial Control Systems
C:\Program
Files(x86)\Siemens\WinCC\diagnose\CCTlgRtCom
monArchiving.log
556
Chapter 72. Industrial Control Systems NXLog User Guide
The example below demonstrates how to read and process Data Manager runtime logs from the C:\Program
Files (x86)\SIEMENS\WinCC\diagnose\CCDmRtServer.log file. To apply the configuration for other types of
logs from the table above, simply replace the file name in the configuration.
557
NXLog User Guide Chapter 72. Industrial Control Systems
Example 332. Processing Data Manager, Tag Archiving, and Servers Logs
In this example, the input sample of a Data Manager runtime event shows which fields can be parsed: the
timestamp of the event, the PID, TID, a short string that represents a parameter, another string terminated
by a colon (:) representing the loader type, and a verbose message.
Input Sample
12.05.2020 13:40:35.357 PID=6128 TID=15760 C *CCDmRtServer: CChannel::StopCyclicReadRequest()
on channel SIMATIC S7 Protocol Suite failed with error 0x800401fd in line SharedMemory.cpp
(@387)
This NXLog configuration needs to load the xm_charconv extension module because this type of log file is
UCS-2LE encoded. In the _charconv extension instance, the LineReader directive sets the encoding type to
be used. In the from_file input instance, the InputType directive is used for referencing the xm_charconv
extension instance by name, _charconv, so that the log file data can be read using the correct encoding
and then converted to UTF-8.
In the configuration file, the regular expression used for capturing these six fields is defined as the constant
DATA_MANAGER_REGEX. The absolute path to the log file is defined by the constant DIAGNOSE_PATH. These
constants will make the from_file input instance more readable and easier to maintain.
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in DATA_MANAGER_REGEX. Each field name is defined within angle brackets (< >) which will
automatically add the captured value to the event record using that field name. In this example, the event
record will be enriched with the following new fields: $PID, $TID, $ParamFive, $Loader, and $Message.
The timestamp string is captured by the regular expression as $1 and $2, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This is then
assigned to the sixth field called $EventTime.
Messages that do not match the DATA_MANAGER_REGEX regular expression are discarded using the drop()
procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
558
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # Regular expression to read the message contents with named groups
2 define DATA_MANAGER_REGEX /(?x)^(\d+.\d+.\d+)\s+(\d+:\d+:\d+).\d+\
3 \s+PID=(?<PID>\d+)\s+TID=(?<TID>\d+)\s+\
4 (?<ParamFive>\w+)\s+\S(?<Loader>\w+):\s+\
5 (?<Message>.*)/
6 # Path to the folder with log files
7 define DIAGNOSE_PATH C:\Program Files (x86)\SIEMENS\WinCC\diagnose
8
9 <Extension json>
10 Module xm_json
11 </Extension>
12
13 <Extension _charconv>
14 Module xm_charconv
15 # Conversion from UCS-2LE to UTF-8
16 LineReader UCS-2LE
17 </Extension>
18
19 <Input from_file>
20 Module im_file
21 File '%DIAGNOSE_PATH%\CCDmRtServer.log'
22 InputType _charconv
23 <Exec>
24 if $raw_event =~ %DATA_MANAGER_REGEX%
25 {
26 # Creating a timestamp from the data and time values
27 $EventTime = strptime($1 + $2,"%d.%m.%Y %T");
28 to_json(); # Conversion to JSON format
29 }
30 else drop(); # Discarding messages not matching DATA_MANAGER_REGEX
31 </Exec>
32 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-21T21:36:30.324551+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Loader": "CCDmRtServer",
"Message": "CChannel::StopCyclicReadRequest() on channel SIMATIC S7 Protocol Suite failed
with error 0x800401fd in line SharedMemory.cpp (@387)",
"PID": "6128",
"ParamFive": "C",
"TID": "15760",
"EventTime": "2020-05-12T13:40:35.000000+03:00"
}
559
NXLog User Guide Chapter 72. Industrial Control Systems
Path Notice
C:\Program Files(x86)\Siemens\WinCC\diagnose\System_Info.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\OPC.log
Filenames containing a wildcard character (*) indicate that they are rotated, for instance:
SIMATIC_S7_Protocol_Suite_01.log, SIMATIC_S7_Protocol_Suite_02.log, etc.
NXLog can collect the unstructured channel diagnostics data, parse it, and then convert it to structured data,
which can then be stored as files or forwarded over the network. The example below explains how all these steps
can be performed.
560
Chapter 72. Industrial Control Systems NXLog User Guide
All channel diagnostics log messages exhibit the following data patterns:
Input Sample
2020-05-04 14:29:05,502 INFO | LogFileName : C:\Program Files
(x86)\SIEMENS\WINCC\Diagnose\SIMATIC_S7_Protocol_Suite_01.LOG
Logs can be read via the im_file module. To track multiple files simultaneously. See the section on wildcards
in the Files (im_file) documentation.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as CHANNEL_REGEX:
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in CHANNEL_REGEX. Each field name is defined within angle brackets (< >) which will automatically
add the captured value to the event record using that field name. In this example, the event record will be
enriched with the $Message field.
The timestamp string is captured by the regular expression as $1 and $2, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
561
NXLog User Guide Chapter 72. Industrial Control Systems
nxlog.conf
1 # Regular expression to read the message contents
2 define CHANNEL_REGEX /(?x)^(\d+-\d+-\d+)\s(\d+:\d+:\d+),\
3 \d+\s+(?<Type>\w+)\s+(?<Message>.*)/
4 # Path to the folder with log files
5 define DIAGNOSE_PATH C:\Program Files (x86)\SIEMENS\WinCC\diagnose
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input from_file>
12 Module im_file
13 # Using the asterisk in the file name enables reading of rotated files
14 File '%DIAGNOSE_PATH%\SIMATIC_S7_Protocol_Suite_*.log'
15 <Exec>
16 if $raw_event =~ %CHANNEL_REGEX%
17 {
18 # Creating a timestamp from the data and time values
19 $EventTime = strptime($1 + $2,"%Y-%m-%d %T");
20 to_json(); # Conversion to JSON format
21 }
22 else drop(); # Discarding messages not matching CHANNEL_REGEX
23 </Exec>
24 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-08T23:11:36.670055+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "| LogFileName : C:\\Program Files (x86)\\SIEMENS\\WINCC\\Diagnose
\\SIMATIC_S7_Protocol_Suite_01.LOG",
"Type": "INFO",
"EventTime": "2020-05-04T14:29:05.000000+03:00"
}
Backslash characters (\) are escaped by default during processing as prescribed by the
NOTE official JSON definition of a string ("Any codepoint except " or \ or control characters"). See
the Introducing JSON section on the JSON website for more details.
Delta loader logs are collected and stored in the CCDeltaLoader.log in the C:\Program Files
(x86)\Siemens\WinCC\diagnose directory.
The example below demonstrates how to read, process, and save processed messages using NXLog.
562
Chapter 72. Industrial Control Systems NXLog User Guide
This delta loader log sample exhibits three types of information that can be parsed: the delta loader name,
a timestamp of the event formatted as dd.mm.yyyy hh:mm:ss, and a message that can vary depending on
the nature of the event. In this case, it contains a state change (logging started) along with the absolute
path and name the file that will contain the events logged.
Input Sample
CCDeltaLoader.exe : 24.04.2020 23:14:31 : Log C:\Program Files
(x86)\SIEMENS\WINCC\Diagnose\CCDeltaLoader.Log started.
This NXLog configuration needs to load the xm_charconv extension module because this type of log file is
UCS-2LE encoded. In the _charconv extension instance, the LineReader directive sets the encoding type to
be used. In the from_file input instance, the InputType directive is used for referencing the xm_charconv
extension instance by name, _charconv, so that the log file data can be read using the correct encoding
and then converted to UTF-8.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as DELTA_REGEX:
DELTA_REGEX Definition
1 define DELTA_REGEX /(?x)^(?<Loader>[a-zA-Z.]*)\s+:\s+(\d+.\d+.\d+)\
2 \s(\d+:\d+:\d+)\s:\s(?<Message>[\w():.\\\s]*)/
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in DELTA_REGEX. Each field name is defined within angle brackets (< >) which will automatically add
the captured value to the event record using that field name. $Loader and $Message.
The timestamp string is captured by the regular expression as $2 and $3, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
Messages that do not match the DELTA_REGEX regular expression are discarded using the drop() procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
563
NXLog User Guide Chapter 72. Industrial Control Systems
nxlog.conf
1 # Regular expression with named groups for reading messages
2 define DELTA_REGEX /(?x)^(?<Loader>[a-zA-Z.]*)\s+:\s+(\d+.\d+.\d+)\
3 \s(\d+:\d+:\d+)\s:\s(?<Message>[\w():.\\\s]*)/
4 # Path to the folder with logs
5 define DIAGNOSE_PATH C:\Program Files (x86)\siemens\wincc\diagnose
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Extension _charconv>
12 Module xm_charconv
13 # Conversion from UCS-2LE to UTF-8
14 LineReader UCS-2LE
15 </Extension>
16
17 <Input from_file>
18 Module im_file
19 File '%DIAGNOSE_PATH%\CCDeltaLoader.Log'
20 InputType _charconv
21 <Exec>
22 if $raw_event =~ %DELTA_REGEX%
23 {
24 # Creating a timestamp from the date and time values
25 $EventTime = strptime($2 + $3,"%d.%m.%Y %T");
26 to_json(); # Conversion to JSON
27 }
28 else drop(); # Discarding if the DELTA_REGEX pattern is not matched
29 </Exec>
30 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-08T23:31:09.157668+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Loader": "CCDeltaLoader.exe",
"Message": "Log C:\\Program Files (x86)\\SIEMENS\\WINCC\\Diagnose\\CCDeltaLoader.Log
started.",
"EventTime": "2020-04-24T23:14:31.000000+03:00"
}
Backslash characters (\) are escaped by default during processing as prescribed by the
NOTE official JSON definition of a string ("Any codepoint except " or \ or control characters"). See
the Introducing JSON section on the JSON website for more details.
OPC Unified Architecture (OPC UA) is the new machine-to-machine communications protocol which is used
extensively in industrial automation and the IoT. It has incorporated the functionality of all previous OPC
564
Chapter 72. Industrial Control Systems NXLog User Guide
specifications, is no longer tied to a single operating system, and incorporates modern technologies such as
secure authentication and a client server architecture.
C:\ProgramData\Siemens\Automation\Logfiles\sinec2.log
NXLog can be configured to process this kind of logs, see the example below.
565
NXLog User Guide Chapter 72. Industrial Control Systems
This OPC UA Server log sample taken from the sinec2.log file contains multiple lines for a single event. In
such a case, NXLog needs to be configured for multiline processing . The first line of the message will be
treated as a message header containing the date, time, event type, and event ID data.
Input Sample
05/05/2020 17:49:51 Event Type: E Event ID: 2134
The computer name no longer matches the computer name in the OPC UA configuration.
Update the OPC UA configuration with the 'SIMATIC NET Configuration --> OPC Settings --> OPC UA
Certificates --> Recreate OPC UA configuration' function of the 'Communication Settings'
program.
The NXLog configuration below defines a constant called OPC_UA_PATH defines the absolute path to the log
file. Another constant, OPC_UA_LOG_HEADER, defines the regular expression for finding message headers.
To correctly process multiline event logs, a pattern needs to be defined as a regular expression that
describes the header line of an event. In the following xm_multiline extension instance, the HeaderLine
directive specifies the regular expression to be used for finding the header line of each event.
In the from_file input instance, the InputType directive is used for referencing the xm_multiline extension
instance by name, _multiline, which will enable the instance to establish the beginning and end of each
event.
To improve the readability of the parsed messages, the Exec block invokes the replace() function to replace
all occurrences of \r\n (Windows line endings) and \t (tabs) with spaces.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
566
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # Regular expression for recognizing the message header
2 define OPC_UA_LOG_HEADER /(?x)^\d+\/\d+\/\d+\s+\d+:\d+:\d+\s+[\d\w\s:]*\d+/
3 # Path to the folder with log files
4 define OPC_UA_PATH C:\ProgramData\Siemens\Automation\Logfiles
5
6 <Extension _multiline>
7 Module xm_multiline
8 # Parsing the header line
9 HeaderLine %OPC_UA_LOG_HEADER%
10 </Extension>
11
12 <Extension json>
13 Module xm_json
14 </Extension>
15
16 <Input from_file>
17 Module im_file
18 File '%OPC_UA_PATH%\sinec2.log'
19 InputType _multiline
20 <Exec>
21 $Message = $raw_event;
22 # Replacing the `\r\n` and `\t` combinations with white spaces
23 $Message = replace($Message, "\r\n" , " ");
24 $Message = replace($Message, "\t" , " ");
25 to_json(); # Conversion of the read data to JSON
26 </Exec>
27 </Input>
Output Sample
{
"EventReceivedTime": "2020-09-30T19:07:46.225581+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "05/05/2020 17:49:51 Event Type: E Event ID: 2134 The computer name no
longer matches the computer name in the OPC UA configuration. Update the OPC UA configuration
with the 'SIMATIC NET Configuration --> OPC Settings --> OPC UA Certificates --> Recreate OPC
UA configuration' function of the 'Communication Settings' program."
}
There are multiple types of Project Manager logs which are all stored in the C:\Program
Files(x86)\Siemens\WinCC\diagnose directory as shown in the table below.
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMActivate.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMAutostart.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMDeactivate.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMDiagnose.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMProjectFile.log
567
NXLog User Guide Chapter 72. Industrial Control Systems
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMService.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMStart.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMStop.log
C:\Program Files(x86)\Siemens\WinCC\diagnose\PMTrace.log
Since NXLog supports wildcards in filenames and these log files all start with PM and have a .log filename
extension, only a single input instance is needed to read them. The following example demonstrates how NXLog
can be configured to process Project Manager log events and output them as structured data which can then be
saved to a file or forwarded over the network.
568
Chapter 72. Industrial Control Systems NXLog User Guide
Based on the Project Manager input sample below, the following fields can be parsed:
Input Sample
2020-10-08 21:44:17.969 PM( 1228-02768) CServiceModule::Run Service is started
This NXLog configuration defines two constants: PM_REGEX and DIAGNOSE_PATH which defines the absolute
path to the log files. In the from_file input instance the File directive uses DIAGNOSE_PATH and the
wildcarded filename PM*.log to read all the logs.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as PM_REGEX:
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in PM_REGEX. Each field name is defined within angle brackets (< >) which will automatically add the
captured value to the event record using that field name. In this example, the event record will be enriched
with the following fields: $Type, $PID, $TID, and $Message.
The timestamp string is captured by the regular expression as $1 and $2, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
Messages that do not match the PM_REGEX regular expression are discarded using the drop() procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
569
NXLog User Guide Chapter 72. Industrial Control Systems
nxlog.conf
1 # Regular expression for parsing log entries with named groups
2 define PM_REGEX /(?x)^(\d+-\d+-\d+)\s+(\d+:\d+:\d+).\d+\s+\
3 (?<Type>\w+)\(\s*(?<PID>\d*)\-(?<TID>\d*)\)\
4 \s*(?<Message>.*)/
5 # Path to the folder with log files
6 define DIAGNOSE_PATH C:\Program Files (x86)\SIEMENS\WinCC\diagnose
7
8 <Extension json>
9 Module xm_json
10 </Extension>
11
12 <Input from_file>
13 Module im_file
14 File '%DIAGNOSE_PATH%\PM*.log'
15 <Exec>
16 if $raw_event =~ %PM_REGEX%
17 {
18 # Transforming the date and time values to the single timestamp
19 $EventTime = strptime($1 + $2,"%Y-%m-%d %T");
20 to_json(); # Converting to JSON
21 }
22 else drop(); # Discarding messages if not matching the PM_REGEX
23 </Exec>
24 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-21T18:53:08.336289+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "CServiceModule::Run Service is started",
"PID": "1228",
"TID": "02768",
"Type": "PM",
"EventTime": "2020-10-08T21:44:17.000000+03:00"
}
• C:\ProgramData\Siemens\Logs\
• C:\Users\All Users\Siemens\Logs\
The example below explains how to process trace files and diagnostics logs using NXLog. Processing here means
that the data will be parsed, processed, and formatted as structured data, which is usually either saved to file or
forwarded over the network.
570
Chapter 72. Industrial Control Systems NXLog User Guide
This log sample contains various fields that can be parsed, such as the entry number, timestamp, process
ID (PID), thread ID (TID), address, process abbreviation, ParamSeven, and two messages fields.
Input Sample
3; 2020-04-20T22:08:48.327Z; 3356; 2844; [0x5A098658]; BCS\ECT; E;
CBCSEqmControlConfig::LoadConfigFromIniFile; "GetCurrentDbIdent failed with hr=0x80040500"
This NXLog configuration defines two constants: TRACE_REGEX and TRACE_PATH which defines the absolute
path to the trace files. In the from_file input instance the File directive uses TRACE_PATH and a wildcard
(*) to read all files in this directory.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as TRACE_REGEX:
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in TRACE_REGEX. Each field name is defined within angle brackets (< >) which will automatically add
the captured value to the event record using that field name. In this example, the event record will be
enriched with the following fields: $PID, $TID, $Address, $Process, $ParamSeven, $MessageOne, and
$MessageTwo.
The first field to be captured as $1 using TRACE_REGEX is the $EntryNumber which is then converted to an
integer using the integer() function. The second field to be captured as $2 is the timestamp of the event
which is in a standardized string format that parsedate() can convert to the datetime data type.
Messages that do not match the TRACE_REGEX regular expression are discarded using the drop() procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
571
NXLog User Guide Chapter 72. Industrial Control Systems
nxlog.conf
1 # Regular expression for parsing logs
2 define TRACE_REGEX /(?x)^[^\w\d]*(\d*);\s*(\d*-\d*\
3 -\d*\w\d*:\d*:\d*.\d*\w);\s*(?<PID>\d*);\
4 \s*(?<TID>\d*);\s*\[(?<Address>\w*\d*)\];\
5 \s(?<Process>[\w\\]*);\s*(?<ParamSeven>\w*)\
6 ;(?<MessageOne>.*);\s*\"(?<MessageTwo>.*)\"/
7 # Path to the folder with the trace files
8 define TRACE_PATH C:\ProgramData\Siemens\Logs\REGSVR32\trace
9
10 <Extension json>
11 Module xm_json
12 </Extension>
13
14 <Input from_file>
15 Module im_file
16 File '%TRACE_PATH%\*'
17 <Exec>
18 if $raw_event =~ %TRACE_REGEX%
19 {
20 # Converting to integer
21 $EntryNumber = integer($1);
22 # Parsing the timestamp
23 $Timestamp = parsedate($2);
24 to_json(); # Converting to JSON
25 }
26 else drop(); # Discarding messages if not matching TRACE_REGEX
27 </Exec>
28 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-21T22:22:58.971760+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Address": "0x5A098658",
"MessageOne": " CBCSEqmControlConfig::LoadConfigFromIniFile",
"MessageTwo": "GetCurrentDbIdent failed with hr=0x80040500",
"PID": "3356",
"ParamSeven": "E",
"Process": "BCS\\ECT",
"TID": "2844",
"EntryNumber": 3,
"Timestamp": "2020-04-21T01:08:48.327000+03:00"
}
572
Chapter 72. Industrial Control Systems NXLog User Guide
The example below explains how these types of logs can be processed with NXLog. In this example, user context
surrogate logs are selected for processing.
573
NXLog User Guide Chapter 72. Industrial Control Systems
The following event sample was taken from a CUCSurrogate.log file. To process WinCC license information
or runtime logs, substitute the filename CUCSurrogate.log assigned to the File directive of the from_file
input instance with either License_Info.log or PDLRT_GUI.log.
Input Sample
08.10.2020 21:44:27 OnChangeState [0]
Based on the sample event, only the timestamp and a message field can be parsed.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as EVENT_REGEX:
EVENT_REGEX definition
1 define EVENT_REGEX /(?x)^(\d+.\d+.\d+)\s+(\d+:\d+:\d+)\s+(?<Message>.*)/
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in EVENT_REGEX. Each field name is defined within angle brackets (< >) which will automatically add
the captured value to the event record using that field name. In this example, the event record will be
enriched with the $Message field.
The timestamp string is captured by the regular expression as $1 and $2, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
Messages that do not match the EVENT_REGEX regular expression are discarded using the drop() procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
574
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # Regular expression for parsing user context surrogate logs
2 define EVENT_REGEX /(?x)^(\d+.\d+.\d+)\s+(\d+:\d+:\d+)\s+(?<Message>.*)/
3 # Path to the folder with logs
4 define DIAGNOSE_PATH C:\Program Files (x86)\SIEMENS\WinCC\diagnose
5
6 <Extension json>
7 Module xm_json
8 </Extension>
9
10 <Input from_file>
11 Module im_file
12 File '%DIAGNOSE_PATH%\CUCSurrogate.log'
13 <Exec>
14 if $raw_event =~ %EVENT_REGEX%
15 {
16 # Converting the date and time values to the single timestamp
17 $EventTime = strptime($1 + $2,"%d.%m.%Y %T");
18 to_json(); # Converting the data to JSON format
19 }
20 else drop(); # Discarding messages if not matching EVENT_REGEX
21 </Exec>
22 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-09T13:35:47.981193+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "OnChangeState [0]",
"EventTime": "2020-10-08T21:44:27.000000+03:00"
}
The table below lists the path and filename pattern associated with each type of WinCC log.
Since the im_file module supports filenames containing wildcards, the filename pattern for WinCC runtime event
logs from the table above could be used for processing WinCC_Sys_01.log, WinCC_Sys_02.log, etc. See the
section on wildcards in the Files (im_file) documentation for details.
The example below uses WinCC startup logs to show how NXLog can process these types of logs. To process
either of the other two log types, substitute the filename in the NXLog configuration file with the one matching
the desired log type.
575
NXLog User Guide Chapter 72. Industrial Control Systems
Input Sample
2303,04.05.2020,14:29:09:662,1000204,4,,DESKTOP-VCF8F0G,DataManager Runtime,S7$Program(1)
Connection 'S7$Program(1)' connected,MSG_STATE_GO
• ID (numeric)
• Timestamp (string format: dd.mm.yyyy,hh:mm:ss:fff)
• Message Number
• Message Class (numeric)
• Station
• Runtime
• Message
• State
This NXLog configuration needs to load the xm_charconv extension module because this type of log file is
UCS-2LE encoded. In the _charconv extension instance, the LineReader directive sets the encoding type to
be used. In the from_file input instance, the InputType directive is used for referencing the xm_charconv
extension instance by name, _charconv, so that the log file data can be read using the correct encoding
and then converted to UTF-8.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as STARTUP_REGEX:
STARTUP_REGEX definition
1 define STARTUP_REGEX /(?x)^(\d+),(\d+.\d+.\d+),(\d+:\d+:\d+):\
2 \d+,(\d+),(\d+),,(?<Station>.*),\
3 (?<Runtime>.*),(?<Message>.*),(?<State>.*)/
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in STARTUP_REGEX. Each field name is defined within angle brackets (< >) which will automatically
add the captured value to the event record using that field name. In this example, the event record will be
enriched with the following fields: $Station, $Runtime, $Message, and $State.
The timestamp string is captured by the regular expression as $2 and $3, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
576
Chapter 72. Industrial Control Systems NXLog User Guide
The remaining fields captured using STARTUP_REGEX are stored in $1, $4, and $5 which are mapped to the
$ID, $MessageNumber, and $MessageClass fields respectively. Even though these fields are meant to
contain integer values, all values captured by regular expressions are stored as strings. The integer()
function is used to convert them to integers.
Messages that do not match the STARTUP_REGEX regular expression are discarded using the drop()
procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
nxlog.conf (truncated)
1 # Regular expression for parsing messages
2 define STARTUP_REGEX /(?x)^(\d+),(\d+.\d+.\d+),(\d+:\d+:\d+):\
3 \d+,(\d+),(\d+),,(?<Station>.*),\
4 (?<Runtime>.*),(?<Message>.*),(?<State>.*)/
5 # Path to the folder with log files
6 define DIAGNOSE_PATH C:\Program Files (x86)\Siemens\WinCC\diagnose
7
8 <Extension json>
9 Module xm_json
10 </Extension>
11
12 <Extension _charconv>
13 Module xm_charconv
14 # Converting data from UCS-2LE to UTF-8
15 LineReader UCS-2LE
16 </Extension>
17
18 <Input from_file>
19 Module im_file
20 File '%DIAGNOSE_PATH%\WinCC_SStart_*.log'
21 InputType _charconv
22 <Exec>
23 if $raw_event =~ %STARTUP_REGEX%
24 {
25 # Processing values
26 $ID = integer($1);
27 $EventTime = strptime($2 + $3,"%d.%m.%Y%T");
28 $MessageNumber = integer($4);
29 [...]
577
NXLog User Guide Chapter 72. Industrial Control Systems
Output Sample
{
"EventReceivedTime": "2020-10-21T21:08:59.626586+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "S7$Program(1)\tConnection 'S7$Program(1)' connected",
"Runtime": "DataManager Runtime",
"State": "MSG_STATE_GO",
"Station": "DESKTOP-VCF8F0G",
"ID": 2303,
"EventTime": "2020-05-04T14:29:09.000000+03:00",
"MessageNumber": 1000204,
"MessageClass": 4
}
SQL Agent logs are located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL12.WINCC\MSSQL\Log\
where they are rotated in the same way as SQLAGENT.* log files.
The following example explains how to process SQL Agent logs using NXLog.
578
Chapter 72. Industrial Control Systems NXLog User Guide
This sample event from an SQL Agent log contains a timestamp and a message.
Input Sample
2020-10-08 21:40:01 - ? [495] The SQL Server Agent startup service account is
WORKGROUP\WINSRV99$.
This NXLog configuration needs to load the xm_charconv extension module because this type of log file is
UCS-2LE encoded. In the _charconv extension instance, the LineReader directive sets the encoding type to
be used. In the from_file input instance, the InputType directive is used for referencing the xm_charconv
extension instance by name, _charconv, so that the log file data can be read using the correct encoding
and then converted to UTF-8.
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as EVENT_SQLAGENT:
Regular expression
1 define EVENT_SQLAGENT /(?x)^(\d+-\d+-\d+)\s+(\d+:\d+:\d+)\
2 \s+-\s+\W\s+(?<Message>.*)/
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in EVENT_SQLAGENT. Each field name is defined within angle brackets (< >) which will automatically
add the captured value to the event record using that field name. In this example, the event record will be
enriched with the $Message field.
The timestamp string is captured by the regular expression as $1 and $2, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
Messages that do not match the EVENT_SQLAGENT regular expression are discarded using the drop()
procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
579
NXLog User Guide Chapter 72. Industrial Control Systems
nxlog.conf
1 # Regular expression for reading logs
2 define EVENT_SQLAGENT /(?x)^(\d+-\d+-\d+)\s+(\d+:\d+:\d+)\
3 \s+-\s+\W\s+(?<Message>.*)/
4 # Path to the folder with SQL log files
5 define SQL_SERVER_PATH C:\Program Files (x86)\Microsoft SQL Server
6
7 <Extension _charconv>
8 Module xm_charconv
9 # Converting from UCS-2LE to UTF-8
10 LineReader UCS-2LE
11 </Extension>
12
13 <Extension json>
14 Module xm_json
15 </Extension>
16
17 <Input from_file>
18 Module im_file
19 File '%SQL_SERVER_PATH%\MSSQL12.WINCC\MSSQL\Log\SQLAGENT.*'
20 InputType _charconv
21 <Exec>
22 if $raw_event =~ %EVENT_SQLAGENT%
23 {
24 # Converting of the data and time values to the single timestamp
25 $EventTime = strptime($1 + $2, "%Y-%m-%d %T");
26 to_json(); # Converting to JSON
27 }
28 else drop(); # Discarding messages if not matching EVENT_SQLAGENT
29 </Exec>
30 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-18T23:13:17.546939+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "[495] The SQL Server Agent startup service account is WORKGROUP\\WINSRV99$.",
"EventTime": "2020-10-08T21:40:01.000000+03:00"
}
580
Chapter 72. Industrial Control Systems NXLog User Guide
Fast tag logging .mdf [MultiprojectName]\[OS_projectName]\wincproj\ Process data archiving with the
[OS_serverName]\ArchiveManager\TagloggingFa cycle shorter than 1 min
.ldf st\*
[MultiprojectName][OS_projectName]\TRANSFER
.log
[MultiprojectName][OS_projectName]\wincproj[
OS_serverName]\TRANSFER.log
The logs generated by User Archives are stored in UALogFile.txt in the path listed above where they can readily
be processed by NXLog.
581
NXLog User Guide Chapter 72. Industrial Control Systems
Input Sample
2020-02-10 08:48:12.803 [p=11912, t=0x3370] Sync: Redundancy is not activated
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expression defined as ARCHIVE_REGEX:
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
defined in ARCHIVE_REGEX. Each field name is defined within angle brackets (< >) which will automatically
add the captured value to the event record using that field name. In this example, the event record will be
enriched with the following fields: $PID, $TID, and $Message.
The timestamp string is captured by the regular expression as $1 and $2, but because these strings cannot
be easily interpreted as a timestamp by parsedate() due to the non-standard string format, the strptime()
function allows a custom format to be defined as the second argument which it then uses to parse and
convert the string in the first argument, to finally return a value having the datetime data type. This value is
then assigned to the explicitly defined $EventTime field.
Messages that do not match the ARCHIVE_REGEX regular expression are discarded using the drop()
procedure.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
582
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # Regular expression for parsing user archives
2 define ARCHIVE_REGEX /(?x)^(\d+-\d+-\d+)\s+(\d+:\d+:\d+).\
3 \d+\s+\[p=(?<PID>\d+),\s+t=(?<TID>.*)\
4 \]\s+(?<Message>.*)/
5 # Path to the folder with logs
6 define PROJECT_PATH C:\Users\Engineer\Documents\Project\BEV_MP
7
8 <Extension json>
9 Module xm_json
10 </Extension>
11
12 <Input from_file>
13 Module im_file
14 File '%PROJECT_PATH%\Hmi\wincproj\HMI\UA\UALogFile.txt'
15 <Exec>
16 if $raw_event =~ %ARCHIVE_REGEX%
17 {
18 # Converting the date and time values to the single timestamp
19 $EventTime = strptime($1 + $2,"%Y-%m-%d %T");
20 to_json(); # Converting parsed data to JSON
21 }
22 else drop(); # Discarding messages if not matching ARCHIVE_REGEX
23 </Exec>
24 </Input>
Output Sample
{
"EventReceivedTime": "2020-10-21T22:58:52.266852+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "Sync: Redundancy is not activated",
"PID": "11912",
"TID": "0x3370",
"EventTime": "2020-02-10T08:48:12.000000+02:00"
}
583
NXLog User Guide Chapter 72. Industrial Control Systems
Log entries generated by the loading protocol are collected in the LOADPROT.log file located in the Automation
Station project directory. The following example explains how to configure NXLog for processing AS protocol of
loading logs.
584
Chapter 72. Industrial Control Systems NXLog User Guide
The following three input samples are related to the protocol of loading.
Each protocol of loading event starts with a header containing the protocol type, path, and a timestamp.
Protocol Header
***** Protocol Of Loading <BEV_Prj\SIMATIC 400(1)\CPU 417-5 H PN/DP\S7 Program(1)\Charts> on
03/13/20 11:53:04
• Type
• Path
• Date (string format: mm/dd/yy)
Based on this first type of event sample, these fields can be parsed:
• Daypart (AM/PM)
• Process
• ParamFour
• Status
Based on this second type of event sample, these fields can be parsed:
• Daypart (AM/PM)
• Process
• Status
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expressions defined by REGEX_LOADPROT_HEADER, REGEX_LOADPROT_ONE, and REGEX_LOADPROT_TWO:
585
NXLog User Guide Chapter 72. Industrial Control Systems
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
contained defined by REGEX_LOADPROT_HEADER, REGEX_LOADPROT_ONE or REGEX_LOADPROT_TWO. Each field
name is defined within angle brackets (< >) which will automatically add the captured value to the event
record using that field name. In this example, depending on which of the three regular expressions an
event matches, the event record will be enriched with a subset of the following fields: $Type, $Path, $Date,
$Time, $Daypart, $Process, $ParamFour, and/or $Status.
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
586
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # Regular expression to recognize the message header
2 define REGEX_LOADPROT_HEADER /(?x)^\s?\**(?<Type>[\w\s]*)\<(?<Path>\
3 [-_ \\\/\(\)\d*\w*]*)\>\s*on\s*(?<Date>\
4 \d+\/\d+\/\d+)\s*(?<Time>\d+:\d+:\d+)/
5 # Regular expression for processing the first type of logs
6 define REGEX_LOADPROT_ONE /(?x)^\[?(?<Time>\d+:\d+:\d+.\d+)\s*\
7 (?<Daypart>AM|PM)\]?\s*(?<Process>\
8 [._ \(\)~@\-\w]*)\[(?<ParamFour>[\w\d]*)\]\
9 \s*\((?<Status>[\w]*)\)/
10 # Regular expression for processing the second type of logs
11 define REGEX_LOADPROT_TWO /(?x)^\[?(?<Time>\d+:\d+:\d+.\d+)\s*\
12 (?<Daypart>AM|PM)\]?\s*(?<Process>.*)\
13 \s*\((?<Status>.*)\)/
14 # Path to the Automation Station project folder
15 define PROJECT_PATH C:\Users\Engineer\Documents\Project\BEV_MP
16
17 <Extension json>
18 Module xm_json
19 </Extension>
20
21 <Input from_file>
22 Module im_file
23 File '%PROJECT_PATH%\BEV_Prj\ES_LOC\1\GEN\loadprot.log'
24 <Exec>
25 # Converting parsed data to JSON
26 if $raw_event =~ %REGEX_LOADPROT_HEADER% to_json();
27 else if $raw_event =~ %REGEX_LOADPROT_ONE% to_json();
28 else if $raw_event =~ %REGEX_LOADPROT_TWO% to_json();
29 else drop(); # Discarding messages if not matching expressions
30 </Exec>
31 </Input>
587
NXLog User Guide Chapter 72. Industrial Control Systems
Load reference logs are stored in the the Automation Station project directory as LOADREFS.log.
NXLog can be configured to process load reference logs as demonstrated in the following example.
588
Chapter 72. Industrial Control Systems NXLog User Guide
Load reference logs are comprised of two types of events: header events and regular log events.
• Type
• Path
• Date (string format: mm/dd/yy)
Based on this regular log event sample, these fields can be parsed:
• ParamOne
• ParamTwo
• ParamThree
• ParamFour
• ParamFive
• ParamSix
• ParamSeven
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expressions defined by REGEX_LOADREF_HEADER and REGEX_LOADREF_ONE:
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
contained defined by REGEX_LOADREF_HEADER or REGEX_LOADREF_ONE. Each field name is defined within
angle brackets (< >) which will automatically add the captured value to the event record using that field
name. In this example, depending on which of the two regular expressions an event matches, the event
record will be enriched with a subset of the following fields: $Type, $Path, $Date, $Time, $ParamOne,
$ParamTwo, $ParamThree, $ParamFour, $ParamFive, $ParamSix, $ParamSeven.
Messages that do not match either REGEX_LOADREF_HEADER or REGEX_LOADREF_ONE are discarded using
the drop() procedure.
589
NXLog User Guide Chapter 72. Industrial Control Systems
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
nxlog.conf
1 # Regular expression for parsing headers
2 define REGEX_LOADREF_HEADER /(?x)^\s?\**(?<Type>[\w ]*)\<(?<Path>\
3 [-_ \\\/\(\)\d*\w*]*)\>\s*on\s*(?<Date>\
4 \d+\/\d+\/\d+)\s*(?<Time>\d+:\d+:\d+)/
5 # Regular expression for parsing log entries
6 define REGEX_LOADREF_ONE /(?x)^(?<ParamOne>[\(\)@\d\w_]*)\s*\
7 \[(?<ParamTwo>[\w\d]*)\]\s*\((?<ParamThree>[\w]\
8 *\s*)\s*?\)\s*->\s*\((?<ParamFour>[\w]*\s*)\)\s*\
9 ->\s(?<ParamFive>[\(\)@\w_.-]*)\s*(?:\[(?<ParamSix>\
10 [\w\d]*)\])?\s*\((?<ParamSeven>[\w]*)\s*\)/
11 # Path to the AS project folder
12 define PROJECT_PATH C:\Users\Engineer\Documents\Project\BEV_MP
13
14 <Extension json>
15 Module xm_json
16 </Extension>
17
18 <Input from_file>
19 Module im_file
20 File '%PROJECT_PATH%\VR_Lib\ES_LOC\1\GEN\loadrefs.log'
21 <Exec>
22 if $raw_event =~ %REGEX_LOADREF_HEADER%
23 {
24 $Type = replace($Type, " LoadRefs of ", "LoadRefs");
25 to_json(); # Converting to JSON format
26 }
27 else if $raw_event =~ %REGEX_LOADREF_ONE% to_json();
28 else drop(); # Discarding messages if not matching expressions
29 </Exec>
30 </Input>
Backslash characters (\) are escaped by default during processing as prescribed by the
NOTE official JSON definition of a string ("Any codepoint except " or \ or control characters"). See
the Introducing JSON section on the JSON website for more details.
590
Chapter 72. Industrial Control Systems NXLog User Guide
[MultiprojectName]\[MasterLibraryName]\Global
\Modify.log
Logs of the shared declarations synchronization are stored in the GDAlignError.log file of the multiproject
directory.
NXLog can be configured to process shared declarations synchronization logs as demonstrated in the following
example.
591
NXLog User Guide Chapter 72. Industrial Control Systems
This sample event shows how this log type spans multiple lines. The entirety of each multiline event will be
flattened to a single $Message field.
Input Sample
Synchronization of the shared declarations on 07.05.2020 14:17:59
Selected object: Shared Declarations BEV_Lib
Actions were performed during the synchronization of the shared declarations in the following
projects/libraries and a log was created:
Project BEV_Prj
Project HMI
To correctly process multiline event logs, a pattern needs to be defined as a regular expression that
describes the header line of an event. In the following xm_multiline extension instance, the HeaderLine
directive specifies the regular expression to be used for finding the header line of each event.
In the from_file input instance, the InputType directive is used for referencing the xm_multiline extension
instance by name, _multiline, which will enable the instance to establish the beginning and end of each
event.
To improve the readability of the parsed messages, the Exec block invokes the replace() function to replace
all occurrences of \r\n (Windows line endings).
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
592
Chapter 72. Industrial Control Systems NXLog User Guide
nxlog.conf
1 # Path to the multiproject folder
2 define PROJECT_PATH C:\Users\Engineer\Documents\Project\BEV_MP
3
4 <Extension _multiline>
5 Module xm_multiline
6 # Regular expression to recognize the message header
7 HeaderLine /^Synchronization.*on\s+\d+.\d+.\d+\s+\d+:\d+:\d+$/
8 </Extension>
9
10 <Extension json>
11 Module xm_json
12 </Extension>
13
14 <Input from_file>
15 Module im_file
16 File '%PROJECT_PATH%\BEV_MP\Global\GDAlignError.log'
17 InputType _multiline
18 <Exec>
19 $Message = $raw_event;
20 # Replacing the `\r\n` combinations with white spaces
21 $Message = replace($Message, "\r\n" , " ");
22 to_json(); # Converting the parsed data to JSON format
23 </Exec>
24 </Input>
Output Sample
{
"EventReceivedTime": "2020-09-30T13:56:54.967315+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "Synchronization of the shared declarations on 07.05.2020 14:17:59 Selected
object: Shared Declarations BEV_Lib Actions were performed during the synchronization of the
shared declarations in the following projects/libraries and a log was created: Project
BEV_Prj Project HMI "
}
[MultiprojectName]\[MasterLibraryName]\Global\[ProcessTagType_name].log
[MultiprojectName]\[MasterLibraryName]\Global\Adjust.log
[MultiprojectName]\[MasterLibraryName]\Global\Modify.log
NXLog can be configured to process import and export assistant logs as demonstrated in the following example.
593
NXLog User Guide Chapter 72. Industrial Control Systems
Assistant logs are comprised of two types of events: header events and regular log events.
To process other files from the list above, simply replace the file name against the File directive of the
im_file module.
• DayOfWeek
• Message
• Month (name)
• Time (string format: hh:mm:ss)
• Path
• Status
• Message
Because these logs exhibit consistent data patterns, specific fields can be parsed using the following regular
expressions defined by ASSIST_REGEX_HEADER and ASSIST_REGEX_LOG:
The logic for parsing and filtering is defined withing the Exec block of the from_file input instance. All
parsed fields that do not require additional processing are captured using the named capturing groups
contained defined by ASSIST_REGEX_HEADER or ASSIST_REGEX_LOG. Each field name is defined within
angle brackets (< >) which will automatically add the captured value to the event record using that field
name. In this example, depending on which of the two regular expressions an event matches, the event
record will be enriched with a subset of the following fields: $Message, $DayOfWeek, $Month, $Time, $Path,
$Status, and/or $Message.
For events that match ASSIST_REGEX_HEADER, the fourth and fifth unnamed capture groups ($4 and $5)
that are used to create the fields $Date (the day of the month) and $Year are converted to integers using
the integer() function.
Messages that do not match either ASSIST_REGEX_HEADER or ASSIST_REGEX_LOG are discarded using the
drop() procedure.
594
Chapter 72. Industrial Control Systems NXLog User Guide
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
nxlog.conf
1 # Regular expression for parsing headers
2 define ASSIST_REGEX_HEADER /(?x)^(?<Message>.*)from:\s*(?<DayOfWeek>\w*),\
3 \s*(?<Month>\w*)\s*(\d*),\s*(\d*)\
4 \s*(?<Time>\d*:\d*:\d*)/
5 # Regular expression for parsing log entries
6 define ASSIST_REGEX_LOG /(?x)^(?<Path>.*)\s+(?<Status>OK|ERROR|Error)\
7 \s+(?<Message>.*)/
8 # Path to the multiproject folder
9 define PROJECT_PATH C:\Users\Engineer\Documents\Project\BEV_MP
10
11 <Extension json>
12 Module xm_json
13 </Extension>
14
15 <Input from_file>
16 Module im_file
17 File '%PROJECT_PATH%\BEV_Lib\Global\modify.log'
18 <Exec>
19 # Converting messages to JSON format
20 if $raw_event =~ %ASSIST_REGEX_HEADER%
21 {
22 # Converting the date and year values to integers
23 $Date = integer($4);
24 $Year = integer($5);
25 to_json(); # Converting to JSON
26 }
27 else if $raw_event =~ %ASSIST_REGEX_LOG% to_json(); # Converting to JSON
28 else drop(); # Discarding messages if not matching expressions
29 </Exec>
30 </Input>
595
NXLog User Guide Chapter 72. Industrial Control Systems
Backslash characters (\) are escaped by default during processing as prescribed by the
NOTE official JSON definition of a string ("Any codepoint except " or \ or control characters"). See
the Introducing JSON section on the JSON website for more details.
[MultiprojectName]\[MasterLibraryName]@CentralBstActualize.TXT
[MultiprojectName]\[MasterLibraryName]@CentralBstActualize_tmp.TXT
NXLog can be configured to process update block types logs as demonstrated in the following example.
596
Chapter 72. Industrial Control Systems NXLog User Guide
Input Sample
The following S7 programs were selected for checking:
-> BEV_Lib\S7 Program(1)
-> BEV_Prj\SIMATIC 400(1)\CPU 417-5 H PN/DP\S7 Program(1)
-> VR_Lib\S7 Program(1)
To correctly process multiline event logs, a pattern needs to be defined as a regular expression that
describes the header line of an event. In the following xm_multiline extension instance, the HeaderLine
directive specifies the regular expression to be used for finding the header line of each event.
In the from_file input instance, the InputType directive is used for referencing the xm_multiline extension
instance by name, _multiline, which will enable the instance to establish the beginning and end of each
event.
The entire event will be assigned to the $Message field. To make the message text more readable, spaces
are substituted for -> and \r\n (Windows line endings).
Finally, by calling the to_json() procedure from the JSON (xm_json) extension module, the newly parsed
fields, along with the core fields, are added to the event record and formatted as JSON prior to being routed
to any output instances.
The following NXLog configuration combines all the steps described above.
597
NXLog User Guide Chapter 72. Industrial Control Systems
nxlog.conf
1 # The path to the multiproject folder
2 define PROJECT_PATH C:\Users\Engineer\Documents\Project\BEV_MP
3
4 <Extension _multiline>
5 Module xm_multiline
6 HeaderLine /^.*:$/
7 </Extension>
8
9 <Extension json>
10 Module xm_json
11 </Extension>
12
13 <Input from_file>
14 Module im_file
15 File '%PROJECT_PATH%\BEV_Lib\@CentralBstActualize*.TXT'
16 InputType _multiline
17 <Exec>
18 $Message = $raw_event;
19 # Replacing the `-> ` and `\r\n` combinations with white spaces
20 $Message = replace($Message, "-> ", " ");
21 $Message = replace($Message, "\r\n", " ");
22 to_json(); # Converting the result to JSON
23 </Exec>
24 </Input>
Output Sample
{
"EventReceivedTime": "2020-09-30T15:01:37.686454+03:00",
"SourceModuleName": "from_file",
"SourceModuleType": "im_file",
"Message": "The following S7 programs were selected for checking: BEV_Lib\\S7 Program(1)
BEV_Prj\\SIMATIC 400(1)\\CPU 417-5 H PN/DP\\S7 Program(1) VR_Lib\\S7 Program(1) No different
blocks found. The central type import will be closed. End of central type update 05.05.2020
19:47:54"
}
Backslash characters (\) are escaped by default during processing as prescribed by the
NOTE official JSON definition of a string ("Any codepoint except " or \ or control characters"). See
the Introducing JSON section on the JSON website for more details.
598
Chapter 72. Industrial Control Systems NXLog User Guide
Example 347. Processing All Siemens Simatec PCS 7 log Files with a Single Configuration
This example is structured with extra headers for easier readability. Each main section is separated with
comments.
nxlog.conf (truncated)
1 # ---------------- REGULAR EXPRESSIONS FOR PARSING DATA ------------------------
2
3 define DATA_MANAGER_REGEX /(?x)^(\d+.\d+.\d+)\s+(\d+:\d+:\d+).\d+\
4 \s+PID=(?<PID>\d+)\s+TID=(?<TID>\d+)\s+\
5 (?<ParamFive>\w+)\s+\S(?<Loader>\w+):\s+\
6 (?<Message>.*)/
7
8 define CHANNEL_REGEX /(?x)^(\d+-\d+-\d+)\s(\d+:\d+:\d+),\
9 \d+\s+(?<Type>\w+)\s+(?<Message>.*)/
10
11 define DELTA_REGEX /(?x)^(?<Loader>[a-zA-Z.]*)\s+:\s+(\d+.\d+.\d+)\
12 \s(\d+:\d+:\d+)\s:\s(?<Message>[\w():.\\\s]*)/
13
14 define OPC_UA_LOG_HEADER /(?x)^\d+\/\d+\/\d+\s+\d+:\d+:\d+\s+[\d\w\s:]*\d+/
15
16 define PM_REGEX /(?x)^(\d+-\d+-\d+)\s+(\d+:\d+:\d+).\d+\s+\
17 (?<Type>\w+)\(\s*(?<PID>\d*)\-(?<TID>\d*)\)\
18 \s*(?<Message>.*)/
19
20 define TRACE_REGEX /(?x)^[^\w\d]*(\d*);\s*(\d*-\d*\
21 -\d*\w\d*:\d*:\d*.\d*\w);\s*(?<PID>\d*);\
22 \s*(?<TID>\d*);\s*\[(?<Address>\w*\d*)\];\
23 \s(?<Process>[\w\\]*);\s*(?<ParamSeven>\w*)\
24 ;(?<MessageOne>.*);\s*\"(?<MessageTwo>.*)\"/
25
26 define EVENT_REGEX /(?x)^(\d+.\d+.\d+)\s+(\d+:\d+:\d+)\s+(?<Message>.*)/
27 [...]
599
NXLog User Guide Chapter 73. Linux Audit System
• the audisp dispatcher daemon which relays events to other applications for additional processing, and
• the auditctl control utility which provides configuration of the kernel component.
These tools are provided for reading the Audit log files:
• aulastlog prints out the last login for all users of a machine,
• ausearch searches Audit logs for events fitting given criteria, and
• auvirt prints a list of virtual machine sessions found in the Audit logs.
For more information about the Audit system, see the System Auditing chapter of the Red Hat Enterprise Linux
Security Guide, the installed manual pages, and the Linux Audit Documentation Project.
There are three types of rules: a control rule modifies Audit’s behavior, a file system rule watches a file or
directory, and a system call rule generates a log event for a particular system call. For more details about Audit
rules, see the Defining Audit Rules page of the Red Hat Enterprise Linux Security Guide.
• -b backlog: Set the maximum number of audit buffers. This should be higher for busier systems or for
heavy log volumes.
• -D: Delete all rules and watches. Normally used as the first rule.
• -e [0..2]: Temporarily disable auditing with 0, enable it with 1, or lock the configuration until the next
reboot with 2 (used as the last rule).
600
Chapter 73. Linux Audit System NXLog User Guide
This is a set of basic rules, some form of which is likely to be found in any ruleset.
• The permissions argument sets the kinds of accesses that are logged, and is a string containing one or
more of r (read access), w (write access), x (execute access), and a (attribute change).
• The key_name argument is an optional tag for identifying the rule.
This rule watches /etc/passwd for modifications and tags these events with passwd.
-w /etc/passwd -p wa -k passwd
• The action argument can be either always (to generate a log entry) or never (to suppress a log entry).
Generally, use never rules before always rules, because rules are matched from first to last.
• The filter argument is one of task (when a task is created), exit (when a system call exits), user (when a
call originates from user space) or exclude (to filter events).
• The system_call argument specifies the system call by name, and can be repeated by using multiple -S
flags.
• The field=value pair can be used to specify additional match options, and can also be used more than
once.
• The key_name argument is an optional tag for identifying the rule.
This rule generates a log entry when the system time is changed.
System call rules can also monitor activities around files, such as:
• creation,
• modification,
• deletion,
• access, permission, and owner modifications.
601
NXLog User Guide Chapter 73. Linux Audit System
This rule generates a log entry when a file is deleted with the unlink or rename command:
This rule checks whether an incoming or outgoing external network connection has been established.
/etc/audit/rules.d/audit.rules
# Delete all rules
-D
For more examples of rules, see the The Linux Audit Project and auditd-attack sections on GitHub.
602
Chapter 73. Linux Audit System NXLog User Guide
The Audit’s syslog plugin should be enabled to forward logs to the /dev/log socket. In this case, the
/etc/audisp/plugins.d/syslog.conf file should be edited to look like the sample below.
1 active = yes
2 direction = out
3 path = builtin_syslog
4 type = builtin
5 args = LOG_INFO
6 format = string
1 -w /tmp/audit_syslog -p wa
NXLog needs to be configured to accept Syslog messages from the /dev/log socket.
By default, NXLog cannot bind to the /dev/log socket due to the limitations of the nxlog
NOTE
user. See the Running Under a Non-Root User on Linux section for ways to handle this.
The configuration below accepts logs from the socket using the im_uds module and the Exec block selects
only messages which contain the audit_syslog string. These messages are parsed with the
parse_syslog_bsd() procedure of the xm_syslog module and converted to JSON using the to_json() procedure
of the xm_json module.
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input from_uds>
10 Module im_uds
11 UDS /dev/log
12 <Exec>
13 if not ($raw_event =~/.+audit_syslog.+/) drop();
14 parse_syslog_bsd();
15 to_json();
16 </Exec>
17 </Input>
Below is an output sample of a JSON-formatted log entry which can be obtained using this configuration.
603
NXLog User Guide Chapter 73. Linux Audit System
{
"EventReceivedTime": "2020-04-28T21:09:13.959876+00:00",
"SourceModuleName": "from_uds",
"SourceModuleType": "im_uds",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "administrator",
"EventTime": "2020-04-28T21:09:13.000000+00:00",
"SourceName": "audispd",
"Message": "node=administrator type=SYSCALL msg=audit(1588108153.953:1246): arch=c000003e
syscall=257 success=yes exit=3 a0=ffffff9c a1=55a4e3921110 a2=41 a3=1a4 items=2 ppid=2417
pid=3374 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=3
comm=\"vim\" exe=\"/usr/bin/vim.basic\" key=\"audit_syslog\""
}
If an im_linuxaudit module instance is suspended and the Audit backlog limit is exceeded,
all processes that generate Audit messages will be blocked. For this reason, it is
recommended for most cases that FlowControl be disabled for im_linuxaudit module
WARNING instances. With flow control disabled, a blocked route will cause Audit messages to be
discarded. To reduce the risk of log data being discarded, make sure the route’s processing
is fast enough to handle the Audit messages by adjusting the LogQueueSizes of the
following modules and/or adding a pm_buffer instance.
604
Chapter 73. Linux Audit System NXLog User Guide
nxlog.conf
1 <Input audit>
2 Module im_linuxaudit
3 FlowControl FALSE
4 <Rules>
5 # Delete all rules (This rule has no affect; it is performed
6 # automatically by im_linuxaudit)
7 -D
8
9 # Increase buffers from default 64
10 -b 320
11
12 # Watch /etc/passwd for modifications and tag with 'passwd'
13 -w /etc/passwd -p wa -k passwd
14
15 # Generate a log entry when the system time is changed
16 -a always,exit -F arch=b64 -S adjtimex -S settimeofday -k system_time
17
18 # Lock Audit rules until reboot
19 -e 2
20 </Rules>
21 </Input>
This configuration is the same as the previous, but it uses a separate rules file. The referenced
audit.rules file is identical to the one shown in the above example, but it is stored in a different location
(because auditd is not required).
nxlog.conf
1 <Input audit>
2 Module im_linuxaudit
3 FlowControl FALSE
4 LoadRule '/opt/nxlog/etc/audit.rules'
5 </Input>
1. Install the Audit package. Include the audispd-plugins package if required for use with audispd (see the
Collecting via Network With audispd section below).
◦ For RedHat/CentOS:
605
NXLog User Guide Chapter 73. Linux Audit System
◦ For Debian/Ubuntu:
2. Configure Auditd by editing the /etc/audit/auditd.conf configuration file, which contains parameters for
auditd. See the Configuring the Audit Service page in the Red Hat Enterprise Linux Security Guide and the
auditd.conf(5) man page.
3. After modifying the configuration or rules, enable or restart the auditd service to reload the configuration
and update the rules (if they are not locked).
◦ For RedHat/CentOS:
◦ For Debian/Ubuntu:
1. NXLog cannot read logs owned as root when running as the nxlog user. Either omit the User option in
nxlog.conf to run NXLog as root, or adjust the permissions as follows (see Reading Rsyslog Log Files for
more information about /var/log permissions):
a. use the log_group option in /etc/audit/audit.conf to set the group ownership for Audit log files,
b. change the current ownership of the log directory and files with chgrp -R adm /var/log/audit, and
c. add the nxlog user to the adm group with usermod -a -G adm nxlog.
606
Chapter 73. Linux Audit System NXLog User Guide
In the Input block of this configuration, Audit logs are read from file, the key-value pairs are parsed with
xm_kvp, and then some additional fields are added. In the Output block, the messages are converted to
JSON format, BSD Syslog headers are added, and the logs are sent to another host via TCP.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Extension audit_parser>
10 Module xm_kvp
11 KVPDelimiter ' '
12 KVDelimiter =
13 EscapeChar '\'
14 </Extension>
15
16 <Input in>
17 Module im_file
18 File "/var/log/audit/audit.log"
19 <Exec>
20 audit_parser->parse_kvp();
21 $Hostname = hostname();
22 $FQDN = hostname_fqdn();
23 $Tag = "audit";
24 $SourceName = "selinux";
25 </Exec>
26 </Input>
27
28 <Output out>
29 Module om_tcp
30 Host 192.168.1.1
31 Port 1514
32 Exec to_json(); to_syslog_bsd();
33 </Output>
1. Configure the audisp-remote plugin. Use appropriate values for the remote_server and format directives.
607
NXLog User Guide Chapter 73. Linux Audit System
/etc/audisp/audisp-remote.conf
remote_server = 127.0.0.1
port = 60
transport = tcp
queue_file = /var/spool/audit/remote.log
mode = immediate
queue_depth = 2048
format = ascii
network_retry_time = 1
max_tries_per_record = 3
max_time_per_record = 5
heartbeat_timeout = 0
network_failure_action = stop
disk_low_action = ignore
disk_full_action = ignore
disk_error_action = syslog
remote_ending_action = reconnect
generic_error_action = syslog
generic_warning_action = syslog
overflow_action = syslog
3. Optionally, auditd may be configured to forward logs only (and not write to log files). Edit
/etc/audit/auditd.conf and set write_logs = no (this option replaces log_format = NOLOG).
With the following configuration, NXLog will accept Audit logs via TCP from audispd on the local host, parse
the key-value pairs with xm_kvp, and add some additional fields to the event record.
nxlog.conf
1 <Extension audit_parser>
2 Module xm_kvp
3 KVPDelimiter ' '
4 KVDelimiter =
5 EscapeChar '\'
6 </Extension>
7
8 <Input in>
9 Module im_tcp
10 Host 127.0.0.1
11 Port 60
12 <Exec>
13 audit_parser->parse_kvp();
14 $Hostname = hostname();
15 $FQDN = hostname_fqdn();
16 $Tag = "audit";
17 $SourceName = "auditd";
18 </Exec>
19 </Input>
608
Chapter 74. Linux System Logs NXLog User Guide
Linux distributions normally use a "Syslog" system logging agent to retrieve events from the kernel (/proc/kmsg)
and accept log messages from user-space applications (/dev/log). Originally, this logger was syslogd; later
syslog‑ng added additional features, and finally Rsyslog is the logger in common use today. For more
information about Syslog, see Syslog.
Many modern Linux distributions also use the Systemd init system, which includes a journal component for
handling log messages. All messages generated by Systemd-controlled processes are sent to the journal. The
journal also handles messages written to /dev/log. The journal stores logs in a binary format, either in memory
or on disk; the logs can be accessed with the journalctl tool. Systemd can also be configured to forward logs via
a socket to a local logger like Rsyslog or NXLog.
There are several ways that NXLog can be configured to collect Linux logs. See Replacing Rsyslog for details
about replacing Rsyslog altogether, handling all logs with NXLog instead. See Forwarding Messages via Socket for
a simple way to forward all logs to NXLog without disabling Rsyslog (this is the least intrusive option). Finally, it is
also possible to read the log files written by Rsyslog; see Reading Rsyslog Log Files.
1. Configure NXLog to collect events from the kernel, the Systemd journal socket, and the /dev/log socket. See
the example below.
2. Configure Systemd to forward log messages to a socket by enabling the ForwardToSyslog option.
/etc/systemd/journald.conf
[Journal]
ForwardToSyslog=yes
3. Stop and disable Rsyslog by running systemctl stop rsyslog and systemctl disable rsyslog as root.
4. Restart NXLog.
5. Reload the journald configuration by running systemctl force-reload systemd-journald.
609
NXLog User Guide Chapter 74. Linux System Logs
This example configures NXLog to read kernel events with the im_kernel module, read daemon messages
from the Systemd journal socket with the im_uds module, and accept other user-space messages from the
/dev/log socket with im_uds. In the om_tcp module instance, all of the logs are converted to JSON format,
BSD Syslog headers are added, and the logs are forwarded to another host via TCP.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input kernel>
10 Module im_kernel
11 Exec parse_syslog_bsd();
12 </Input>
13
14 <Input journal>
15 Module im_uds
16 UDS /run/systemd/journal/syslog
17 Exec parse_syslog_bsd();
18 </Input>
19
20 <Input devlog>
21 Module im_uds
22 UDS /dev/log
23 FlowControl FALSE
24 Exec $raw_event =~ s/\s+$//; parse_syslog_bsd();
25 </Input>
26
27 <Output out>
28 Module om_tcp
29 [...]
Some local Syslog sources will add a trailing newline (\n) to each log message. The
NOTE $raw_event =~ s/\s+$//; statement in the devlog input section above will
automatically remove this and any other trailing whitespace before processing the
message.
By default, SELinux blocks communication via Unix domain sockets in CentOS7. To enable socket
communication, run the following commands.
semodule -i nxlog-fix.pp
610
Chapter 74. Linux System Logs NXLog User Guide
The description below contains steps for configuring Rsyslog to work with NXLog.
1. Configure NXLog to accept log messages from Rsyslog via a socket. See the example below.
2. Configure Rsyslog to write to the socket by adding the following configuration file. See the Rsyslog
documentation for more information about configuring what is forwarded to NXLog.
/etc/rsyslog.d/nxlog.conf
# Load omuxsock module
$ModLoad omuxsock
3. Restart NXLog and Rsyslog in that order to create and use the socket (NXLog must create the socket before
Rsyslog will write to it). Run systemctl restart nxlog and systemctl restart rsyslog.
With this example configuration, NXLog will create the socket and accept log messages from Rsyslog
through the socket. The messages will then be parsed as Syslog, converted to JSON format, prefixed with a
BSD Syslog header, and forwarded to another host via TLS.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_uds
11 UDS /opt/nxlog/var/spool/nxlog/rsyslog_sock
12 Exec parse_syslog();
13 </Input>
14
15 <Output out>
16 Module om_ssl
17 Host 192.168.1.1
18 Port 6514
19 CAFile %CERTDIR%/ca.pem
20 CertFile %CERTDIR%/client-cert.pem
21 CertKeyFile %CERTDIR%/client-key.pem
22 Exec $Message = to_json(); to_syslog_bsd();
23 </Output>
611
NXLog User Guide Chapter 74. Linux System Logs
NXLog will not have access to the facility and severity codes because Rsyslog, by default, follows
NOTE
the BSD Syslog convention of not writing the PRI code to the /var/log/messages file.
By default, NXLog runs as user nxlog and does not have permission to read files in /var/log. The simplest
solution for this is to run NXLog as root by omitting the User option, but it is more secure to provide the
necessary permissions explicitly.
1. Check the user or group ownership of the files in /var/log and configure if necessary. Some distributions
use a group for the log files by default. On Debian/Ubuntu, for example, Rsyslog is configured to use the adm
group. Otherwise, modify the Rsyslog configuration to use different ownership for log files as shown below.
/etc/rsyslog.conf or /etc/rsyslog.d/nxlog.conf
$FileOwner root
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
# Default on Debian/Ubuntu
$FileGroup adm
2. Run NXLog under a user or group that has permission to read the log files. Either use a user or group directly
with the User or Group option in nxlog.conf, or add the nxlog user to a group that has permission. For
example, on Debian/Ubuntu add the nxlog user to the adm group by running usermod -a -G adm nxlog.
3. If necessary, fix permissions for any files NXLog will be reading from that already exist (use the correct group
for your system).
4. Configure NXLog to read from the required file(s) (see the example below). Then restart NXLog.
5. If the Rsyslog configuration has been modified, restart Rsyslog (systemctl restart rsyslog).
612
Chapter 74. Linux System Logs NXLog User Guide
With the following configuration, NXLog will read logs from /var/log/messages, parse the events as
Syslog, convert them to JSON, and forward the plain JSON to another host via TCP.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/log/messages'
12 Exec parse_syslog();
13 </Input>
14
15 <Output out>
16 Module om_tcp
17 Host 192.168.1.1
18 Port 1514
19 Exec $raw_event = to_json();
20 </Output>
613
NXLog User Guide Chapter 75. Log Event Extended Format (LEEF)
The LEEF log format is used by IBM Security QRadar products and supports Syslog as a transport. It describes an
event using key-value pairs, and provides a list of predefined event attributes. Additional attributes can be used
for specific applications.
• LEEF version
• Vendor
• Product name
• Product version
• Event ID
• Optional delimiter character, as the character or its hexadecimal value prefixed by 0x or x (LEEF version 2.0)
The EVENT_ATTRIBUTES part contains a list of key-value pairs separated by a tab or the delimiter specified in the
LEEF header.
614
Chapter 75. Log Event Extended Format (LEEF) NXLog User Guide
With the following configuration, NXLog will accept LEEF logs via TCP, convert them to JSON, and output the
result to file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _leef>
6 Module xm_leef
7 </Extension>
8
9 <Input in>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 Exec parse_leef();
14 </Input>
15
16 <Output out>
17 Module om_file
18 File '/var/log/json'
19 Exec to_json();
20 </Output>
Input Sample
Oct 11 11:27:23 myserver LEEF:2.0|Microsoft|MSExchange|2013 SP1|15345|src=10.50.1.1 ⇥
dst=2.10.20.20 ⇥ spt=1200↵
Output Sample
{
"EventReceivedTime": "2016-10-11 11:27:24",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"Hostname": "myserver",
"LEEFVersion": "LEEF:2.0",
"Vendor": "Microsoft",
"SourceName": "MSExchange",
"Version": "2013 SP1",
"EventID": "15345"
}
615
NXLog User Guide Chapter 75. Log Event Extended Format (LEEF)
With this configuration, NXLog will parse the input JSON format from file and forward it as LEEF via TCP.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _leef>
6 Module xm_leef
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/log/json'
12 Exec parse_json();
13 </Input>
14
15 <Output out>
16 Module om_tcp
17 Host 10.12.0.1
18 Port 514
19 Exec to_leef();
20 </Output>
Input Sample
{
"EventTime": "2016-09-13 11:23:11",
"Hostname": "myserver",
"Purpose": "test",
"Message": "This is a test log message."
}
Output Sample
<13>Sep 13 11:23:11 myserver LEEF:1.0|NXLog|in|3.0.1775|unknown|EventReceivedTime=2016-09-13
11:23:12 ⇥ SourceModuleName=in ⇥ SourceModuleType=im_file ⇥ devTime=2016-09-13 11:23:11 ⇥
identHostName=myserver ⇥ Purpose=test ⇥ Message=This is a test log message. ⇥
devTimeFormat=yyyy-MM-dd HH:mm:ss↵
616
Chapter 76. McAfee Enterprise Security Manager (ESM) NXLog User Guide
NXLog can be configured to collect events and forward them to ESM. This chapter provides information about
setting up NXLog to forward events from several types of log sources.
NOTE The instructions and examples in this chapter were tested with ESM 11.2.0.
1. Create or locate a certificate authority (CA) certificate and private key. The CA certificate (for example,
rootCA.pem) will be used by the NXLog agent to authenticate the ESM receiver in Forwarding Logs below.
2. Create a certificate and private key for ESM (for example, server.crt and server.key).
3. Upload the server.crt and server.key files to ESM (for more information, see Install SSL certificate on
McAfee.com):
a. On the McAfee web interface, open the menu in the upper left corner, click on System Properties, and
choose ESM Management in the left panel.
b. Open the Key Management tab and click Certificate.
c. Select Upload Certificate, click Upload, acknowledge the notification, and upload the certificate files.
4. When adding or editing a log source, check Require syslog TLS (see Adding a Log Source below).
617
NXLog User Guide Chapter 76. McAfee Enterprise Security Manager (ESM)
receiver.
1. On the McAfee web interface, open the menu in the upper left corner and click on More Settings.
2. Select the Local Receiver-ELM in the left panel and click on Add Data Source.
3. Choose a Data Source Vendor, Data Source Model, Data Format, and Data Retrieval. Consult the
sections below for the correct values to use for each log source type.
618
Chapter 76. McAfee Enterprise Security Manager (ESM) NXLog User Guide
Field Value
For more information, see DHCP server audit logging and the Microsoft DHCP Server page in the McAfee ESM
Data Source Configuration Reference Guide.
In this example, NXLog is configured to read logs from the DhcpSrvLog and DhcpV6SrvLog log files. NXLog
then adds a Syslog header with xm_syslog to prepare the events for forwarding to ESM.
Input Sample
64,08/31/19,14:38:17,No static IP address bound to DHCP server,,,,,0,6,,,,,,,,,0↵
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input dhcp>
6 Module im_file
7 File 'C:\Windows\System32\dhcp\DhcpSrvLog-*.log'
8 File 'C:\Windows\System32\dhcp\DhcpV6SrvLog-*.log'
9 <Exec>
10 # Discard header lines
11 if $raw_event !~ /^\d+,/ drop();
12
13 # Add Syslog header
14 $Message = $raw_event;
15 to_syslog_bsd();
16 </Exec>
17 </Input>
Output Sample
<13>Aug 31 14:38:17 Host 64,08/31/19,14:38:17,No static IP address bound to DHCP
server,,,,,0,6,,,,,,,,,0↵
619
NXLog User Guide Chapter 76. McAfee Enterprise Security Manager (ESM)
Field Value
For more information, see Windows DNS Server and the Microsoft DNS Debug page in the McAfee ESM Data
Source Configuration Reference Guide.
The following configuration uses im_file to read from the Windows DNS debug log. A Syslog header is
added with the xm_syslog to_syslog_bsd() procedure.
Input Sample
8/31/2019 15:17:04 PM 2AE8 PACKET 00000005D03B4CE0 UDP Snd 192.168.1.42 fdd7 R Q [8081 DR
NOERROR] A (9)imap-mail(7)outlook(3)com(0)↵
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File 'C:\logs\dns.log'
8 <Exec>
9 # Discard header lines
10 if $raw_event !~ /^\d+\/\d+\/\d+/ drop();
11
12 # Add Syslog header
13 $Message = $raw_event;
14 to_syslog_bsd();
15 </Exec>
16 </Input>
Output Sample
<13>Aug 31 15:17:04 Host 8/31/2019 15:17:04 PM 2AE8 PACKET 00000005D03B4CE0 UDP Snd
192.168.1.42 fdd7 R Q [8081 DR NOERROR] A (9)imap-mail(7)outlook(3)com(0)↵
Field Value
620
Chapter 76. McAfee Enterprise Security Manager (ESM) NXLog User Guide
Field Value
For more information about collecting Windows Event Log, see the Windows Event Log chapter.
In this configuration, Windows Event Log data is collected from the Security channel with im_msvistalog and
converted to CEF with a Syslog header.
nxlog.conf
1 <Extension _cef>
2 Module xm_cef
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input eventlog>
10 Module im_msvistalog
11 Channel Security
12 <Exec>
13 $Message = to_cef();
14 to_syslog_bsd();
15 </Exec>
16 </Input>
Output Sample
<14>Sep 25 23:25:53 WINSERV Microsoft-Windows-Security-Auditing[568]:
CEF:0|NXLog|NXLog|4.99.5128|0|-|7|end=1569453953000 dvchost=WINSERV
Keywords=9232379236109516800 outcome=AUDIT_SUCCESS SeverityValue=2 Severity=INFO
externalId=4801 SourceName=Microsoft-Windows-Security-Auditing ProviderGuid={54849625-5478-
4994-A5BA-3E3B0328C30D} Version=0 TaskValue=12551 OpcodeValue=0 RecordNumber=395661
ActivityID={61774D29-73EB-0000-4B4D-7761EB73D501} ExecutionProcessID=568 ExecutionThreadID=3164
deviceFacility=Security msg=The workstation was unlocked.\r\n\r\nSubject:\r\n\tSecurity
ID:\t\tS-1-5-21-2262720663-2632382095-2856924348-500\r\n\tAccount
Name:\t\tAdministrator\r\n\tAccount Domain:\t\tWINSERV\r\n\tLogon ID:\t\t0x112FE1\r\n\tSession
ID:\t1 cat=Other Logon/Logoff Events Opcode=Info duid=S-1-5-21-2262720663-2632382095-
2856924348-500 duser=Administrator dntdom=WINSERV TargetLogonId=0x112fe1 SessionId=1
EventReceivedTime=1569453953949 SourceModuleName=eventlog SourceModuleType=im_msvistalog↵
621
NXLog User Guide Chapter 76. McAfee Enterprise Security Manager (ESM)
This om_tcp instance sends logs to ESM via TCP. In this example, events are sent from the Windows Event
Log source.
nxlog.conf
1 <Output esm>
2 Module om_tcp
3 Host 10.10.1.10
4 Port 514
5 </Output>
6
7 <Route r>
8 Path eventlog => esm
9 </Route>
Forwarding logs with TLS requires adding a certificate to ESM and setting Require syslog TLS on the data
source(s), as described in the Set up TLS Transport section.
The om_ssl module is used here to send logs to ESM securely, with TLS encryption.
nxlog.conf
1 <Output esm>
2 Module om_ssl
3 Host 10.10.1.10
4 Port 6514
5 CAFile C:\Program Files\cert\rootCA.pem
6 </Output>
622
Chapter 77. McAfee ePolicy Orchestrator NXLog User Guide
NXLog can be configured to collect events and audit logs from the ePO SQL databases.
The instructions and examples in this section were tested with ePolicy Orchestrator 5.10.0 and
NOTE
NXLog running on the same server.
ePO will need to have the associated packages installed first, prior to log collection from these
NOTE sources. For example, VirusScan Enterprise or Host Intrusion Prevention Content must be
installed.
623
NXLog User Guide Chapter 77. McAfee ePolicy Orchestrator
ePO stores these logs in the dbo.OrionAuditLog table in the SQL database. The following configuration
will query dbo.OrionAuditLog using the im_odbc module configured to collect these audit log events. It
will then format them to JSON via xm_json.
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString DSN=MQIS;database=ePO_Host; \
4 uid=user;pwd=password;
5 IdType timestamp
6 # With ReadFromLast and MaxIdSQL, NXLog will start reading from the last
7 # record when reading from the database for the first time.
8 ReadFromLast TRUE
9 MaxIdSQL SELECT MAX(StartTime) AS maxid FROM dbo.OrionAuditLog
10 SQL SELECT StartTime as id,StartTime as EventTime, \
11 * FROM dbo.OrionAuditLog \
12 WHERE StartTime > CAST(? AS datetime)
13 Exec delete($id);to_json();
14 </Input>
624
Chapter 77. McAfee ePolicy Orchestrator NXLog User Guide
625
NXLog User Guide Chapter 77. McAfee ePolicy Orchestrator
The following configuration uses the im_odbc module to collect VirusScan events from the dbo.EPOEvents
SQL view. The AnalyzerName column determines the source module of the events in the view, therefore the
query contains the conditional clause AnalyzerName LIKE 'VirusScan%.
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString DSN=MQIS;database=ePO_Host; \
4 uid=user;pwd=password;
5 IdType timestamp
6 # With ReadFromLast and MaxIdSQL, NXLog will start reading from the last
7 # record when reading from the database for the first time.
8 #ReadFromLast TRUE
9 #MaxIdSQL SELECT MAX(ReceivedUTC) AS maxid FROM dbo.EPOEvents
10 SQL SELECT ReceivedUTC as id,ReceivedUTC as EventTime,AutoID,ServerID,\
11 AnalyzerName,AnalyzerHostName,\
12 dbo.RSDFN_ConvertIntToIPString \
13 (cast (AnalyzerIPV4 as varchar(15))) as 'IPv4',\
14 AnalyzerDetectionMethod,SourceHostName,\
15 dbo.RSDFN_ConvertIntToIPString \
16 (cast (SourceIPV4 as varchar(15))) as 'Source IPv4',\
17 SourceProcessName,TargetHostName,\
18 dbo.RSDFN_ConvertIntToIPString \
19 (cast (TargetIPV4 as varchar(15))) as 'Target IPv4',\
20 TargetUserName,TargetFileName,ThreatCategory,ThreatEventID,\
21 ThreatSeverity,ThreatName,ThreatType,ThreatActionTaken,TenantID\
22 FROM dbo.EPOEvents\
23 WHERE ReceivedUTC > CAST(? AS datetime) AND AnalyzerName LIKE 'VirusScan%'
24 Exec delete($id);to_json();
25 </Input>
626
Chapter 77. McAfee ePolicy Orchestrator NXLog User Guide
627
NXLog User Guide Chapter 77. McAfee ePolicy Orchestrator
The configuration below uses the im_odbc module to collect Data Loss Prevention events from the
dbo.EPOEvents SQL view. The AnalyzerName column determines the source module of events in the view,
therefore the query contains the conditional clause AnalyzerName LIKE 'Data%.
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString DSN=MQIS;database=ePO_Host; \
4 uid=user;pwd=password;
5 IdType timestamp
6 # With ReadFromLast and MaxIdSQL, NXLog will start reading from the last
7 # record when reading from the database for the first time.
8 #ReadFromLast TRUE
9 #MaxIdSQL SELECT MAX(ReceivedUTC) AS maxid FROM dbo.EPOEvents
10 SQL SELECT ReceivedUTC as id,ReceivedUTC as EventTime,AutoID,ServerID,\
11 AnalyzerName,AnalyzerHostName,\
12 dbo.RSDFN_ConvertIntToIPString \
13 (cast (AnalyzerIPV4 as varchar(15))) as 'IPv4',\
14 AnalyzerDetectionMethod,SourceHostName,\
15 dbo.RSDFN_ConvertIntToIPString \
16 (cast (SourceIPV4 as varchar(15))) as 'Source IPv4',\
17 SourceProcessName,TargetHostName,\
18 dbo.RSDFN_ConvertIntToIPString \
19 (cast (TargetIPV4 as varchar(15))) as 'Target IPv4',\
20 TargetUserName,TargetFileName,ThreatCategory,ThreatEventID,\
21 ThreatSeverity,ThreatName,ThreatType,ThreatActionTaken,TenantID\
22 FROM dbo.EPOEvents\
23 WHERE ReceivedUTC > CAST(? AS datetime) AND AnalyzerName LIKE 'Data%'
24 Exec delete($id);to_json();
25 </Input>
628
Chapter 78. Microsoft Active Directory Domain Controller NXLog User Guide
For a full list of Active Directory events that should be monitored, see Events to Monitor on Microsoft Docs.
Event Description
ID
4649 A replay attack was detected. May be a harmless false positive due to a misconfiguration error.
4794 An attempt was made to set the Directory Services Restore Mode.
629
NXLog User Guide Chapter 78. Microsoft Active Directory Domain Controller
In this example, im_msvistalog is used to capture the most important security-related events on a Windows
Server 2012/2016 domain controller.
The Event Log supports a limited number of Event IDs in a query. Due to this limitation, an
NOTE Exec block is used to match the required Event IDs rather than listing every Event ID in the
query.
nxlog.conf (truncated)
1 define SecurityIDs 4618, 4649, 4719, 4765, 4766, 4794, 4897, 4964, 5124, \
2 4621, 4675, 4692, 4693, 4706, 4713, 4714, 4715, 4716, \
3 4724, 4727, 4735, 4737, 4739, 4754, 4755, 4764, 4780, \
4 4816, 4865, 4866, 4867, 4868, 4870, 4882, 4885, 4890, \
5 4892, 4896, 4906, 4907, 4908, 4912, 4960, 4961, 4962, \
6 4963, 4965, 4976, 4977, 4978, 4983, 4984, 5027, 5028, \
7 5029, 5030, 5035, 5037, 5038, 5120, 5121, 5122, 5123, \
8 5376, 5377, 5453, 5480, 5483, 5484, 5485, 6145, 6273, \
9 6274, 6275, 6276, 6277, 6278, 6279, 6280, 4608, 4609, \
10 4610, 4611, 4612, 4614, 4615, 4616, 4624, 4625, 4634, \
11 4647, 4648, 4656, 4657, 4658, 4660, 4661, 4662, 4663, \
12 4672, 4673, 4674, 4688, 4689, 4690, 4691, 4696, 4697, \
13 4698, 4699, 4700, 4701, 4702, 4704, 4705, 4707, 4717, \
14 4718, 4720, 4722, 4723, 4725, 4726, 4728, 4729, 4730, \
15 4731, 4732, 4733, 4734, 4738, 4740, 4741, 4742, 4743, \
16 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, \
17 4753, 4756, 4757, 4758, 4759, 4760, 4761, 4762, 4767, \
18 4768, 4769, 4770, 4771, 4772, 4774, 4775, 4776, 4778, \
19 4779, 4781, 4783, 4785, 4786, 4787, 4788, 4789, 4790, \
20 4869, 4871, 4872, 4873, 4874, 4875, 4876, 4877, 4878, \
21 4879, 4880, 4881, 4883, 4884, 4886, 4887, 4888, 4889, \
22 4891, 4893, 4894, 4895, 4898, 5136, 5137
23
24 define BitLockerIDs 24586, 24592, 24593, 24594
25
26 define EventlogID 1102
27
28 define SecuritySrc Microsoft-Windows-Security-Auditing
29 [...]
630
Chapter 78. Microsoft Active Directory Domain Controller NXLog User Guide
4. Go to Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit
Policy Configuration > Audit Policies > DS Access.
631
NXLog User Guide Chapter 78. Microsoft Active Directory Domain Controller
5. Enable the four listed polices to provide access to security auditing events.
For more information on configuring the Advanced Security Auditing Policy, and descriptions of event IDs, please
view Step-By-Step: Enabling Advanced Security Audit Policy via DS Access on Microsoft TechNet.
632
Chapter 78. Microsoft Active Directory Domain Controller NXLog User Guide
Once security auditing has been enabled, the related events in the Event Log can be queried and collected
by NXLog with the im_msvistalog module. This configuration collects all Windows Security Auditing events
that have an Event Level of critical, warning, or error.
nxlog.conf
1 <Input SecurityAuditEvents>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0" Path="Security">
6 <Select Path="Security">*[System[Provider[@Name='Microsoft-Windows
7 -Security-Auditing'] and (Level=1 or Level=2 or Level=3) and
8 ((EventID=4928 and EventID=4931) or (EventID=4932 and EventID=4937)
9 or EventID=4662 or (EventID=5136 and EventID = 5141))]]</Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 </Input>
For more information on troubleshooting domain controller promotions and installations, please view
Troubleshooting Domain Controller Deployment
633
NXLog User Guide Chapter 78. Microsoft Active Directory Domain Controller
This configuration uses the im_file module to read from all dcpromo log files. Each event is parsed with a
regular expression, and then the timestamp is parsed with the parsedate() function.
Log Sample
10/02/2018 04:43:47 [INFO] Creating directory partition: CN=Configuration,DC=nxlog,DC=org; 1270
objects remaining↵
10/02/2018 04:43:47 [INFO] Creating directory partition: CN=Configuration,DC=nxlog,DC=org; 1269
objects remaining↵
10/02/2018 04:43:47 [INFO] Creating directory partition: CN=Configuration,DC=nxlog,DC=org; 1268
objects remaining↵
nxlog.conf
1 <Input dcpromo>
2 Module im_file
3 File "%systemroot%\debug\DCPROMO.log"
4 File "%systemroot%\debug\DCPROMO.*.log"
5 <Exec>
6 if $raw_event =~ /^(\S+ \S+) \[(\S+)\] (.+)$/
7 {
8 $EventTime = parsedate($1);
9 $Severity = $2;
10 $Message = $3;
11 }
12 </Exec>
13 </Input>
634
Chapter 79. Microsoft Azure NXLog User Guide
NXLog can be set up to collect event data from Azure AD and Office 365 APIs. This functionality is available as an
add-on. See Microsoft Azure and Office 365 for more information.
NXLog can be configured to connect to the OMS Log Analytics service and forward or collect log data via its REST
API. See the Azure OMS and Log Analytics documentation for more information about configuring and using
Azure OMS and its log management service.
1. Log in to the Azure portal and go to the Log Analytics service (for instance by typing the service name into
the search bar).
2. Select an existing OMS Workspace or create a new one by clicking the Add button.
3. From the Management section in the main workspace screen, click OMS Portal.
4. In the Microsoft Operations Management Suite, click the settings icon in the top right corner, navigate to
Settings > Connected Sources > Linux Servers, and copy the WORKSPACE ID and PRIMARY KEY values.
These are needed for API access.
635
NXLog User Guide Chapter 79. Microsoft Azure
5. Enable Custom Logs. As of this writing it is a preview feature, available under Settings > Preview Features >
Custom Logs.
6. Place the oms-pipe.py script in a location accessible by NXLog and make sure it is executable by NXLog.
7. Set the customer ID, shared key, and log type values in the script.
8. Configure NXLog to execute the script with the om_exec module. The contents of the $raw_event field will
be forwarded.
636
Chapter 79. Microsoft Azure NXLog User Guide
This configuration reads raw events from file and forwards them to Azure OMS.
nxlog.conf
1 <Input messages>
2 Module im_file
3 File '/var/log/messages'
4 </Input>
5
6 <Output azure_oms>
7 Module om_exec
8 Command oms-pipe.py
9 </Output>
oms-pipe.py (truncated)
#!/usr/bin/env python
# This is a PoF script that can be used with 'om_exec' NXLog module to
# ship logs to Microsoft Azure Cloud (Log Analytics / OMS) via REST API.
# NXLog configuration:
# -------------------
# <Output out>
# Module om_exec
# Command /tmp/samplepy
# </Output>
# -------------------
import requests
import datetime
import hashlib
import hmac
import base64
[...]
637
NXLog User Guide Chapter 79. Microsoft Azure
With this configuration, NXLog Enterprise Edition reads W3C records with from file with im_file, parses the
records with xm_w3c, converts the internal event fields to JSON format with xm_json to_json(), and forwards
the result to Azure OMS with om_exec.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension w3c_parser>
6 Module xm_w3c
7 </Extension>
8
9 <Input messages>
10 Module im_file
11 File '/var/log/httpd-log'
12 InputType w3c_parser
13 </Input>
14
15 <Output azure_oms>
16 Module om_exec
17 Command oms-pipe.py
18 Exec to_json();
19 </Output>
1. Register an application in Azure Active Directory and generate an access key for the application.
2. Under your Subscription, go to Access control (IAM) and assign the Log Analytics Reader role to this
application.
3. Place the oms-download.py script in a location accessible by NXLog.
4. Set the resource group, workspace, subscription ID, tenant ID, application ID, and application key values in
the script. Adjust the query details as required.
The Tenant ID can be found as Directory ID under the Azure Active Directory Properties
NOTE
tab.
638
Chapter 79. Microsoft Azure NXLog User Guide
This configuration uses the im_python module and the oms-download.py script to periodically collect log
data from the Log Analytics service.
nxlog.conf
1 <Input oms>
2 Module im_python
3 PythonCode oms-download.py
4 </Input>
oms-download.py (truncated)
import datetime
import json
import requests
import adal
import nxlog
class LogReader:
Azure SQL database includes auditing features that can be used to generate events based on audit policies.
NXLog can be used as a collector for audit data from an Azure SQL Database instance.
It is also possible to send SQL audit logs directly to OMS Log Analytics. This can be configured on
the Azure portal; see Get started with SQL database auditing on Microsoft Docs. In this case, see
NOTE
Azure Operations Management Suite (OMS) for information about integrating NXLog with OMS
Log Analytics.
To start with, auditing for an instance must be enabled; see Get started with SQL database auditing in the Azure
documentation for detailed steps. Once this is done, NXLog can be configured to periodically download the audit
logs using either PowerShell or Python.
639
NXLog User Guide Chapter 79. Microsoft Azure
The procedure for non-interactive Azure authentication might vary, depending on the account
type. This example assumes that a service principal to access resources has been created. For
detailed information about creating an identity for unattended script execution, see Use Azure
NOTE PowerShell to create a service principal with a certificate in the Azure documentation.
Alternatively, Save-AzureRmContext can be used to store account information in a JSON file
and it can be loaded later with Import-AzureRmContext.
640
Chapter 79. Microsoft Azure NXLog User Guide
This configuration uses im_exec to run the azure-sql.ps1 PowerShell script. The xm_json module is used
to parse the JSON event data into NXLog fields.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 envvar systemroot
6 <Input azure_sql>
7 Module im_exec
8 Command "%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe"
9 # Bypass the system execution policy for this session only.
10 Arg "-ExecutionPolicy"
11 Arg "Bypass"
12 # Skip loading the local PowerShell profile.
13 Arg "-NoProfile"
14 # This specifies the path to the PowerShell script.
15 Arg "-File"
16 Arg "%systemroot%\azure_sql.ps1"
17 <Exec>
18 # Parse JSON
19 parse_json();
20
21 # Convert $EventTime field to datetime
22 $EventTime = parsedate($event_time);
23 </Exec>
24 </Input>
azure-sql.ps1 (truncated)
# If running 32-bit on a 64-bit system, run 64-bit PowerShell instead.
if ( $env:PROCESSOR_ARCHITEW6432 -eq "AMD64" ) {
Write-Output "Running 64-bit PowerShell."
&"$env:SYSTEMROOT\SysNative\WindowsPowerShell\v1.0\powershell.exe" `
-NonInteractive -NoProfile -ExecutionPolicy Bypass `
-File "$($myInvocation.InvocationName)" $args
exit $LASTEXITCODE
}
################################################################################
• The script requires installation of the Microsoft ODBC Driver; see Installing the Microsoft ODBC Driver for
SQL Server on Linux and macOS on Microsoft Docs.
641
NXLog User Guide Chapter 79. Microsoft Azure
This configuration uses the im_python module to execute the azure-sql.py Python script. The script logs
in to Azure, collects audit logs, and creates NXLog events.
nxlog.conf
1 <Input sql>
2 Module im_python
3 PythonCode azure_sql.py
4 Exec $EventTime = parsedate($EventTime);
5 </Input>
azure-sql.py (truncated)
import binascii, collections, datetime, nxlog, pyodbc
from azure.storage.blob import PageBlobService
################################################################################
# MSSQL details
DRIVER = "{ODBC Driver 13 for SQL Server}"
SERVER = 'tcp:XXXXXXXX.database.windows.net'
DATABASE = 'XXXXXXXX'
USERNAME = 'XXXXXXXX@XXXXXXXX'
PASSWORD = 'XXXXXXXX'
642
Chapter 80. Microsoft Azure Event Hubs NXLog User Guide
NXLog can be configured to send data to Azure Event Hubs via the Kafka and HTTP protocols using the om_kafka
and om_http modules. NXLog can also receive log data from Azure Event Hubs via the Kafka protocol using the
im_kafka module.
Kafka requires at least a Standard Tier, while HTTP works with any tier. For more information on tiers, see the
What is the difference between Event Hubs Basic and Standard tiers? section in the Microsoft documentation.
With both methods a SAS (Shared Access Signature) is used for authentication.
Once signed in to Azure, a resource group an Event Hubs namespace and an event hub need to be created. The
names of these will be required when configuring NXLog.
With all of the above created, the event hub can be found by browsing to the Home > Event Hubs >
<YOURNAMESPACE> > Event Hubs page in the Azure portal. This page lists some basic details about the event
hub as well as graphs of the data flow. In addition, the left side panel serves as a control panel for managing your
event hub.
• The entry for the BrokerList directive. This is derived from the name of the namespace and a fixed URL
with a port number and looks like: <YOURNAMESPACE>.servicebus.windows.net:9093. The namespace
needs to be changed to match your environment.
• The name of the event hub created in Azure for the Topic directive.
• The name of your resource group defined in an Option directive. Read more about What is a resource group
in the Microsoft Documentation.
• Either your primary key or your secondary key will be needed per the instructions in Get an Event Hubs
connection string for retrieving the connection string defined in an Option directive as a SASL password.
• A CA certificate, even though it is not listed as a requirement by Azure Event Hubs.
643
NXLog User Guide Chapter 80. Microsoft Azure Event Hubs
Example 377. Sending Windows Event Log events to Azure Event Hubs with Kafka
In this configuration the logs are forwarded to Azure Event Hubs by the om_kafka module.
nxlog.conf
1 <Output out>
2 Module om_kafka
3 BrokerList <YOURNAMESPACE>.servicebus.windows.net:9093
4 Topic <YOUREVENTHUB>
5 Option security.protocol SASL_SSL
6 Option group.id <YOURCONSUMERGROUP>
7 Option sasl.mechanisms PLAIN
8 Option sasl.username $ConnectionString
9 Option sasl.password <YOUR Connection string–primary key>
10 CAFile C:\Program Files\nxlog\cert\<ca.pem>
11 </Output>
• A shared access signature (SAS) token. The Microsoft documentation lists various scripts and methods to
generate a SAS token. For the example below, the PowerShell example were used. None of the other
methods or scripts were tested.
• Entries for the URL directive and the Host HTTP header set by the AddHeader directive require the name of
the namespace you have created.
TIP The PowerShell example can be executed in the Azure Cloud Shell using the Try it button.
The om_http module also supports sending logs in batches by defining the BatchMode directive. The accepted
values for this directive are multiline and multipart, however Azure Event Hubs can only process logs sent
with the multiline batching method.
Example 378. Sending Linux kernel logs to Event Hub with HTTP
In this configuration logs are sent to Azure Event Hubs using the om_http module with BatchMode enabled.
nxlog.conf
1 <Output out>
2 Module om_http
3 BatchMode multiline
4 URL https://<YOURNAMESPACE>.servicebus.windows.net/nxlogeventhub/messages
5 HTTPSCAFile C:\cacert.pem
6 AddHeader Authorization: <YOURSASTOKEN>
7 AddHeader Content-Type: application/atom+xml;type=entry;charset=utf-8
8 AddHeader Host: <YOURNAMESPACE>.servicebus.windows.net
9 </Output>
644
Chapter 80. Microsoft Azure Event Hubs NXLog User Guide
The easiest was to look at it is to browse to the Home > Event Hubs > <YOURNAMESPACE> > Event Hubs page
in the Azure portal where Microsoft provides a chart which displays incoming and outgoing message counts as
well as event throughput metrics.
Logs forwarded to Azure Event Hubs by NXLog can also be collected using the im_kafka module. The logs
collected with this method are identical to the ones sent to Azure Event Hubs.
This configuration uses the same settings as the om_kafka configuration in the first example. The only
difference is the direction of the log flow. This configuration collects the logs and writes them to a file.
nxlog.conf
1 <Input in>
2 Module im_kafka
3 BrokerList nxlognamespace.servicebus.windows.net:9093
4 Topic nxlogeventhub
5 Option security.protocol SASL_SSL
6 Option group.id nxlogconsumergroup
7 Option sasl.mechanisms PLAIN
8 Option sasl.username $ConnectionString
9 Option sasl.password <Connection string–primary key>
10 CAFile C:\Program Files\nxlog\cert\ca.pem
11 </Input>
12
13 <Output file>
14 Module om_file
15 File "C:\\logs\\logmsg.txt"
16 </Output>
In addition to the above, Azure Event Hubs provides facilities to feed data into Azure’s own storage technologies
such as Azure Blob Storage and Azure Data Lake Storage where data reception can also be confirmed. However,
these methods are outside of the scope of this document.
When deciding on which method to use for sending logs to Azure Event Hubs, performance, throughput, and size
can all be important and decisive factors. It is important to note, when measuring throughput, the performance
of a system depends on a number of factors including, but not limited to:
• The performance and resource availability of the node which NXLog runs on.
645
NXLog User Guide Chapter 80. Microsoft Azure Event Hubs
• The performance and capability of any networking equipment between MS Azure Event Hubs and the
machine NXLog runs on.
• The quality of service provided by your ISP. This includes bandwidth restrictions as well.
• Your geographic location and how you set up Azure Event Hubs.
• The number of throughput units you have purchased with your Azure Event Hubs subscription.
In addition, it is worth considering which tier to use as Kafka requires a more expensive subscription as it is not
available in the Basic Tier according to the Event Hubs pricing.
In our tests we have used a single data throughput unit generating data with the im_testgen module and
concluded that both Kafka and HTTP works reliably, but HTTP offers better throughput especially with batching
enabled.
646
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
Failure to install the NXLog Perl package for Debian/Ubuntu will result in the following error
message:
See the Packages in a Debian/Ubuntu Archive table for details about installing individual
packages.
647
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
Since the Azure Monitor authentication system does not use static tokens, a dynamically-generated, hashed
string that can only be generated programmatically with cryptographic libraries is required for each HTTP
request. As such, the following Perl script has been developed for use with the Perl (xm_perl) module which
needs to be located relative to the agent’s NXLog installation directory as follows:
Linux
%INSTALLDIR%/lib/nxlog/modules/extension/perl/sentinelauth.pl
sentinelauth.pl (truncated)
#!/usr/bin/perl
use strict;
use warnings;
use Log::Nxlog;
use MIME::Base64;
use Digest::SHA qw(hmac_sha256);
BEGIN {
# Statements to be executed when NXLog starts
}
648
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
Windows
%INSTALLDIR%\modules\extension\perl\sentinelauth.pl
sentinelauth.pl (truncated)
use lib 'c:\Program Files\nxlog\data';
use strict;
use warnings;
use Log::Nxlog;
use MIME::Base64;
use Digest::SHA qw(hmac_sha256);
BEGIN {
# Statements to be executed when NXLog starts
}
The line in the script which defines $logMessage can be commented or removed if desired. It is
included here to provide a means of debugging. On both Linux and Windows, the output will be
sent to nxlog.log:
2020-07-28 23:00:43 INFO [om_http|http] Generated from Shared Key and hashed signing
NOTE
string based on:
ContentLength: 674;
x-ms-date: Wed, 29 Jul 2020 04:00:43 GMT;
Authorization: SharedKey 18fb21ab-d8d4-4448-bdf6-
3748c9c03135:tnYTXEkqWw35Nunv4X4o3kXM727KeEhQ5vQR4ubPkkg=
From this script it is readily apparent that the hashed part of the authorization string will vary according to the
following:
The keys needed by the hashing algorithm are passed to the sentinelauth.pl Perl script via the NXLog
configuration as demonstrated in the following example.
649
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
In this example, the NXLog Linux Audit System im_linuxaudit module is used as the event source. However,
basically any event source that has been captured and converted to JSON format can be forwarded to
Azure Sentinel once the correct keys have been defined in a configuration similar to the one featured
below.
Please note that the first (opening) line of the Input block defines the name of this instance as
LinuxAudit. This is the name that will be used for the Azure Sentinel table where these events will be
collected.
The xm_resolver module is needed for the ResolveValues directive in the audit input instance, where it is
used for resolving some of the numeric values to human readable string values.
The first five define directives establish the constants needed for constructing the REST API’s URL,
resource, and the keys needed for authorization. The define SIZELIMIT 65000 directive sets the
maximum payload size in bytes to the HTTP(s) (om_http) module limit. This enables batch forwarding of
multiple events to minimize the number of HTTP connections needed for forwarding events to Azure
Sentinel.
The xm_perl plxm instance provides access to the requisite hashing algorithm for generating the
Authorization header string. The om_http module contructs the HTTP request and uses three
add_http_header() procedure calls to set the custom headers.
The second add_http_header() procedure call defines the table, $SourceModuleName, to which the events
will be forwarded within Azure Sentinel’s set of Custom Tables. In this case, the input instance’s name is
LinuxAudit. Azure automatically appends _CL to all Custom Tables thus the table will appear as
LinuxAudit_CL in the list of Custom Tables.
650
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _resolver>
6 Module xm_resolver
7 </Extension>
8
9 <Input LinuxAudit>
10 Module im_linuxaudit
11 FlowControl FALSE
12 LoadRule "src/docs/topics/high-availability/snippets/im_linuxaudit.rules"
13 ResolveValues TRUE
14 Exec to_json();
15 </Input>
16
17 define WORKSPACE 18fb21ab-d8d4-4448-bdf6-3748c9c03135
18 define SHAREDKEY
VfIQqBoz6fxmnI/E4PKVPza2clH/YAdJ20RnCDwzHCqCMnobYdM1/dD1+KJ6cI6AkR4xPJlTIWI/jfwPU6QHmw==
19 define SUBDOMAIN ods.opinsights.azure.com
20 define RESOURCE api/logs
21 define APIVER api-version=2016-04-01
22 define SIZELIMIT 65000
23
24 <Extension plxm>
25 Module xm_perl
26 PerlCode %INSTALLDIR%/lib/nxlog/modules/extension/perl/sentinelauth.pl
27 </Extension>
28 [...]
The following JSON event was triggered and captured according to a Linux Audit rule. In this instance, a
rules file is defined by the LoadRule directive in the audit input instance shown above.
{
"type": "PATH",
"time": "2020-09-09T01:44:47.783000+00:00",
"seq": 40649,
"item": 1,
"name": "/etc/bind/zones/db.example.com",
"inode": 528911,
"dev": "fc:02",
"mode": "file,644",
"ouid": "root",
"ogid": "bind",
"rdev": "00:00",
"nametype": "CREATE",
"cap_fp": "0",
"cap_fi": "0",
"cap_fe": "0",
"cap_fver": "0",
"cap_frootid": "0",
"EventReceivedTime": "2020-09-09T01:44:47.797048+00:00",
"SourceModuleName": "LinuxAudit",
"SourceModuleType": "im_linuxaudit"
}
Upon successful receipt in the Log Analytics workspace by Azure Monitor, events are further processed and
finally ingested by Azure Sentinel where they can be viewed via user-defined queries.
651
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
After expanding the following event to reveal its columns and their values, it can be verified against the
JSON formatted event above that was sent via the REST API:
652
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
653
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
Example 381. Forwarding Windows DNS Server audit events to Azure Sentinel
In this example, NXLog collects DNS logs via ETW from the Microsoft-Windows-DNSServer provider using
the Event Tracing for Windows (im_etw) module. The collected logs are converted to JSON so that Azure
Sentinel can parse and ingest them. As illustrated in the previous example, basically any log source that has
been captured and converted to JSON format can be forwarded to Azure Sentinel once the correct keys
have been defined in a configuration similar to the one featured below.
Please note that the first (opening) line of the Input block defines the name of this instance as DNS_Logs.
This is the name that will be used for the Azure Sentinel table where these events will be collected.
The first five define directives establish the constants needed for constructing the REST API’s URL,
resource, and the keys needed for authorization. The define SIZELIMIT 65000 directive sets the
maximum payload size in bytes to the HTTP(s) (om_http) module limit. This enables batch forwarding of
multiple events to minimize the number of HTTP connections needed for forwarding events to Azure
Sentinel.
The xm_perl plxm instance provides access to the requisite hashing algorithm for generating the
Authorization header string. The om_http module contructs the HTTP request and uses three
add_http_header() procedure calls to set the custom headers. The second add_http_header() procedure call
defines the table, $SourceModuleName, to which the events will be forwarded within Azure Sentinel’s set of
Custom Tables. In this case, the input instance’s name is DNS_Logs. Azure automatically appends _CL to all
Custom Tables thus the table will appear as DNS_Logs_CL in the list of Custom Tables.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input DNS_Logs>
6 Module im_etw
7 Provider Microsoft-Windows-DNSServer
8 Exec to_json();
9 </Input>
10
11 define WORKSPACE 18fb21ab-d8d4-4448-bdf6-3748c9c03135
12 define SHAREDKEY
VfIQqBoz6fxmnI/E4PKVPza2clH/YAdJ20RnCDwzHCqCMnobYdM1/dD1+KJ6cI6AkR4xPJlTIWI/jfwPU6QHmw==
13 define SUBDOMAIN ods.opinsights.azure.com
14 define RESOURCE api/logs
15 define APIVER api-version=2016-04-01
16 define SIZELIMIT 65000
17
18 <Extension plxm>
19 Module xm_perl
20 PerlCode %INSTALLDIR%\modules\extension\perl\sentinelauth.pl
21 </Extension>
22
23 <Output AzureHTTP>
24 Module om_http
25 URL https://%WORKSPACE%.%SUBDOMAIN%/%RESOURCE%?%APIVER%
26 ContentType application/json
27 HTTPSAllowUntrusted TRUE
28 HTTPSCAFile %INSTALLDIR%\cert\ca-certificates.crt
29 [...]
The following event is typical of Windows DNS Server Audit events captured by the im_etw module. Based
on EventId 516 logged for this particular event, it is evident that a DNS zone record in the example.com
654
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
{
"SourceName": "Microsoft-Windows-DNSServer",
"ProviderGuid": "{EB79061A-A566-4698-9119-3ED2807060E7}",
"EventId": 516,
"Version": 0,
"ChannelID": 17,
"OpcodeValue": 0,
"TaskValue": 5,
"Keywords": "4611686018428436480",
"EventTime": "2020-09-09T21:34:21.600556-05:00",
"ExecutionProcessID": 1784,
"ExecutionThreadID": 4056,
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Domain": "WIN-FFMCPAJ76HP",
"AccountName": "Administrator",
"UserID": "S-1-5-21-1830054504-3820897498-340727717-500",
"AccountType": "User",
"Flags": "EXTENDED_INFO|IS_64_BIT_HEADER|PROCESSOR_INDEX (577)",
"Type": "1",
"NAME": "u18s1.example.com",
"TTL": "0",
"BufferSize": "4",
"RDATA": "0xC0A80119",
"Zone": "example.com",
"ZoneScope": "Default",
"VirtualizationID": ".",
"EventReceivedTime": "2020-09-09T21:34:23.634177-05:00",
"SourceModuleName": "DNS_Logs",
"SourceModuleType": "im_etw"
}
Upon successful receipt in the Log Analytics workspace by Azure Monitor, events are further processed and
finally ingested by Azure Sentinel where they can be viewed via user-defined queries. Querying for events
having a value of 516 for EventId yields the following list. The second one has the same NAME as the
example above: u18s1.example.com.
655
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
After expanding the following event to reveal its columns and their values, it can be verified against the
JSON formatted event above that was sent via the REST API:
656
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
657
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
658
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
Example 382. Capturing BSM audit events from the macOS kernel
This configuration reads BSM audit events directly from the kernel via the (default) /dev/auditpipe device.
The output instance toAzureHTTPforwarder sends the events to the remote Linux NXLog agent listening
on TCP port 1514 where they will be routed without any additional processing to Azure Sentinel.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input BSMmacOS>
6 Module im_bsm
7 DeviceFile /dev/auditpipe
8 Exec to_json();
9 </Input>
10
11 <Output toAzureHTTPforwarder>
12 Module om_tcp
13 Host mas-relay-1.example.com:1514
14 </Output>
The following JSON sample illustrates a typical kernel audit event captured using this configuration.
{
"TokenVersion": "11",
"EventType": "AUE_ssauthorize",
"EventName": "SecSrvr AuthEngine",
"EventModifier": "",
"EventTime": "2020-12-16 18:20:15",
"SubjectAuditID": "ruser2",
"SubjectUID": "ruser2",
"SubjectGID": "staff",
"SubjectRealUID": "ruser2",
"SubjectRealGID": "staff",
"SubjectPID": "2793",
"SubjectSID": "100041",
"SubjectTerminal": "",
"SubjectTerminal.Port": "0:5486",
"SubjectTerminal.Host": "0.0.0.0",
"Text": "creator /System/Library/CoreServices/Setup Assistant.app",
"ReturnErrno": "failure: Operation not permitted",
"ReturnRetval": "-60007",
"Identity": "",
"Identity.SignerType": "1",
"Identity.SignerId": "com.apple.authd",
"Identity.SignerIdTruncated": "0",
"Identity.TeamId": "",
"Identity.TeamIdTruncated": "0",
"Identity.CDHash": "0x9120b9dcb969ee1e8fbdb63bd428e263111e9e9c",
"TrailerCount": "305",
"EventReceivedTime": "2020-12-16T18:20:15.360930-08:00",
"SourceModuleName": "BSMmacOS",
"SourceModuleType": "im_bsm"
}
659
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
Example 383. Capturing macOS BSM audit events via a Linux relay to Azure Sentinel
In order for the macOS kernel audit logs to be sent to their own unique Azure Sentinel table, the
SourceModuleName must be preserved. The value assigned to SourceModuleName, i.e. the input module’s
instance name, directly determines the name of the Azure Sentinel table that will contain the ingested
event logs. In this example, the instance name BSMmacOS will be used, resulting in BSMmacOS_CL as the table
name.
The following configuration on the remote Linux host functioning as a log event forwarder is comprised of
the Linux audit logs to Azure Sentinel configuration which has been modified and extended to handle not
only its own Linux kernel audit events, but also the macOS kernel audit events it receives. The first notable
change can be seen in lines 9-13 where a new TCP input module instance fromBSMmacOS has been defined.
This input instance listens for macOS kernel audit events on TCP port 1514. Since the data being received is
already in JSON format, it is essential that the parse_json() procedure is executed.
The original output instance (lines 35-80) is generic and could be used to send both Linux and macOS
kernel audit logs to Azure Sentinel were it not for the self-imposed requirement that each log source should
have its own unique Azure Sentinel table. For this reason, the entire output instance has been duplicated in
lines 82-127. Except for their instance names, LinuxAudit_AzureHTTP and BSMmacOS_AzureHTTP, they are
identical.
Finally, the two routes (lines 129-135) ensure that events from each log source remain separate.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _resolver>
6 Module xm_resolver
7 </Extension>
8
9 <input fromBSMmacOS>
10 Module im_tcp
11 ListenAddr 0.0.0.0:1514
12 Exec parse_json();
13 </Input>
14
15 <Input LinuxAudit>
16 Module im_linuxaudit
17 FlowControl FALSE
18 LoadRule "src/docs/topics/high-availability/snippets/im_linuxaudit.rules"
19 ResolveValues TRUE
20 Exec to_json();
21 </Input>
22
23 define WORKSPACE 18fb21ab-d8d4-4448-bdf6-3748c9c03135
24 define SHAREDKEY
VfIQqBoz6fxmnI/E4PKVPza2clH/YAdJ20RnCDwzHCqCMnobYdM1/dD1+KJ6cI6AkR4xPJlTIWI/jfwPU6QHmw==
25 define SUBDOMAIN ods.opinsights.azure.com
26 define RESOURCE api/logs
27 define APIVER api-version=2016-04-01
28 define SIZELIMIT 65000
29 [...]
Upon successful receipt in the Log Analytics workspace by Azure Monitor, macOS kernel audit events are
further processed and finally ingested by Azure Sentinel where they can be viewed via user-defined queries.
660
Chapter 81. Microsoft Azure Sentinel NXLog User Guide
After expanding the following event to reveal its columns and their values, it can be verified against the
JSON formatted event above that was sent via the REST API:
661
NXLog User Guide Chapter 81. Microsoft Azure Sentinel
662
Chapter 82. Microsoft Exchange NXLog User Guide
MS Exchange stores most of its operational logs in a comma-delimited format similar to W3C. These MS
Exchange logs can be read with im_file and the xm_w3c extension module. For NXLog Community Edition, the
xm_csv extension module can be used instead, with the fields listed explicitly and the header lines skipped. In
some of the log files, the W3C header is prepended by an additional CSV header line enumerating the same
fields as the #Fields directive; NXLog must be configured to skip that line also. See the sections under Exchange
transport logs for examples.
The information provided here is not intended to be comprehensive, but rather provides a general overview of
NXLog integration with some of the major log mechanisms used by Exchange. Other logs generated by Exchange
can be found in the Logging and other sub-directories of the installation directory.
This Guide focuses on Exchange Server 2010 SP1 and later versions. Older versions are either
NOTE not supported by Microsoft or are being decommissioned. Apart from passing their end of life
date, these versions also lack the audit logging feature.
663
NXLog User Guide Chapter 82. Microsoft Exchange
664
Chapter 82. Microsoft Exchange NXLog User Guide
Log Sample
#Software: Microsoft Exchange Server↵
#Version: 15.01.1034.026↵
#Log-type: Message Tracking Log↵
#Date: 2017-09-15T20:01:45.863Z↵
#Fields: date-time,client-ip,client-hostname,server-ip,server-hostname,source-context,connector-
id,source,event-id,internal-message-id,message-id,network-message-id,recipient-address,recipient-
status,total-bytes,recipient-count,related-recipient-address,reference,message-subject,sender-
address,return-path,message-info,directionality,tenant-id,original-client-ip,original-server-
ip,custom-data,transport-traffic-type,log-id,schema-version↵
2017-09-15T20:01:45.863Z,,,,WINEXC,No suitable shadow
servers,,SMTP,HAREDIRECTFAIL,34359738369,<49b4b9a2781a45cba555008075f7bffa@test.com>,8e1061b7-a376-
497c-3172-
08d4fc7497bf,test1@test.com,,6533,1,,,test,Administrator@test.com,Administrator@test.com,,Originatin
g,,,,S:DeliveryPriority=Normal;S:AccountForest=test.com,Email,63dc9d79-5b4e-4f6c-1358-
08d4fc7497c3,15.01.1034.026↵
NXLog can be configured to get message tracking log data with the im_file module, and to parse them with
xm_w3c.
This configuration collects message tracking logs from the defined BASEDIR and parses them using the
xm_w3c module. The logs are then converted to JSON format and forwarded via TCP.
nxlog.conf
1 define BASEDIR C:\Program Files\Microsoft\Exchange Server\V15
2
3 <Extension _json>
4 Module xm_json
5 </Extension>
6
7 <Extension w3c_parser>
8 Module xm_w3c
9 Delimiter ,
10 </Extension>
11
12 <Input messagetracking>
13 Module im_file
14 File '%BASEDIR%\TransportRoles\Logs\MessageTracking\MSGTRK*.LOG'
15 InputType w3c_parser
16 </Input>
17
18 <Output tcp>
19 Module om_tcp
20 Host 10.0.0.1
21 Port 1514
22 Exec to_json();
23 </Output>
For NXLog Community Edition, the xm_csv module can be configured to parse these files.
665
NXLog User Guide Chapter 82. Microsoft Exchange
This configuration uses the xm_csv module to parse the message tracking logs.
nxlog.conf
1 define BASEDIR C:\Program Files\Microsoft\Exchange Server\V15
2
3 <Extension csv_parser>
4 Module xm_csv
5 Fields date-time, client-ip, client-hostname, server-ip, server-hostname, \
6 source-context, connector-id, source, event-id, \
7 internal-message-id, message-id, network-message-id, \
8 recipient-address, recipient-status, total-bytes, recipient-count, \
9 related-recipient-address, reference, message-subject, \
10 sender-address, return-path, message-info, directionality, \
11 tenant-id, original-client-ip, original-server-ip, custom-data, \
12 transport-traffic-type, log-id, schema-version
13 </Extension>
14
15 <Input messagetracking>
16 Module im_file
17 File '%BASEDIR%\TransportRoles\Logs\MessageTracking\MSGTRK*.LOG'
18 <Exec>
19 if $raw_event =~ /^(\xEF\xBB\xBF)?(date-time,|#)/ drop();
20 else
21 {
22 csv_parser->parse_csv();
23 $EventTime = parsedate(${date-time});
24 }
25 </Exec>
26 </Input>
Log Sample
#Software: Microsoft Exchange Server↵
#Version: 15.0.0.0↵
#Log-type: Transport Connectivity Log↵
#Date: 2017-09-15T03:09:34.541Z↵
#Fields: date-time,session,source,Destination,direction,description↵
2017-09-15T03:09:33.526Z,,Transport,,*,service started; #MaxConcurrentSubmissions=20;
MaxConcurrentDeliveries=20; MaxSmtpOutConnections=Unlimited↵
NXLog can be configured to collect exchange connectivity logs with the im_file module, and to parse them with
xm_w3c.
666
Chapter 82. Microsoft Exchange NXLog User Guide
This configuration collects connectivity logs from the defined BASEDIR and parses them using the xm_w3c
module.
nxlog.conf
1 define BASEDIR C:\Program Files\Microsoft\Exchange Server\V15
2
3 <Extension w3c_parser>
4 Module xm_w3c
5 Delimiter ,
6 </Extension>
7
8 <Input connectivity>
9 Module im_file
10 File '%BASEDIR%\TransportRoles\Logs\Hub\Connectivity\CONNECTLOG*.LOG'
11 InputType w3c_parser
12 </Input>
For NXLog Community Edition, the xm_csv module can be configured to parse these files.
This configuration uses the xm_csv module to parse the connectivity logs.
nxlog.conf
1 define BASEDIR C:\Program Files\Microsoft\Exchange Server\V15
2
3 <Extension csv_parser>
4 Module xm_csv
5 Fields date-time, session, source, Destination, direction, description
6 </Extension>
7
8 <Input connectivity>
9 Module im_file
10 File '%BASEDIR%\TransportRoles\Logs\Hub\Connectivity\CONNECTLOG*.LOG'
11 <Exec>
12 if $raw_event =~ /^(\xEF\xBB\xBF)?(date-time,|#)/ drop();
13 else
14 {
15 csv_parser->parse_csv();
16 $EventTime = parsedate(${date-time});
17 }
18 </Exec>
19 </Input>
667
NXLog User Guide Chapter 82. Microsoft Exchange
Log sample
#Software: Microsoft Exchange Server↵
#Version: 15.0.0.0↵
#Log-type: SMTP Send Protocol Log↵
#Date: 2017-09-20T21:00:47.866Z↵
#Fields: date-time,connector-id,session-id,sequence-number,local-endpoint,remote-
endpoint,event,data,context↵
2017-09-20T21:00:47.167Z,internet,08D5006A392BE443,0,,64.8.70.48:25,*,,attempting to connect↵
NXLog can be configured to collect exchange protocol logs and SMTP logs with the im_file module, and to parse
them with xm_w3c.
This configuration collects protocol logs from the defined BASEDIR and parses them using the xm_w3c
module.
nxlog.conf
1 define BASEDIR C:\Program Files\Microsoft\Exchange Server\V15
2
3 <Extension w3c_parser>
4 Module xm_w3c
5 Delimiter ,
6 </Extension>
7
8 <Input smtp_receive>
9 Module im_file
10 File '%BASEDIR%\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive\RECV*.LOG'
11 InputType w3c_parser
12 </Input>
13
14 <Input smtp_send>
15 Module im_file
16 File '%BASEDIR%\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend\SEND*.LOG'
17 InputType w3c_parser
18 </Input>
For NXLog Community Edition, the xm_csv module can be configured to parse these files.
668
Chapter 82. Microsoft Exchange NXLog User Guide
This configuration uses the xm_csv module to parse the protocol logs.
nxlog.conf
1 define BASEDIR C:\Program Files\Microsoft\Exchange Server\V15
2
3 <Extension csv_parser>
4 Module xm_csv
5 Fields date-time, connector-id, session-id, sequence-number, \
6 local-endpoint, remote-endpoint, event, data, context
7 </Extension>
8
9 <Input smtp_receive>
10 Module im_file
11 File '%BASEDIR%\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive\RECV*.LOG'
12 <Exec>
13 if $raw_event =~ /^(\xEF\xBB\xBF)?(date-time,|#)/ drop();
14 else
15 {
16 csv_parser->parse_csv();
17 $EventTime = parsedate(${date-time});
18 }
19 </Exec>
20 </Input>
21
22 <Input smtp_send>
23 Module im_file
24 File '%BASEDIR%\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend\SEND*.LOG'
25 <Exec>
26 if $raw_event =~ /^(\xEF\xBB\xBF)?(date-time,|#)/ drop();
27 else
28 {
29 csv_parser->parse_csv();
30 $EventTime = parsedate(${date-time});
31 }
32 </Exec>
33 </Input>
See also Windows Event Log for more information about using NXLog to collect logs from Windows Event Log.
669
NXLog User Guide Chapter 82. Microsoft Exchange
With this configuration, NXLog will use the im_msvistalog module to subscribe to the Application and
System channels (Critical, Error, and Warning event levels only) and the MSExchange Management crimson
channel (all event levels). Note that the Application and System channels will include other non-Exchange
events.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0" Path="Application">
6 <Select Path="Application">
7 *[System[(Level=1 or Level=2 or Level=3)]]</Select>
8 <Select Path="System">
9 *[System[(Level=1 or Level=2 or Level=3)]]</Select>
10 <Select Path="MSExchange Management">*</Select>
11 </Query>
12 </QueryList>
13 </QueryXML>
14 </Input>
See the Microsoft IIS chapter for more information about collecting events from IIS with NXLog.
The nxlog-xchg utility can be used to retrieve these logs. See the Exchange (nxlog-xchg) add-on documentation.
670
Chapter 83. Microsoft IIS NXLog User Guide
This chapter also includes sections about collecting logs from the SMTP server and about Automatic retrieval of
IIS site log locations.
1. Open IIS Manager, which can be accessed from the Tools menu in the Server Manager or from
Administrative Tools.
2. In the Connections pane on the left, select the server or site for which to configure logging. Select a server
to configure logging server-wide, or a site to configure logging for that specific site.
3. Double-click the Logging icon in the center pane.
671
NXLog User Guide Chapter 83. Microsoft IIS
The resulting logs can be collected by NXLog as shown in the following sections.
Log sample
#Software: Microsoft Internet Information Services 10.0↵
#Version: 1.0↵
#Date: 2017-10-02 17:11:27↵
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent)
cs(Referer) sc-status sc-substatus sc-win32-status time-taken↵
2017-10-02 17:11:27 fe80::b5d8:132c:cec9:daef%6 RPC_IN_DATA /rpc/rpcproxy.dll 1d4026cb-6730-43bf-
91eb-df80f41c050f@test.com:6001&CorrelationID=<empty>;&RequestId=11d6a78a-7c34-4f43-9400-
ad23b114aa62&cafeReqId=11d6a78a-7c34-4f43-9400-ad23b114aa62; 80 TEST\HealthMailbox418406e
fe80::b5d8:132c:cec9:daef%6 MSRPC - 500 0 0 7990↵
2017-10-02 17:12:57 fe80::a425:345a:7143:3b15%2 POST /powershell
clientApplication=ActiveMonitor;PSVersion=5.1.14393.1715 80 - fe80::a425:345a:7143:3b15%2
Microsoft+WinRM+Client - 500 0 0 11279↵
Note that field names with special characters must be referenced with curly braces (for example, ${s-ip} and
672
Chapter 83. Microsoft IIS NXLog User Guide
${cs(User-Agent)}).
See also the W3C Extended Log File Format section and the W3C Extended Log File Format (IIS 6.0) and W3C
Extended Log File Examples (IIS 6.0) articles on Microsoft TechNet.
This configuration reads from file with im_file and parses with xm_w3c.
nxlog.conf
1 <Extension w3c_parser>
2 Module xm_w3c
3 </Extension>
4
5 <Input iis_w3c>
6 Module im_file
7 File 'C:\inetpub\logs\LogFiles\W3SVC*\u_ex*.log'
8 InputType w3c_parser
9 </Input>
For NXLog Community Edition, the xm_csv module can be used instead for parsing the records.
673
NXLog User Guide Chapter 83. Microsoft IIS
This configuration parses the logs with the xm_csv module. The header lines are discarded and the $date
and $time fields are parsed in order to set an $EventTime field.
The field list must be set according to the configured IIS fields. The fields shown here
WARNING
correspond with the default field selection in IIS versions 8.5 and 10.
nxlog.conf
1 <Extension w3c_parser>
2 Module xm_csv
3 Fields date, time, s-ip, cs-method, cs-uri-stem, cs-uri-query, \
4 s-port, cs-username, c-ip, cs(User-Agent), cs(Referer), \
5 sc-status, sc-substatus, sc-win32-status, time-taken
6 FieldTypes string, string, string, string, string, string, integer, \
7 string, string, string, string, integer, integer, integer, \
8 integer
9 Delimiter ' '
10 EscapeChar '"'
11 QuoteChar '"'
12 EscapeControl FALSE
13 UndefValue -
14 </Extension>
15
16 <Input iis_w3c>
17 Module im_file
18 File 'C:\inetpub\logs\LogFiles\W3SVC*\u_ex*.log'
19 <Exec>
20 if $raw_event =~ /^#/ drop();
21 else
22 {
23 w3c_parser->parse_csv();
24 $EventTime = parsedate($date + "T" + $time + ".000Z");
25 }
26 </Exec>
27 </Input>
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
For detailed information about this registry key’s specific values, please see Error logging in HTTP APIs on
Microsoft Support.
Log sample
#Software: Microsoft HTTP API 2.0↵
#Version: 1.0↵
#Date: 2018-10-01 22:10:02↵
#Fields: date time c-ip c-port s-ip s-port cs-version cs-method cs-uri sc-status s-siteid s-reason
s-queuename↵
2018-10-01 22:10:02 ::1%0 49211 ::1%0 47001 - - - - - Timer_ConnectionIdle -↵
2018-10-01 22:10:02 ::1%0 49212 ::1%0 47001 - - - - - Timer_ConnectionIdle -↵
2018-10-01 23:45:09 172.31.77.6 2094 172.31.77.6 80 HTTP/1.1 GET /qos/1kbfile.txt 503 – ConnLimit↵
674
Chapter 83. Microsoft IIS NXLog User Guide
This configuration parses the logs with the xm_w3c module. The header lines are discarded and the $date
and $time fields are parsed in order to set an $EventTime field.
nxlog.conf
1 <Extension w3c_parser>
2 Module xm_w3c
3 </Extension>
4
5 <Input iis_http>
6 Module im_file
7 File 'C:\Windows\System32\LogFiles\HTTPERR\httperr1.log'
8 InputType w3c_parser
9 </Input>
The xm_w3c module is not included in NXLog Community Edition, so the xm_csv module should
NOTE
be used.
Log sample
::1, HealthMailbox418406e8ac5b4b61a6b731ac4c660553@test.com, 9/28/2017, 14:49:00, W3SVC1, WINEXC,
::1, 7452, 592, 2538, 302, 0, POST, /OWA/auth.owa, &CorrelationID=<empty>;&cafeReqId=728beb5e-98de-
4680-acb2-45968bef533c;&encoding=;,
127.0.0.1, -, 9/28/2017, 14:49:01, W3SVC1, WINEXC, 127.0.0.1, 6798, 2502, 682, 302, 0, GET, /ecp/,
&CorrelationID=<empty>;&cafeReqId=0ed28871-4083-492f-99c2-
2fbdb06a9466;&LogoffReason=NoCookiesGetOrE14AuthPost,
675
NXLog User Guide Chapter 83. Microsoft IIS
This configuration reads from file with im_file and parses the fields with xm_csv. The $Date and $Time
fields are parsed in order to set an $EventTime field.
nxlog.conf
1 <Extension iis_parser>
2 Module xm_csv
3 Fields ClientIPAddress, UserName, Date, Time, ServiceAndInstance, \
4 ServerName, ServerIPAddress, TimeTaken, ClientBytesSent, \
5 ServerBytesSent, ServerStatusCode, WindowsStatusCode, RequestType, \
6 TargetOfOperation, Parameters
7 FieldTypes string, string, string, string, string, string, string, integer, \
8 integer, integer, integer, integer, string, string, string
9 UndefValue -
10 </Extension>
11
12 <Input iis>
13 Module im_file
14 File 'C:\inetpub\logs\LogFiles\W3SVC*\u_in*.log'
15 <Exec>
16 iis_parser->parse_csv();
17 $EventTime = strptime($Date + " " + $Time, "%m/%d/%Y %H:%M:%S");
18 </Exec>
19 </Input>
Log sample
fe80::a425:345a:7143:3b15%2 - - [02/Oct/2017:13:16:18 -0700] "POST
/mapi/emsmdb/?useMailboxOfAuthenticatedUser=true HTTP/1.1" 401 7226
fe80::a425:345a:7143:3b15%2 - TEST\HealthMailboxc0bafd1 [02/Oct/2017:13:16:20 -0700] "POST
/mapi/emsmdb/?useMailboxOfAuthenticatedUser=true HTTP/1.1" 200 1482
676
Chapter 83. Microsoft IIS NXLog User Guide
This configuration reads from file with the im_file module and uses a regular expression to parse each
record.
nxlog.conf
1 <Input iis_ncsa>
2 Module im_file
3 File 'C:\inetpub\logs\LogFiles\W3SVC*\u_nc*.log'
4 <Exec>
5 if $raw_event =~ /(?x)^(\S+)\ -\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
6 \ HTTP\/\d\.\d\"\ (\S+)\ (\S+)/
7 {
8 $RemoteHostAddress = $1;
9 if $2 != '-' $UserName = $2;
10 $EventTime = parsedate($3);
11 $HTTPMethod = $4;
12 $HTTPURL = $5;
13 $HTTPResponseStatus = $6;
14 $BytesSent = $7;
15 }
16 </Exec>
17 </Input>
During operation, the IIS SMTP Server pads the W3C log to 64 KiB with NUL characters.
WARNING When the SMTP Server stops, it truncates the file to remove the padding, causing im_file to
re-read the log file and generate duplicate events.
1. Open Internet Information Services (IIS) 6.0 Manager from Administrative Tools.
2. Right click on the corresponding SMTP Virtual Server and click Properties.
677
NXLog User Guide Chapter 83. Microsoft IIS
3. Check Enable logging and choose the logging format from the Active log format drop-down menu. The
W3C format is recommended.
4. Click the [Properties…] button to configure the log location and other options.
5. If using the W3C format, adjust the logged fields under the Advanced tab. Include the Date and Time fields
and whatever extended properties are required.
678
Chapter 83. Microsoft IIS NXLog User Guide
Example 396. Collecting W3C logs from the IIS SMTP server
The following configuration retrieves W3C logs and parses them using the xm_w3c module.
nxlog.conf
1 <Extension w3c_parser>
2 Module xm_w3c
3 </Extension>
4
5 <Input smtp>
6 Module im_file
7 File 'C:\Windows\System32\LogFiles\SmtpSvc1\ex*.log'
8 InputType w3c_parser
9 </Input>
See the preceding sections for more information about processing the other log formats or using xm_csv for
processing W3C logs with NXLog Community Edition.
679
NXLog User Guide Chapter 83. Microsoft IIS
The following polyglot script should be installed in the NXLog installation (or ROOT) directory. It uses the
WebAdministration PowerShell module to return the configured log path for each site. If IIS is configured to
use one log file per server, the path should instead be configured manually.
If there are multiple log formats in the log directory due to configuration changes, the
wildcard path should be adjusted to match only those files that are in the
WARNING
corresponding format. For example, for W3C logging use u_ex*.log in the last line of
the script.
get_iis_log_paths.cmd
@( Set "_= (
Rem " ) <#
)
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
if defined PROCESSOR_ARCHITEW6432 (
set powershell=%SystemRoot%\SysNative\WindowsPowerShell\v1.0\powershell.exe
) else (
set powershell=powershell.exe
)
%powershell% -ExecutionPolicy Bypass -NoProfile ^
-Command "iex ((gc '%~f0') -join [char]10)"
EndLocal & Exit /B %ErrorLevel%
#>
Import-Module -Name WebAdministration
foreach($Site in $(get-website)) {
$LogDir=$($Site.logFile.directory.replace("%SystemDrive%",$env:SystemDrive))
# WARNING: adjust path to match format (for example, for W3C use `u_ex*.log`).
Write-Output "File '$LogDir\W3SVC$($Site.id)\*.log'" }
nxlog.conf
1 <Extension w3c_parser>
2 Module xm_w3c
3 </Extension>
4
5 <Input iis>
6 Module im_file
7 include_stdout %ROOT%\get_iis_log_paths.cmd
8 InputType w3c_parser
9 </Input>
680
Chapter 84. Microsoft SharePoint NXLog User Guide
Microsoft SharePoint Server provides many different types of logs, many of which are configurable. SharePoint
logs are written to files, databases, and Windows Event Log. NXLog can be configured to collect SharePoint logs,
as discussed in the following sections.
See the Monitoring and Reporting in SharePoint Server on Microsoft TechNet for more information about
SharePoint logging.
The trace log files are generated by and stored locally on each server running SharePoint in the farm, using file
names containing the server hostname and timestamp (HOSTNAME-YYYYMMDD-HHMM.log). SharePoint trace logs
are created at regular intervals and whenever there is an IISRESET. It is common for many trace logs to be
generated within a 24-hour period.
If configured in the farm settings, each SharePoint server also writes trace logs to the logging database. These
logs are written by the Diagnostic Data Provider: Trace Log job. NXLog can be configured to collect these
SharePoint logs from the logging database.
For more information about diagnostic logging, see the Configure diagnostic logging in SharePoint Server article
on Microsoft TechNet.
681
NXLog User Guide Chapter 84. Microsoft SharePoint
As shown by the second and third events in the log sample above, long messages span multiple records. In this
case, the timestamp of each subsequent record is followed by an asterisk (*). However, trace log messages are
not guaranteed to appear consecutively within the trace log. See Writing to the Trace Log on MSDN.
2. In the Event Throttling section, use the checkboxes to select a set of categories or subcategories for which
to modify the logging level. Expand categories as necessary to view the corresponding subcategories.
682
Chapter 84. Microsoft SharePoint NXLog User Guide
3. Set the event log and trace log levels for the selected categories or subcategories.
Only select the verbose level for troubleshooting, as a large number of logs will be
WARNING
generated.
4. To set other levels for other categories or subcategories, click [OK] and repeat from step 1.
5. In the Trace Log section, adjust the trace log path and retention policy as required. The specified log location
must exist on all servers in the farm.
Further steps are required to enable writing trace logs to the logging database. For configuring the logging
database itself (server, name, and authentication), see the Configuring usage logging section.
1. Log in to Central Administration and go to Monitoring › Timer Jobs › Review job definitions.
683
NXLog User Guide Chapter 84. Microsoft SharePoint
684
Chapter 84. Microsoft SharePoint NXLog User Guide
This configuration collects logs from the ULS trace log files and uses xm_csv to parse them. $EventTime
and $Hostname fields are added to the event record. Each event is converted to JSON format and written to
file.
The defined SHAREPOINT_LOGS path should be set to the trace log file directory configured
NOTE
in the Configuring diagnostic logging section.
nxlog.conf (truncated)
1 define SHAREPOINT_LOGS C:\Program Files\Common Files\microsoft shared\Web Server \
2 Extensions\16\LOGS
3
4 <Extension json>
5 Module xm_json
6 </Extension>
7
8 <Extension uls_parser>
9 Module xm_csv
10 Fields Timestamp, Process, TID, Area, Category, EventID, Level, Message, \
11 Correlation
12 Delimiter \t
13 </Extension>
14
15 <Input trace_file>
16 Module im_file
17 # Use a file mask to read from ULS trace log files only
18 File '%SHAREPOINT_LOGS%\*-????????-????.log'
19 <Exec>
20 # Drop header lines and empty lines
21 if $raw_event =~ /^(\xEF\xBB\xBF|Timestamp)/ drop();
22 else
23 {
24 # Remove extra spaces
25 $raw_event =~ s/ +(?=\t)//g;
26
27 # Parse with uls_parser instance defined above
28 uls_parser->parse_csv();
29 [...]
Output sample
{
"EventReceivedTime": "2017-10-12 16:02:20",
"SourceModuleName": "uls",
"SourceModuleType": "im_file",
"Timestamp": "10/12/2017 16:02:18.30",
"Process": "hostcontrollerservice.exe (0x0948)",
"TID": "0x191C",
"Area": "SharePoint Foundation",
"Category": "Topology",
"EventID": "aup1c",
"Level": "Medium",
"Message": "Current app domain: hostcontrollerservice.exe (1)",
"EventTime": "2017-10-12 16:02:18",
"Hostname": "WIN-SHARE.test.com"
}
685
NXLog User Guide Chapter 84. Microsoft SharePoint
The im_odbc module can be used to collect diagnostic logs from the farm-wide logging database.
The following Input configuration collects logs from the ULSTraceLog view in the WSS_UsageApplication
database.
The datetime data type is not timezone-aware, and the timestamps are stored in UTC.
NOTE Therefore, an offset is applied when setting the $EventTime field in the configuration
below.
nxlog.conf
1 <Input trace_db>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 13 for SQL Server};\
4 SERVER=SHARESERVE1;DATABASE=WSS_UsageApplication;\
5 Trusted_Connection=yes
6 IdType timestamp
7
8 # With ReadFromLast and MaxIdSQL, NXLog will start reading from the last
9 # record when reading from the database for the first time.
10 #ReadFromLast TRUE
11 #MaxIdSQL SELECT MAX(LogTime) AS maxid FROM dbo.ULSTraceLog
12
13 SQL SELECT LogTime AS id, * FROM dbo.ULSTraceLog \
14 WHERE LogTime > CAST(? AS datetime)
15 <Exec>
16 # Set $EventTime with correct time zone, remove incorrect fields
17 $EventTime = parsedate(strftime($id, '%Y-%m-%d %H:%M:%SZ'));
18 delete($id);
19 delete($LogTime);
20 </Exec>
21 </Input>
See the SharePoint Windows Event Log events section below for an example configuration that reads events
from the Windows Event Log.
Log sample
FarmId ⇥ UserLogin ⇥ SiteSubscriptionId ⇥ TimestampUtc ⇥ CorrelationId ⇥ Action ⇥ Target ⇥
Details↵
42319181-e881-44f1-b422-d7ab5f8b0117 ⇥ TEST\Administrator ⇥ 00000000-0000-0000-0000-000000000000 ⇥
2017-10-17 23:15:26.667 ⇥ 00000000-0000-0000-0000-000000000000 ⇥ Administration.Feature.Install ⇥
AccSrvRestrictedList ⇥ {"Id":"a4d4ee2c-a6cb-4191-ab0a-21bb5bde92fb"}↵
42319181-e881-44f1-b422-d7ab5f8b0117 ⇥ TEST\Administrator ⇥ 00000000-0000-0000-0000-000000000000 ⇥
2017-10-17 23:15:26.839 ⇥ 00000000-0000-0000-0000-000000000000 ⇥ Administration.Feature.Install ⇥
ExpirationWorkflow ⇥ {"Id":"c85e5759-f323-4efb-b548-443d2216efb5"}↵
686
Chapter 84. Microsoft SharePoint NXLog User Guide
WARNING The usage and health data collection settings are farm-wide.
1. Log in to Central Administration and go to Monitoring › Reporting › Configure usage and health data
collection.
2. In the Usage Data Collection section, check Enable usage data collection to enable it.
3. In the Event Selection section, use the checkboxes to select the required event categories. It is
recommended that only those categories be enabled for which regular reports are required.
4. In the Usage Data Collection Settings section, specify the path for the usage log files. The specified log
location must exist on all servers in the farm.
5. In the Health Data Collection section, check Enable health data collection to enable it. Click Health
Logging Schedule to edit the job definitions for the Microsoft SharePoint Foundation Timer service.
6. Click the Log Collection Schedule link to edit the job definitions for the Microsoft SharePoint Foundation
Usage service.
7. In the Logging Database Server section, adjust the authentication method as required. To change the
database server and name, see Log usage data in a different logging database by using Windows PowerShell
on TechNet.
687
NXLog User Guide Chapter 84. Microsoft SharePoint
688
Chapter 84. Microsoft SharePoint NXLog User Guide
This configuration collects logs from the AdministrativeActions usage log file (see Using Administrative
Actions logging in SharePoint Server 2016 on TechNet) and uses xm_csv to parse them. $EventTime and
$Hostname fields are added to the event record. Each event is converted to JSON format and written to file.
The defined SHAREPOINT_LOGS path should be set to the trace log file directory configured
NOTE
in the Configuring diagnostic logging section.
Unlike the diagnostic/trace logs, the various usage/health data categories generate logs
NOTE with differing field sets. Therefore it is not practical to parse multiple types of usage/health
logs with a single xm_csv parser.
nxlog.conf (truncated)
1 define SHAREPOINT_LOGS C:\Program Files\Common Files\microsoft shared\Web Server \
2 Extensions\16\LOGS
3
4 <Extension json>
5 Module xm_json
6 </Extension>
7
8 <Extension admin_actions_parser>
9 Module xm_csv
10 Fields FarmId, UserLogin, SiteSubscriptionId, TimestampUtc, \
11 CorrelationId, Action, Target, Details
12 Delimiter \t
13 </Extension>
14
15 <Input admin_actions_file>
16 Module im_file
17 # Use a file mask to read from the USAGE files only
18 File '%SHAREPOINT_LOGS%\AdministrativeActions\*.usage'
19 <Exec>
20 # Drop header lines and empty lines
21 if $raw_event =~ /^(\xEF\xBB\xBF|FarmId)/ drop();
22 else
23 {
24 # Parse with parser instance defined above
25 admin_actions_parser->parse_csv();
26
27 # Set $EventTime field
28 $EventTime = parsedate($TimestampUtc + "Z");
29 [...]
689
NXLog User Guide Chapter 84. Microsoft SharePoint
Output sample
{
"EventReceivedTime": "2017-10-17 20:46:14",
"SourceModuleName": "admin_actions",
"SourceModuleType": "im_file",
"FarmId": "42319181-e881-44f1-b422-d7ab5f8b0117",
"UserLogin": "TEST\\Administrator",
"SiteSubscriptionId": "00000000-0000-0000-0000-000000000000",
"TimestampUtc": "2017-10-17 23:15:26.667",
"CorrelationId": "00000000-0000-0000-0000-000000000000",
"Action": "Administration.Feature.Install",
"Target": "AccSrvRestrictedList",
"Details": {
"Id": "a4d4ee2c-a6cb-4191-ab0a-21bb5bde92fb"
},
"EventTime": "2017-10-17 16:15:26",
"Hostname": "WIN-SHARE.test.com"
}
The im_odbc module can be used to collect usage and health logs from the farm-wide logging database.
The following Input configuration collects Administrative Actions logs from the AdministrativeActions view
in the WSS_UsageApplication database.
The datetime data type is not timezone-aware, and the timestamps are stored in UTC.
NOTE Therefore, an offset is applied when setting the $EventTime field in the configuration
below.
nxlog.conf
1 <Input admin_actions_db>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 13 for SQL Server};\
4 SERVER=SHARESERVE1;DATABASE=WSS_UsageApplication;\
5 Trusted_Connection=yes
6 IdType timestamp
7
8 # With ReadFromLast and MaxIdSQL, NXLog will start reading from the last
9 # record when reading from the database for the first time.
10 #ReadFromLast TRUE
11 #MaxIdSQL SELECT MAX(LogTime) AS maxid FROM dbo.AdministrativeActions
12
13 SQL SELECT LogTime AS id, * FROM dbo.AdministrativeActions \
14 WHERE LogTime > CAST(? AS datetime)
15 <Exec>
16 # Set $EventTime with correct time zone, remove incorrect fields
17 $EventTime = parsedate(strftime($id, '%Y-%m-%d %H:%M:%SZ'));
18 delete($id);
19 delete($LogTime);
20 </Exec>
21 </Input>
See the SharePoint Windows Event Log events section for an example configuration that reads events from the
Windows EventLog.
690
Chapter 84. Microsoft SharePoint NXLog User Guide
SharePoint audit logging is disabled by default, and can be enabled on a per-site basis. To enable audit logging,
follow these steps. For more details, see the Configure audit settings for a site collection article on Office
Support.
4. On the Site Settings page, in the Site Collection Administration section, click Site collection audit
settings.
If the Site Collection Administration section is not shown, make sure you have adequate
NOTE
permissions.
5. Set audit log trimming settings, select the events to audit, and click [OK].
In order for NXLog to have SharePoint Shell access when running as a service, run the following PowerShell
commands. This will add the NT AUTHORITY\SYSTEM user to the SharePoint_Shell_Access role for the
SharePoint configuration database.
691
NXLog User Guide Chapter 84. Microsoft SharePoint
This configuration collects audit events via SharePoint’s API with the auditlog.ps1 PowerShell script. The
script also adds the following fields (performing lookups as required): $ItemName, $Message, $SiteURL, and
$UserName. SharePoint audit logs are collected from all available sites and the site list is updated each time
the logs are collected. See the options in the script header.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 envvar systemroot
6 <Input audit_powershell>
7 Module im_exec
8 Command "%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe"
9 Arg "-ExecutionPolicy"
10 Arg "Bypass"
11 Arg "-NoProfile"
12 Arg "-File"
13 Arg "C:\auditlog.ps1"
14 <Exec>
15 parse_json();
16 $EventTime = parsedate($EventTime);
17 </Exec>
18 </Input>
Event sample
{
"EventReceivedTime": "2018-03-01 02:12:45",
"SourceModuleName": "audit_ps",
"SourceModuleType": "im_exec",
"UserID": 18,
"LocationType": 0,
"EventName": null,
"MachineName": null,
"ItemName": null,
"EventData": "<Version><AllVersions/></Version><Recycle>1</Recycle>",
"Event": 4,
"UserName": "i:0#.w|test\\test",
"SourceName": null,
"SiteURL": "http://win-share",
"EventTime": "2018-03-01 02:12:12",
"EventSource": 0,
"Message": "The audited object is deleted.",
"DocLocation": "Shared Documents/document.txt",
"ItemID": "48341996-7844-4842-bef6-94b43ace0582",
"SiteID": "51108732-0903-4721-aae7-0f9fb5aebfc2",
"MachineIP": null,
"AppPrincipalID": 0,
"ItemType": 1
}
692
Chapter 84. Microsoft SharePoint NXLog User Guide
auditlog.ps1 (truncated)
# This script can be used with NXLog to fetch Audit logs via the SharePoint
# API. See the configurable options below. Based on:
# <http://shokochino-sharepointexperience.blogspot.ch/2013/05/create-auditing-reports-in-
sharepoint.html>
#Requires -Version 3
This configuration collects audit events from the AuditData table in the WSS_Content database.
The datetime data type is not timezone-aware, and the timestamps are stored in UTC.
NOTE Therefore, an offset is applied when setting the $EventTime field in the configuration
below.
nxlog.conf
1 <Input audit_db>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 13 for SQL Server}; \
4 Server=SHARESERVE1; Database=WSS_Content; \
5 Trusted_Connection=yes
6 IdType timestamp
7
8 # With ReadFromLast and MaxIdSQL, NXLog will start reading from the last
9 # record when reading from the database for the first time.
10 #ReadFromLast TRUE
11 #MaxIdSQL SELECT MAX(Occurred) AS maxid FROM dbo.AuditData
12
13 SQL SELECT Occurred AS id, * FROM dbo.AuditData \
14 WHERE Occurred > CAST(? AS datetime)
15 <Exec>
16 # Set $EventTime with correct time zone, remove incorrect fields
17 $EventTime = parsedate(strftime($id, '%Y-%m-%d %H:%M:%SZ'));
18 delete($id);
19 delete($Occurred);
20 </Exec>
21 </Input>
693
NXLog User Guide Chapter 84. Microsoft SharePoint
This configuration uses the im_msvistalog module to collect all logs from four SharePoint crimson channels,
as well as Application channel events of Warning or higher level. The Application channel will include other
non-SharePoint events. There may be other SharePoint events generated which will not be collected with
this query, depending on the configuration and the channels used.
nxlog.conf
1 <Input eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0" Path="Application">
6 <Select Path="Application">
7 *[System[(Level=1 or Level=2 or Level=3)]]</Select>
8 <Select Path="System">
9 *[System[(Level=1 or Level=2 or Level=3)]]</Select>
10 <Select Path="Microsoft-Office Server-Search/Operational">
11 *</Select>
12 <Select Path="Microsoft-Office-EduServer Diagnostics">*</Select>
13 <Select Path="Microsoft-SharePoint Products-Shared/Operational">
14 *</Select>
15 <Select Path="Microsoft-SharePoint Products-Shared/Audit">*</Select>
16 </Query>
17 </QueryList>
18 </QueryXML>
19 </Input>
See the Microsoft IIS chapter for more information about collecting events from IIS with NXLog.
694
Chapter 85. Microsoft SQL Server NXLog User Guide
NXLog can be integrated with SQL Server in several ways. The server error log file can be read and parsed. SQL
Server Auditing can be configured for a database and the logs collected. It is also possible to read logs from or
write logs to databases hosted by SQL Server. The last section provides some additional information about
setting up ODBC for connecting to a database in order to collect MS SQL logs.
This example uses the xm_charconv LineReader input reader to convert the input to UTF-8 encoding. Events
spanning multiple lines are joined and each event is parsed into $EventTime, $Source, and $Message
fields.
nxlog.conf (truncated)
1 <Extension charconv>
2 Module xm_charconv
3 LineReader UTF-16LE
4 </Extension>
5
6 define ERRORLOG_EVENT /(?x)^(\xEF\xBB\xBF)? \
7 (?<EventTime>\d+-\d+-\d+\ \d+:\d+:\d+.\d+) \
8 \ (?<Source>\S+)\s+(?<Message>.+)$/s
9 <Input mssql_errorlog>
10 Module im_file
11 File 'C:\Program Files\Microsoft SQL Server\' + \
12 'MSSQL14.MSSQLSERVER\MSSQL\Log\ERRORLOG'
13 InputType charconv
14 <Exec>
15 # Attempt to match regular expression
16 if $raw_event =~ %ERRORLOG_EVENT%
17 {
18 # Check if previous lines were saved
19 if defined(get_var('saved'))
20 {
21 $tmp = $raw_event;
22 $raw_event = get_var('saved');
23 set_var('saved', $tmp);
24 delete($tmp);
25 # Process and send previous event
26 $raw_event =~ %ERRORLOG_EVENT%;
27 $EventTime = parsedate($EventTime);
28 }
29 [...]
Because there is no closing/footer line for the events, a log message is kept in the buffers,
NOTE
and not forwarded, until a new log message is read.
695
NXLog User Guide Chapter 85. Microsoft SQL Server
Example 406. Reading from the SQL Server error log (NXLog Community Edition)
This example uses the xm_charconv module convert() function to convert the character set to UTF-8. For log
messages that span multiple lines, an event is created for each line. Variables are used to retain the same
$EventTime and $Source values for subsequent events in this case.
nxlog.conf (truncated)
1 <Extension _charconv>
2 Module xm_charconv
3 </Extension>
4
5 <Input mssql_errorlog>
6 Module im_file
7 File 'C:\Program Files\Microsoft SQL Server\' + \
8 'MSSQL14.MSSQLSERVER\MSSQL\Log\ERRORLOG'
9 <Exec>
10 # Convert character encoding
11 $raw_event = convert($raw_event, 'UTF-16LE', 'UTF-8');
12 # Discard empty lines
13 if $raw_event == '' drop();
14 # Attempt to match regular expression
15 else if $raw_event =~ /(?x)^(?<EventTime>\d+-\d+-\d+\ \d+:\d+:\d+.\d+)
16 \ (?<Source>\S+)\s+(?<Message>.+)$/s
17 {
18 # Convert $EventTime field to datetime type
19 $EventTime = parsedate($EventTime);
20 # Save $EventTime and $Source; may be needed for next event
21 set_var('last_EventTime', $EventTime);
22 set_var('last_Source', $Source);
23 }
24 # If regular expression does not match, this is a multi-line event
25 else
26 {
27 # Use the entire line for the $Message field
28 $Message = $raw_event;
29 [...]
While in earlier versions these logs had to be generated by SQL Trace or a custom monitoring process, it is now
possible to start recording audit logs with a few clicks in Management Studio or a relatively simple SQL script.
The following instructions require a Microsoft SQL Server with auditing support and the Microsoft SQL
Management Studio. Consult the relevant documentation below to determine whether "Fine Grained Auditing" is
available for your SQL Server version and edition.
696
Chapter 85. Microsoft SQL Server NXLog User Guide
For more information, see SQL Server Audit (Database Engine) on Microsoft Docs.
2. Right-click on Audits and select New Audit. The Create Audit dialog box appears. Choose a name for
the audit object.
3. In the Audit destination drop-down list, choose Security log or File (for security reasons, Application
log is not recommended as a target). For File, enter a file path and configure log rotation.
4. Click OK. The Server Audit object is created. Note the red arrow next to the newly created object’s name
indicating this is a disabled object. To enable it, right click on the audit object and select Enable audit (in
case of an error, see Checking SQL audit generation below).
SQL script
To instead create the Server Audit object via SQL, run the CREATE SERVER AUDIT and ALTER SERVER AUDIT
commands. For example:
2. Right-click on Server Audit Specifications and select New Audit. The Create Audit dialog box appears.
3. Choose a Server Audit object (the one defined earlier) and select the actions to be reported.
4. Click OK. The Server Audit Specification object is created. Note the red arrow next to the newly created
object’s name indicating this is a disabled object. To enable it, right click on the audit object and select
Enable audit.
SQL script
Alternatively, use the CREATE SERVER AUDIT SPECIFICATION and ALTER SERVER AUDIT SPECIFICATION
commands. For example:
697
NXLog User Guide Chapter 85. Microsoft SQL Server
2. Click on the plus (+) next to the database to be audited, then click on the plus (+) next to Security under
the database.
3. Right-click on Database Audit Specifications and select New Audit. The Create Audit dialog box
appears.
4. Choose a Server Audit object (the one defined earlier) and select the actions to be reported.
5. Click OK. The Database Audit Specification object is created.
SQL script
Alternatively, use the CREATE DATABASE AUDIT SPECIFICATION and ALTER DATABASE AUDIT
SPECIFICATION commands. For example:
This is a registry related permission error: the account running the SQL server instance is unable to create an
entry under HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Security and fails with ID 33204.
1. Run regedit.
2. Grant Full Control permission for the account running the SQL server instance (for example, Network
Service or a named account) to HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Security.
698
Chapter 85. Microsoft SQL Server NXLog User Guide
3. Disable, then re-enable the Server Audit; this creates a sub-key, MSSQLSERVER$AUDIT.
4. Optionally, remove the Full Control permission that was just added. This permission is no longer
required now that the sub-key has been created.
699
NXLog User Guide Chapter 85. Microsoft SQL Server
In this example, events with ID 33205 are retrieved and some additional fields are parsed from $Message.
Sample Event
2011-11-11 11:00:00 sql2008-ent AUDIT_SUCCESS 33205 Audit event: event_time:2011-11-11
11:00:00.0000000↵
sequence_number:1↵
action_id:SL↵
succeeded:true↵
permission_bitmask:1↵
is_column_permission:true↵
session_id:57↵
server_principal_id:264↵
database_principal_id:1↵
target_server_principal_id:0↵
target_database_principal_id:0↵
object_id:2105058535↵
class_type:U↵
session_server_principal_name:SQL2008-ENT\myuser↵
server_principal_name:SQL2008-ENT\myuser↵
server_principal_sid:0105000000000002120000001aaaaaabbbbcccccddddeeeeffffffff↵
database_principal_name:dbo↵
target_server_principal_name:↵
target_server_principal_sid:↵
target_database_principal_name:↵
server_instance_name:SQL2008-ENT↵
database_name:logindb↵
schema_name:dbo↵
object_name:users↵
statement:select username nev from dbo.users;↵
additional_information:↵
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0" Path="Security">
6 <Select Path="Security">*[System[(EventID=33205)]]</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 <Exec>
11 if $Message =~ /action_id:(.*)/ $ActionId = $1;
12 if $Message =~ /session_server_principal_name:(.*)/ $SessionSPN = $1;
13 if $Message =~ /database_principal_name:(.*)/ $DBPrincipal = $1;
14 if $Message =~ /server_instance_name:(.*)/ $ServerInstance = $1;
15 if $Message =~ /database_name:(.*)/ $DBName = $1;
16 if $Message =~ /schema_name:dbo(.*)/ $SchemaName = $1;
17 if $Message =~ /object_name:(.*)/ $ObjectName = $1;
18 if $Message =~ /statement:(.*)/ $Statement = $1;
19 </Exec>
20 </Input>
700
Chapter 85. Microsoft SQL Server NXLog User Guide
The configuration below uses the im_odbc module to collect audit logs via ODBC. A corresponding name
for the action_id is included via a lookup performed on the sys.dm_audit_actions table (see Translating
the action_id field below for more information).
NOTE This configuration has been tested with SQL Server 2017.
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; DATABASE=TESTDB_doc81;
5 PollInterval 5
6 IdType timestamp
7 SQL SELECT event_time AS 'id', f.*, a.name AS action_name \
8 FROM fn_get_audit_file('C:\audit_log\Audit-*.sqlaudit', default, \
9 default) AS f \
10 INNER JOIN sys.dm_audit_actions AS a \
11 ON f.action_id = a.action_id \
12 WHERE event_time > ?
13 <Exec>
14 delete($id);
15 rename_field($event_time, $EventTime);
16 </Exec>
17 </Input>
The SQL directive requires a SELECT statement for collecting logs. An id field must be returned, and must be used
to limit the results of the SELECT statement. Also, some data types may need special handling in order to be used
with NXLog. Continue to the following sections for more details.
701
NXLog User Guide Chapter 85. Microsoft SQL Server
Writing a working SELECT statement for the SQL directive requires consideration of the id field in two ways.
1. The SELECT statement must return an id field. While there could be a field named id in a table, it is more
common to alias a field as id with the AS clause in SQL.
2. The SELECT statement must limit the results by including a WHERE clause. The WHERE clause should include
a question mark (?) which will be substituted with the highest value of the id that was previously seen by the
module instance.
The ways that the id can be generated are limited only by the database and the SQL language. However, the
following examples show the basic use of the int and datetime2 data types, as well as three which may require
special handling: datetimeoffset, datetime, and timestamp (or rowversion).
In this example, im_odbc collects logs from a table with an auto-increment (identity) int ID field.
Sample table
CREATE TABLE dbo.test1 (
RecordID int IDENTITY(1,1) NOT NULL,
EventTime datetime2 NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Input reading_integer_id>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType integer
6 SQL SELECT RecordID AS id, * FROM dbo.test1 WHERE RecordID > ?
7 Exec delete($id);
8 </Input>
Event fields
{
"RecordID": 1,
"EventTime": "2017-12-31T23:00:00.000000Z",
"Message": "This is a test message",
"EventReceivedTime": "2018-04-01T10:40:54.313071Z",
"SourceModuleName": "reading_integer_id",
"SourceModuleType": "im_odbc"
}
702
Chapter 85. Microsoft SQL Server NXLog User Guide
This example shows a table with a datetime2 timestamp field, which im_odbc is configured to use as the id.
Sample table
CREATE TABLE dbo.test1 (
EventTime datetime2 NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Input reading_datetime2_id>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType timestamp
6 SQL SELECT EventTime AS id, * FROM dbo.test1 WHERE EventTime > ?
7 Exec delete($id);
8 </Input>
This example collects logs from a table with a datetimeoffset field used as the id. The datetimeoffset type
stores both a timestamp and an associated time-zone offset, and is not directly supported by im_odbc.
Thus, the CAST() function is used to convert the value to a datetime2 type.
Sample table
CREATE TABLE dbo.test1 (
EventTime datetimeoffset NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Input reading_datetimeoffset_id>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType timestamp
6 SQL SELECT CAST(EventTime AS datetime2) AS id, Message FROM dbo.test1 \
7 WHERE EventTime > ?
8 Exec delete($id);
9 </Input>
703
NXLog User Guide Chapter 85. Microsoft SQL Server
This example shows a table with a datetime type timestamp which will be used as the id. The datetime type
has been deprecated, and due to a change in the internal representation of datetime values in SQL Server,
some timestamp values (such as the one shown below) cannot be compared correctly without an explicit
casting in the WHERE clause. Without the CAST(), SQL Server may return certain records repeatedly (at
each PollInterval) until a later datetime value is added to the table.
Sample table
CREATE TABLE dbo.test1 (
EventTime datetime NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Input reading_datetime_id>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType timestamp
6 SQL SELECT EventTime AS id, * FROM dbo.test1 \
7 WHERE EventTime > CAST(? as datetime)
8 Exec delete($id);
9 </Input>
This example shows a table with a timestamp (or rowversion, see rowversion (Transact-SQL) on Microsoft
Docs) type field which is used as the id. Notice that the IdType directive is set to integer rather than
timestamp, because the timestamp type is not actually a timestamp.
Sample table
CREATE TABLE dbo.test1 (
RowVersion timestamp NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Input reading_rowversion_id>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType integer
6 SQL SELECT RowVersion AS id, * FROM dbo.test1 WHERE RowVersion > ?
7 Exec delete($id);
8 </Input>
704
Chapter 85. Microsoft SQL Server NXLog User Guide
In this example, a datetimeoffset type field is read as two distinct fields: $EventTime for the timestamp value
and $TZOffset for the time-zone offset value (in minutes).
Sample table
CREATE TABLE dbo.test1 (
RecordID int IDENTITY(1,1) NOT NULL,
LogTime datetimeoffset NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Input reading_datetimeoffset>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType integer
6 SQL SELECT RecordID AS id, \
7 CAST(LogTime AS datetime2) AS EventTime, \
8 DATEPART(tz, LogTime) AS TZOffset, \
9 Message \
10 FROM dbo.test1 WHERE RecordID > ?
11 Exec rename_field($id, $RecordID);
12 </Input>
Event fields
{
"RecordID": 1,
"EventTime": "2017-12-31T23:00:00.000000Z",
"TZOffset": 60,
"Message": "This is a test message",
"EventReceivedTime": "2018-04-01T10:40:54.313071Z",
"SourceModuleName": "odbcdrv17_in",
"SourceModuleType": "im_odbc"
}
705
NXLog User Guide Chapter 85. Microsoft SQL Server
The following configuration inserts records into the dbo.test1 table of the specified database. The
$EventTime and $Message fields in the event record are used for the EventTime and Message fields in the
table.
Sample table
CREATE TABLE dbo.test1 (
RecordID int IDENTITY(1,1) NOT NULL,
EventTime datetime2 NOT NULL,
Message varchar(100) NOT NULL,
)
nxlog.conf
1 <Output mssql>
2 Module om_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 SQL "INSERT INTO dbo.test1 (EventTime, Message) VALUES (?,?)", \
6 $EventTime, $Message
7 </Output>
To use a DSN instead, consult either the ODBC Data Source Administrator and Data Source
NOTE Wizard sections on Microsoft Docs (for Windows) or the unixODBC documentation (for Linux), in
addition to the content below.
Connections to an SQL Server database can use either Windows Authentication (also called "trusted connection")
or SQL Server Authentication. For more information, see Choose an Authentication Mode on Microsoft Docs.
When connecting to an SQL Server database with SQL Server Authentication, the
connection string stored in the NXLog configuration file will need to include UID and PWD
keywords for username and password, respectively (this is true for both DSN and DSN-less
WARNING connections). Because these credentials are stored in plain text, it is important to verify that
the configuration file permissions are set correctly. It is also possible to fetch the
connection string from another file with the include directive or via a script with
include_stdout.
706
Chapter 85. Microsoft SQL Server NXLog User Guide
Example 416. Using ODBC driver 17 for SQL Server with Windows authentication
This example uses the "ODBC Driver 17 for SQL Server" driver to connect to the specified server and
database. Windows Authentication is used to authenticate (the Trusted_Connection keyword). The UID
and PWD keywords are not required in this case. The user account under which NXLog is running must have
permission to access the database.
nxlog.conf
1 <Input win_auth>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType integer
6 SQL SELECT Record AS id, * FROM dbo.test1 WHERE Record > ?
7 </Input>
Example 417. Using ODBC driver 13 for SQL Server with SQL Server authentication
This example uses the "ODBC Driver 13 for SQL Server" driver to connect to the specified server and
database. In this case, SQL Server Authentication is used to authenticate. The UID and PWD keywords must
be used to provide the SQL Server login account and password, respectively.
nxlog.conf
1 <Input sql_auth>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 13 for SQL Server}; Server=MSSQL-HOST; \
4 UID=test; PWD=testpass; Database=TESTDB
5 IdType integer
6 SQL SELECT Record AS id, * FROM dbo.test1 WHERE Record > ?
7 </Input>
85.5.2. FreeTDS
It is also possible to use the FreeTDS driver on Linux.
For more information about using FreeTDS, see the FreeTDS User Guide.
707
NXLog User Guide Chapter 85. Microsoft SQL Server
This example uses the FreeTDS driver to connect to the specified server and database.
nxlog.conf
1 <Input freetds>
2 Module im_odbc
3 ConnectionString Driver={FreeTDS}; Server=MSSQL-HOST; Port=1433; UID=test; \
4 PWD=testpass; Database=TESTDB
5 IdType integer
6 SQL SELECT Record AS id, * FROM dbo.test1 WHERE Record > ?
7 </Input>
708
Chapter 86. Microsoft System Center Endpoint Protection NXLog User Guide
Because the SCEP client logs events to Windows Event Log, it is possible to collect these events with NXLog.
709
NXLog User Guide Chapter 86. Microsoft System Center Endpoint Protection
Example 419. Collecting and Parsing Forefront (FCSAM) Events From Windows Event Log
This configuration uses the im_msvistalog module to collect FCSAM client events from Windows Event Log.
This will result in an $EventData field in the event record containing <Data> entries similar to the previous
example.
To extract values from the $EventData field, a regular expression is selected based on the event ID. Then
each <Data> entry is identified by a combination of its position in the list and a pattern match on its value.
For example, the <Data>1.5.1937.0</Data> portion of the EventData string is extracted and saved to the
NXLog $ClientVersion field.
This example includes regular expressions for parsing event IDs 3004, 3005, 5007, 5008, 1000, 1001, 1002,
1006 and 1007. Some fields, which are empty or otherwise do not contain useful data are skipped. The
configuration could be extended to parse other events logged by the FCSAM client via adding more regular
expressions, parsing multiple event IDs with a single expression, and/or dividing the parsing into multiple
expressions for a single event.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 define FCSAMEvents 3004, 3005, 5007, 5008, 1000, 1001, 1002, 1006, 1007
6
7 define EventID_3004_REGEX /(?x) \
8 <Data>(?<ClientVersion>(\d+\.\d+\.\d+\.\d+))<\/Data> \
9 <Data>(?<ScanID>(\{[\d\w\-]+\}))<\/Data> \
10 <Data>\d+<\/Data> \
11 <Data>\%\%\d{3}<\/Data> \
12 <Data><\/Data> \
13 <Data>(?<ProcessName>(\w{1}:\\.*\.exe))<\/Data> \
14 <Data>(?<Domain>([\w\d]+))<\/Data> \
15 <Data>(?<User>([\w\d]+))<\/Data> \
16 <Data>(?<SID>(S-[\d\-]+))<\/Data> \
17 <Data>(?<Filename>.*)<\/Data> \
18 <Data>(?<ID>(\d{9,11}))<\/Data> \
19 <Data>(?<SeverityID>(\d{1,2}))<\/Data> \
20 <Data>(?<CategoryID>(\d{1,3}))<\/Data> \
21 <Data>(?<FWLink>(http.*id=\d{10}))<\/Data> \
22 <Data>(?<PathFound>(file:\w{1}:.*\.\w{2,4}))<\/Data> \
23 <Data><\/Data> \
24 <Data><\/Data> \
25 <Data>\d+<\/Data> \
26 <Data>\%\%\d+<\/Data> \
27 <Data>\d+<\/Data> \
28 <Data>\%\%\d+<\/Data> \
29 [...]
710
Chapter 86. Microsoft System Center Endpoint Protection NXLog User Guide
Event Sample
{
"EventTime": "2019-01-11T12:19:22.000000+01:00",
"Hostname": "Host.DOMAIN.local",
"Keywords": "36028797018963968",
"EventType": "WARNING",
"SeverityValue": 3,
"Severity": "Severe",
"EventID": 3004,
"SourceName": "FCSAM",
"TaskValue": 0,
"RecordNumber": 11595,
"ExecutionProcessID": 0,
"ExecutionThreadID": 0,
"Channel": "System",
"Message": "Microsoft Forefront Client Security Real-Time Protection agent has detected
changes. Microsoft recommends you analyze the software that made these changes for potential
risks. You can use information about how these programs operate to choose whether to allow them
to run or remove them from your computer. Allow changes only if you trust the program or the
software publisher. Microsoft Forefront Client Security can't undo changes that you allow.\r\n
For more information please see the following:
\r\nhttp://go.microsoft.com/fwlink/?linkid=37020&name=EICAR_Test_File&threatid=2147519003\r\n
\tScan ID: {92224018-9446-4C2D-AFCB-EC4456B8859E}\r\n \tAgent: On Access\r\n \tUser: DOMAIN
\\admin\r\n \tName: EICAR_Test_File\r\n \tID: 2147519003\r\n \tSeverity: Severe\r\n \tCategory:
Virus\r\n \tPath Found: file:C:\\Users\\admin\\Downloads\\eicar.com(2).txt\r\n \tAlert Type:
\r\n \tProcess Name: C:\\Program Files\\Mozilla Firefox\\firefox.exe\r\n \tDetection Type:
Concrete\r\n \tStatus: Suspend",
"Opcode": "Info",
"EventData": "<Data>%%830</Data><Data>1.5.1937.0</Data><Data>{92224018-9446-4C2D-AFCB-
EC4456B8859E}</Data><Data>10</Data><Data>%%843</Data><Data></Data><Data>C:\\Program Files
\\Mozilla Firefox\\firefox.exe</Data><Data>DOMAIN</Data><Data>admin</Data><Data>S-1-5-21-
314323950-2314161084-4234690932-
1002</Data><Data>EICAR_Test_File</Data><Data>2147519003</Data><Data>5</Data><Data>42</Data><Dat
a>http://go.microsoft.com/fwlink/?linkid=37020&name=EICAR_Test_File&threatid=2147519003
</Data><Data>file:C:\\Users\\admin\\Downloads\\eicar.com(2).txt</Data><Data></Data><Data></Data
><Data>4</Data><Data>%%814</Data><Data>0</Data><Data>%%823</Data><Data></Data><Data></Data><Dat
a>Severe</Data><Data>Virus</Data><Data></Data><Data></Data>",
"EventReceivedTime": "2019-01-11T12:19:22.883100+01:00",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog",
"Category": "Virus",
"CategoryID": "42",
"ClientVersion": "1.5.1937.0",
"FWLink":
"http://go.microsoft.com/fwlink/?linkid=37020&name=EICAR_Test_File&threatid=2147519003"
,
"Filename": "EICAR_Test_File",
"ID": "2147519003",
"PathFound": "file:C:\\Users\\admin\\Downloads\\eicar.com(2).txt",
"ProcessName": "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
"SID": "S-1-5-21-314323950-2314161084-4234690932-1002",
"ScanID": "{92224018-9446-4C2D-AFCB-EC4456B8859E}",
"SeverityID": "5",
"User": "DOMAIN \\ admin"
}
711
NXLog User Guide Chapter 86. Microsoft System Center Endpoint Protection
• Definition updates
• Malware detections
• Monitoring alerts
712
Chapter 86. Microsoft System Center Endpoint Protection NXLog User Guide
The following configuration collects events from SCEP files with the im_file module. Logs are written in the
UTF-16LE character encoding, so the xm_charconv extension module is used to convert the input.
nxlog.conf (truncated)
1 <Extension charconv>
2 Module xm_charconv
3 LineReader UTF-16LE
4 </Extension>
5
6 <Extension _json>
7 Module xm_json
8 </Extension>
9
10 <Input Antimalware>
11 Module im_file
12 File 'C:\ProgramData\Microsoft\Microsoft Antimalware\Support\' + \
13 'MPDetection-*.log'
14 File 'C:\ProgramData\Microsoft\Microsoft Antimalware\Support\' + \
15 'MPLog-*.log'
16 File 'C:\ProgramData\Microsoft\Microsoft Security Client\Support\' + \
17 'EppSetup.log'
18 File 'C:\ProgramData\Microsoft\Microsoft Security Client\Support\' + \
19 'MSSecurityClient_Setup*.log'
20 ReadFromLast TRUE
21 InputType charconv
22 <Exec>
23 file_name() =~ /(?<Filename>[^\\]+)$/;
24 if $FileName =~ /MPLog|MPDetection/
25 if $raw_event =~ /(.*\.\d{3}Z)\s+(.*)/
26 {
27 $EventTime = $1;
28 [...]
713
NXLog User Guide Chapter 86. Microsoft System Center Endpoint Protection
714
Chapter 86. Microsoft System Center Endpoint Protection NXLog User Guide
The following configuration queries the SCCM database with the im_odbc module. This example contains
two SQL queries collecting Last Malware alerts and AV Detection alerts.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input last_malware>
6 Module im_odbc
7 ConnectionString DSN=SMS;database=CM_CND;uid=user;pwd=password;
8 IdType timestamp
9 SQL SELECT DetectionTime as id,* \
10 FROM vEP_LastMalware \
11 WHERE DetectionTime > CAST(? AS datetime)
12 Exec to_json();
13 </Input>
14
15 <Input av_detections>
16 Module im_odbc
17 ConnectionString DSN=SMS;database=CM_CND;uid=user;pwd=password;
18 IdType timestamp
19 SQL SELECT DetectionTime as id,* \
20 FROM v_GS_Threats \
21 INNER JOIN v_R_System \
22 ON v_GS_Threats.ResourceID=v_R_System.ResourceID \
23 WHERE DetectionTime > CAST(? AS datetime)
24 Exec to_json();
25 </Input>
715
NXLog User Guide Chapter 86. Microsoft System Center Endpoint Protection
716
Chapter 87. Microsoft System Center Configuration Manager NXLog User Guide
Server log files Logs on the server or related to specific system roles.
Log files by functionality Logs related to application management, endpoint protection, software updates
and so on.
SCCM stores log files in various locations depending on the process originator and system configuration.
SCCM enables logging for client and server components by default. NXLog can collect these events with the
im_file module.
717
NXLog User Guide Chapter 87. Microsoft System Center Configuration Manager
The following configuration uses the im_file module for collecting the log files and parses the contents via
regular expressions to extract the fields. It contains two types of custom regular expressions for the usage
of proper fields.
nxlog.conf (truncated)
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 define type1 /(?x)^(?<Message>.*)\$\$\<\
6 (?<Component>.*)\>\<\
7 (?<EventTime>.*).\d{3}-\d{2}\>\<thread=\
8 (?<Thread>\d+)/s
9
10 define type2 /(?x)^\<\!\[LOG\[(?<Message>.*)\]LOG\]\!\>\<time=\"\
11 (?<Time>.*).\d{3}-\d{2}\"\s+date=\"\
12 (?<Date>.*)\"\s+component=\"\
13 (?<Component>.*)\"\s+context=\"\
14 (?<Context>.*)\"\s+type=\"\
15 (?<Type>.*)\"\s+thread=\"\
16 (?<Thread>.*)\"\s+file=\"\
17 (?<File>.*)\"\>/s
18
19
20 <Input in>
21 Module im_file
22 File 'C:\WINDOWS\SysWOW64\CCM\Logs\*'
23 File 'C:\WINDOWS\System32\CCM\Logs\*'
24 File 'C:\Program Files\Microsoft Configuration Manager\Logs\*'
25 File 'C:\Program Files\SMS_CCM\Logs\*'
26 <Exec>
27 if file_name() =~ /^.*\\(.*)$/ $Filename = $1;
28 if $raw_event =~ %type1%;
29 [...]
For this, an ODBC System Data Source need to be configured either on the server running NXLog or on a remote
718
Chapter 87. Microsoft System Center Configuration Manager NXLog User Guide
server, in the case you would like to get log data via ODBC remotely.
For more information, consult the relevant ODBC documentation; the Microsoft ODBC Data Source
Administrator guide or the unixODBC Project.
The below configuration example contains two im_odbc module instances to fetch data from the following two
views:
• V_SMS_Alert — lists information about built-in and user created alerts, which might be displayed in the
SCCM console.
• V_StatMsgWithInsStrings — lists information about status messages returned by each SCCM component.
SCCM provides an overview of audit related information in the Monitoring > Overview >
NOTE System Status > Status Message Queries list in the GUI. SCCM stores audit related
information in the V_StatMsgWithInsStrings view of the SQL database.
Audit related messages are vital to track which accounts have modified or deleted settings in the
NOTE
SCCM environment. These messages are purged from the database after 180 days.
Queries are based on the Microsoft System Center Configuration Manager Schema. For more information, see
the Status and alert views section in the SSCM documentation.
719
NXLog User Guide Chapter 87. Microsoft System Center Configuration Manager
Example 421. Configuration with two SQL Queries and a Combined Output
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input sccm_alerts>
6 Module im_odbc
7 ConnectionString DSN=SMS SQL;database=CM_CND;uid=user;pwd=password;
8 SQL SELECT ID,TypeID,TypeInstanceID,Name,FeatureArea, \
9 ObjectWmiClass,Severity FROM V_SMS_Alert
10 </Input>
11
12 <Input sccm_audit>
13 Module im_odbc
14 ConnectionString DSN=SMS SQL;database=CM_CND;uid=user;pwd=password;
15 SQL SELECT * FROM v_StatMsgWithInsStrings
16 </Input>
17
18 <Output outfile>
19 Module om_file
20 File 'C:\logs\out.log'
21 Exec to_json();
22 </Output>
23
24 <Route sccm>
25 Path sccm_alerts, sccm_audit => outfile
26 </Route>
720
Chapter 88. Microsoft System Center Operations Manager NXLog User Guide
Alert logs
Alerts are significant events generated by rules and monitors.
The default retention time for resolved alerts and collected events is seven days, after which the
NOTE database entries are groomed. To configure database grooming settings read the TechNet
article How to Configure Grooming Settings for the Operations Manager Database.
• Create a Windows/SQL account with read permissions for the Operations Manager database.
• Configure an ODBC 32-bit System Data Source on the server running NXLog. For more information, consult
the relevant ODBC documentation: the Microsoft ODBC Data Source Administrator guide or the unixODBC
Project.
• Set an appropriate firewall rule on the database server that accepts connections from the server running
NXLog. Open TCP port 1433 or whichever port the SQL Server is configured to allow SQL Server access on.
For further information read the Configure Firewall for Database Engine Access guide.
NXLog can then be configured with one or more im_odbc input modules, each with an SQL query that produces
the fields to be logged.
The configured SQL query must contain a way to serialize the result set, enabling NXLog to
NOTE resume reading logs where it left off after a restart. This is easily achieved by using an auto-
increment-like solution or a timestamp field. See the example below.
721
NXLog User Guide Chapter 88. Microsoft System Center Operations Manager
This example queries the database for event logs and unresolved alert logs, then sends the results in JSON
format to a plain text file. Note the Exec directive in the scom_alerts input instance. It is used to extract
the content of the AlertParameters field that is itself a composite (XML) structure. You should define your
own regular expressions to extract data you are interested in from the alerts' AlertParameters and Context
fields and the events' EventData and EventParameters fields.
This example uses the DATEDIFF SQL function to generate a timestamp from an SQL datetime field with
millisecond precision. The timestamp is used to serialize the result set as required by NXLog. Starting with
SQL Server 2016 the DATEDIFF_BIG T-SQL function can be used instead (see DATEDIFF_BIG (Transact-SQL) at
MSDN).
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input scom_events>
6 Module im_odbc
7 ConnectionString DSN=scom;uid=username@mydomain.local;pwd=mypassword;\
8 database=OperationsManager
9 SQL SELECT CAST(DATEDIFF(minute, '19700101', CAST(EV.TimeGenerated AS DATE)) \
10 AS BIGINT) * 60000 + DATEDIFF(ms, '19000101', \
11 CAST(EV.TimeGenerated AS TIME)) AS 'id', \
12 EV.TimeGenerated AS 'EventTime', \
13 EV.TimeAdded AS 'EventAddedTime', \
14 EV.Number AS 'EventID', \
15 EV.MonitoringObjectDisplayName AS 'Source', \
16 R.DisplayName AS 'RuleName', \
17 EV.EventData, EV.EventParameters \
18 FROM EventView EV JOIN RuleView R WITH (NOLOCK) ON \
19 EV.RuleId = R.id \
20 WHERE CAST(DATEDIFF(minute, '19700101', CAST(EV.TimeGenerated \
21 AS DATE)) AS BIGINT) * 60000 + DATEDIFF(ms, '19000101', \
22 CAST(EV.TimeGenerated AS TIME)) > ?
23 PollInterval 30
24 IdIsTimeStamp FALSE
25 </Input>
26
27 <Input scom_alerts>
28 Module im_odbc
29 [...]
722
Chapter 88. Microsoft System Center Operations Manager NXLog User Guide
723
NXLog User Guide Chapter 89. MongoDB
NXLog can be configured to collect data from a MongoDB database. A proof-of-concept Perl script is shown in
the example below.
724
Chapter 89. MongoDB NXLog User Guide
This configuration uses im_perl to execute a Perl script which reads data from a MongoDB database. The
generated events are written to file with om_file.
When new documents are available in the database, the script sorts them by ObjectId and processes them
sequentially. Each document is passed to NXLog by calling Log::Nxlog::add_input_data(). The script will
poll the database continuously with Log::Nxlog::set_read_timer(). In the event that the MongoDB
server is unreachable, the timer delay will be increased to attempt reconnection later.
The Perl script shown here is a proof-of-concept only. The script must be modified to
NOTE
correspond with the data to be collected from MongoDB.
nxlog.conf
1 <Input perl>
2 Module im_perl
3 PerlCode mongodb-input.pl
4 </Input>
5
6 <Output file>
7 Module om_file
8 File '/tmp/output.log'
9 </Output>
mongodb-input.pl (truncated)
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
use Log::Nxlog;
use MongoDB;
use Try::Tiny;
my $counter;
my $client;
my $collection;
my $cur;
my $count;
my $logfile;
[...]
For this example, a JSON data set of US ZIP (postal) codes was used. The data set was fed to MongoDB with
mongoimport -d zips -c zips --file zips.json.
725
NXLog User Guide Chapter 89. MongoDB
Input Sample
{ "_id" : "01001", "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state"
: "MA" }
{ "_id" : "01008", "city" : "BLANDFORD", "loc" : [ -72.936114, 42.182949 ], "pop" : 1240,
"state" : "MA" }
{ "_id" : "01010", "city" : "BRIMFIELD", "loc" : [ -72.188455, 42.116543 ], "pop" : 3706,
"state" : "MA" }
{ "_id" : "01011", "city" : "CHESTER", "loc" : [ -72.988761, 42.279421 ], "pop" : 1688, "state"
: "MA" }
{ "_id" : "01020", "city" : "CHICOPEE", "loc" : [ -72.576142, 42.176443 ], "pop" : 31495,
"state" : "MA" }
Output Sample
ID: 01001 City: AGAWAM Loc: -72.622739,42.070206 Pop: 15338 State: MA↵
ID: 01008 City: BLANDFORD Loc: -72.936114,42.182949 Pop: 1240 State: MA↵
ID: 01010 City: BRIMFIELD Loc: -72.188455,42.116543 Pop: 3706 State: MA↵
ID: 01011 City: CHESTER Loc: -72.988761,42.279421 Pop: 1688 State: MA↵
ID: 01020 City: CHICOPEE Loc: -72.576142,42.176443 Pop: 31495 State: MA↵
726
Chapter 90. Nagios Log Server NXLog User Guide
By default, Nagios Log Server does not require any post-installation configuration which means logs can be
received from NXLog right away.
To see the IP address and ports of the Nagios Log Server instance, open the Configure page and find the
Configuration Editor section.
727
NXLog User Guide Chapter 90. Nagios Log Server
The configuration below reads systemd messages using the im_systemd module and selects only those
entries which contain the sshd character combination. The selected messages are processed with the
xm_kvp module and converted to JSON using the xm_json module. Sending over TCP is carried out using
the om_tcp module.
1 <Extension kvp>
2 Module xm_kvp
3 KVDelimiter =
4 KVPDelimiter " "
5 </Extension>
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input systemd>
12 Module im_systemd
13 ReadFromLast TRUE
14 Exec if not ($raw_event =~ /sshd/) drop();
15 </Input>
16
17 <Output out>
18 Module om_tcp
19 Host 192.168.31.179
20 Port 3515
21 <Exec>
22 kvp->parse_kvp();
23 to_json();
24 </Exec>
25 </Output>
Below is the event sample of a log message which is sent over TCP.
728
Chapter 90. Nagios Log Server NXLog User Guide
{
"Severity": "info",
"SeverityValue": 6,
"Facility": "syslog",
"FacilityValue": 4,
"Message": "Accepted password for administrator from 192.168.31.179 port 46534 ssh2",
"SourceName": "sshd",
"ProcessID": 3168,
"User": "root",
"Group": "root",
"ProcessName": "sshd",
"ProcessExecutable": "/usr/sbin/sshd",
"ProcessCmdLine": "sshd: administrator [priv]",
"Capabilities": "3fffffffff",
"SystemdCGroup": "/system.slice/ssh.service",
"SystemdUnit": "ssh.service",
"SystemdSlice": "system.slice",
"SelinuxContext": "unconfined\n",
"EventTime": "2020-03-25 18:59:53",
"BootID": "1eb2f28ae8064c7a954e2420be54a7f2",
"MachineID": "0823d4a95f464afeb0021a7e75a1b693",
"SysInvID": "984c8a16fd20462a9ac8c0682081979c",
"Hostname": "ubuntu",
"Transport": "syslog",
"EventReceivedTime": "2020-03-25T18:59:53.565177+00:00",
"SourceModuleName": "systemd",
"SourceModuleType": "im_systemd"
}
729
NXLog User Guide Chapter 90. Nagios Log Server
The configuration below reads Windows Event Log entries and selects only those entries which contain IDs
4624 and 4625 using the im_msvistalog module. The collected logs are then converted to JSON using the
xm_json module after the Message field is deleted from the entry. Sending over UDP is carried out using the
om_udp module.
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input in_eventlog>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id="0">
10 <Select Path="Security">
11 *[System[Level=0 and (EventID=4624 or EventID=4625)]]</Select>
12 </Query>
13 </QueryList>
14 </QueryXML>
15 <Exec>
16 delete($Message);
17 json->to_json();
18 </Exec>
19 </Input>
20
21 <Output out>
22 Module om_udp
23 Host 192.168.31.179
24 Port 5544
25 Exec to_json();
26 </Output>
Below is the event sample of a log message which is sent over UDP.
730
Chapter 90. Nagios Log Server NXLog User Guide
{
"EventTime": "2020-03-22T13:48:55.455545-07:00",
"Hostname": "WIN-IVR26CIVSF6",
"Keywords": "9232379236109516800",
"EventType": "AUDIT_SUCCESS",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 4624,
"SourceName": "Microsoft-Windows-Security-Auditing",
"ProviderGuid": "{54849625-5478-4994-A5BA-3E3B0328C30D}",
"Version": 2,
"TaskValue": 12544,
"OpcodeValue": 0,
"RecordNumber": 15033,
"ActivityID": "{CFEB8893-00D2-0000-E289-EBCFD200D601}",
"ExecutionProcessID": 532,
"ExecutionThreadID": 572,
"Channel": "Security",
"Category": "Logon",
"Opcode": "Info",
"SubjectUserSid": "S-1-5-18",
"SubjectUserName": "WIN-IVR26CIVSF6$",
"SubjectDomainName": "WORKGROUP",
"SubjectLogonId": "0x3e7",
"TargetUserSid": "S-1-5-90-0-6",
"TargetUserName": "DWM-6",
"TargetDomainName": "Window Manager",
"TargetLogonId": "0x1c8f13",
"LogonType": "2",
"LogonProcessName": "Advapi ",
"AuthenticationPackageName": "Negotiate",
"WorkstationName": "-",
"LogonGuid": "{00000000-0000-0000-0000-000000000000}",
"TransmittedServices": "-",
"LmPackageName": "-",
"KeyLength": "0",
"ProcessId": "0x848",
"ProcessName": "C:\\Windows\\System32\\winlogon.exe",
"IpAddress": "-",
"IpPort": "-",
"ImpersonationLevel": "%%1833",
"RestrictedAdminMode": "-",
"TargetOutboundUserName": "-",
"TargetOutboundDomainName": "-",
"VirtualAccount": "%%1842",
"TargetLinkedLogonId": "0x1c8f24",
"ElevatedToken": "%%1842",
"EventReceivedTime": "2020-03-22T13:48:56.870657-07:00",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog"
}
Configuration of NXLog for sending logs over SSL/TLS is already described in the Sending NXLogs With SSL/TLS
section on the Nagios website.
To read more about encrypted transfer of data, see the Encrypted Transfer and TLS/SSL (om_ssl) chapters on
NXLog website.
Other examples of sending log data using NXLog from the Nagios website:
731
NXLog User Guide Chapter 90. Nagios Log Server
On the log source page, find the Verify Incoming Logs section, type in the IP address of the NXLog server and
click the Verify button. The verification should show a number of log entries which have already been accepted
by the Log Server from the specified IP address.
To observe the collected entries, go to the Reports page and click the required IP address (hostname) in the
table.
The table with log entries will open. To expand information about the specified entry, click its line in the table.
Each entry contains structured information about its fields and values.
732
Chapter 90. Nagios Log Server NXLog User Guide
733
NXLog User Guide Chapter 91. Nessus Vulnerability Scanner
Scan Sample
<?xml version="1.0" ?>
<NessusClientData_v2>
<Report xmlns:cm="http://www.nessus.org/cm" name="Scan Testbed">
<ReportHost name="192.168.1.112">
<HostProperties>
<tag name="HOST_END">Wed Jun 18 04:20:45 2014</tag>
<tag name="patch-summary-total-cves">1</tag>
<tag name="traceroute-hop-1">?</tag>
<tag name="traceroute-hop-0">10.10.10.20</tag>
<tag name="operating-system">Linux Kernel</tag>
<tag name="host-ip">192.168.1.112</tag>
<tag name="HOST_START">Wed Jun 18 04:19:21 2014</tag>
</HostProperties>
<ReportItem port="6667" svc_name="irc" protocol="tcp" severity="0" pluginID="22964"
pluginName="Service Detection" pluginFamily="Service detection">
<description>It was possible to identify the remote service by its banner or by
looking at the error
message it sends when it receives an HTTP request.
</description>
<fname>find_service.nasl</fname>
<plugin_modification_date>2014/06/03</plugin_modification_date>
<plugin_name>Service Detection</plugin_name>
<plugin_publication_date>2007/08/19</plugin_publication_date>
<plugin_type>remote</plugin_type>
<risk_factor>None</risk_factor>
<script_version>$Revision: 1.137 $</script_version>
<solution>n/a</solution>
<synopsis>The remote service could be identified.</synopsis>
<plugin_output>An IRC server seems to be running on this port is running on this
port.</plugin_output>
</ReportItem>
</ReportHost>
</Report>
</NessusClientData_v2>
While the above sample illustrates the correct syntax, it is not a complete Nessus report. For
NOTE
more information refer to the Nessus v2 File Format document on tenable.com.
The preferred approach for parsing Nessus scans is with im_perl and a Perl script; this provides fine-grained
control over the collected information. If Perl is not available, the xm_multiline and xm_xml extension modules
can be used instead. Both methods require NXLog Enterprise Edition.
734
Chapter 91. Nessus Vulnerability Scanner NXLog User Guide
In this example, the im_perl input module executes the nessus.pl Perl script which reads the Nessus scan.
The script generates an event for each ReportItem, and includes details from Report and ReportHost in
each event. Furthermore, normalized $EventTime, $Severity, and $SeverityValue fields are added to
the event record.
nxlog.conf
1 <Input perl>
2 Module im_perl
3 PerlCode nessus.pl
4 </Input>
Event Sample
{
"EventTime": "2014-06-18 04:20:45",
"Report": "Scan Testbed",
"ReportHost": "192.168.1.112",
"port": "6667",
"svc_name": "irc",
"protocol": "tcp",
"NessusSeverityValue": 0,
"NessusSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"pluginID": "22964",
"pluginName": "Service Detection",
"pluginFamily": "Service detection",
"description": "It was possible to identify the remote service by its banner or by looking at
the error\nmessage it sends when it receives an HTTP request.\n",
"fname": "find_service.nasl",
"plugin_modification_date": "2014/06/03",
"plugin_name": "Service Detection",
"plugin_publication_date": "2007/08/19",
"plugin_type": "remote",
"risk_factor": "None",
"script_version": "$Revision: 1.137 $",
"solution": "n/a",
"synopsis": "The remote service could be identified.",
"plugin_output": "An IRC server seems to be running on this port is running on this port.",
"EventReceivedTime": "2017-11-29 20:29:40",
"SourceModuleName": "perl",
"SourceModuleType": "im_perl"
}
735
NXLog User Guide Chapter 91. Nessus Vulnerability Scanner
nessus.pl (truncated)
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
use Log::Nxlog;
use XML::LibXML;
sub read_data {
my $doc = XML::LibXML->load_xml( location => 'scan.nessus' );
my $report = $doc->findnodes('/NessusClientData_v2/Report');
my @nessus_sev = ("INFO","LOW","MEDIUM","HIGH","CRITICAL");
my @nxlog_sev_val = (2,3,4,5,5);
my @nxlog_sev = ("INFO","WARNING","ERROR","CRITICAL","CRITICAL");
my %mon2num = qw(
Jan 01 Feb 02 Mar 03 Apr 04 May 05 Jun 06
[...]
736
Chapter 91. Nessus Vulnerability Scanner NXLog User Guide
This example depicts an alternative way to collect results from Nessus XML scan files, recommended only if
Perl is not available. This configuration generates an event for each ReportItem found in the scan report.
nxlog.conf
1 <Extension multiline_parser>
2 Module xm_multiline
3 HeaderLine /^<ReportItem/
4 EndLine /^<\/ReportItem>/
5 </Extension>
6
7 <Extension _xml>
8 Module xm_xml
9 ParseAttributes TRUE
10 </Extension>
11
12 <Input in>
13 Module im_file
14 File "nessus_report.xml"
15 InputType multiline_parser
16 <Exec>
17 # Discard everything that doesn't seem to be an xml event
18 if $raw_event !~ /^<ReportItem/ drop();
19
20 # Parse the xml event
21 parse_xml();
22 </Exec>
23 </Input>
Event Sample
{
"EventReceivedTime": "2017-11-09 10:22:58",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"ReportItem.port": "6667",
"ReportItem.svc_name": "irc",
"ReportItem.protocol": "tcp",
"ReportItem.severity": "0",
"ReportItem.pluginID": "22964",
"ReportItem.pluginName": "Service Detection",
"ReportItem.pluginFamily": "Service detection",
"ReportItem.description": "It was possible to identify the remote service by its banner or by
looking at the error\nmessage it sends when it receives an HTTP request.\n",
"ReportItem.fname": "find_service.nasl",
"ReportItem.plugin_modification_date": "2014/06/03",
"ReportItem.plugin_name": "Service Detection",
"ReportItem.plugin_publication_date": "2007/08/19",
"ReportItem.plugin_type": "remote",
"ReportItem.risk_factor": "None",
"ReportItem.script_version": "$Revision: 1.137 $",
"ReportItem.solution": "n/a",
"ReportItem.synopsis": "The remote service could be identified.",
"ReportItem.plugin_output": "An IRC server seems to be running on this port is running on
this port."
}
737
NXLog User Guide Chapter 92. NetApp
Log Sample
4/14/2017 15:40:25 p-netapp1 DEBUG repl.engine.error: replStatus="8",
replFailureMsg="5898503", replFailureMsgDetail="0", functionName="repl_util::Result
repl_core::Instance::endTransfer(spinnp_uuid_t*)", lineNumber="738"↵
For more details about configuring logging on NetApp storage, please refer to the Product Documentation
section of the NetApp Support site. Search for your ONTAP version, which can be determined by running
version -b from the command line.
> version -b
/cfcard/x86_64/freebsd/image1/kernel: OS 8.3.1P2
The steps below have been tested with ONTAP 8 and should work for earlier versions. Exact
NOTE
commands for newer versions may vary.
1. Configure NXLog to receive log entries via UDP and process them as Syslog (see the examples below). Then
restart NXLog.
2. Make sure the NXLog agent is accessible from each member of the cluster.
3. Log in to the cluster address with SSH.
4. Run the following command to configure the Syslog destination. Replace NAME and IP_ADDRESS with the
required values. The default port for UDP is 514.
5. Now select the messages to be sent. Use the same NAME as in the previous step and set MSGS to the required
value.
A list of messages can be obtained by running the command with a question mark (?) as the argument.
It is also possible to specify a severity level in addition to message types. The severity levels are EMERGENCY,
ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFORMATIONAL, and DEBUG.
738
Chapter 92. NetApp NXLog User Guide
The following commands send all messages with Informational severity level (including higher
severites) to 192.168.6.143 in Syslog format via UDP port 514.
This example shows NetApp Syslog logs as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/netapp.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.5.61",
"EventReceivedTime": "2017-04-14 15:38:58",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 0,
"SyslogFacility": "KERN",
"SyslogSeverityValue": 7,
"SyslogSeverity": "DEBUG",
"SeverityValue": 1,
"Severity": "DEBUG",
"Hostname": "192.168.5.61",
"EventTime": "2017-04-14 15:40:25",
"Message": "[p-netapp1:repl.engine.error:debug]: replStatus=\"8\", replFailureMsg=\"5898503
\", replFailureMsgDetail=\"0\", functionName=\"repl_util::Result
repl_core::Instance::endTransfer(spinnp_uuid_t*)\", lineNumber=\"738\""
}
739
NXLog User Guide Chapter 92. NetApp
Messages that contain key-value pairs, like the example at the beginning of the section, can be parsed with
the xm_kvp module to extract more fields if required.
nxlog.conf
1 <Output out>
2 Module om_null
3 </Output>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Extension kvp>
10 Module xm_kvp
11 KVPDelimiter ,
12 KVDelimiter =
13 EscapeChar \\
14 </Extension>
15
16 <Input in_syslog_udp>
17 Module im_udp
18 Host 0.0.0.0
19 Port 514
20 <Exec>
21 parse_syslog();
22 if $Message =~ /(?x)^\[([a-z-A-Z0-9-]*):([a-z-A-Z.]*):([a-z-A-Z]*)\]:
23 \ ([a-zA-Z]+=.+)/
24 {
25 $NAUnit = $1;
26 $NAMsgName = $2;
27 $NAMsgSev = $3;
28 $NAMessage = $4;
29 kvp->parse_kvp($4);
30 }
31 </Exec>
32 </Input>
740
Chapter 92. NetApp NXLog User Guide
Output Sample
{
"MessageSourceAddress": "192.168.5.63",
"EventReceivedTime": "2017-04-15 23:13:45",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 0,
"SyslogFacility": "KERN",
"SyslogSeverityValue": 7,
"SyslogSeverity": "DEBUG",
"SeverityValue": 1,
"Severity": "DEBUG",
"Hostname": "192.168.5.63",
"EventTime": "2017-04-15 23:15:14",
"Message": "[p-netapp3:repl.engine.error:debug]: replStatus=\"5\", replFailureMsg=\"5898500
\", replFailureMsgDetail=\"0\", functionName=\"void
repl_volume::Query::_queryResponse(repl_spinnp::Request&, const spinnp_repl_result_t&,
repl_spinnp::Response*)\", lineNumber=\"149\"",
"NAUnit": "p-netapp3",
"NAMsgName": "repl.engine.error",
"NAMsgSev": "debug",
"NAMessage": "replStatus=\"5\", replFailureMsg=\"5898500\", replFailureMsgDetail=\"0\",
functionName=\"void repl_volume::Query::_queryResponse(repl_spinnp::Request&, const
spinnp_repl_result_t&, repl_spinnp::Response*)\", lineNumber=\"149\"",
"replStatus": "5",
"replFailureMsg": "5898500",
"replFailureMsgDetail": "0",
"functionName": "void repl_volume::Query::_queryResponse(repl_spinnp::Request&, const
spinnp_repl_result_t&, repl_spinnp::Response*)",
"lineNumber": "149"
}
To accomplish this, create and enable an audit policy for each virtual server.
These commands set up an audit policy that sends logs to the specified share, rotates log files at 100 MB,
and retains the last 10 rotated log files.
741
NXLog User Guide Chapter 92. NetApp
This example shows NetApp events as collected and processed by NXLog from an EventLog file.
nxlog.conf
1 <Input in_file_evt>
2 Module im_msvistalog
3 File C:\Temp\NXLog\audit_vs_p12_cifs_last.evtx
4 </Input>
5
6 <Output file_from_eventlog>
7 Module om_file
8 File "C:\Temp\evt.log"
9 Exec to_json();
10 </Output>
Output Sample
{
"EventTime": "2017-05-10 21:17:12",
"Hostname": "e3864b4d-8937-11e5-b812-00a098831757/bf4a40a5-9216-11e5-8d9a-00a098831757",
"Keywords": -9214364837600035000,
"EventType": "AUDIT_SUCCESS",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 4624,
"SourceName": "NetApp-Security-Auditing",
"ProviderGuid": "{3CB2A168-FE19-4A4E-BDAD-DCF422F13473}",
"Version": 101,
"OpcodeValue": 0,
"RecordNumber": 0,
"ProcessID": 0,
"ThreadID": 0,
"Channel": "Security",
"ERROR_EVT_UNRESOLVED": true,
"IpAddress' IPVersion='4": "192.168.17.151",
"IpPort": "49421",
"TargetUserSID": "S-1-5-21-4103495029-501085275-2219630704-2697",
"TargetUserName": "App_Service",
"TargetUserIsLocal": "false",
"TargetDomainName": "DOMAIN",
"AuthenticationPackageName": "KRB5",
"LogonType": "3",
"EventReceivedTime": "2017-05-10 22:33:00",
"SourceModuleName": "in_file_evt",
"SourceModuleType": "im_msvistalog"
}
742
Chapter 93. .NET Application Logs NXLog User Guide
This guide uses the SharpDevelop IDE, but Microsoft Visual Studio™ on Windows, or MonoDevelop on Linux
could also be used. The log4net package and log4net.Ext.Json extension are also required.
The following instructions were tested with SharpDevelop 5.1.0, .NET 4.5, log4net 2.0.5, and
log4net.Ext.Json 1.2.15.14586. To use NuGet packages without the NuGet package manager,
NOTE
simply download the nupkg file using the "Download" link, add a .zip extension to the file
name, and extract.
1. Create a new Solution in SharpDevelop by selecting File › New › Solution and choosing the Console
Application option. Enter a name and click [Create].
2. Place the log4net and log4net.Ext.Json DLL files in the bin\Debug directory of your project.
3. Select Project › Add Reference. Open the .NET Assembly Browser tab and click [Browse]. Add the two
DLL files so that they appear in the Selected References list, then click [OK].
4. Edit the AssemblyInfo.cs file (under Properties in the Projects sidebar) and add the following line.
743
NXLog User Guide Chapter 93. .NET Application Logs
5. Click the Refresh icon in the Projects sidebar to show all project files.
6. Create a file named App.config in the bin\Debug folder, open it for editing, and add the following code.
Update the remoteAddress value of the with the IP address (or host name) of the NXLog instance.
App.config
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<remoteAddress value="192.168.56.103" />
<remotePort value="514" />
<layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json" />
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="UdpAppender"/>
</root>
</log4net>
</configuration>
7. Edit the Program.cs file, and replace its contents with the following code. This loads the log4net module and
creates some sample log messages.
744
Chapter 93. .NET Application Logs NXLog User Guide
Program.cs
using System;
using log4net;
namespace demo
{
class Program
{
private static readonly log4net.ILog mylog = log4net.LogManager.GetLogger(typeof(
Program));
public static void Main(string[] args)
{
log4net.Config.BasicConfigurator.Configure();
mylog.Debug("This is a debug message");
mylog.Warn("This is a warn message");
mylog.Error("This is an error message");
mylog.Fatal("This is a fatal message");
Console.ReadLine();
}
}
}
8. Configure NXLog.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input in>
6 Module im_udp
7 Host 0.0.0.0
8 Port 514
9 <Exec>
10 $raw_event =~ s/\s+$//;
11
12 # Parse JSON into fields for later processing if required
13 parse_json();
14 </Exec>
15 </Input>
16
17 <Output out>
18 Module om_file
19 File "/tmp/output"
20 </Output>
21
22 <Route r>
23 Path in => out
24 </Route>
9. In SharpDevelop, press the F5 key to build and run the application. The following output should appear.
Demo Output
4301 [1] DEBUG demo.Program (null) - This is a debug message↵
4424 [1] WARN demo.Program (null) - This is a warn message↵
4425 [1] ERROR demo.Program (null) - This is an error message↵
4426 [1] FATAL demo.Program (null) - This is a fatal message↵
10. Examine the /tmp/output file. It should show the sample log entries produced by the .NET application.
745
NXLog User Guide Chapter 93. .NET Application Logs
NXLog Output
{"date":"2014-03-
19T09:41:08.7231787+01:00","Level":"DEBUG","AppDomain":"demo.exe","Logger":"demo.Program","Threa
d":"1","Message":"This is a debug message","Exception":""}↵
{"date":"2014-03-
19T09:41:08.8456254+01:00","Level":"WARN","AppDomain":"demo.exe","Logger":"demo.Program","Thread
":"1","Message":"This is a warn message","Exception":""}↵
{"date":"2014-03-
19T09:41:08.8466327+01:00","Level":"ERROR","AppDomain":"demo.exe","Logger":"demo.Program","Threa
d":"1","Message":"This is an error message","Exception":""}↵
{"date":"2014-03-
19T09:41:08.8476223+01:00","Level":"FATAL","AppDomain":"demo.exe","Logger":"demo.Program","Threa
d":"1","Message":"This is a fatal message","Exception":""}↵
746
Chapter 94. Nginx NXLog User Guide
With the following directive, Nginx will log all messages of "warn" severity or higher to the specified log file.
nginx.conf
error_log /var/log/nginx/error.log warn;
Following is a log message generated by Nginx, an NXLog configuration for parsing it, and the resulting
JSON.
Log Sample
2017/08/07 04:37:16 [emerg] 17479#17479: epoll_create() failed (24: Too many open files)↵
nxlog.conf
1 <Input nginx_error>
2 Module im_file
3 File '/var/log/nginx/error.log'
4 <Exec>
5 if $raw_event =~ /^(\S+ \S+) \[(\S+)\] (\d+)\#(\d+): (\*(\d+) )?(.+)$/
6 {
7 $EventTime = strptime($1, '%Y/%m/%d %H:%M:%S');
8 $NginxLogLevel = $2;
9 $NginxPID = $3;
10 $NginxTID = $4;
11 if $6 != '' $NginxCID = $6;
12 $Message = $7;
13 }
14 </Exec>
15 </Input>
Output Sample
{
"EventReceivedTime": "2017-08-07T04:37:16.245375+02:00",
"SourceModuleName": "nginx_error",
"SourceModuleType": "im_file",
"EventTime": "2017-08-07T04:37:16.000000+02:00",
"NginxLogLevel": "emerg",
"NginxPID": "17479",
"NginxTID": "17479",
"Message": "epoll_create() failed (24: Too many open files)"
}
747
NXLog User Guide Chapter 94. Nginx
With this directive, Nginx will forward all messages of "warn" severity or higher to the specified Syslog
server. The messages will be generated with the "local7" facility.
nginx.conf
error_log syslog:server=192.168.1.1:514,facility=local7 warn;
nxlog.conf
1 <Input nginx_error>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /^\S+ \S+ \[\S+\] (\d+)\#(\d+): (\*(\d+) )?(.+)$/
8 {
9 $NginxPID = $1;
10 $NginxTID = $2;
11 if $4 != '' $NginxCID = $4;
12 $Message = $5;
13 }
14 </Exec>
15 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.1.12",
"EventReceivedTime": "2017-08-07T04:37:16.441368+02:00",
"SourceModuleName": "nginx_error",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 23,
"SyslogFacility": "LOCAL7",
"SyslogSeverityValue": 1,
"SyslogSeverity": "ALERT",
"SeverityValue": 5,
"Severity": "CRITICAL",
"Hostname": "nginx-host",
"EventTime": "2017-08-07T04:37:16.000000+02:00",
"SourceName": "nginx",
"Message": "epoll_create() failed (24: Too many open files)",
"NginxPID": "17479",
"NginxTID": "17479"
}
748
Chapter 94. Nginx NXLog User Guide
With this directive, Nginx will forward all messages of "warn" severity or higher to the specified Unix
domain socket. The messages will be sent in Syslog format with the "local7" Syslog facility.
nginx.conf
error_log syslog:server=unix:/var/log/nginx/error.sock,facility=local7 warn;
nxlog.conf
1 <Input nginx_error>
2 Module im_uds
3 UDS /var/log/nginx/error.sock
4 <Exec>
5 parse_syslog();
6 if $Message =~ /^\S+ \S+ \[\S+\] (\d+)\#(\d+): (\*(\d+) )?(.+)$/
7 {
8 $NginxPID = $1;
9 $NginxTID = $2;
10 if $4 != '' $NginxCID = $4;
11 $Message = $5;
12 }
13 </Exec>
14 </Input>
The log format can be customized by setting the log_format directive; see the Nginx documentation for more
information.
749
NXLog User Guide Chapter 94. Nginx
With this directive, Nginx will forward access logs to the specified Syslog server. The messages will be
generated with the "local7" facility and the "info" severity.
nginx.conf
access_log syslog:server=192.168.1.1:514,facility=local7,severity=info;
nxlog.conf
1 <Input nginx_access>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /(?x)^(\S+)\ \S+\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
8 \ HTTP\/\d\.\d\"\ (\S+)\ (\S+)\ \"([^\"]+)\"
9 \ \"([^\"]+)\"/
10 {
11 $Hostname = $1;
12 if $2 != '-' $AccountName = $2;
13 $EventTime = parsedate($3);
14 $HTTPMethod = $4;
15 $HTTPURL = $5;
16 $HTTPResponseStatus = $6;
17 if $7 != '-' $FileSize = $7;
18 if $8 != '-' $HTTPReferer = $8;
19 if $9 != '-' $HTTPUserAgent = $9;
20 delete($Message);
21 }
22 </Exec>
23 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.1.12",
"EventReceivedTime": "2017-08-07T06:15:55.662319+02:00",
"SourceModuleName": "nginx_access",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 23,
"SyslogFacility": "LOCAL7",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "192.168.1.12",
"EventTime": "2017-08-07T06:15:55.000000+02:00",
"SourceName": "nginx",
"HTTPMethod": "GET",
"HTTPURL": "/",
"HTTPResponseStatus": "304",
"FileSize": "0",
"HTTPUserAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0"
}
750
Chapter 94. Nginx NXLog User Guide
With this directive, Nginx will forward all messages of "warn" severity or higher to the specified Unix
domain socket. The messages will be sent in Syslog format with the "local7" Syslog facility.
nginx.conf
access_log syslog:server=unix:/var/log/nginx/access.sock,facility=local7,severity=info;
nxlog.conf
1 <Input nginx_access>
2 Module im_uds
3 UDS /var/log/nginx/access.sock
4 <Exec>
5 parse_syslog();
6 if $Message =~ /(?x)^(\S+)\ \S+\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
7 \ HTTP\/\d\.\d\"\ (\S+)\ (\S+)\ \"([^\"]+)\"
8 \ \"([^\"]+)\"/
9 {
10 $Hostname = $1;
11 if $2 != '-' $AccountName = $2;
12 $EventTime = parsedate($3);
13 $HTTPMethod = $4;
14 $HTTPURL = $5;
15 $HTTPResponseStatus = $6;
16 if $7 != '-' $FileSize = $7;
17 if $8 != '-' $HTTPReferer = $8;
18 if $9 != '-' $HTTPUserAgent = $9;
19 delete($Message);
20 }
21 </Exec>
22 </Input>
751
NXLog User Guide Chapter 95. Okta
NXLog can be set up to pull events from Okta using their REST API. For more information, see the Okta add-on.
752
Chapter 96. Osquery NXLog User Guide
According to Osquery’s documentation, osquery "does not implement log forwarding internally." In fact, "the act
of forwarding logs and analyzing logs is mostly left as an exercise for the reader." NXLog can be integrated with
osquery to forward logs when deployed on Windows, MacOS, Linux, and FreeBSD.
1 bash /usr/bin/bash
22 bash /usr/bin/bash
37 vim /usr/bin/vim
0 [System Process]
4 System
For more information about osquery commands, see the osqueryi (shell) and SQL Introduction sections on the
osquery website.
• differential — logs changes in the system between the previous and the current query executions.
753
NXLog User Guide Chapter 96. Osquery
For more information on installing osquery, see the Getting Started section on the osquery website.
Osquery can be configured via the osquery.conf file using a JSON format. This file should be located under the
following paths:
• Linux: /etc/osquery/
• FreeBSD: /usr/local/etc/
• MacOS: /private/var/osquery/
The following configuration is an example of a differential logging configuration. The schedule object
contains the nested processes object, which contains two fields:
• query — This key specifies the SQL statement. In this case, it selects all entries from the processes
table.
• interval — This key contains the number of seconds after which the statement is executed again. In
this example, the query is executed every 10 seconds.
osquery.conf
{
"schedule": {
"processes": {
"query": "SELECT pid, name, path FROM processes;",
"interval": 10
}
}
}
The processes object contains the additional snapshot key, which is a boolean flag to enable the snapshot
logging mode.
osquery.conf
{
"schedule": {
"processes": {
"query": "SELECT pid, name, path FROM processes;",
"interval": 10,
"snapshot": true
}
}
}
For more information, see the Configuration section on the osquery website.
754
Chapter 96. Osquery NXLog User Guide
• osqueryd.INFO,
• osqueryd.WARNING,
• osqueryd.ERROR.
By default, all osquery log files are available under the following paths:
Below are the samples of the execution logs from Ubuntu and Windows.
osqueryd.INFO on Ubuntu
Log file created at: 2019/11/25 10:07:54↵
Running on machine: ubuntu↵
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg↵
I1125 10:07:54.233732 28060 events.cpp:863] Event publisher not enabled: auditeventpublisher:
Publisher disabled via configuration↵
I1125 10:07:54.233835 28060 events.cpp:863] Event publisher not enabled: syslog: Publisher
disabled via configuration↵
osqueryd.INFO on Windows
Log file created at: 2019/11/28 10:57:00↵
Running on machine: WIN-SFULD4GOF4H↵
Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg↵
I1128 10:57:00.979398 3908 scheduler.cpp:105] Executing scheduled query processes: SELECT pid,
name, path FROM processes;↵
E1128 10:57:01.009029 3908 processes.cpp:312] Failed to lookup path information for process 4↵
E1128 10:57:01.024600 3908 processes.cpp:332] Failed to get cwd for 4 with 31↵
I1128 10:58:01.649113 3908 scheduler.cpp:105] Executing scheduled query processes: SELECT pid,
name, path FROM processes;↵
E1128 10:58:01.681404 3908 processes.cpp:312] Failed to lookup path information for process 4↵
E1128 10:58:01.712568 3908 processes.cpp:332] Failed to get cwd for 4 with 31↵
755
NXLog User Guide Chapter 96. Osquery
Below are the samples of the differential logs from Ubuntu and Windows.
osqueryd.results.log on Ubuntu
{"name":"users","hostIdentifier":"ubuntu","calendarTime":"Mon Nov 25 09:11:40 2019
UTC","unixTime":1574673100,"epoch":0,"counter":0,"logNumericsAsNumbers":false,"columns":{"direc
tory":"/","uid":"111","username":"kernoops"},"action":"removed"}↵
{"name":"users","hostIdentifier":"ubuntu","calendarTime":"Mon Nov 25 09:11:40 2019
UTC","unixTime":1574673100,"epoch":0,"counter":0,"logNumericsAsNumbers":false,"columns":{"direc
tory":"/bin","uid":"2","username":"bin"},"action":"removed"}↵
osqueryd.results.log on Windows
{"name":"processes","hostIdentifier":"WIN-SFULD4GOF4H","calendarTime":"Fri Nov 29 18:18:00 2019
UTC","unixTime":1575051480,"epoch":0,"counter":23,"logNumericsAsNumbers":false,"columns":{"name
":"conhost.exe","path":"C:\\Windows\\System32\\conhost.exe","pid":"2936"},"action":"removed"}↵
{"name":"processes","hostIdentifier":"WIN-SFULD4GOF4H","calendarTime":"Fri Nov 29 18:18:00 2019
UTC","unixTime":1575051480,"epoch":0,"counter":23,"logNumericsAsNumbers":false,"columns":{"name
":"dllhost.exe","path":"C:\\Windows\\System32\\dllhost.exe","pid":"3784"},"action":"removed"}↵
Below are the samples of the snapshot logs from Ubuntu and Windows.
osqueryd.snapshots.log on Ubuntu
{"snapshot":[{"name":"gsd-rfkill","path":"/usr/lib/gnome-settings-daemon/gsd-
rfkill","pid":"944"},{"name":"gsd-screensaver","path":"/usr/lib/gnome-settings-daemon/gsd-
screensaver-proxy","pid":"947"},{"name":"gsd-sharing","path":"/usr/lib/gnome-settings-
daemon/gsd-sharing","pid":"949"},{"name":"gsd-smartcard","path":"/usr/lib/gnome-settings-
daemon/gsd-smartcard","pid":"955"},{"name":"gsd-sound","path":"/usr/lib/gnome-settings-
daemon/gsd-sound","pid":"962"},{"name":"gsd-wacom","path":"/usr/lib/gnome-settings-daemon/gsd-
wacom","pid":"965"},{"name":"kstrp","path":"","pid":"98"}],"action":"snapshot","name":"users","
hostIdentifier":"ubuntu","calendarTime":"Mon Nov 25 09:14:25 2019
UTC","unixTime":1574673265,"epoch":0,"counter":0,"logNumericsAsNumbers":false}↵
osqueryd.snapshots.log on Windows
{"snapshot":[{"name":"[System
Process]","path":"","pid":"0"},{"name":"System","path":"","pid":"4"},{"name":"smss.exe","path":
"C:\\Windows\\System32\\smss.exe","pid":"244"},{"name":"csrss.exe","path":"C:\\Windows\\System3
2\\csrss.exe","pid":"328"},{"name":"wininit.exe","path":"C:\\Windows\\System32\\wininit.exe","p
id":"408"},{"name":"winlogon.exe","path":"C:\\Windows\\System32\\winlogon.exe","pid":"452"},{"n
ame":"services.exe","path":"C:\\Windows\\System32\\services.exe","pid":"512"},{"name":"RuntimeB
roker.exe","path":"C:\\Windows\\System32\\RuntimeBroker.exe","pid":"2664"},{"name":"sihost.exe"
,"path":"C:\\Windows\\System32\\sihost.exe","pid":"2700"},{"name":"svchost.exe","path":"C:\\Win
dows\\System32\\svchost.exe","pid":"2708"}],"action":"snapshot","name":"processes","hostIdentif
ier":"WIN-SFULD4GOF4H","calendarTime":"Fri Nov 29 18:13:04 2019
UTC","unixTime":1575051184,"epoch":0,"counter":0,"logNumericsAsNumbers":false}↵
For more information about the logging system of osquery, see the Logging section on the osquery website.
756
Chapter 96. Osquery NXLog User Guide
The following configuration uses the im_file module to read the osquery log entries and process them with
the xm_json module.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input osquery_diff>
6 Module im_file
7 File "/var/log/osquery/osqueryd.results.log"
8 Exec parse_json();
9 </Input>
10
11 <Input osquery_snap>
12 Module im_file
13 File "/var/log/osquery/osqueryd.snapshots.log"
14 Exec parse_json();
15 </Input>
The following configuration uses the im_file module to read the osquery log entries and process them with
the xm_json module.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input osquery_diff>
6 Module im_file
7 File "C:\\Program Files\\osquery\\log\\osqueryd.results.log"
8 Exec parse_json();
9 </Input>
10
11 <Input osquery_snap>
12 Module im_file
13 File "C:\\Program Files\\osquery\\log\\osqueryd.snapshots.log"
14 Exec parse_json();
15 </Input>
Using an appropriate output module, NXLog can be configured to forward osquery logs to a remote system.
As an example, the om_tcp module is used.
nxlog.conf
1 <Output snap_out>
2 Module om_tcp
3 Host 192.168.1.1
4 Port 1515
5 </Output>
757
NXLog User Guide Chapter 97. Postfix
The component indicates the Postfix process that produced the log message. Most log entries, those relevant to
particular email messages, also include the queue ID of the email message as the first part of the message.
Log Sample
Oct 10 01:23:45 mailhost postfix/smtpd[2534]: 4F9D195432C: client=localhost[127.0.0.1]↵
Oct 10 01:23:45 mailhost postfix/cleanup[2536]: 4F9D195432C: message-
id=<20161001103311.4F9D195432C@mail.example.com>↵
Oct 10 01:23:46 mailhost postfix/qmgr[2531]: 4F9D195432C: from=<origin@other.com>, size=344, nrcpt=1
(queue active)↵
Oct 10 01:23:46 mailhost postfix/smtp[2538]: 4F9D195432C: to=<destination@example.com>,
relay=mail.example.com[216.150.150.131], delay=11, status=sent (250 Ok: queued as 8BDCA22DA71)↵
lmtp_tls_loglevel
smtp_tls_loglevel
smtpd_tls_loglevel
The loglevel directives should be set to 0 (disabled, the default) or 1 during normal operation. Values of 2 or
3 can be used for troubleshooting.
debug_peer_level
Specify the increment in logging level when a remote client or server matches a pattern in the
debug_peer_list parameter (default 2).
debug_peer_list
Provide a list of remote client or server hostnames or network address patterns for which to increase the
logging level.
See the Postfix Debugging Howto and the postconf(5) man page for more information.
758
Chapter 97. Postfix NXLog User Guide
This configuration reads the Postfix logs from file and forwards them via TCP to a remote host.
nxlog.conf
1 <Input postfix>
2 Module im_file
3 File "/var/log/mail.log"
4 </Input>
5
6 <Output out>
7 Module om_tcp
8 Host 192.168.1.1
9 Port 1514
10 </Output>
It is also possible to parse individual Postfix messages into fields, providing access to more fine-grained filtering
and analysis of log data. The NXLog Exec directive can be used to apply regular expressions for this purpose.
759
NXLog User Guide Chapter 97. Postfix
Here is the Input module instance again, extended to parse the Postfix messages in the example above.
Various fields are added to the event record, depending on the particular message received. Then in the
Output module instance, only those log entries that are from Postfix’s smtp component and are being
relayed through mail.example.com are logged to the output file.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input postfix>
6 Module im_file
7 File "/var/log/mail.log"
8 <Exec>
9 if $raw_event =~ /(?x)^(\S+\ +\d+\ \d+:\d+:\d+)\ (\S+)
10 \ postfix\/(\S+)\[(\d+)\]:\ (.+)$/
11 {
12 $EventTime = parsedate($1);
13 $HostName = $2;
14 $SourceName = "postfix";
15 $Component = $3;
16 $ProcessID = $4;
17 $Message = $5;
18 if $Component == "smtpd" and
19 $Message =~ /(\w+): client=(\S+)\[([\d.]+)\]/
20 {
21 $QueueID = $1;
22 $ClientHostname = $2;
23 $ClientIP = $3;
24 }
25 if $Component == "cleanup" and
26 $Message =~ /(\w+): message-id=(<\S+@\S+>)/
27 {
28 $QueueID = $1;
29 [...]
Using the example log entries above, this configuration results in a single JSON entry written to the log file.
760
Chapter 97. Postfix NXLog User Guide
Output Sample
{
"EventReceivedTime": "2016-10-05 16:38:57",
"SourceModuleName": "postfix",
"SourceModuleType": "im_file",
"EventTime": "2016-10-10 01:23:46",
"HostName": "mail",
"SourceName": "postfix",
"Component": "smtp",
"ProcessID": "2538",
"Message": "4F9D195432C: to=<destination@example.com>,
relay=mail.example.com[216.150.150.131], delay=11, status=sent (250 Ok: queued as
8BDCA22DA71)",
"QueueID": "4F9D195432C",
"Recipient": "<destination@example.com>",
"RelayHostname": "mail.example.com",
"RelayIP": "216.150.150.131",
"Delay": "11",
"Status": "sent",
"SMTPCode": "250",
"QueueIDDelivered": "8BDCA22DA71"
}
761
NXLog User Guide Chapter 98. Promise
Log Sample
2654 Fan 4 Enc 1 Info Apr 27, 2017 19:08:48 PSU fan or blower speed is decreased↵
There is a single management interface no matter how many shelves are installed, so configuration only needs
to be performed once from the Promise web interface or the command line.
More information about configuring Promise arrays is available in the E-Class product manual. Also, additional
details on CNMP configuration and links to MIB files are available in the following KB article.
1. Configure NXLog for receiving SNMP traps (see the example below). Remember to place the MIB file in the
directory specified by the MIBDir directive. Then restart NXLog.
2. Make sure the NXLog agent is accessible from the unit.
3. Configure Promise by using the web interface or the command line. See the following sections.
762
Chapter 98. Promise NXLog User Guide
This example shows SNMP trap messages from Promise, as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Extension snmp>
10 Module xm_snmp
11 MIBDir /usr/share/mibs/iana
12 </Extension>
13
14 <Input in_snmp_udp>
15 Module im_udp
16 Host 0.0.0.0
17 Port 162
18 InputType snmp
19 Exec parse_syslog();
20 </Input>
21
22 <Output file_snmp>
23 Module om_file
24 File "/var/log/snmp.log"
25 Exec to_json();
26 </Output>
763
NXLog User Guide Chapter 98. Promise
Output Sample
{
"SNMP.CommunityString": "public",
"SNMP.RequestID": 1295816642,
"EventTime": "2017-04-27 20:44:37",
"SeverityValue": 2,
"Severity": "INFO",
"OID.1.3.6.1.2.1.1.3.0": 67,
"OID.1.3.6.1.6.3.1.1.4.1.0": "1.3.6.1.4.1.7933.1.20.0.11.0.1",
"OID.1.3.6.1.4.1.7933.1.20.0.10.1": 2654,
"OID.1.3.6.1.4.1.7933.1.20.0.10.2": 327683,
"OID.1.3.6.1.4.1.7933.1.20.0.10.3": 327683,
"OID.1.3.6.1.4.1.7933.1.20.0.10.4": 2,
"OID.1.3.6.1.4.1.7933.1.20.0.10.5": "Fan 4 Enc 1",
"OID.1.3.6.1.4.1.7933.1.20.0.10.6": "Apr 27, 2017 19:08:48",
"OID.1.3.6.1.4.1.7933.1.20.0.10.7": "PSU fan or blower speed is decreased",
"MessageSourceAddress": "192.168.10.21",
"EventReceivedTime": "2017-04-27 20:44:37",
"SourceModuleName": "in_snmp_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"Hostname": "INFO",
"Message": "OID.1.3.6.1.2.1.1.3.0=\"67\" OID.1.3.6.1.6.3.1.1.4.1.0=
\"1.3.6.1.4.1.7933.1.20.0.11.0.1\" OID.1.3.6.1.4.1.7933.1.20.0.10.1=\"2654\"
OID.1.3.6.1.4.1.7933.1.20.0.10.2=\"327683\" OID.1.3.6.1.4.1.7933.1.20.0.10.3=\"327683\"
OID.1.3.6.1.4.1.7933.1.20.0.10.4=\"2\" OID.1.3.6.1.4.1.7933.1.20.0.10.5=\"Fan 4 Enc 1\"
OID.1.3.6.1.4.1.7933.1.20.0.10.6=\"Apr 27, 2017 19:08:48\" OID.1.3.6.1.4.1.7933.1.20.0.10.7=
\"PSU fan or blower speed is decreased\""
}
The steps below have been tested on the VTrak E600 series and should work on other models as
NOTE
well.
764
Chapter 98. Promise NXLog User Guide
5. Make sure Running Status is Started and Startup Type is set to Automatic.
6. Click [Submit] and confirm SNMP restart.
5. Specify the remote IP address under Trap Sink Server and the logging level under Trap Filter.
6. Select Save SNMP Trap Sink.
7. Select Return to Previous Menu and then Restart.
8. Make sure Startup Type is set to Automatic.
765
NXLog User Guide Chapter 99. Rapid7 InsightIDR SIEM
NXLog can be configured to collect and forward event logs to InsightIDR. It can also be used to rewrite event
fields to meet the log field name requirements of InsightIDR’s Universal Event Format (UEF).
1. Create, deploy and activate an InsightIDR Collector. A Collector is required before adding any data sources to
InsightIDR.
Read more about the requirements in Rapid7’s InsightIDR Collector Requirements documentation before you
install and deploy the InsightIDR Collector.
2. To confirm that the Collector is running, select Data Collection in the left side panel, then under the Data
Collection Management pane, select the Collectors tab.
Here you can check the state of the Collectors. If the Collector is not running, review the Collector
Troubleshooting page in the Rapid7’s Collector Troubleshooting documentation.
3. To add a new Data Source, in the Data Collection Management pane, select the Event Sources tab, then in
the Product Types list, adjacent to Rapid7, click Add.
4. To configure the Event Source, select the name of the Collector and the Event Source from the
corresponding dropdown lists, optionally enter the Display Name, and then select the Timezone from the
dropdown list.
For the Event Source, select either Rapid 7 Raw Data (if using JSON) or Rapid7 Generic Syslog (if using
Syslog-formatted logs).
5. For the Collection Method, select the Listen For Syslog button, in the Port field enter the port number, then
from the drop down list select a Protocol.
6. If TCP was selected for the Protocol, optionally select Encrypted, then click Save.
The newly created Event Source is visible under the Event Sources tab of the Data Collection Management
Pane.
766
Chapter 99. Rapid7 InsightIDR SIEM NXLog User Guide
Example 451. Event Logs Collected from Event Tracing for Windows (ETW)
This configuration uses the im_etw module to collect Windows DNS Server log data and send it to
InsightIDR as JSON.
nxlog.conf
1 <Input etw_in>
2 Module im_etw
3 Provider Microsoft-Windows-DNSServer
4 Exec to_json();
5 </Input>
767
NXLog User Guide Chapter 99. Rapid7 InsightIDR SIEM
This example sends Windows Event Log collected from the Security Channel using the im_msvistalog
module. The events are sent to InsightIDR in Snare format. When sending Windows Event Log security
events, create a data source with the type Rapid7 Generic Windows Event Log.
nxlog.conf
1 <Input eventlog_in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id='0'>
6 <Select Path='Security'>*</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 <Exec>
11 $Message = replace($Message, "\t", " "); $Message = replace \
12 ($Message, "\n", " "); $Message = replace($Message, "\r", " ");
13 $raw_event = $Message;
14 to_syslog_snare();
15 </Exec>
16 </Input>
768
Chapter 99. Rapid7 InsightIDR SIEM NXLog User Guide
In this configuration, the im_msvistalog module is configured to collect Windows DHCP events and send
them as JSON, but other types of Windows events can be collected too. In this case, the Rapid7 log source is
set as Rapid7 Generic Syslog, so the logs are indexed and parsed.
nxlog.conf
1 <Input dhcp_server_eventlog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="DhcpAdminEvents">*</Select>
7 <Select Path="Microsoft-Windows-Dhcp-Server/FilterNotifications"> \
8 *</Select>
9 <Select Path="Microsoft-Windows-Dhcp-Server/Operational">*</Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 Exec to_syslog_bsd();
14 </Input>
• The Event Source should be one of the supported Rapid7 Universal Event Format types.
• The logs need to be converted to either JSON or KVP.
• Relevant fields should be rewrited, added and whitelisted to support the UEF specification for the log source
type.
• Confirm that the logs have no format violations and are correctly indexed by Rapid7 InsightIDR. See the
Verifying Data Collection section.
The following configuration examples are based on collecting Rapid7 Ingress Authentication events. The steps,
fields and input options will vary depending on the UEF source types. For more information, see the Universal
Event Sources section in the Rapid7 documentation.
769
NXLog User Guide Chapter 99. Rapid7 InsightIDR SIEM
Use the xm_rewrite module to rename raw data fields to match SIEM and dashboard field
NOTE
names.
Use the xm_kvp module to delete, add and rename raw data fields. For more information, see
NOTE the Universal Event Formats in InsightIDR: A Step-by-Step NXLog Guide in the Rapid7
documentation.
Use the xm_rewrite module to specify which fields to keep and rename. The fields to rewrite will depend on
the operating system as shown below. For both, the fields $version and $event_type are added.
nxlog.conf
1 <Extension rewrite>
2 Module xm_rewrite
3 # Fields associated with UEF are whitelisted
4 Keep EventTime, version, event_type, authentication_result \
5 IpAddress, WorkstationName, Hostname
6
7 # Rename the following fields to the UEF specification
8 Rename EventTime, time
9 Rename Hostname, account
10 Rename IpAddress, source_ip
11 Rename WorkstationName, authentication_target
12 Rename Version, version
13 </Extension>
nxlog.conf
1 <Extension rewrite>
2 Module xm_rewrite
3 # The syslog raw data needs to be parsed first
4 Exec parse_syslog();
5 Keep Hostname, account, version, user, custom_message, Message, \
6 event_type, EventReceivedTime, authentication_result, raw_event, \
7 authentication_target, source_ip
8 Rename HostName, authentication_target
9 Rename EventReceivedTime, time
10 Rename Message, custom_message
11 </Extension>
770
Chapter 99. Rapid7 InsightIDR SIEM NXLog User Guide
In Windows, $EventTime is converted to the required ISO 8601 format. The SUCCESS and FAILURE results
are mapped to $authentication_result based on the event ID.
nxlog.conf
1 <Input in_auth_windows>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Security">*[System[(Level<=4)]]</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 <Exec>
11 # Convert the $EventTime string to ISO 8601 extended format.
12 $EventTime = strftime($EventTime, '%Y-%m-%dT%H:%M:%SZ');
13
14 # Add the required input for $version
15 $version = "v1";
16
17 # Add the required input for $event_type
18 $event_type = "INGRESS_AUTHENTICATION";
19
20 # Add the required authentication results for EventLog IDs
21 if ($EventID IN (4625)) { $authentication_result = "FAILURE"; } \
22 else if ($EventID IN (4624)) { $authentication_result = "SUCCESS"; } \
23 # Drop all other event IDs
24 else drop();
25
26 # Add the process to rewrite the fields and convert to JSON
27 rewrite->process();
28 to_json();
29 </Exec>
30 </Input>
In Linux, $EventReceivedTime is used and converted to the ISO 8601 format. The SUCCESS and FAILURE
results are mapped to $authentication_result based on string results in the $raw_event field.
Additional parsing of the $raw_event field is made to obtain the string data for the $account and
$source_ip values.
771
NXLog User Guide Chapter 99. Rapid7 InsightIDR SIEM
nxlog.conf (truncated)
1 <Input in_auth_linux>
2 Module im_file
3 File "/var/log/auth.log"
4 <Exec>
5 # Convert the $EventReceivedTime string to ISO 8601 extended format
6 $EventReceivedTime = strftime($EventReceivedTime, '%Y-%m-%dT%H:%M:%SZ');
7
8 # Add the required input for $version
9 $version = "v1";
10
11 # Add the required input for $event_type
12 $event_type = "INGRESS_AUTHENTICATION";
13
14 # Use xm_rewrite module for the $source_ip and $account fields
15 rewrite->process();
16
17 # Obtain the $source_ip and $account string data from $raw_event
18 if ($raw_event =~ /Accepted publickey for\ (\S+)\ from\ (\S+)/)
19 {
20 $account = $1;
21 $source_ip = $2;
22 }
23
24 # Success and Authentication messages based on the $raw_event field
25 if ($raw_event =~ /authentication failure/) \
26 { $authentication_result = "FAILURE"; } \
27 else if ($raw_event =~ /successfully authenticated/) \
28 { $authentication_result = "SUCCESS"; } \
29 [...]
772
Chapter 99. Rapid7 InsightIDR SIEM NXLog User Guide
The following examples display the JSON output based on the NXLog configuration files above. It is
recommended to first test the input to determine that the fields are renamed and added. There is an
option to provide a $custom_message, as displayed in the Linux example.
773
NXLog User Guide Chapter 99. Rapid7 InsightIDR SIEM
Once indexed, logs collected using NXLog can be further processed in Rapid7 InsightIDR.
774
Chapter 100. RSA NetWitness NXLog User Guide
1. Make sure Syslog collection is enabled. RSA NetWitness creates Syslog listeners by default for UDP on port
514, TCP on port 514, and SSL on port 6514. See Configure Syslog Event Sources for Remote Collector on RSA
Link for further setup notes.
2. Add a Log Decoder using the "Envision Config File" resource.
a. From the NetWitness menu, select Configure > Live Content.
b. In the Keywords field, enter Envision Config File.
c. In the Matching Resources pane, check the Envision Config File entry and click Deploy in the menu
bar.
f. In the Review pane, review the changes and click Deploy. Click Close after the deployment task has
finished.
3. Deploy the Common Event Format.
a. From the NetWitness menu, select Live > Search.
b. In the Keywords field, enter Common Event Format.
775
NXLog User Guide Chapter 100. RSA NetWitness
c. In the Matching Resources pane, check the Common Event Format entry and click Deploy in the
menu bar.
c. Enable the cef parser in the Service Parsers Configuration and click Apply.
776
Chapter 100. RSA NetWitness NXLog User Guide
c. Edit the file, adding the following lines after the end of the preceding <MESSAGE … /> section:
<MESSAGE
id1="NXLog_NXLog"
id2="NXLog_NXLog"
eventcategory="1612000000"
functions="<@msg:*PARMVAL($MSG)><@event_time:*EVNTTIME($MSG,'%R %F
%Z',event_time_string)><@endtime:*EVNTTIME($MSG,'%W-%D-%G
%Z',param_endtime)><@starttime:*EVNTTIME($MSG,'%W-%G-%FT%Z',param_starttime)>"
content="<param_endtime><param_starttime><msghold>" />
6. If required, edit the CEF custom configuration to support custom fields as follows.
a. Connect via SFTP.
b. Locate and back up the XML file at /etc/netwitness/ng/envision/etc/devices/cef/cef-
custom.xml, if it exists.
c. Create the file with the following contents. Or if the file already exists, add only the required sections.
<VendorProducts>
<Vendor2Device vendor="NXlog" product="NXLog Enterprise Edition"
device="NXLog_NXLog" group="Analysis"/>
</VendorProducts>
<ExtensionKeys>
<ExtensionKey cefName="Keywords" metaName="Keywords"/>
<ExtensionKey cefName="Severity" metaName="Severity"/>
<ExtensionKey cefName="SeverityValue" metaName="SeverityValue"/>
<ExtensionKey cefName="SourceName" metaName="SourceName"/>
<ExtensionKey cefName="ProviderGuid" metaName="ProviderGuid"/>
<ExtensionKey cefName="TaskValue" metaName="TaskValue"/>
<ExtensionKey cefName="OpcodeValue" metaName="OpcodeValue"/>
<ExtensionKey cefName="RecordNumber" metaName="RecordNumber"/>
<ExtensionKey cefName="ExecutionProcessID" metaName="ExecutionProcessID"/>
<ExtensionKey cefName="ExecutionThreadID" metaName="ExecutionThreadID"/>
<ExtensionKey cefName="param2" metaName="param2"/>
<ExtensionKey cefName="SourceModuleName" metaName="SourceModuleName"/>
<ExtensionKey cefName="SourceModuleType" metaName="SourceModuleType"/>
<ExtensionKey cefName="EventReceivedTime" metaName="param_starttime"/>
777
NXLog User Guide Chapter 100. RSA NetWitness
<mappings>
<mapping envisionName="severity" nwName="severity" flags="None" format="Text"/>
<mapping envisionName="Keywords" nwName="Keywords" flags="None" format="Text"/>
<mapping envisionName="Severity" nwName="Severity" flags="None" format="Text"/>
<mapping envisionName="SeverityValue" nwName="SeverityValue" flags="None" format="Text"/>
<mapping envisionName="dvcpid" nwName="dvcpid" flags="None" format="Text"/>
<mapping envisionName="hardware_id" nwName="hardware.id" flags="None" format="Text"/>
<mapping envisionName="SourceName" nwName="SourceName" flags="None" format="Text"/>
<mapping envisionName="ProviderGuid" nwName="ProviderGuid" flags="None" format="Text"/>
<mapping envisionName="TaskValue" nwName="TaskValue" flags="None" format="Text"/>
<mapping envisionName="OpcodeValue" nwName="OpcodeValue" flags="None" format="Text"/>
<mapping envisionName="RecordNumber" nwName="RecordNumber" flags="None" format="Text"/>
<mapping envisionName="ExecProcID" nwName="ExecProcID" flags="None" format="Text"/>
<mapping envisionName="ExecThreadID" nwName="ExecThreadID" flags="None" format="Text"/>
<mapping envisionName="cs_devfacility" nwName="deviceFacility" flags="None" format="Text"/>
<mapping envisionName="info" nwName="info" flags="None" format="Text"/>
<mapping envisionName="param2" nwName="param2" flags="None" format="Text"/>
<mapping envisionName="SourceModuleName" nwName="SourceModuleName" flags="None"
format="Text"/>
<mapping envisionName="SourceModuleType" nwName="SourceModuleType" flags="None"
format="Text"/>
<mapping envisionName="param_endtime" nwName="end" flags="None" format="TimeT"/>
<mapping envisionName="param_starttime" nwName="start" flags="none" format="TimeT"/>
</mappings>
778
Chapter 100. RSA NetWitness NXLog User Guide
779
NXLog User Guide Chapter 100. RSA NetWitness
This example configuration reads from the Windows EventLog with im_msvistalog, converts the log data to
CEF, and forwards it to NetWitness via TCP.
The xm_cef extension module provides the to_cef() function, which generates the CEF format. The xm_syslog
extension module provides the to_syslog_bsd() procedure, which adds the BSD Syslog header.
nxlog.conf
1 <Extension _cef>
2 Module xm_cef
3 </Extension>
4
5 <Extension syslog>
6 Module _xm_syslog
7 </Extension>
8
9 <Input eventlog>
10 Module im_msvistalog
11 </Input>
12
13 <Output netwitness_tcp>
14 Module om_tcp
15 Host 127.0.0.1
16 Port 514
17 <Exec>
18 $Message = to_cef();
19 to_syslog_bsd();
20 </Exec>
21 </Output>
nxlog.conf
1 <Output netwitness_udp>
2 Module om_udp
3 Host 127.0.0.1
4 Port 514
5 <Exec>
6 $Message = to_cef();
7 to_syslog_bsd();
8 </Exec>
9 </Output>
Go to Admin and select the Log Decoder. In the Events area, select an event to view its details.
780
Chapter 100. RSA NetWitness NXLog User Guide
It is also possible to examine the raw log to verify that the output to NetWitness is in CEF.
Output Sample
Nov 13 12:34:17 test.test.com Service_Control_Manager: CEF:0|NXLog|NXLog|4.1.4016|0|-|7|end=2018-11-
13 12:34:17 dvchost=test.test.com Keywords=9259400833873739776 outcome=INFO SeverityValue=2
Severity=INFO externalId=7036 SourceName=Service Control Manager ProviderGuid={555908D1-A6D7-4695-
8E1E-26931D2012F4} Version=0 TaskValue=0 OpcodeValue=0 RecordNumber=3037 ExecutionProcessID=496
ExecutionThreadID=2136 deviceFacility=System msg=The Windows Installer service entered the stopped
state. param1=Windows Installer param2=stopped EventReceivedTime=2018-11-13 12:40:28
SourceModuleName=eventlog SourceModuleType=im_msvistalog↵
781
NXLog User Guide Chapter 101. SafeNet KeySecure
In case of a cluster with two or more KeySecure devices, the configuration change on one of them will be
replicated to other members. Each member will be sending logs separately. For more details regarding logging
configuration on SafeNet KeySecure, refer to the KeySecure Appliance User Guide.
This section covers configuration for sending logs via UDP. To use TCP instead, just select it
NOTE
instead where appropriate.
1. Configure NXLog for receiving Syslog logs (see the examples below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from the KeySecure device.
3. Configure Syslog logging on KeySecure using either the web interface or the command line. See the following
sections.
The steps in the following sections have been tested on KeySecure 460 and should work on
NOTE
other models also.
782
Chapter 101. SafeNet KeySecure NXLog User Guide
This example shows a KeySecure Audit log message as received and processed by NXLog. Use the im_tcp
module instead of im_udp to receive Syslog messages via TCP instead.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/keysecure.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.5.20",
"EventReceivedTime": "2017-03-26 18:11:36",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 17,
"SyslogFacility": "LOCAL1",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "p-keysecure1",
"EventTime": "2017-03-26 18:12:26",
"SourceName": "IngrianAudit",
"Message": "2017-03-26 18:12:26 [admin] [Login] [CLI]: Logged in from 192.168.15.231 via SSH"
}
783
NXLog User Guide Chapter 101. SafeNet KeySecure
Additional field extraction can also be configured. Note that this depends on which particular log the
message is coming from, as each has a different format.
nxlog.conf
1 <Input in_syslog_udp>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ /(?x)^\d{4}-\d{2}-\d{2}\ \d{2}:\d{2}:\d{2}\ \[([a-zA-Z]*)\]
8 \ \[([a-zA-Z]*)\]\ \[([a-zA-Z]*)\]:\ (.*)$/
9 {
10 $KSUsername = $1;
11 $KSEvent = $2;
12 $KSSubsys = $3;
13 $KSMessage = $4;
14 }
15 </Exec>
16 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.5.20",
"EventReceivedTime": "2017-04-15 19:14:59",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 17,
"SyslogFacility": "LOCAL1",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "p-keysecure1",
"EventTime": "2017-04-15 19:16:29",
"SourceName": "IngrianAudit",
"Message": "2017-04-15 19:16:29 [admin] [Login] [CLI]: Logged in from 192.168.15.231 via
SSH",
"KSUsername": "admin",
"KSEvent": "Login",
"KSSubsys": "CLI",
"KSMessage": "Logged in from 192.168.15.231 via SSH"
}
784
Chapter 101. SafeNet KeySecure NXLog User Guide
5. Click [Save].
6. Repeat for the other log types as required.
# configure
# system syslog
# audit syslog
# activity syslog
# clientevent syslog
The following commands enable sending System logs to 192.168.6.43 via UDP port 514.
p-keysecure1# configure
p-keysecure1 (config)# system syslog
Enable Syslog [y]:
Syslog Server #1 IP: 192.168.6.143
Syslog Server #1 Port [514]:
Server #1 Proto:
1: udp
2: tcp
Enter a number (1 - 2) [1]:
Syslog Server #2 IP:
Syslog Server #2 Port [514]:
Server #2 Proto:
1: udp
2: tcp
Enter a number (1 - 2) [1]:
Syslog Facility:
1: local0
2: local1
3: local2
4: local3
5: local4
6: local5
7: local6
8: local7
Enter a number (1 - 8) [2]:
System Log syslog settings successfully saved. Syslog is enabled.
Warning: The syslog protocol insecurely transfers logs in cleartext
785
NXLog User Guide Chapter 102. Salesforce
NXLog can be set up to fetch Event Log Files from Salesforce using the REST API. For more information, see the
Salesforce add-on.
786
Chapter 103. Snare NXLog User Guide
The Snare format can be used with or without the Syslog header.
Snare Format
HOSTNAME ⇥ MSWinEventLog ⇥ Criticality ⇥ EventLogSource ⇥ SnareCounter ⇥ SubmitTime ⇥ EventID ⇥
SourceName ⇥ UserName ⇥ SIDType ⇥ EventLogType ⇥ ComputerName ⇥ CategoryString ⇥ DataString ⇥
ExpandedString ⇥ OptionalMD5Checksum↵
787
NXLog User Guide Chapter 103. Snare
With the following configuration, NXLog will accept Snare format logs via UDP, parse them, convert to JSON,
and output the result to file. This configuration supports both "Snare over Syslog" and the regular Snare
format.
nxlog.conf (truncated)
1 <Extension snare>
2 Module xm_csv
3 Fields $MSWINEventLog, $Criticality, $EventLogSource, $SnareCounter, \
4 $SubmitTime, $EventID, $SourceName, $UserName, $SIDType, \
5 $EventLogType, $ComputerName, $Category, $Data, $Expanded, \
6 $MD5Checksum
7 FieldTypes string, integer, string, integer, datetime, integer, string, \
8 string, string, string, string, string, string, string, string
9 Delimiter \t
10 </Extension>
11
12 <Extension json>
13 Module xm_json
14 </Extension>
15
16 <Extension syslog>
17 Module xm_syslog
18 </Extension>
19
20 <Input in>
21 Module im_udp
22 Host 0.0.0.0
23 Port 6161
24 <Exec>
25 parse_syslog_bsd();
26 if $Message =~ /^((\w+)\t)?(MSWinEventLog.+)$/
27 {
28 if $2 != ''
29 [...]
788
Chapter 103. Snare NXLog User Guide
Output Sample
{
"EventReceivedTime": "2016-11-21 11:40:28",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "myserver",
"EventTime": "2016-11-21 11:40:27",
"Message": "Ended process ID: 2455",
"MSWINEventLog": "MSWinEventLog",
"Criticality": 0,
"EventLogSource": "Security",
"SnareCounter": 32,
"SubmitTime": "2016-11-21 11:40:27",
"EventID": 592,
"SourceName": "Security",
"UserName": "Andy",
"SIDType": "User",
"EventLogType": "SuccessAudit",
"ComputerName": "MAIN",
"CategoryString": "DetailedTracking",
"DataString": "Process ended",
"ExpandedString": "Ended process ID: 2455"
}
789
NXLog User Guide Chapter 103. Snare
With this configuration, NXLog will read the Windows EventLog, convert it to Snare format, and output it via
UDP. NXLog log messages are also included (via the im_internal module). Tabs and newline sequences are
replaced with spaces.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input internal>
6 Module im_internal
7 </Input>
8
9 <Input eventlog>
10 Module im_msvistalog
11 Exec $Message =~ s/(\t|\R)/ /g;
12 </Input>
13
14 <Output out>
15 Module om_udp
16 Host 192.168.1.1
17 Port 514
18 Exec to_syslog_snare();
19 </Output>
20
21 <Route r>
22 Path internal, eventlog => out
23 </Route>
Output Sample
<13>Nov 21 11:40:27 myserver MSWinEventLog ⇥ 0 ⇥ Security ⇥ 32 ⇥ Mon Nov 21 11:40:27 2016 ⇥
592 ⇥ Security ⇥ N/A ⇥ N/A ⇥ Success Audit ⇥ MAIN ⇥ DetailedTracking ⇥ Process ended ⇥ Ended
process ID: 2455↵
790
Chapter 104. Snort NXLog User Guide
Snort writes log entries to the /var/log/snort/alert file. Each entry contains the date and time of the event,
the packet header, a description of the type of breach that was detected, and a severity rating. Each log entry
traverses multiple lines, and there is neither a fixed number of lines nor a separator.
Following are three example Snort rules and corresponding log messages.
Snort Rule
alert icmp any any -> any any (msg:"ICMP Packet"; sid:477; rev:3;)
Log Sample
[**] [1:477:3] ICMP Packet [**]↵
[Priority: 0]↵
04/30-07:54:41.759229 172.25.212.245 -> 172.25.212.153↵
ICMP TTL:64 TOS:0x0 ID:0 IpLen:20 DgmLen:96 DF↵
Type:8 Code:0 ID:16348 Seq:0 ECHO↵
Snort Rule
alert tcp any any -> any any (msg:"Exploit detected"; sid:1000001; content:"exploit";)
Log Sample
[**] [1:1000001:0] Exploit detected [**]↵
[Priority: 0]↵
04/30-07:54:38.312536 172.25.212.204:80 -> 192.168.255.110:46127↵
TCP TTL:64 TOS:0x0 ID:19844 IpLen:20 DgmLen:505 DF↵
***AP*** Seq: 0xF936BE12 Ack: 0x2C9A47D8 Win: 0x7B TcpLen: 20↵
Snort Rule
alert tcp any any -> any any (msg:"Advanced exploit detected"; \
sid:1000002; content:"backdoor"; reference:myserver,myrules; \
gid:1000001; rev:1; classtype:shellcode-detect; priority:100; \
metadata:meta data;)
Log Sample
[**] [1000001:1000002:1] Advanced exploit detected [**]↵
[Classification: Executable Code was Detected] [Priority: 100]↵
04/30-07:54:35.707783 192.168.255.110:46117 -> 172.25.212.204:80↵
TCP TTL:127 TOS:0x0 ID:14547 IpLen:20 DgmLen:435 DF↵
***AP*** Seq: 0x49649AA5 Ack: 0x5BC496C0 Win: 0x40 TcpLen: 20↵
[Xref => myserver myrules]↵
791
NXLog User Guide Chapter 104. Snort
This configuration uses an xm_multiline extension module instance with a HeaderLine regular expression
to parse the log entries. An Exec directive is also used to drop all empty lines.
In the Input module instance, another regular expression captures the parts of the message and adds
corresponding fields to the event record. Additional information could be extracted also, such as Xref data,
by adding (.*)\s+(.*)\s+\[Xref => (.*)\] to the expression and then $Xref = $13; below it.
Finally, the log entries are formatted as JSON with the to_json() procedure.
nxlog.conf (truncated)
1 <Extension snort>
2 Module xm_multiline
3 HeaderLine /^\[\*\*\] \[\S+] (.*) \[\*\*\]/
4 Exec if $raw_event =~ /^\s+$/ drop();
5 </Extension>
6
7 <Extension _json>
8 Module xm_json
9 </Extension>
10
11 <Input in>
12 Module im_file
13 File "/var/log/snort/alert"
14 InputType snort
15 <Exec>
16 if $raw_event =~ /(?x)^\[\*\*\]\ \[\S+\]\ (.*)\ \[\*\*\]\s+
17 (?:\[Classification:\ ([^\]]+)\]\ )?
18 \[Priority:\ (\d+)\]\s+
19 (\d\d).(\d\d)\-(\d\d:\d\d:\d\d\.\d+)
20 \ (\d+.\d+.\d+.\d+):?(\d+)?\ ->
21 \ (\d+.\d+.\d+.\d+):?(\d+)?\s+\ /
22 {
23 $EventName = $1;
24 $Classification = $2;
25 $Priority = $3;
26 $EventTime = parsedate(year(now()) + "-" + $4 + "-" + $5 + " " + $6);
27 $SourceIPAddress = $7;
28 $SourcePort = $8;
29 [...]
Output Sample
{
"EventReceivedTime": "2014-05-05 09:08:58",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"EventName": "Advanced exploit detected",
"Classification": "Executable Code was Detected",
"Priority": "100",
"EventTime": "2014-04-30 07:54:35",
"SourceIPAddress": "192.168.255.110",
"SourcePort": "46117",
"DestinationIPAddress": "172.25.212.204",
"DestinationPort": "80"
}
792
Chapter 105. Solarwinds Loggly NXLog User Guide
Solarwinds Loggly is a cloud-based log analysis and monitoring service. NXLog can be configured to send log
data to Loggly in Syslog format over TCP, or via the Loggly API using HTTP(S).
The NXLog configuration will need this token for sending log data to Loggly.
When using this method, the customer token and any custom tags need to be included in the structured data
section of the Syslog message.
793
NXLog User Guide Chapter 105. Solarwinds Loggly
In the configuration below, NXLog processes a log file using the im_file module, generates a Syslog message
using the xm_syslog module, and sends it to Loggly using the om_tcp module. The log data is formatted as
JSON using the xm_json module. Logs are given the tag linux to make them easily searchable in Loggly.
The CUSTOMER_TOKEN value needs to be replaced with an actual Loggly customer token. In this example,
processing is done in the output instance where the NXLog ID in the structured data of the Syslog message
is replaced with the customer token defined by the CUSTOMER_TOKEN constant.
Output Sample
The following is a sample of the Syslog header that will be sent to Loggly. The structured data includes the
customer token and tag as specified in the NXLog configuration.
The JSON formatted log sample below will be sent as part of the Syslog message to the Loggly service.
794
Chapter 105. Solarwinds Loggly NXLog User Guide
{
"EventReceivedTime": "2020-11-26 08:22:43",
"SourceModuleName": "file",
"SourceModuleType": "im_file",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "NXLog-Ubuntu-1",
"EventTime": "2020-11-26 06:41:43",
"SourceName": "dbus-daemon",
"ProcessID": "3540",
"Message": "Successfully activated service 'org.gnome.Terminal'"
}
795
NXLog User Guide Chapter 105. Solarwinds Loggly
The configuration below uses the im_msvistalog module to collect events from the Windows Event Log,
generates a Syslog message using the xm_syslog module, and sends it to Loggly using the om_ssl module.
The event data is formatted in JSON using the xm_json module. Events are given the tag windows to make
them easily searchable in Loggly.
The CUSTOMER_TOKEN value needs to be replaced with an actual Loggly customer token. In this example,
processing is done in the output instance where the customer token defined by the CUSTOMER_TOKEN
constant is inserted before the JSON data.
The CERTDIR value needs to be replaced with the actual path to the Loggly certificate.
Output Sample
The following is a sample of the Syslog header that will be sent to Loggly. The structured data includes the
customer token and tag as specified in the NXLog configuration.
The JSON formatted sample event below will be sent as part of the Syslog message to the Loggly service.
796
Chapter 105. Solarwinds Loggly NXLog User Guide
{
"EventTime": "2020-11-26 12:09:30",
"Hostname": "Hopper",
"Keywords": "36028797018963968",
"EventType": "ERROR",
"SeverityValue": 4,
"Severity": "ERROR",
"EventID": 12,
"SourceName": "VBoxNetLwf",
"TaskValue": 0,
"RecordNumber": 44000,
"ExecutionProcessID": 0,
"ExecutionThreadID": 0,
"Channel": "System",
"Message": "The driver detected an error on \\Device\\VBoxNetLwf.",
"Data": "\\Device\\VBoxNetLwf",
"EventData.Binary": "00000C0001000000000000000C0004",
"EventReceivedTime": "2020-11-26 13:19:02",
"SourceModuleName": "eventlog",
"SourceModuleType": "im_msvistalog"
}
When logs are sent over HTTPS, the Loggly customer token and any custom tags need to be included as part of
the URL.
To send data to Loggly using HTTPS, the Loggly certificate file needs to be downloaded and placed in a location
accessible to NXLog.
In the configuration below, NXLog will send a POST request for every log record it processes. The events are
given the tag http to make them easily searchable in Loggly. This method is suited for low volume log
sources where a considerable amount of time elapses between each new event. For high volume logging,
see the configuration for sending logs in batches.
The CUSTOMER_TOKEN value needs to be replaced with an actual Loggly customer token.
The HTTPSCAFile directive needs to specify the actual path and filename of the Loggly certificate.
797
NXLog User Guide Chapter 105. Solarwinds Loggly
In the configuration below, NXLog will POST log data to Loggly in batches. The events are given the tag http
to make them easily searchable in Loggly. The BatchMode directive in the output block needs to be set to
multiline, to specify that each log record should be separated by a new line.
The Loggly bulk endpoint supports up to 1MB per event and a maximum of 5MB per batch. For simplicity,
this example uses the default NXLog batch settings. For further configuration options, see the BatchSize
and BatchFlushInterval directives.
The CUSTOMER_TOKEN value needs to be replaced with an actual Loggly customer token.
The HTTPSCAFile directive needs to specify the actual path and filename of the Loggly certificate.
It may take a few minutes for data to be indexed and shown in the Loggly web interface. If not,
NOTE
see the Loggly documentation on troubleshooting HTTP.
798
Chapter 105. Solarwinds Loggly NXLog User Guide
The image below shows a Syslog event in JSON format that was sent to Loggly as a Syslog message over TCP.
799
NXLog User Guide Chapter 105. Solarwinds Loggly
The image below shows a Windows Event Log event in JSON format that was sent to Loggly as a Syslog message.
800
Chapter 105. Solarwinds Loggly NXLog User Guide
The image below shows a Syslog event in JSON format that was sent to Loggly via HTTPS.
801
NXLog User Guide Chapter 105. Solarwinds Loggly
The following is a sample Windows Event Log event exported from Loggly in JSON format. The original event was
sent to Loggly by NXLog as a Syslog message.
802
Chapter 105. Solarwinds Loggly NXLog User Guide
{
"total_events": 1,
"page": 0,
"events": [
{
"timestamp": 1606388970592,
"unparsed": null,
"event": {
"syslog": {
"severity": "Error",
"facility": "user-level messages",
"timestamp": "2020-11-26T11:09:30.592060Z",
"appName": "VBoxNetLwf",
"pid": 0,
"priority": "11",
"host": "Hopper"
},
"json": {
"ExecutionProcessID": 0,
"EventID": 12,
"EventTime": "2020-11-26 12:09:30",
"EventData_Binary": "00000C0001000000000000000C0004",
"Severity": "ERROR",
"RecordNumber": 44031,
"SourceModuleType": "im_msvistalog",
"SourceName": "VBoxNetLwf",
"EventType": "ERROR",
"SourceModuleName": "eventlog",
"Hostname": "Hopper",
"ExecutionThreadID": 0,
"TaskValue": 0,
"Keywords": "36028797018963968",
"SeverityValue": 4,
"Message": "The driver detected an error on \\Device\\VBoxNetLwf.",
"Data": "\\Device\\VBoxNetLwf",
"Channel": "System",
"EventReceivedTime": "2020-11-26 13:19:02"
}
}
}
]
}
803
NXLog User Guide Chapter 106. Splunk
For more information, see the Splunk Enterprise documentation. See also the Sending ETW Logs to Splunk with
NXLog post.
When planning a migration to NXLog, the various types of log sources being collected by Splunk universal
forwarders should be evaluated. Depending on the type of log source, it could be as simple as creating a new
TCP data input port and following some of the examples contained in this chapter, such as forwarding BSD
Syslog events. As long as the log source provides data in a standard format that Splunk can easily index, and
Splunk is retaining the original field names, no special configurations need be written.
In the case of Windows Event Log providers, special NXLog configurations are required to emulate the event
fields and format sent by the Splunk universal forwarder since Splunk renames at least four Windows fields and
adds some new fields to the event schema. See the comparison table below.
* NXLog normalizes this field name across all modules and log sources.
It should be emphasized that NXLog is capable of forwarding Windows events or any other kind
of structured logs to Splunk for indexing without any need to emulate the format or event
NOTE schema used by the Splunk universal forwarder. There is no technical requirement or advantage
in using Splunk’s proprietary format for forwarding logs to Splunk, especially for new Splunk
deployments which have no existing corpus of Windows events.
804
Chapter 106. Splunk NXLog User Guide
The only purpose of emulating the Splunk universal forwarder format is to maintain continuity with
previously indexed Windows events that were forwarded with the Splunk universal forwarder. Forwarding
Windows Event Log data in JSON format over TCP to Splunk is the preferred method.
After defining a network data input port (see Adding a TCP or UDP Data Input in the next section for details), the
only NXLog configuration needed for forwarding events to Splunk is a simple, generic TCP (or UDP) output
module instance that converts the logs to JSON as they are being sent.
805
NXLog User Guide Chapter 106. Splunk
Example 469. Forwarding Windows DNS Server Events in JSON Format to Splunk
This example uses Windows ETW to collect Windows DNS Server events. The output instance defines the IP
address and port of the host where Splunk Enterprise is receiving data on TCP port 1527 which was defined
in Splunk to have a Source Type of _json.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input dns_server>
6 Module im_etw
7 Provider Microsoft-Windows-DNSServer
8 </Input>
9
10 <Output splunk>
11 Module om_tcp
12 Host 192.168.1.21
13 Port 1527
14 Exec to_json();
15 </Output>
Since Splunk readily accepts formats like JSON and XML that support highly structured data, querying JSON-
806
Chapter 106. Splunk NXLog User Guide
When creating configurations with NXLog for maintaining backwards compatibility with events previously
collected by the universal forwarder, only a few general principles need to be observed:
• When creating a new TCP data input in Splunk, choose the right Source Type.
• In the NXLog configuration, rename event fields to the field names Splunk associates with that Source Type.
• In the NXLog configuration, make sure the data matches the format shown in Splunk as closely as possible,
unless Splunk is failing to parse specific fields.
• In the NXLog configuration, manually parse embedded structured data as new, full-fledged fields. A common
cause of failed parsing using this technique are fields containing long strings of embedded subfields.
The following steps should be followed for each type of log source being forwarded:
1. Examine the events in Splunk and note which value is assigned to sourcetype= listed below each event. The
universal forwarder may list different values for sourcetype even when they are coming from the same
source. Try to determine which one is the best fit.
2. In Splunk, create a new TCP Data Input port for each log source type to be forwarded and set the Source
Type to the same one assigned to events that have been sent by the universal forwarder after they have
been ingested by Splunk.
3. Note which fields are being parsed and indexed after they have been received and processed by Splunk.
4. Create an NXLog configuration that will capture the log source data, rename the field names to those
associated with the Source Type, and format them to match the format that the Splunk universal forwarder
uses.
The actual format used by the Splunk universal forwarder is "cooked" data which has a binary header
component and a footer. A single line containing the date and time of the event marks the beginning of the event
data on the next line, which is generally formatted as key-value pairs, unquoted, separated by an equals sign (=),
with only one key-value pair per line. The header and footer parts are not needed for forwarding events to a TCP
Data Input port. Only the first line containing the event’s date/time and the subsequent lines containing the key-
value pairs are needed.
Windows Event Log data can be forwarded to Splunk using NXLog in such a way that Splunk parses and indexes
807
NXLog User Guide Chapter 106. Splunk
them as if they were sent by the Splunk universal forwarder. Only three criteria need to be met:
1. The Splunk Add-on for Microsoft Windows has been installed where the forwarded events will be received.
See About installing Splunk add-ons on Splunk Docs for more details.
2. The NXLog configuration rewrites events to match the field names expected by the corresponding log source
in the Splunk Add-on for Microsoft Windows and formats the event to match the format of the Splunk
universal forwarder.
3. A unique TCP Data Input port is created for each type of Windows Event Provider by following the procedure
in Adding a TCP or UDP Data Input. When specifying the Source type it is imperative to choose the correct
name from the dropdown list that follows this naming convention: WinEventLog:Provider[/Channel].
When adding a new TCP Data Input, the desired Source type for Windows might not be present
in the Select Source Type dropdown menu. If so, select or manually enter WinEventLog and
NOTE create the TCP Data Input. Once created, go back to the list of TCP Data Inputs and edit it by
clicking the TCP port number. Make sure Set source type is set to Manual, then enter the
correct name in the Source type field.
The following examples have been tested with Splunk 8.0.0 and the "Splunk Add-on for
NOTE
Microsoft Windows" version 8.0.0.
808
Chapter 106. Splunk NXLog User Guide
Example 470. Forwarding Windows DNS Server Audit Events Using the Universal Forwarder Format
This example illustrates the method for emulating the Splunk Universal Forwarder for sending Windows
DNS Server Audit events to Splunk. First, a new TCP Input on port 1515 with a Source type of
WinEventLog:Microsoft-Windows-DNSServer/Audit is created for receiving the forwarded events.
This configuration uses the im_msvistalog module to collect and the parse the log data. Since there will be
no need for filtering in this example, a simple File directive defines the location of the log source to be
read, otherwise a QueryXML block would have been used to define the filters and the Provider/Channel as
the log source. The Exec block contains the necessary logic for converting the parsed data to the format
used by the Splunk universal forwarder. Since each event will be formatted and output as a multi-line
record stored as a single string in the $raw_event field, the xm_rewrite is used to delete the original fields.
Once converted, events are then forwarded over TCP port 1515 to Splunk.
nxlog.conf (truncated)
1 <Extension Drop_Fields>
2 Module xm_rewrite
3 Keep # Remove all
4 </Extension>
5
6 <Input DNS_Server_Audit>
7 Module im_msvistalog
8 File %SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-DNSServer%4Audit.evtx
9 <Exec>
10 # Create a header variable for storing the Splunk datetime string
11 create_var('timestamp_header');
12 create_var('event'); # The Splunk equivalent of a $raw_event
13 create_var('message'); # For preserving the $Message field
14 create_var('vip_fields'); # Message subfields converted to fields
15
16 # Get the Splunk datetime string needed for the Header Line
17 $dts = strftime($EventTime,'YYYY-MM-DD hh:mm:ss.sTZ');
18 $hr = ""; # Hours, 2-digit
19 $ap = ""; # For either "AM" or "PM";
20 if ($dts =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/ ) {
21 if (hour($EventTime) < 12) {
22 $ap = "AM";
23 $hr = $4;
24 if (hour($EventTime) == 0) $hr = "12";
25 }
26 if (hour($EventTime) > 11) {
27 $ap = "PM";
28 if (hour($EventTime) == 12) $hr = $4;;
29 [...]
809
NXLog User Guide Chapter 106. Splunk
810
Chapter 106. Splunk NXLog User Guide
Example 471. Forwarding Sysmon DNS Query Events Using the Universal Forwarder Format
This example illustrates the method for emulating the Splunk Universal Forwarder for sending Windows
Sysmon DNS Query Events events to Splunk. First, a new TCP Input on port 1515 with a Source type of
WinEventLog:Microsoft-Windows-Sysmon/Operational is created for receiving the forwarded events.
The configuration uses the im_msvistalog module to collect and the parse the log data. The QueryXML block
is used to specify not only the Provider/Channel, but also provides additional filtering for collecting only DNS
Query events. The Exec block contains the necessary logic for converting the data to the format used by the
Splunk universal forwarder. Since each event will be formatted and output as a multi-line record stored as a
single string in the $raw_event field, the xm_rewrite is used to delete the original fields. Once converted,
events are then forwarded over TCP port 1517 to Splunk.
811
NXLog User Guide Chapter 106. Splunk
nxlog.conf (truncated)
1 <Extension Drop_Fields>
2 Module xm_rewrite
3 Keep # Remove all
4 </Extension>
5
6 <Input DNS_Sysmon>
7 Module im_msvistalog
8 <QueryXML>
9 <QueryList>
10 <Query Id="0">
11 <Select Path="Microsoft-Windows-Sysmon/Operational">
12 *[System[(EventID=22)]]
13 </Select>
14 </Query>
15 </QueryList>
16 </QueryXML>
17 <Exec>
18 # Create a header variable for storing the Splunk datetime string
19 create_var('timestamp_header');
20 create_var('event'); # The Splunk equivalent of a $raw_event
21 create_var('message'); # For preserving the $Message field
22 create_var('message_fields'); # Message subfields converted to fields
23
24 # Get the Splunk datetime string needed for the Header Line
25 $dts = strftime($EventTime,'YYYY-MM-DD hh:mm:ss.sTZ');
26 $hr = ""; # Hours, 2-digit
27 $ap = ""; # For either "AM" or "PM";
28 if ($dts =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/ ) {
29 [...]
812
Chapter 106. Splunk NXLog User Guide
813
NXLog User Guide Chapter 106. Splunk
In the following example, a central NXLog server receives events for all log sources within the enterprise
and forwards each log source type via a TCP data input connection that has been preconfigured on the
Splunk Enterprise server for that Source type.
nxlog.conf (truncated)
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 # Receive Events from ALL Enterprise Servers
6 <Input syslog_in>
7 Module im_tcp
8 Host 0.0.0.0
9 Port 1514
10 </Input>
11
12 <Input dns_audit_in>
13 Module im_tcp
14 Host 0.0.0.0
15 Port 1515
16 </Input>
17
18 # Cache the Events to Disk in case of Splunk unavailability
19 <Output syslog_cache>
20 Module om_file
21 File '/opt/nxlog/var/log/cached/syslog.bin'
22 OutputType Binary
23 </Output>
24
25 <Output dns_audit_cache>
26 Module om_file
27 File '/opt/nxlog/var/log/cached/dns-audit.bin'
28 OutputType Binary
29 [...]
814
Chapter 106. Splunk NXLog User Guide
1. In order to generate certificates, issue the following commands from the server’s console. The script will ask
for a password to protect the key.
815
NXLog User Guide Chapter 106. Splunk
$ mkdir /opt/splunk/etc/certs
$ export OPENSSL_CONF=/opt/splunk/openssl/openssl.cnf
$ /opt/splunk/bin/genRootCA.sh -d /opt/splunk/etc/certs
$ /opt/splunk/bin/genSignedServerCert.sh -d /opt/splunk/etc/certs -n splunk -c splunk -p
2. Go to the app’s folder and edit the inputs file. For the Search & Reporting app, the path is
$SPLUNK_HOME/etc/apps/search/local/inputs.conf. Add [tcp-ssl] and [SSL] sections.
inputs.conf
[tcp-ssl://10514]
disabled = false
sourcetype = <optional>
[SSL]
serverCert = /opt/splunk/etc/certs/splunk.pem
sslPassword = <The password provided in step 1>
requireClientCert = false
server.conf
[sslConfig]
sslPassword = <Automatically generated>
sslRootCAPath = /opt/splunk/etc/certs/cacert.pem
5. Setup can be tested with netstat or a similar command. If everything went correctly, the following output is
produced.
6. Copy the cacert.pem file from $SPLUNK_HOME/etc/certs to the NXLog certificate directory.
This configuration illustrates how to send a log file via a TLS-encrypted connection. The AllowUntrusted
setting is required in order to accept a self-signed certificate.
nxlog.conf
1 <Output out>
2 Module om_ssl
3 Host 127.0.0.1
4 Port 10514
5 CertFile %CERTDIR%/cacert.pem
6 AllowUntrusted TRUE
7 </Output>
816
Chapter 106. Splunk NXLog User Guide
Set up and use HTTP Event Collector in Splunk Web, Format events for HTTP Event Collector, and Input endpoint
descriptions.
1. Open Settings > Data inputs and click on the HTTP Event Collector type.
2. Click the Global Settings button (in the upper-right corner).
3. For All Tokens, click the Enabled button.
4. Optionally, set the Default Source Type, Default Index, and Default Output Group settings.
5. Check Enable SSL to require events to be sent encrypted (recommended). See Configuring TLS Collection.
6. Change the HTTP Port Number if required, or leave it set to the default port 8088.
7. Click Save.
1. If not already on the HTTP Event Collector page, open Settings > Data inputs and click on the HTTP Event
Collector type.
2. Click New Token.
3. Enter a name for the token and modify any other settings if required; then click Next.
4. For the Source type, choose Automatic. The source type will be specified using an HTTP header as shown in
the examples in the following sections.
5. Choose an App context; for example, Search & Reporting (search).
6. Adjust the remaining default values, if required, and click Review.
817
NXLog User Guide Chapter 106. Splunk
7. Verify the information on the summary page and click Submit. The HEC token is created and its value is
presented.
8. The configuration can be tested with the following command (substitute the correct token):
$ curl -k https://<host>:8088/services/collector \
-H 'Authorization: Splunk <token>' -d '{"event":"test"}'
If configured correctly, Splunk will respond that the test event was delivered.
{"text":"Success","code":0}
The HEC uses a JSON event format, with event data in the event key and additional metadata sent in time, host,
source, sourcetype, index, and fields keys. For details about the format, see Format events for HTTP Event
Collector on Splunk Docs and in particular, the Event metadata section there. Because the source type is
specified in the event metadata, it is not necessary to set the source type on Splunk or to use separate tokens for
different source types.
818
Chapter 106. Splunk NXLog User Guide
This example shows an output instance that uses the xm_json and om_http modules to send the data to
the HEC. Events are formatted specifically for the HEC standard /services/collector endpoint.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension clean_splunk_fields>
6 Module xm_rewrite
7 Keep time, host, source, sourcetype, index, fields, event
8 </Extension>
9
10 <Output out>
11 Module om_http
12 URL https://127.0.0.1:8088/services/collector
13 AddHeader Authorization: Splunk c6580856-29e8-4abf-8bcb-ee07f06c80b3
14 HTTPSCAFile %CERTDIR%/cacert.pem
15 <Exec>
16 # Rename event fields to what Splunk uses
17 if $Severity rename_field($Severity, $vendor_severity);
18 if $SeverityValue rename_field($SeverityValue, $severity_id);
19
20 # Convert all fields to JSON and write to $event field
21 $event = to_json();
22
23 # Convert $EventTime to decimal seconds since epoch UTC
24 $time = string(integer($EventTime));
25 $time =~ /^(?<sec>\d+)(?<ms>\d{6})$/;
26 $time = $sec + "." + $ms;
27
28 # Specify the log source type
29 [...]
Output Sample
{
"event": {
"EventReceivedTime": "2019-10-18 19:58:19",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"SyslogFacility": "USER",
"vendor_severity": "INFO",
"severity_id": 2,
"EventTime": "2019-10-18 19:58:02",
"Hostname": "myserver2",
"ProcessID": 14533,
"SourceName": "sshd",
"Message": "Failed password for invalid user"
},
"time": "1571428682.218749",
"sourcetype": "_json",
"host": "myserver2",
"source": "sshd"
}
819
NXLog User Guide Chapter 106. Splunk
Name Value
TIME_PREFIX "time":"
TIME_FORMAT %s.%6N
Then select this new source type the TCP data input, as described in Adding a TCP or UDP Data Input.
820
Chapter 106. Splunk NXLog User Guide
This configuration sets the $time field for Splunk, converts the event data to JSON with the xm_json
to_json() procedure, and forwards via TCP with the om_tcp module.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Output out>
6 Module om_tcp
7 Host 127.0.0.1
8 Port 514
9 <Exec>
10 # Convert $EventTime to decimal seconds since epoch UTC
11 $time = string(integer($EventTime));
12 $time =~ /^(?<sec>\d+)(?<ms>\d{6})$/;
13 $time = $sec + "." + $ms;
14 delete($sec);
15 delete($ms);
16
17 # Write to JSON
18 to_json();
19 </Exec>
20 </Output>
These instructions have been tested with Splunk 7.3.1.1 and the "Splunk Add-on for Microsoft
NOTE
Windows" version 6.0.0.
821
NXLog User Guide Chapter 106. Splunk
1. Install the Splunk Add-on for Microsoft Windows. See About installing Splunk add-ons on Splunk Docs for
more details.
2. Configure the log source type as XmlWinEventLog.
3. Optionally, add a configuration value to use the event SystemTime value as Splunk’s event _time during
indexing (otherwise Splunk will fall back to using the received time). This can be added to the specific event
source or to the XmlWinEventLog source type. To modify the XmlWinEventLog source type from the
Splunk web interface, follow these steps:
a. Open Settings > Source types.
b. Find the XmlWinEventLog source type (uncheck Show only popular) and click Edit.
c. Open the Advanced tab and add the following configuration value:
Name Value
4. Use the im_msvistalog CaptureEventXML directive to capture the XML-formatted event data from the Event
Log. Forward this value to Splunk.
822
Chapter 106. Splunk NXLog User Guide
This example reads events from the Security channel. With the CaptureEventXML directive set to TRUE, the
XML event data is stored in the $EventXML field. The contents of this field are then assigned to the
$raw_event field, which sent is to Splunk by the the splunk_hec output instance.
nxlog.conf
1 <Input eventxml>
2 Module im_msvistalog
3 Channel Security
4 CaptureEventXML TRUE
5 Exec $raw_event = $EventXML;
6 </Input>
7
8 <Output splunk_hec>
9 Module om_http
10 URL https://127.0.0.1:8088/services/collector/raw
11 AddHeader Authorization: Splunk c6580856-29e8-4abf-8bcb-ee07f06c80b3
12 </Output>
823
NXLog User Guide Chapter 106. Splunk
In this example, events in Syslog format are read from file and sent to Splunk via TCP with no additional
processing. Because the source type is set to syslog, Splunk automatically parses the Syslog header
metadata.
nxlog.conf
1 <Input syslog>
2 Module im_file
3 File '/var/log/messages'
4 </Input>
5
6 <Output splunk>
7 Module om_tcp
8 Host 10.10.1.12
9 Port 514
10 </Output>
824
Chapter 107. Sumo Logic NXLog User Guide
Sumo Logic offers different plans for their service including a free plan. Some of the methods
NOTE
described here may require a paid plan.
NXLog provides more control at the log processing stage before events are sent to the Sumo Logic service. This is
especially useful since Sumo Logic charges per ingested byte. Although installed collectors support processing
rules to drop or keep certain events, these are quite basic compared to the flexibility an NXLog agent provides.
When used with NXLog, event data can be manipulated to determine which information to keep, rather than
dropping an entire event, as well as having full control over the output format. See the topic on Reducing
Bandwidth and Data Size for some of the configuration options available when using NXLog.
Sumo Logic collectors are designed to work with standard log formats primarily stored in flat files. When logs
were not generated by a Sumo Logic supported log source or are not stored in a supported format, such as data
stored in a database, network packet captures, or other types of events which are not in a standardized log
format, it may not be possible to process such data with the Sumo logic collector. With its vast selection of input
modules, NXLog can easily fill this gap as it can be configured to process a broad spectrum of log sources.
Additionally, it can also process log data using custom scripts with support for Go, Java, Perl, Python and Ruby.
See the NXLog documentation on Available Modules for a complete list of input, processing, and extension
modules.
Platform requirements
The Sumo Logic collector is a Java-based agent that requires a substantial amount of resources. NXLog, with its
smaller footprint, is a powerful alternative for use cases where the dependency on Java needs to be eliminated
or a less resource intensive agent with more flexibility is preferred. Case in point: when installed on a Microsoft
Windows 10 system and processing only the Application Windows Event Log channel, it was observed that the
Sumo Logic collector consumes 200+ MB of memory, compared with 4-6 MB of memory usage by the NXLog
agent when tested under the same conditions. See the table below for the minimum system requirements for
both the NXLog and Sumo Logic agents. Furthermore, the Sumo Logic collector does not support collecting
events in the older Microsoft Windows Event Log format as documented in this Sumo Logic article on Windows
2003 Event Logs ingestion. NXLog, on the other hand, specifically supports the Windows XP/2000/2003 event log
format through its im_mseventlog input module and can be installed on systems running such older Microsoft
Windows releases.
Processor Cores 1 1
825
NXLog User Guide Chapter 107. Sumo Logic
Memory 60 MB 512 MB
Disk Space 50 MB 8 GB
For more details, see the Sumo Logic documentation on how to Configure a Hosted Collector.
107.3.1. Linux
On Linux, the certificate needs to be downloaded from the DigiCert website and then the OpenSSL tool can be
used to convert it.
826
Chapter 107. Sumo Logic NXLog User Guide
1. From the Sumo Logic web interface, navigate to Manage Data > Collection.
2. On the Collection tab, click on Add Source next to the previously created hosted collector.
3. Select Cloud Syslog and fill in the required details. It is recommended to specify a Source Category to make
events from this source easily searchable in Sumo Logic.
4. Click Save to finish creating the syslog source.
5. On creation of the new syslog source a dialog is displayed containing the Token, Host, and TCP Port. The
NXLog configuration will need these details for sending log data to Sumo Logic.
For further details on configuring a syslog source, see the Sumo Logic documentation on Cloud Syslog Sources.
Syslog messages must be compliant with RFC 5424 or they will be dropped by Sumo Logic.
NOTE
Messages over 64KB will be truncated.
827
NXLog User Guide Chapter 107. Sumo Logic
In this configuration, NXLog processes a log file using the im_file module, then generates a syslog message
using the xm_syslog module and sends it to Sumo Logic using the om_ssl module. The log data is formatted
as JSON using the xm_json module.
The SUMO_TOKEN value needs to be replaced with an actual Sumo Logic Syslog source token. In this
example, processing is done in the output instance where the NXLog ID in the structured data of the syslog
message is replaced with the token defined by the SUMO_TOKEN constant.
The SUMO_HOST value needs to be replaced with an actual Sumo Logic Syslog source host URL.
The SUMO_PORT value needs to be replaced with the correct port for the host defined by the SUMO_HOST
constant.
The CA_FILE value needs to be replaced with the actual path to the DigiCert Certification Authority
certificate.
Output sample
This sample of the syslog header will be sent to Sumo Logic. The structured data contains the Sumo Logic
token as specified in the NXLog configuration.
This sample JSON-formatted event will be sent as part of the syslog message to the Sumo Logic service.
828
Chapter 107. Sumo Logic NXLog User Guide
{
"EventReceivedTime": "2020-12-04 13:37:47",
"SourceModuleName": "file",
"SourceModuleType": "im_file",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "NXLog-Ubuntu-1",
"EventTime": "2020-12-04 11:33:47",
"SourceName": "systemd",
"ProcessID": "1",
"Message": "Started Run anacron jobs."
}
829
NXLog User Guide Chapter 107. Sumo Logic
In this configuration, NXLog processes Windows Event Log events using the im_msvistalog module,
generates a syslog message using the xm_syslog module, and sends it to Sumo Logic using the om_ssl
module. The log data is formatted as JSON using the xm_json module.
The SUMO_TOKEN value needs to be replaced with an actual Sumo Logic Syslog source token. In this
example, processing is done in the output instance where the token defined by the SUMO_TOKEN constant is
inserted before the JSON data.
The SUMO_HOST value needs to be replaced with an actual Sumo Logic Syslog source host URL.
The SUMO_PORT value needs to be replaced with the correct port for the host defined by the SUMO_HOST
constant.
The CA_FILE value needs to be replaced with the actual path to the DigiCert Certification Authority
certificate.
Output sample
This syslog header sample will be sent to Sumo Logic. The structured data contains the Sumo Logic token
as specified in the NXLog configuration.
830
Chapter 107. Sumo Logic NXLog User Guide
This sample JSON-formatted event will be sent as part of the syslog message to the Sumo Logic service.
{
"EventTime": "2020-12-07 11:30:19",
"Hostname": "Hopper",
"Keywords": "36028797018963968",
"EventType": "ERROR",
"SeverityValue": 4,
"Severity": "ERROR",
"EventID": 12,
"SourceName": "VBoxNetLwf",
"TaskValue": 0,
"RecordNumber": 44758,
"ExecutionProcessID": 0,
"ExecutionThreadID": 0,
"Channel": "System",
"Message": "The driver detected an error on \\Device\\VBoxNetLwf.",
"Data": "\\Device\\VBoxNetLwf",
"EventData.Binary": "00000C0001000000000000000C0004",
"EventReceivedTime": "2020-12-07 11:31:38",
"SourceModuleName": "eventlog",
"SourceModuleType": "im_msvistalog"
}
1. From the Sumo Logic web interface, navigate to Manage Data > Collection
2. On the Collection tab, click on Add Source next to the previously created hosted collector.
3. Select HTTP Logs & Metrics and fill in the required details. It is recommended to specify a Source Category
to make events from this source easily searchable in Sumo Logic.
4. Click Save to finish creating the HTTP source.
5. On creation of the new HTTP source a dialog is displayed containing the HTTP Source Address. The NXLog
configuration will need this URL for sending log data to Sumo Logic.
For further details on configuring an HTTP source, see the Sumo Logic documentation on HTTP Logs and Metrics
Sources.
831
NXLog User Guide Chapter 107. Sumo Logic
In this configuration, NXLog POST log data to Sumo Logic using the om_http module. To send data in
batches, the BatchMode directive in the output instance needs to be set to multiline to specify that each
log record should be separated by a new line.
Sumo Logic accepts batched requests up to 1MB of uncompressed data. For simplicity, this example uses
the default NXLog batch settings. For further configuration options, see the BatchSize and
BatchFlushInterval directives.
Data can be sent to Sumo Logic as plain uncompressed or compressed by the deflate or gzip method.
The om_http module supports data compression based on the zlib compression library (deflate). In the
configuration below, the HTTPSSSLCompression directive specifies that compression should be used when
sending data to Sumo Logic. If this directive is not specified or set to FALSE, data will be sent
uncompressed.
When sending data over HTTP(S), Sumo Logic accepts additional optional headers to configure custom
settings related to the log records. For more information, see the Sumo Logic documentation on Supported
HTTP Headers. The om_http module supports specifying additional headers by using the AddHeader
directive. In the configuration below, the X-Sumo-Category header is added with the value my-category.
The SUMO_URL value needs to be replaced with an actual Sumo Logic HTTP source URL.
The CA_FILE value needs to be replaced with the actual path to the DigiCert Certification Authority
certificate.
It may take a few minutes for data to be shown in the Sumo Logic web interface. If not, see
NOTE
the Sumo Logic documentation on troubleshooting HTTP Sources.
Sumo Logic supports metrics in the Graphite, Carbon 2.0, and Prometheus formats. NXLog can be configured to
send data in any of these formats, either by reading preformatted records from a file, or by using an Exec block
to output the data in the desired format.
For more information on the requirements of host metrics, refer to the Sumo Logic documentation on Uploading
Metrics to an HTTP Source and Metric Formats.
832
Chapter 107. Sumo Logic NXLog User Guide
This configuration illustrates how NXLog can retrieve Microsoft Windows performance counters using the
im_winperfcount module and send the data to Sumo Logic in the Carbon 2.0 format using the om_http
module.
The input instance is configured to poll the host’s available memory every 30 seconds. The field containing
the retrieved value is renamed to MemFreeBytes to make it easier for referencing in the output instance.
The Exec block in the output instance builds the metric in the required Carbon 2.0 format. Sumo Logic
accepts timestamps in seconds or milliseconds, therefore in this example, the NXLog timestamp is
converted from microseconds to milliseconds.
The SUMO_URL value needs to be replaced with an actual Sumo Logic HTTP source URL.
The CA_FILE value needs to be replaced with the actual path to the DigiCert Certification Authority
certificate.
Output sample
The following is a sample of the data that will be sent to Sumo Logic. In this example, the metric is named
Mem_Free and represents the available free memory in bytes.
It may take a few minutes for data to appear in the Sumo Logic web interface. If not, see the
NOTE
Sumo Logic documentation on troubleshooting HTTP Sources.
833
NXLog User Guide Chapter 107. Sumo Logic
This image displays the NXLog hosted collector and a list of sources in the Sumo Logic web interface. The icon to
open the log search is highlighted.
This image displays a syslog event in JSON format that was sent to Sumo Logic via HTTPS.
834
Chapter 107. Sumo Logic NXLog User Guide
This image displays a Windows Event Log event in JSON format that was sent to Sumo Logic as a syslog message.
Events can be exported from Sumo Logic in CSV format, in which event fields are output as comma-separated
values. The following is a sample syslog message exported from Sumo Logic. The original event was sent by
NXLog via HTTPS.
"_messagetimems","_messagetime","_raw","_collector","_size","_source","_sourcecategory","_sourcehost
","_sourcename"
"1607341156001","12/07/2020 12:39:16.001 +0100","{""EventReceivedTime"":""2020-12-
07T12:39:16.001994+01:00"",""SourceModuleName"":""file"",""SourceModuleType"":""im_file"",""SyslogFa
cilityValue"":1,""SyslogFacility"":""USER"",""SyslogSeverityValue"":5,""SyslogSeverity"":""NOTICE"",
""SeverityValue"":2,""Severity"":""INFO"",""Hostname"":""NXLog-Ubuntu-1"",""EventTime"":""2020-12-
07T12:30:37.000000+01:00"",""SourceName"":""systemd"",""ProcessID"":""1"",""Message"":""Started
Fingerprint Authentication Daemon.""}","NXLog","414","NXLog-Ubuntu1","linux-
http","19.168.0.100","Http Input"
Host Metrics can be viewed in the Sumo Logic web interface by clicking on the + New button to open a Metrics
tab, and adding a metric query for the desired property. The image below shows host metrics sent by NXLog for
available memory (Bytes) over a period of time. When sending the data, the metric was named Mem_Free.
835
NXLog User Guide Chapter 107. Sumo Logic
836
Chapter 108. Symantec Endpoint Protection NXLog User Guide
Symantec Endpoint Protection Manager (SEPM) stores log data in an MSSQL Server database or in an
embedded database. For more details, see Managing log data in the Symantec Endpoint Protection Manager
(SEPM) on Symantec Support.
The following steps and configurations were tested with SEPM 14.2; see Released versions of
NOTE
Symantec Endpoint Protection on Symantec Support.
1. Create a Windows/SQL account with read permissions for the SEPM database.
2. Configure an ODBC 32-bit System Data Source on the server running NXLog. For more information, consult
the relevant ODBC documentation: the Microsoft ODBC Data Source Administrator guide or the unixODBC
Project.
3. Set an appropriate firewall rule on the database server that accepts connections from the server running
NXLog. For more information, see Configure a Windows Firewall for Database Engine Access on Microsoft
Docs.
4. Configure NXLog to collect logs via ODBC with the im_odbc module.
If a custom query is needed, it may be helpful to consult the Database schema reference for
TIP
Endpoint Protection 14.x on Symantec Support.
837
NXLog User Guide Chapter 108. Symantec Endpoint Protection
This example uses the im_odbc module to connect to the Symantec Endpoint Protection Manager server
via ODBC and collect logs from the MSSQL database. The first query below collects alerts and the second
(commented) query collects audit events.
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString DSN=SymantecEndpointSecurityDSN; \
4 database=sem5;uid=user;pwd=password;
5
6 # Query for Virus Alerts
7 SQL SELECT DATEADD(s,convert(bigint,TIME_STAMP)/1000,'01-01-1970 00:00:00') \
8 AS EventTime,IDX,ALERT_IDX,COMPUTER_IDX,SOURCE,VIRUSNAME_IDX, \
9 FILEPATH,ALERTDATETIME,USER_NAME FROM V_ALERTS
10
11 # Alternative query for the Audit log
12 #SQL SELECT DATEADD(s,convert(bigint,TIMESTAMP)/1000,'01-01-1970 00:00:00') \
13 # AS EventTime,METHOD,ARGUMENTS,IP_ADDR FROM V_AUDIT_LOG
14 </Input>
838
Chapter 108. Symantec Endpoint Protection NXLog User Guide
2. Configure NXLog to collect logs via ODBC with the im_odbc module. Specify SQL Anywhere as the ODBC
Driver in the ConnectionString directive.
For more technical information about querying the embedded database, check How to query the
TIP
SEPM embedded database on Symantec Support.
If it becomes necessary to migrate the embedded database to an MSSQL database, consult Moving
TIP
from the embedded database to Microsoft SQL Server on Symantec Support.
839
NXLog User Guide Chapter 108. Symantec Endpoint Protection
This example uses the im_odbc module to connect to the Symantec Endpoint Protection Manager
embedded database via ODBC with the SQL Anywhere driver. The first query below collects alerts and the
second (commented) query collects audit events.
nxlog.conf
1 <Input in>
2 Module im_odbc
3 ConnectionString Driver=SQL Anywhere 17;ENG=Host; \
4 UID=user;PWD=password;DBN=sem5;LINKS=ShMem;
5
6 # Query for Virus Alerts
7 SQL SELECT DATEADD(ss, TIME_STAMP/1000, '1970-01-01 00:00:00') AS EventTime, \
8 IDX,Alert_IDX,Computer_IDX,Source,Virusname_IDX,FilePath,AlertDateTime, \
9 User_Name,Last_Log_Session_Guid FROM V_ALERTS
10
11 # Alternative query for the Audit log
12 #SQL SELECT DATEADD(ss, TIMESTAMP/1000, '1970-01-01 00:00:00') AS EventTime, \
13 # Method,Arguments,IP_ADDR FROM V_AUDIT_LOG
14
15 Exec $EventTime = strftime($EventTime, 'YYYY-MM-DDThh:mm:ss.sTZ');
16 </Input>
840
Chapter 109. Synology DiskStation NXLog User Guide
NOTE The steps below have been tested with DSM 5.2 and should work with newer versions as well.
1. Configure NXLog to receive log entries over the network and process them as Syslog (see the TCP example
below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from DiskStation device being configured.
3. Log in to the DiskStation web interface.
4. Go to Log Center › Log Sending.
5. Under the Location tab, specify the Syslog server, port, protocol, and log format. Enable and configure SSL if
required.
6. Click [Apply].
841
NXLog User Guide Chapter 109. Synology DiskStation
This configuration uses the im_tcp module to collect the DiskStation logs via TCP. A JSON output sample
shows the resulting logs as received and processed by NXLog.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 Exec parse_syslog();
14 </Input>
15
16 <Output out>
17 Module om_file
18 File "/var/log/synology.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.4.20",
"EventReceivedTime": "2017-07-28 18:30:04",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "DiskStation1",
"EventTime": "2017-07-28 18:30:02",
"Message": "Connection PWD\\sql_psqldw1:\tCIFS client [PWD\\sql_psqldw1] from
[192.168.15.138(IP:192.168.15.138)] accessed the shared folder [db_backup]."
}
{
"MessageSourceAddress": "192.168.4.20",
"EventReceivedTime": "2017-07-28 18:29:48",
"SourceModuleName": "in_syslog_tcp",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "DiskStation1",
"EventTime": "2017-07-28 18:29:56",
"Message": "System Test message from Synology Syslog Client from (0.240.175.244)"
}
842
Chapter 110. Syslog NXLog User Guide
Log Sample
<30>Nov 21 11:40:27 myserver sshd[26459]: Accepted publickey for john from 192.168.1.1 port 41193
ssh2↵
BSD Syslog defines both the log entry format and the transport. The message format is free-form, allowing for
the payload to be JSON or another structured data format.
While this is the common and recommended format for a BSD Syslog message, there are no set
NOTE requirements and a device may send a BSD Syslog log message containing only a free-form
message, without PRI or HEADER parts.
The PRI part, or "priority", is calculated from the facility and severity codes. The facility code indicates the type of
program that generated the message, and the severity code indicates the severity of the message (see the Syslog
Facilities and Syslog Severities tables below). The priority code is calculated by multiplying the facility code by
eight and then adding the severity code.
The PRI part is not written to file by many Syslog loggers. In that case, each log entry begins with
NOTE
the HEADER.
The HEADER part contains two fields: TIMESTAMP and HOSTNAME. The TIMESTAMP provides the local time when
the message was generated in Mmm dd hh:mm:ss format, with no year or time zone specified; the HOSTNAME is
the name of the host where the message was generated.
The MSG part contains two fields: TAG and CONTENT. The TAG is the name of the program or process that
generated the message, and contains only alphanumeric characters. Any other character will represent the
beginning of the CONTENT field. The CONTENT field often contains the process ID enclosed by brackets ([]), a
colon (:), a space, and then the actual message. In the log sample above, the MSG part begins with myserver
sshd[26459]: Accepted publickey; in this case, the TAG is ssh and the CONTENT field begins with [26459].
The CONTENT field can contain only ASCII printable characters (32-126).
843
NXLog User Guide Chapter 110. Syslog
Facility Description
Code
0 kernel messages
1 user-level messages
2 mail system
3 system daemons
4 security/authorization messages
8 UUCP subsystem
9 clock daemon
10 security/authorization messages
11 FTP daemon
12 NTP subsystem
13 log audit
14 log alert
15 scheduling daemon
Severity Description
Code
844
Chapter 110. Syslog NXLog User Guide
Severity Description
Code
• The transport defined by RFC 3164 uses UDP and provides no mechanism to ensure reliable delivery,
integrity, or confidentiality of log messages.
• Many undocumented variations exist among implementations.
• The timestamp indicates neither the year nor the timezone, and does not provide precision greater than the
second.
• The PRI field (and therefore the facility and severity codes) are not retained by many Syslog loggers when
writing to log files.
• The entire length of the log entry is limited to 1024 bytes.
• Only ASCII characters 32-126 are allowed, no Unicode or line breaks.
Log Sample
<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3"
eventSource="Application" eventID="1011"] An application event log entry...↵
• HOSTNAME
845
NXLog User Guide Chapter 110. Syslog
The PRI field is not written to file by many Syslog loggers. In that case, each log entry begins with
NOTE
the VERSION field.
The STRUCTURED-DATA part is optional. If it is omitted, then a hyphen acts as a placeholder. Otherwise, it is
surrounded by brackets. It contains an ID of the block and a list of space-separated "key=value" pairs.
The MSG part is optional and contains a free-form, single-line message. If the message is encoded in UTF-8, then
it may be preceded by a Unicode byte order mark (BOM).
RFC 5425 also documents the octet-framing method that is used for TLS transport and provides support for
multi-line messages. Octet-framing can be used with plain TCP also, TLS is not required. The message length is
pre-pended as in the following example which shows the raw data that is sent over TCP/TLS.
In practice IETF Syslog is commonly transferred without octet-framing over TCP or TLS. In this case the newline
(\n) character is used as the record separator, similarly to how BSD Syslog is transferred over TCP or TLS.
Make sure NXLog has permission to read log files in /var/log. See Reading Rsyslog Log Files for more
information.
846
Chapter 110. Syslog NXLog User Guide
This configuration reads log messages from file and parses them using the parse_syslog() procedure.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File '/var/log/messages'
8 Exec parse_syslog();
9 </Input>
The parse_syslog() procedure parses the log entry as either BSD or IETF format (the
NOTE
parse_syslog_bsd() and parse_syslog_ietf() procedures can be used alternatively).
◦ modify the configuration to disable reading from /dev/log (for example, remove $ModLoad imuxsock
from /etc/rsyslog.conf and restart Rsyslog).
3. Restart NXLog.
847
NXLog User Guide Chapter 110. Syslog
With this configuration, NXLog uses the im_uds module to read messages from /dev/log, and the
parse_syslog() procedure to parse them.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_uds
7 UDS /dev/log
8 FlowControl FALSE
9 Exec parse_syslog();
10 </Input>
1. Configure NXLog with im_udp, im_tcp, or im_ssl. See the examples below.
2. For NXLog to listen for messages on port 514, the local Syslog agent must not be listening on that port. It
may be necessary to either
◦ disable the service entirely (for example, systemctl disable rsyslogd) or
◦ modify the configuration to disable listening on port 514 (for example, remove input(type="imudp"
port="514") from /etc/rsyslog.conf and restart Rsyslog).
3. Restart NXLog.
This configuration accepts either BSD or IETF Syslog from the local system only, via UDP.
The UDP transport can lose log entries and is therefore not recommended for
WARNING
receiving logs over the network.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_udp
7 Host localhost
8 Port 514
9 Exec parse_syslog();
10 </Input>
848
Chapter 110. Syslog NXLog User Guide
This configuration accepts either BSD or IETF Syslog via TCP, without supporting octet-framing.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 1514
9 Exec parse_syslog();
10 </Input>
This configuration accepts IETF Syslog via TCP, with support for octet-framing.
Though this is for plain TCP, the Syslog_TLS directive is required because it refers to the
NOTE
octet-framing method described by RFC 5425.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_tcp
7 Host 0.0.0.0
8 Port 1514
9 InputType Syslog_TLS
10 Exec parse_syslog_ietf();
11 </Input>
This configuration accepts IETF Syslog via TLS, with support for octet-framing.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_ssl
7 Host 0.0.0.0
8 Port 6514
9 CAFile %CERTDIR%/ca.pem
10 CertFile %CERTDIR%/client-cert.pem
11 CertKeyFile %CERTDIR%/client-key.pem
12 InputType Syslog_TLS
13 Exec parse_syslog_ietf();
14 </Input>
849
NXLog User Guide Chapter 110. Syslog
The configuration below reads user-space messages from the /dev/log socket using the im_uds module.
In the Exec block, messages are parsed using the parse_syslog_bsd() procedure from the xm_syslog
module.
Using the conditional statement, values from the $SyslogSeverityValue field are checked and messages
with severity level over 6 are discarded using the drop() procedure.
The remaining messages are converted to JSON using to_json() procedure from the xm_json module.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_uds>
6 Module im_uds
7 UDS /dev/log
8 <Exec>
9 parse_syslog_bsd();
10 if NOT ($SyslogSeverityValue < 6)
11 {
12 drop();
13 }
14 to_json();
15 </Exec>
16 </Input>
850
Chapter 110. Syslog NXLog User Guide
The configuration below reads log messages from the /dev/log socket using the im_uds module. In the
Exec block, messages are parsed using the parse_syslog_bsd() procedure from the xm_syslog module.
Using the conditional statement, complex filtering is carried out as per the following parameters:
In case a message does not meet at least one filtering condition, it is discarded using the drop() procedure.
Otherwise, it is converted to JSON using to_json() procedure from the xm_json module.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_uds>
6 Module im_uds
7 UDS /dev/log
8 <Exec>
9 parse_syslog_bsd();
10 if NOT (
11 ($SyslogSeverityValue < 6) OR
12 ($SyslogFacility IN ('AUTHPRIV', 'AUTH', 'MAIL', 'CRON')) OR
13 ($SourceName IN ('apt','nxlog','osqueryd'))
14 )
15 {
16 drop();
17 }
18 to_json();
19 </Exec>
20 </Input>
Syslog messages can be filtered by the $Message field values using regular expressions.
851
NXLog User Guide Chapter 110. Syslog
The configuration below reads log messages from the Linux kernel using the im_kernel module. In the Exec
block, messages are parsed using the parse_syslog_bsd() procedure from the xm_syslog module.
Using the conditional statement, messages without the mount options string in the $Message field are
discarded using the drop() procedure.
The remaining messages are converted to JSON using to_json() procedure from the xm_json module.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_kernel>
6 Module im_kernel
7 <Exec>
8 parse_syslog_bsd();
9 if NOT ($Message =~ /mount options/)
10 {
11 drop();
12 }
13 to_json();
14 </Exec>
15 </Input>
• write it to file,
• send it to the local syslog daemon via the /dev/log Unix domain socket, or
• forward it to another destination over the network (via UDP, TCP, or TLS).
In each case, the to_syslog_bsd() and to_syslog_ietf() procedures are used to generate the $raw_event field from
the corresponding fields in the event record.
852
Chapter 110. Syslog NXLog User Guide
This configuration write logs to the specified file in the BSD Syslog format.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File "/var/log/syslog"
8 Exec to_syslog_bsd();
9 </Output>
NXLog can be configured to write BSD Syslog to a file without the PRI part, emulating traditional Syslog
implementations.
This configuration includes a regular expression for removing the PRI part from the $raw_event field after
it is generated by the to_syslog_bsd() procedure.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_file
7 File "/var/log/syslog"
8 Exec to_syslog_bsd(); $raw_event =~ s/^\<\d+\>//;
9 </Output>
This configuration sends BSD Syslog to the Syslog daemon via /dev/log.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_uds
7 UDS /dev/log
8 Exec to_syslog_bsd();
9 </Output>
853
NXLog User Guide Chapter 110. Syslog
This configuration sends logs in BSD Syslog format to the specified host, via UDP port 514.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_udp
7 Host 192.168.1.1
8 Port 514
9 Exec to_syslog_bsd();
10 </Output>
This configuration sends logs in BSD format to the specified host, via TCP port 1514.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_tcp
7 Host 192.168.1.1
8 Port 1514
9 Exec to_syslog_bsd();
10 </Output>
854
Chapter 110. Syslog NXLog User Guide
With this configuration, NXLog sends logs in IETF format to the specified host, via port 6514.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Output out>
6 Module om_ssl
7 Host 192.168.1.1
8 Port 6514
9 CAFile %CERTDIR%/ca.pem
10 CertFile %CERTDIR%/client-cert.pem
11 CertKeyFile %CERTDIR%/client-key.pem
12 OutputType Syslog_TLS
13 Exec to_syslog_ietf();
14 </Output>
Log Sample
<13>1 2016-10-13T14:23:11.000000-06:00 myserver - - - [NXLOG@14506 Purpose="test"] This is a test
message.↵
NXLog can parse IETF Syslog with the parse_syslog() procedure provided by the xm_syslog extension module.
855
NXLog User Guide Chapter 110. Syslog
With this configuration, NXLog will parse the input IETF Syslog format from file, convert it to JSON, and
output the result to file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/log/messages'
12 Exec parse_syslog();
13 </Input>
14
15 <Output out>
16 Module om_file
17 File '/var/log/json'
18 Exec to_json();
19 </Output>
20
21 <Route r>
22 Path in => out
23 </Route>
Output Sample
{
"EventReceivedTime": "2016-10-13 15:23:12",
"SourceModuleName": "in",
"SourceModuleType": "im_file",
"SyslogFacilityValue": 1,
"SyslogFacility": "USER",
"SyslogSeverityValue": 5,
"SyslogSeverity": "NOTICE",
"SeverityValue": 2,
"Severity": "INFO",
"EventTime": "2016-10-13 15:23:11",
"Hostname": "myserver",
"Purpose": "test",
"Message": "This is a test log message."
}
NXLog can also generate IETF Syslog with a Structured-Data part, using the to_syslog_ietf() procedure provided by
the xm_syslog extension module.
856
Chapter 110. Syslog NXLog User Guide
With the following configuration, NXLog will parse the input JSON from file, convert it to IETF Syslog format,
and output the result to file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/log/json'
12 Exec parse_json();
13 </Input>
14
15 <Output out>
16 Module om_file
17 File '/var/log/ietf'
18 Exec to_syslog_ietf();
19 </Output>
20
21 <Route r>
22 Path in => out
23 </Route>
Input Sample
{
"EventTime": "2016-09-13 11:23:11",
"Hostname": "myserver",
"Purpose": "test",
"Message": "This is a test log message."
}
Output Sample
<13>1 2016-09-13T11:23:11.000000-05:00 myserver - - - [NXLOG@14506 EventReceivedTime="2016-09-
13 11:23:12" SourceModuleName="in" SourceModuleType="im_file" Purpose="test] This is a test log
message.↵
857
NXLog User Guide Chapter 110. Syslog
With the following configuration, NXLog will read the Windows Event Log, convert it to JSON format, add a
Syslog header, and send the logs via UDP to a Syslog agent. NXLog log messages are also included (via the
im_internal module).
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input internal>
10 Module im_internal
11 </Input>
12
13 <Input eventlog>
14 Module im_msvistalog
15 </Input>
16
17 <Output out>
18 Module om_udp
19 Host 192.168.1.1
20 Port 514
21 Exec $Message = to_json(); to_syslog_bsd();
22 </Output>
23
24 <Route r>
25 Path internal, eventlog => out
26 </Route>
If Syslog compatibility is not a concern, JSON can be transported without the Syslog header
NOTE
(omit the to_syslog_bsd() procedure).
858
Chapter 111. Sysmon NXLog User Guide
On Windows Vista and higher, Sysmon’s events are stored in the Microsoft-Windows-Sysmon/Operational event log.
On older systems, events are written to the System event log.
3. A complex configuration with filtering can be deployed by creating a custom XML configuration file for
Sysmon.
See SwiftOnSecurity Sysmon configuration, or IONStorm Sysmon configuration on GitHub. Both provide
good information for understanding what is possible with Sysmon and include many examples.
> sysmon -u
859
NXLog User Guide Chapter 111. Sysmon
Sysmon audit log data can be collected with im_msvistalog (or other modules, see Windows Event Log). The Data
tags will be automatically parsed, and the values will be available as fields in the event records. The log data can
then be forwarded to a log analytics system to allow identification of malicious or anomalous activity.
860
Chapter 111. Sysmon NXLog User Guide
Here, the im_msvistalog module will collect all Sysmon events from the EventLog. A sample event is shown
below.
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Sysmon/Operational">*</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 </Input>
861
NXLog User Guide Chapter 111. Sysmon
Output Sample
{
"EventTime": "2015-04-27 15:23:46",
"Hostname": "WIN-OUNNPISDHIG",
"Keywords": -9223372036854776000,
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 1,
"SourceName": "Microsoft-Windows-Sysmon",
"ProviderGuid": "{5770385F-C22A-43E0-BF4C-06F5698FFBD9}",
"Version": 3,
"Task": 1,
"OpcodeValue": 0,
"RecordNumber": 2335906,
"ProcessID": 1680,
"ThreadID": 1728,
"Channel": "Microsoft-Windows-Sysmon/Operational",
"Domain": "NT AUTHORITY",
"AccountName": "SYSTEM",
"UserID": "SYSTEM",
"AccountType": "Well Known Group",
"Message": "Process Create:\r\nUtcTime: 2015.04.27. 13:23\r\nProcessGuid: {00000000-3862-
553E-0000-001051D40527}\r\nProcessId: 25848\r\nImage: c:\\Program Files (x86)\\nxlog\\
nxlog.exe\r\nCommandLine: \"c:\\Program Files (x86)\\nxlog\\nxlog.exe\" -f\r\nUser: WIN-
OUNNPISDHIG\\Administrator\r\nLogonGuid: {00000000-568E-5453-0000-0020D5ED0400}\r\nLogonId:
0x4edd5\r\nTerminalSessionId: 2\r\nIntegrityLevel: High\r\nHashType: SHA1\r\nHash:
1DCE4B0F24C40473CE7B2C57EB4F7E9E3E14BF94\r\nParentProcessGuid: {00000000-3862-553E-0000-
001088D30527}\r\nParentProcessId: 26544\r\nParentImage: C:\\msys\\1.0\\bin\\sh.exe
\r\nParentCommandLine: C:\\msys\\1.0\\bin\\sh.exe",
"Opcode": "Info",
"UtcTime": "2015.04.27. 13:23",
"ProcessGuid": "{00000000-3862-553E-0000-001051D40527}",
"Image": "c:\\Program Files (x86)\\nxlog\\nxlog.exe",
"CommandLine": "\"c:\\Program Files (x86)\\nxlog\\nxlog.exe\" -f",
"User": "WIN-OUNNPISDHIG\\Administrator",
"LogonGuid": "{00000000-568E-5453-0000-0020D5ED0400}",
"LogonId": "0x4edd5",
"TerminalSessionId": "2",
"IntegrityLevel": "High",
"HashType": "SHA1",
"Hash": "1DCE4B0F24C40473CE7B2C57EB4F7E9E3E14BF94",
"ParentProcessGuid": "{00000000-3862-553E-0000-001088D30527}",
"ParentProcessId": "26544",
"ParentImage": "C:\\msys\\1.0\\bin\\sh.exe",
"ParentCommandLine": "C:\\msys\\1.0\\bin\\sh.exe",
"EventReceivedTime": "2015-04-27 15:23:47",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog"
}
862
Chapter 111. Sysmon NXLog User Guide
Sysmon configuration
Sysmon supports filtering tags that can be used to avoid logging unwanted events. See Setting up Sysmon
above and the Sysmon page for details about the available tags. This method is the most efficient because it
avoids creating the unwanted log entries in the first place.
The following example shows a query that collects only events that have an event ID of 1 (process
creation).
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Sysmon/Operational">
7 *[System[(EventID='1')]]
8 </Select>
9 </Query>
10 </QueryList>
11 </QueryXML>
12 </Input>
NXLog language
Finally, the built-in filtering capabilities of NXLog can be used, which may be easier to write than the XML
query syntax provided by the EventLog API.
863
NXLog User Guide Chapter 111. Sysmon
This example discards all network connection events (event ID 3) regarding HTTP network connections
to a particular server and port, and all process creation and termination events (event IDs 1 and 5) for
conhost.exe.
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Sysmon/Operational">*</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 <Exec>
11 if ($EventID in (1, 5) and
12 $Image == "C:\\Windows\\System32\\conhost.exe") or
13 ($EventID == 3 and
14 $DestinationPort == 80 and
15 $DestinationIp == 10.0.0.1)
16 drop();
17 </Exec>
18 </Input>
864
Chapter 112. Ubiquiti UniFi NXLog User Guide
More information about configuring the UniFi Controller can be found in the corresponding user guide.
The steps below have been tested with UniFi Controller v4 and should work for other versions
NOTE
also.
1. Configure NXLog for receiving Syslog log entries via UDP (see the examples below). Then restart NXLog.
2. Make sure the NXLog agent is accessible from the server with the Controller software.
3. Log in to the Controller’s web interface.
4. Go to Settings › Site.
5. Select Enable remote syslog server and specify the IP address and UDP port that the NXLog agent is
listening on. If necessary, also select Enable debug level syslog. Then click [Apply].
By default, the UniFi Controller sends a lot of low level information which may complicate field extraction if
additional intelligence is required. The Syslog level can be adjusted individually for each access point from the
Controller server by changing the syslog.level value in the system.cfg file. The location of this file varies
depending on the host operating system. If the Controller software is running on Windows, the file can be found
865
NXLog User Guide Chapter 112. Ubiquiti UniFi
Unfortunately, once configured with remote Syslog address, the Controller only sends log messages that
originate from access points. The Controller’s own log is located on the server where it is installed. The location
of this file depends on the host operating system, on Windows it can be found at C:\Ubiquiti
UniFi\logs\server.log. If needed, this file can be parsed with the om_file module.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in_syslog_udp>
10 Module im_udp
11 Host 0.0.0.0
12 Port 514
13 Exec parse_syslog();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/unifi.log"
19 Exec to_json();
20 </Output>
Output Sample
{
"MessageSourceAddress": "192.168.10.147",
"EventReceivedTime": "2017-04-27 19:38:55",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "192.168.10.147",
"EventTime": "2017-04-27 19:40:44",
"Message": "(\"U7P,0418d6809ce2,v3.7.11.5131\") hostapd: ath4: STA 34:02:86:45:8e:e0 IEEE
802.11: disassociated"
}
866
Chapter 112. Ubiquiti UniFi NXLog User Guide
Additional fields can be extracted from the Syslog messages with a configuration like the one below.
nxlog.conf
1 <Input in_syslog_udp>
2 Module im_udp
3 Host 0.0.0.0
4 Port 514
5 <Exec>
6 parse_syslog();
7 if $Message =~ / ([a-z]*): (.*)$/
8 {
9 $UFProcess = $1;
10 $UFMessage = $2;
11 if $UFMessage =~ /^([a-z0-9]*): (.*)$/
12 {
13 $UFSubsys = $1;
14 $UFMessage = $2;
15 if $UFMessage =~ /^STA (.*) ([A-Z0-9. ]*): (.*)$/
16 {
17 $UFMac = $1;
18 $UFProto = $2;
19 $UFMessage = $3;
20 }
21 }
22 }
23 </Exec>
24 </Input>
Output Sample
{
"MessageSourceAddress": "192.168.10.149",
"EventReceivedTime": "2017-05-01 20:30:13",
"SourceModuleName": "in_syslog_udp",
"SourceModuleType": "im_udp",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 6,
"SyslogSeverity": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Hostname": "192.168.10.149",
"EventTime": "2017-05-01 20:32:11",
"Message": "(\"U7P,0418d6809b78,v3.7.11.5131\") hostapd: ath2: STA 80:19:34:97:62:a6 RADIUS:
stopped accounting session 5907CFDD-00000002",
"UFProcess": "hostapd",
"UFSubsys": "ath2",
"UFMac": "80:19:34:97:62:a6",
"UFProto": "RADIUS",
"UFMessage": "stopped accounting session 5907CFDD-00000002"
}
867
NXLog User Guide Chapter 113. VMware vCenter
• NXLog can be installed directly on the vCenter host machine and configured to collect all logs locally. This
method provides more feedback and more detailed logs, and is the recommended method. See Local
vCenter Logging.
• Alternatively, vCenter logs can be collected remotely using the vSphere Perl SDK. This option is less flexible,
but may be the only feasible option in some environments due to security restrictions. See Remote vCenter
Logging.
4. Click [OK] to save your changes. vCenter will now start writing detailed logs. The location of the logs
depends on the version of vCenter you are running.
◦ vCenter Server 5.x and earlier versions on Windows XP, 2000, and 2003:
%ALLUSERSPROFILE%\Application Data\VMware\VMware VirtualCenter\Logs\
◦ vCenter Server 5.x and earlier versions on Windows Vista, 7, and 2008:
C:\ProgramData\VMware\VMware VirtualCenter\Logs\
If vCenter is running under a specific user account, then the logs may be located in the
NOTE
profile directory of that user, instead of %ALLUSERSPROFILE%.
868
Chapter 113. VMware vCenter NXLog User Guide
vpxd.log The main vCenter Server logs, consisting of all vSphere Client and WebServices
connections, internal tasks and events, and communication with the vCenter
Server Agent (vpxa) on managed ESX/ESXi hosts.
vpxd-profiler.log, Profiled metrics for operations performed in vCenter Server. Used by the VPX
profiler.log Operational Dashboard (VOD) accessible at https://VCHost/vod/index.html.
cim-diag.log and vws.log Common Information Model monitoring information, including communication
between vCenter Server and managed hosts’ CIM interface
drmdump (directory) Actions proposed and taken by VMware Distributed Resource Scheduler (DRS),
grouped by the DRS-enabled cluster managed by vCenter Server. These logs are
compressed.
ls.log Health reports for the Licensing Services extension, connectivity logs to vCenter
Server.
vimtool.log Dump of string used during the installation of vCenter Server with hashed
information for DNS, username and output for JDBC creation.
stats.log Provides information about the historical performance data collection from the
ESXi/ESX hosts
sms.log Health reports for the Storage Monitoring Service extension, connectivity logs to
vCenter Server, the vCenter Server database and the xDB for vCenter Inventory
Service.
eam.log Health reports for the ESX Agent Monitor extension, connectivity logs to vCenter
Server.
catalina.date.log and Connectivity information and status of the VMware Webmanagement Services.
localhost.date.log
jointool.log Health status of the VMwareVCMSDS service and individual ADAM database
objects, internal tasks and events, and replication logs between linked-mode
vCenter Servers.
The various log files use different formats. You must examine your chosen file in order to
NOTE
determine how to parse its entries.
The main log file, vpxd.log, contains all login and management information. This file will be used as an
example. The file has the general format of timestamp [tag-1] [optional-tag-2] message, and the
message part might contain a multi-line trace.
869
NXLog User Guide Chapter 113. VMware vCenter
vpxd.log Sample
2014-06-13T22:44:46.878-07:00 [04372 info 'Default' opID=DACDA564-00000004-7c] [Auth]: User
Administrator↵
2014-06-13T23:15:07.222-07:00 [04136 error 'vpxdvpxdMain'] [Vpxd::ServerApp::Init] Init failed:
VpxdVdb::Init(VpxdVdb::GetVcVdbInstId(), false, false, NULL)↵
--> Backtrace:↵
--> backtrace[00] rip 000000018018a8ca↵
--> backtrace[01] rip 0000000180102f28↵
--> backtrace[02] rip 000000018010423e↵
--> backtrace[03] rip 000000018008e00b↵
--> backtrace[04] rip 00000000003c5c2c↵
-->↵
870
Chapter 113. VMware vCenter NXLog User Guide
In the configuration below, the xm_multiline extension module is used with the HeaderLine directive to
parse log entries even when they span multiple lines. An Exec directive is used to drop all empty lines. A
regular expression with matching groups adds fields to the event record from each log message, and the
resulting log entries are sent to another host via TCP in JSON format.
nxlog.conf
1 <Extension vcenter>
2 Module xm_multiline
3 HeaderLine /(?x)(\d+-\d+-\d+T\d+:\d+:\d+).\d+-\d+:\d+\s+\[(.*?)\]\s+ \
4 (?:\[(.*?)\]\s+)?(.*)/
5 Exec if $raw_event =~ /^\s+$/ drop();
6 </Extension>
7
8 <Extension _json>
9 Module xm_json
10 </Extension>
11
12 <Input in>
13 Module im_file
14 File "C:\ProgramData\VMware\VMware VirtualCenter\Logs\vpxd*.log"
15 InputType vcenter
16 <Exec>
17 if $raw_event =~ /(?x)(\d+-\d+-\d+T\d+:\d+:\d+.\d+-\d+:\d+)\s+\[(.*?)\]\s+
18 (?:\[(.*?)\]\s+)?((.*\s*)*)/
19 {
20 $EventTime = parsedate($1);
21 $Tag1 = $2;
22 $Tag2 = $3;
23 $Message = $4;
24 }
25 </Exec>
26 </Input>
27
28 <Output out>
29 Module om_tcp
30 Host 192.168.1.1
31 Port 1514
32 Exec to_json();
33 </Output>
871
NXLog User Guide Chapter 113. VMware vCenter
Output Sample
{
"EventReceivedTime": "2017-04-29 13:46:49",
"SourceModuleName": "vcenter_in1",
"SourceModuleType": "im_file",
"EventTime": "2014-06-14 07:44:46",
"Tag1": "04372 info 'Default' opID=DACDA564-00000004-7c",
"Tag2": "",
"Message": "[Auth]: User Administrator"
}
{
"EventReceivedTime": "2017-04-29 13:46:49",
"SourceModuleName": "vcenter_in1",
"SourceModuleType": "im_file",
"EventTime": "2014-06-14 08:15:07",
"Tag1": "04136 error 'vpxdvpxdMain'",
"Tag2": "Vpxd::ServerApp::Init",
"Message": "Init failed: VpxdVdb::Init(VpxdVdb::GetVcVdbInstId(), false, false, NULL)\n-->
Backtrace:\n--> backtrace[00] rip 000000018018a8ca\n--> backtrace[01] rip 0000000180102f28\n-->
backtrace[02] rip 000000018010423e\n--> backtrace[03] rip 000000018008e00b\n--> backtrace[04]
rip 00000000003c5c2c\n-->\n"
}
1. Download and install the latest Perl runtime and the vSphere SDK for Perl. For Windows, the vSphere CLI is
recommended instead, because it includes the required Perl runtime environment and VIperl libraries.
2. The script will use a timestamp file to store the timestamp of the most recently downloaded log entry. The
timestamp ensures that even if the vCenter server is restarted, NXLog can correctly resume log collection.
The timestamp file will be created automatically. However, to specify a timestamp manually, create a file with
a timestamp in yyyy-mm-ddThh-mm format (for example, 2017-01-19T18:00). Then use the -r option to
specify the location of the timestamp file. Any logs with earlier timestamps will be skipped.
3. To test the vcenter.pl script with the vCenter host, run the script as shown below. Substitute the correct
server IP address and credentials for the vCenter server. The -t argument is optional and can be used to
adjust the time between polls (the default of 60 seconds is the minimum recommended). The -r argument is
also optional and can be used to specify a custom location for the timestamp file. Events such as connection
or authentication errors are logged to standard output.
Because the script connects to vCenter remotely, we recommend setting up a dedicated user in
NOTE
vCenter as a security measure.
872
Chapter 113. VMware vCenter NXLog User Guide
This configuration uses the im_exec module to run the Perl script and accept logs from its standard output.
The xm_json module is used to parse the JSON event data. The $EventTime field is converted to a datetime
value.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input in>
6 Module im_exec
7 # For users who have the VMware CLI installed:
8 Command "C:\Program Files (x86)\VMware\VMware vSphere CLI\Perl\bin\perl.exe"
9 # For Linux and regular Perl users this would be sufficient:
10 #Command perl
11 Arg "C:\scripts\vcenter.pl"
12 Arg -u
13 Arg <username>
14 Arg -p
15 Arg <password>
16 Arg -s
17 Arg <server_ip_addr>
18 <Exec>
19 # Parse JSON into fields for later processing if required
20 parse_json();
21
22 # Parse EventTime field as timestamp
23 $EventTime = parsedate($EventTime);
24 </Exec>
25 </Input>
Event Samples
{
"EventTime": "2014-06-20T18:00:00.163Z",
"Message": "User Administrator@192.168.71.1 logged in as VI Perl",
"UserName": "Administrator"
}
{
"EventTime": "2014-06-20T10:56:23",
"Message": "Error: Cannot complete login due to an incorrect user name or password.",
"UserName": "Administrator"
}
873
NXLog User Guide Chapter 113. VMware vCenter
vcenter.pl (truncated)
#!/usr/bin/perl -w
use Encode;
use VMware::VIRuntime;
use VMware::VILib;
use Getopt::Long;
use IO::File;
use POSIX;
my $startTime;
my $stopTime;
my $server;
my $sleepTime = 60;
my $userName;
my $passWord;
my $timeStamp;
my $timeStampFile = "timestamp.txt";
my $timeNow;
[...]
874
Chapter 114. Windows AppLocker NXLog User Guide
AppLocker logs events to the Windows Event Log. There are four logs available, shown in the Event Viewer under
Applications and Services Logs > Microsoft > Windows > Applocker:
NXLog can collect these events with the im_msvistalog module or other Windows Event Log modules.
875
NXLog User Guide Chapter 114. Windows AppLocker
The following configuration uses the im_msvistalog module to collect Applocker events from the four
EventLog logs listed above. The xm_xml parse_xml() procedure is used to further parse the UserData XML
portion of the event.
nxlog.conf
1 <Extension _xml>
2 Module xm_xml
3 </Extension>
4
5 <Input in>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id="0">
10 <Select Path="Microsoft-Windows-AppLocker/MSI and Script">
11 *</Select>
12 <Select Path="Microsoft-Windows-AppLocker/EXE and DLL">
13 *</Select>
14 <Select Path="Microsoft-Windows-AppLocker/Packaged app-Deployment">
15 *</Select>
16 <Select Path="Microsoft-Windows-AppLocker/Packaged app-Execution">
17 *</Select>
18 </Query>
19 </QueryList>
20 </QueryXML>
21 Exec if $UserData parse_xml($UserData);
22 </Input>
Output Sample
{
"EventTime": "2019-01-09T22:34:44.164099+01:00",
"Hostname": "Host.DOMAIN.local",
"Keywords": "9223372036854775808",
"EventType": "ERROR",
"SeverityValue": 4,
"Severity": "ERROR",
"EventID": 8004,
"SourceName": "Microsoft-Windows-AppLocker",
"ProviderGuid": "{CBDA4DBF-8D5D-4F69-9578-BE14AA540D22}",
"Version": 0,
"TaskValue": 0,
"OpcodeValue": 0,
"RecordNumber": 40,
"ExecutionProcessID": 5612,
"ExecutionThreadID": 5220,
"Channel": "Microsoft-Windows-AppLocker/EXE and DLL",
"Domain": "DOMAIN",
"AccountName": "admin",
"UserID": "S-1-5-21-314323950-2314161084-4234690932-1002",
"AccountType": "User",
"Message": "%PROGRAMFILES%\\WINDOWS NT\\ACCESSORIES\\WORDPAD.EXE was prevented from
running.",
"Opcode": "Info",
"UserData": "<RuleAndFileData
xmlns='http://schemas.microsoft.com/schemas/event/Microsoft.Windows/1.0.0.0'><PolicyNameLength>
3</PolicyNameLength><PolicyName>EXE</PolicyName><RuleId>{4C8E638D-3DE8-4DCB-B0E4-
B0597074D06B}</RuleId><RuleNameLength>113</RuleNameLength><RuleName>WORDPAD.EXE, in MICROSOFT®
876
Chapter 114. Windows AppLocker NXLog User Guide
877
NXLog User Guide Chapter 115. Windows Command Line Auditing
This monitoring featureis available starting from Windows Server 2012 R2, see the Command line process
auditing section on the Microsoft website. For more information about security, see also the Security Monitoring
Recommendations on the Microsoft website.
NXLog can be configured to collect and parse command line auditing logs.
Monitoring of process creation with command line is also available through utilizing Sysmon,
NOTE although the native command line auditing solution may be more preferable since it does not
require installation of any third-party software.
The command line process auditing writes events to the Windows Event Log, which can be monitored by
capturing event entries with the Event ID 4688.
2. To enable audit process creation, go to Computer Configuration > Windows Settings > Security Settings >
Advanced Audit Policy Configuration > System Audit Policies > Detailed Tracking and open the Audit
878
Chapter 115. Windows Command Line Auditing NXLog User Guide
Process Creation setting, then check the Configure the following audit events and Success checkboxes.
3. To enable command line process creation, go to Computer Configuration > Administrative Templates >
System > Audit Process Creation, click the Include command line in process creation event setting, then
select the Enabled radio button.
For more information about enabling the command line auditing, see How to Determine What Just Ran on
Windows Console section on Microsoft website.
879
NXLog User Guide Chapter 115. Windows Command Line Auditing
The configuration below demonstrates how to collect Windows Event Log entries with the ID 4688 of the
Security channel to log the activity of the C:\Windows\System32\ftp.exe application. First, it drops entries
without the ftp.exe substring in the NewProcessName field. After that, the Message field from the selected
entries is deleted to make the example output shorter. Finally, the logs are converted to JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input from_eventlog>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id="0">
10 <Select Path="Security">
11 *[System[Level=0 and (EventID=4688)]]
12 </Select>
13 </Query>
14 </QueryList>
15 </QueryXML>
16 <Exec>
17 if not ($NewProcessName =~ /.*ftp.exe/) drop();
18 delete($Message);
19 json->to_json();
20 </Exec>
21 </Input>
880
Chapter 115. Windows Command Line Auditing NXLog User Guide
Output Sample
{
"EventTime": "2020-04-18T16:26:48.737490+03:00",
"Hostname": "WIN-IVR26CIVSF6",
"Keywords": "9232379236109516800",
"EventType": "AUDIT_SUCCESS",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 4688,
"SourceName": "Microsoft-Windows-Security-Auditing",
"ProviderGuid": "{54849625-5478-4994-A5BA-3E3B0328C30D}",
"Version": 2,
"TaskValue": 13312,
"OpcodeValue": 0,
"RecordNumber": 18112,
"ExecutionProcessID": 4,
"ExecutionThreadID": 3720,
"Channel": "Security",
"Category": "Process Creation",
"Opcode": "Info",
"SubjectUserSid": "S-1-5-21-2751412651-3826291291-1936999150-500",
"SubjectUserName": "Administrator",
"SubjectDomainName": "WIN-IVR26CIVSF6",
"SubjectLogonId": "0x23d19",
"NewProcessId": "0xa24",
"NewProcessName": "C:\\Windows\\System32\\ftp.exe",
"TokenElevationType": "%%1936",
"ProcessId": "0x2a8",
"CommandLine": "ftp -s:ftp.txt",
"TargetUserSid": "S-1-0-0",
"TargetUserName": "-",
"TargetDomainName": "-",
"TargetLogonId": "0x0",
"ParentProcessName": "C:\\Windows\\System32\\cmd.exe",
"MandatoryLabel": "S-1-16-12288",
"EventReceivedTime": "2020-04-18T16:26:50.674636+03:00",
"SourceModuleName": "from_eventlog",
"SourceModuleType": "im_msvistalog"
}
881
NXLog User Guide Chapter 116. Windows Event Log
Unlike other event logs, such as the UNIX Syslog, Windows Event Log is not stored as a plain text file, but in a
proprietary binary format. It is not possible to view Windows Event Log in a text editor, nor is it possible to send
it as a Syslog event while retaining its original format. However, the raw event data can be translated into XML
using the Windows Event Log API and forwarded in that format.
The EVTX format includes many new features and enhancements: a number of new event properties, the use of
channels to publish events, a new Event Viewer, a rewritten Windows Event Log service, and support for the
Extensible Markup Language (XML) format. From a log processing perspective, the added support for XML is the
most important addition, as it provides the possibility to share or further process the event data in a structured
format.
For the built in channels, Windows automatically saves the corresponding EVTX file into the
C:\Windows\System32\winevt\Logs\ directory. Events can also be saved manually from the Event Viewer MMC
snap-in, in four different formats: EVTX, XML, TXT, and CSV.
NXLog can directly read EVTX and EVT files using the im_msvistalog File directive. In addition, the
CaptureEventXML directive of the same module can be used to store and send raw XML-formatted event data in
the $EventXML field.
The Event Viewer includes three views for displaying the data for a selected event. These are shown on the
preview pane or in the Event Properties window when an event is opened.
• The general view is shown by default. It includes the full message rendered from template and the "System"
set of key/value pairs.
• The Friendly View is available on the Details tab. It shows a hierachical view of the System properties and
additional EventData properties defined by the event provider. It does not show a rendered message.
• The XML View can be selected under the Details tab. It shows the event properties in XML format. It does
not show a rendered message.
882
Chapter 116. Windows Event Log NXLog User Guide
Events can be accessed through the Event Log API (see Windows Event Log Functions on Microsoft Docs). In
particular:
• EvtQuery() fetches events from a given channel or log file that match a given query—see Querying for
Events.
• EvtFormatMessage() generates a message string for an event using the event properties and the localized
message template—see Formatting Event Messages.
• The Windows Logs group contains a set of exactly five channels, which are used for Windows system events.
• The Applications and Services Logs group contains channels created for individual applications or
components. These channels are further organized in a folder hierarchy.
There are two channel types indicating how the events are handled:
• Serviced channels offer relatively low volume, reliable delivery of events. Events in these channels may be
forwarded to another system, and these channels may be subscribed to.
• Direct channels are for high-performance collection of events. It is not possible to subscribe to a a direct
channel. By default, these channels are disabled. To see these channels in the Event Viewer, check Show
Analytic and Debug Logs in the View menu. To enable logging for one of these channels, select the channel,
open the Action menu, click Properties, and check Enable logging on the General tab.
Each of the above is subdivided into two more channel types according to the the intended audience for the
events collected by that channel:
• Administrative channels collects events for end users, administrators, and support. This is a serviced
channel type.
• Operational channels collect events used for diagnosing problems. This is a serviced channel type.
• Analytic channels are for events that describe program operation. These channels often collect a high
volume of events. This is a direct channel type.
• Debug channels are intended to be used by developers only. This is a direct channel type.
883
NXLog User Guide Chapter 116. Windows Event Log
The im_msvistalog module can be configured to collect events from a specific channel with the Channel directive.
For more information about event channels, see these two pages on Microsoft Docs: Event Logs and Event Logs
and Channels in Windows Event Log.
116.1.4. Providers
Event log providers write events to event logs. An event log provider can be a service, driver, or program that runs
on the computer and has the necessary instrumentation to write to the event log.
For more information on providers, see the Providers section in the Microsoft Windows documentation.
• The im_msvistalog module is available on Windows only, and captures event log data from Windows
2008/Vista and later. It can be configured to collect event log data from the local system or from a remote
system via MSRPC (MSRPC is supported by NXLog Enterprise Edition only). See Local Collection With
im_msvistalog and Remote Collection With im_msvistalog.
• The im_wseventing module is available on both Linux and Windows (NXLog Enterprise Edition only). With it,
event log data can be received from remote Windows systems using Windows Event Forwarding. This is the
recommended module for most cases where remote capturing is required, because it is not necessary to
specify each host that Event Log data will be captured from. See Remote Collection With im_wseventing.
• The im_mseventlog module is available on Windows only, and captures event log data locally from Windows
XP, Windows 2000, and Windows 2003. See Local Collection With im_mseventlog.
884
Chapter 116. Windows Event Log NXLog User Guide
Because the Windows Event Log subsystem does not support subscriptions to the Debug and
NOTE
Analytic channels, these types of events can not be collected with the im_msvistalog module.
Example 512. Collecting Event Log Locally From Windows 2008/Vista or Later
In this example, NXLog reads all events from the local Windows Event Log. The data is converted to JSON
format and written to a local file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input eventlog>
6 Module im_msvistalog
7 </Input>
8
9 <Output file>
10 Module om_file
11 File 'C:\test\sysmon.json'
12 Exec to_json();
13 </Output>
For information about filtering events, particularly when using im_msvistalog, see Filtering Events.
Because the Windows Event Log subsystem does not support subscriptions to the Debug and
NOTE
Analytic channels, these types of events can not be collected with the im_msvistalog module.
885
NXLog User Guide Chapter 116. Windows Event Log
In this example configuration, the im_msvistalog module is used to get events from a remote server named
mywindowsbox using MSRPC.
To replicate this example in your environment, modify the RemoteServer, RemoteUser, RemoteDomain, and
RemotePassword to reflect the access credentials for the target machine.
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id='1'>
6 <Select Path='Application'>*</Select>
7 <Select Path='Security'>*[System/Level=4]</Select>
8 <Select Path='System'>*</Select>
9 </Query>
10 </QueryList>
11 </QueryXML>
12 RemoteServer mywindowsbox
13 RemoteUser Administrator
14 RemoteDomain Workgroup
15 RemotePassword secret
16 </Input>
The module looks up the available Event Log sources stored under the registry key
SYSTEM\CurrentControlSet\Services\Eventlog, and polls logs from each of these or only the sources
defined with the Sources directive of the NXLog configuration.
Example 514. Forwarding Event Log Data from Windows to a Remote Host
This example shows the most basic configuration of the im_mseventlog module. This configuration
forwards all Event Log sources listed in the Windows registry over the network to a remote NXLog instance
at the IP address 192.168.1.1.
nxlog.conf
1 <Input eventlog>
2 Module im_mseventlog
3 </Input>
4
5 <Output tcp>
6 Module om_tcp
7 Host 192.168.1.1
8 Port 514
9 </Output>
886
Chapter 116. Windows Event Log NXLog User Guide
Example 515. Receiving Windows Event Log Data using the im_wseventing Module
This configuration receives data from all source computers, by listening on port 5985 for connections from
all sources. It also shows a configured HTTPS certificate, used to secure the transfer of Event Log data.
nxlog.conf
1 <Input in>
2 Module im_wseventing
3 ListenAddr 0.0.0.0
4 Port 5985
5 Address https://linux.corp.domain.com:5985/wsman
6 HTTPSCertFile %CERTDIR%/server-cert.pem
7 HTTPSCertKeyFile %CERTDIR%/server-key.pem
8 HTTPSCAFile %CERTDIR%/ca.pem
9 <QueryXML>
10 <QueryList>
11 <Query Id="0" Path="Application">
12 <Select Path="Application">*</Select>
13 <Select Path="Microsoft-Windows-Winsock-AFD/Operational">*</Select>
14 <Select Path="Microsoft-Windows-Wired-AutoConfig/Operational">
15 *
16 </Select>
17 <Select Path="Microsoft-Windows-Wordpad/Admin">*</Select>
18 <Select Path="Windows PowerShell">*</Select>
19 </Query>
20 </QueryList>
21 </QueryXML>
22 </Input>
A query for specific hosts can be set by adding an additional QueryXML block with a <Computer> tag. This
tag contains a pattern that NXLog matches against the name of the connecting Windows client. Computer
names not matching the pattern will use the default QueryXML block (containing no <Computer> tag). The
following QueryXML block, if added to the above configuration, would provide an alternate query for
computer names matching the pattern foo*.
nxlog.conf
1 <QueryXML>
2 <QueryList>
3 <Computer>foo*</Computer>
4 <Query Id="0" Path="Application">
5 <Select Path="Application">*</Select>
6 </Query>
7 </QueryList>
8 </QueryXML>
• A specific channel can be specified with the Channel directive to collect all the events written to a single
channel.
• An XPath query can be given with the QueryXML block (or Query directive). The specified query is then used
to subscribe to events. An XPath query can be used to subscribe to multiple channels and/or limit events by
various attributes. However, XPath queries have a maximum length, limiting the possibilities for detailed
event subscriptions. See XPath Filtering below.
887
NXLog User Guide Chapter 116. Windows Event Log
• A log file can be read by setting the File directive, in which case im_msvistalog will read all events from the
file (for example, Security.evtx). This is intended primarily for forensics purposes, such as with nxlog-
processor.
• After being read from the source, events can be discarded by matching events in an Exec block and
discarding them selectively with the drop() procedure.
Subscribing to a restricted set of events with an XPath query can offer a performance advantage because the
events are never received by NXLog. However, XPath queries have a maximum length and limited filtering
capabilities, so in some cases it is necessary to combine an XPath query with Exec block filtering in an
im_msvistalog configuration. For examples, see examples in Event IDs to Monitor.
The Event Viewer offers the most practical way to write and test query strings. An XPath query can be generated
and/or tested by filtering the current log or creating a custom view.
1. In the Event Viewer, click an event channel to open it, then right-click the channel and choose Filter Current
Log from the context menu. Or, click Create Custom View in the context menu. Either way, a dialog box will
open and options for basic filtering will be shown in the Filter tab.
2. Specify the desired criteria. The corresponding XPath query on the XML tab will be updated automatically.
3. To view the query string, switch to the XML tab. This string can be copied into the im_msvistalog QueryXML
directive.
4. If required, advanced filtering can be done by selecting the Edit query manually checkbox and editing the
query. The query can then be tested to be sure it matches the correct events and finally copied to the NXLog
configuration with the QueryXML block.
888
Chapter 116. Windows Event Log NXLog User Guide
Figure 12. A Custom View Querying the Application Channel for Events With ID 1008
Sometimes it is helpful to use a query with sources that may not be available. In this case, set the
TolerateQueryErrors directive to TRUE to ensure that the module will continue to collect logs.
Here, NXLog queries the local Windows Event Log for operational events only.
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Sysmon/Operational">*</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 </Input>
This query collects System channel events with levels below 4 (Critical, Error, and Warning).
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path='System'>*[System/Level<4]</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 </Input>
889
NXLog User Guide Chapter 116. Windows Event Log
This example discards all Sysmon network connection events (event ID 3) regarding HTTP network
connections to a particular server and port, and all process creation and termination events (event IDs 1
and 5) for conhost.exe.
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Sysmon/Operational">*</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 <Exec>
11 if ($EventID in (1, 5) and
12 $Image == "C:\\Windows\\System32\\conhost.exe") or
13 ($EventID == 3 and
14 $DestinationPort == 80 and
15 $DestinationIp == 10.0.0.1)
16 drop();
17 </Exec>
18 </Input>
Event IDs are unique per source but are not globally unique. The same event ID may be used by
NOTE
different sources to identify unrelated occurrences.
• The Microsoft Events and Errors page on Microsoft Docs provides a directory of events grouped by area.
Start by navigating through the areas listed in the Available Documentation section.
• Palantir has published a Windows Event Forwarding Guidance repository, which contains a comprehensive WEF
Event Mappings table with categorized event IDs and details.
• The NSA Spotting the Adversary with Windows Event Log Monitoring paper provides event IDs for security
monitoring. See the example configuration here.
• The JPCERT/CC Detecting Lateral Movements Tool Analysis resource provides a collection of event codes that are
observed to indicate lateral movements. See the example configuration here.
890
Chapter 116. Windows Event Log NXLog User Guide
• See the NXLog User Guide on Active Directory Domain Services for a list and configuration sample of security
event IDs relevant to Active Directory.
The table below displays a small sample of important events to monitor in the Windows Server Security Log for a
local server. See the Security-focused Event IDs to Monitor section for the configuration file holding these event
IDs.
Event Description
ID
4946 A change has been made to Windows Firewall exception list. A rule was added.
6424 The installation of this device was allowed, after having previously been forbidden by policy.
The example configurations in this section are likely to require further modifications to suit each
NOTE
individual deployment.
Due to a bug or limitation of the Windows Event Log API, 23 or more clauses in a query will
result in a failure with the following error message: ERROR failed to subscribe to
NOTE
msvistalog events, the Query is invalid: This operator is unsupported by this
implementation of the filter.; [error code: 15001]
Event IDs are globally applied to all providers of a given XPath expression so events that match
NOTE these IDs will be collected. You should tweak your chosen dashboard or alerting system to
ensure that the right Event IDs and its subsequent providers are appropriately associated.
891
NXLog User Guide Chapter 116. Windows Event Log
This configuration provides a basic example of Windows Security events to monitor. Since only a small
number of IDs are presented, this configuration explicitly provides the actual event IDs to be collected.
nxlog.conf
1 <Input MonitorWindowsSecurityEvents>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Security">*[System[(Level=1 or Level=2 or Level=3 or Level=4
or Level=0) and (EventID=1102 or EventID=4719 or EventID=4704 or EventID=4717 or
EventID=4738 or EventID=4798 or EventID=4705 or EventID=4674 or EventID=4697 or EventID=4648
or EventID=4723 or EventID=4946 or EventID=4950 or EventID=6416 or EventID=6424 or
EventID=4732)]]</Select>
7 </Query>
8 </QueryList>
9 </QueryXML>
10 </Input>
This extended configuration provides a much wider scope of log collection. Note that this approach for
specifying the event IDs requires defining the event IDs based on groups of events first. The QueryXML
paths are added in the QueryXML block in bulk. Then the Exec block will filter for the defined event IDs, but
only within the paths specified. It also drops event IDs that are not defined.
nxlog.conf (truncated)
1 # define Account Usage Events
2 define AccountUsage 4740, 4648, 4781, 4733, 1518, 4776, 5376, 5377, \
3 4625, 300, 4634, 4672, 4720, 4722, 4782, 4793, \
4 4731, 4735, 4766, 4765, 4624, 1511, 4726, 4725, \
5 4767, 4728, 4732, 4756, 4704
6
7 # define Application Crash Events
8 define AppCrashes 1000, 1002, 1001
9
10 # define Application Whitelisting Events
11 define AppWhitelisting 8023, 8020, 8002, 8003, 8004, 8006, 8007, 4688, \
12 4689, 8005, 865, 866, 867, 868, 882
13
14 # define Boot Events
15 define BootEvents 13, 12
16
17 # define Certificate Services Events
18 define CertServices 95, 4886, 4890, 4874, 4873, 4870, 4887, 4885, \
19 4899, 4896, 1006, 1004, 1007, 1003, 1001, 1002
20
21 # define Clearing Event Logs Events
22 define ClearingLogs 1100, 104, 1102
23
24 # define DNS and Directory Services Events
25 define DNSDirectoryServ 5137, 5141, 5136, 5139, 5138, 3008, 3020
26
27 # define External Media Detection events
28 [...]
892
Chapter 116. Windows Event Log NXLog User Guide
This configuration, similar to the extended configuration above, lists event IDs associated with the detection
of malicious lateral movements. It is based on the security research conducted by the CERT (Computer
Emergency Response Team) cybersecurity researchers on Detecting Lateral Movement through Tracking
Event Logs.
nxlog.conf (truncated)
1 # define Security Events
2 define SecurityEvents 4624, 4634, 4648, 4656, 4658, 4660, 4663, 4672, \
3 4673, 4688, 4689, 4698, 4720, 4768, 4769, 4946, \
4 5140, 5142, 5144, 5145, 5154, 5156, 5447, 8222
5
6 # define Sysmon Events
7 define SysmonEvents 1, 2, 5, 8, 9
8
9 # define Application Management event
10 define ApplicationMgmt 104
11
12 # define Windows Remote Management Events
13 define WRMEvents 80, 132, 143, 166, 81
14
15 # define Task Scheduler - Operational Events
16 define TaskSchedEvents 106, 129, 200, 201
17
18 # define Local Session Manager - Operational Events
19 define LocalSessionMgrEvents 21, 24
20
21 #define BitsClient Events
22 define BitsClientsEvents 60
23
24 <Input LateralMovementEvents>
25 Module im_msvistalog
26 TolerateQueryErrors TRUE
27 <QueryXML>
28 <QueryList>
29 [...]
Event descriptions in Event Log data may contain tabs and newlines, but these are not supported by some
formats like BSD Syslog. In this case, a regular expression can be used to remove them.
This input instance is configured to modify the $Message field (the event description) by replacing all tab
characters and newline sequences with spaces.
nxlog.conf
1 <Input in>
2 Module im_mseventlog
3 Exec $Message =~ s/(\t|\R)/ /g;
4 </Input>
893
NXLog User Guide Chapter 116. Windows Event Log
This example configuration removes tab characters and newline sequences from the $Message field,
converts the event record to BSD Syslog format, and forwards the event via UDP.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input eventlog>
6 Module im_msvistalog
7 Exec $Message =~ s/(\t|\R)/ /g; to_syslog_bsd();
8 </Input>
9
10 <Output udp>
11 Module om_udp
12 Host 10.10.1.1
13 Port 514
14 </Output>
NOTE The to_syslog_bsd() procedure will use only a subset of the Event Log fields.
Output Sample
<14>Jan 2 10:21:16 win7host Service_Control_Manager[448]: The Computer Browser service entered
the running state.↵
894
Chapter 116. Windows Event Log NXLog User Guide
This example configuration converts the event record to JSON format and forwards the event via TCP.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input eventlog>
6 Module im_msvistalog
7 Exec to_json();
8 </Input>
9
10 <Output tcp>
11 Module om_tcp
12 Host 192.168.10.1
13 Port 1514
14 </Output>
Output Sample
{
"EventTime": "2017-01-02 10:21:16",
"Hostname": "win7host",
"Keywords": -9187343239835812000,
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 7036,
"SourceName": "Service Control Manager",
"ProviderGuid": "{525908D1-A6D5-5695-8E2E-26921D2011F3}",
"Version": 0,
"Task": 0,
"OpcodeValue": 0,
"RecordNumber": 2629,
"ProcessID": 448,
"ThreadID": 2872,
"Channel": "System",
"Message": "The Computer Browser service entered the running state.",
"param1": "Computer Browser",
"param2": "running",
"EventReceivedTime": "2017-01-02 10:21:17",
"SourceModuleName": "eventlog",
"SourceModuleType": "im_msvistalog"
}
For compatibility with logging systems that require BSD Syslog, the JSON format can be used with a BSD Syslog
header.
895
NXLog User Guide Chapter 116. Windows Event Log
This example configuration converts the event record to JSON, adds a BSD Syslog header, and forwards the
event via UDP.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input eventlog>
10 Module im_msvistalog
11 Exec $Message = to_json(); to_syslog_bsd();
12 </Input>
13
14 <Output udp>
15 Module om_udp
16 Host 192.168.2.1
17 Port 514
18 </Output>
Output Sample
<14>Jan 2 10:21:16 win7host Service_Control_Manager[448]: {"EventTime":"2017-01-02
10:21:16","Hostname":"win7host","Keywords":-
9187343239835811840,"EventType":"INFO","SeverityValue":2,"Severity":"INFO","EventID":7036,"Sour
ceName":"Service Control Manager","ProviderGuid":"{525908D1-A6D5-5695-8E2E-
26921D2011F3}","Version":0,"Task":0,"OpcodeValue":0,"RecordNumber":2629,"ProcessID":448,"Thread
ID":2872,"Channel":"System","Message":"The Computer Browser service entered the running
state.","param1":"Computer Browser","param2":"running","EventReceivedTime":"2017-01-02
10:21:17","SourceModuleName":"eventlog","SourceModuleType":"im_msvistalog"}↵
896
Chapter 116. Windows Event Log NXLog User Guide
This example configuration removes tab characters and newline sequences from the $Message field,
converts the event record to the Snare over Syslog format, and forwards the event via UDP.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input eventlog>
6 Module im_msvistalog
7 Exec $Message =~ s/(\t|\R)/ /g; to_syslog_snare();
8 </Input>
9
10 <Output snare>
11 Module om_udp
12 Host 192.168.1.1
13 Port 514
14 </Output>
Output Sample
<14>Jan 2 10:21:16 win7host MSWinEventLog ⇥ 1 ⇥ System ⇥ 193 ⇥ Mon Jan 02 10:21:16 2017 ⇥
7036 ⇥ Service Control Manager ⇥ N/A ⇥ N/A ⇥ Information ⇥ win7host ⇥ N/A ⇥ ⇥ The Computer
Browser service entered the running state. ⇥ 2773↵
897
NXLog User Guide Chapter 116. Windows Event Log
This example configuration uses the im_python module to execute a script and formats the events to JSON.
The Python script uses the python-evtx module to read the events from the EVTX file.
nxlog.conf
1 <Extension xml>
2 Module xm_xml
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input evtx>
10 Module im_python
11 PythonCode /opt/nxlog/etc/process_evtx.py
12 <Exec>
13 parse_windows_eventlog_xml($Message);
14 delete($Message);
15 to_json();
16 </Exec>
17 </Input>
process_evtx.py
import Evtx.Evtx as evtx
import Evtx.Views as e_views
import nxlog
def read_data(module):
nxlog.log_debug('Starting Processing EVTX')
with evtx.Evtx('/tmp/security.evtx') as log:
for record in log.records():
event = module.logdata_new()
event.set_field('Message', record.xml())
event.post()
898
Chapter 116. Windows Event Log NXLog User Guide
Output Sample
{
"EventReceivedTime": "2020-11-19T18:47:06.548281+01:00",
"SourceModuleName": "evtx",
"SourceModuleType": "im_python",
"SourceName": "Microsoft-Windows-Security-Auditing",
"ProviderGuid": "{54849625-5478-4994-a5ba-3e3b0328c30d}",
"EventID": 5379,
"Version": 0,
"LevelValue": 0,
"TaskValue": 13824,
"OpcodeValue": 0,
"Keywords": "0x8020000000000000",
"EventTime": "2020-11-19T17:36:15.751457+01:00",
"RecordNumber": 342859,
"ActivityID": "{d9a2c36d-bc3e-0003-83c3-a2d93ebcd601}",
"ExecutionProcessID": 872,
"ExecutionThreadID": 956,
"Channel": "Security",
"Hostname": "PC1",
"SubjectUserSid": "S-1-5-21-774634756-2905300177-2392840219-1003",
"SubjectUserName": "John",
"SubjectDomainName": "PC1",
"SubjectLogonId": "0x00000000000ccd46",
"TargetName": "MicrosoftOffice*",
"Type": "0",
"CountOfCredentialsReturned": "1",
"ReadOperation": "%%8100",
"ReturnCode": "0",
"ProcessCreationTime": "2020-11-16 17:36:12.644609",
"ClientProcessId": "12088",
"EventType": "AUDIT_SUCCESS",
"SeverityValue": 2,
"Severity": "INFO"
}
Sometimes events from the Windows Event Log contain values which need to be resolved
NOTE using an external reference. Processing EVTX files using the python-evtx library may result
in some events containing unresolved values.
899
NXLog User Guide Chapter 117. Windows Firewall
Log Sample
#Software: Microsoft Windows Firewall↵
#Time Format: Local↵
#Fields: date time action protocol src-ip dst-ip src-port dst-port size tcpflags tcpsyn tcpack
tcpwin icmptype icmpcode info path↵
↵
2018-10-16 08:20:36 ALLOW UDP 127.0.0.1 127.0.0.1 54348 53 0 - - - - - - - SEND↵
2018-10-16 08:20:36 ALLOW UDP 127.0.0.1 127.0.0.1 54348 53 0 - - - - - - - RECEIVE↵
2018-10-16 08:20:36 ALLOW 250 127.0.0.1 127.0.0.1 - - 0 - - - - - - - SEND↵
There are several different actions that can be logged in the action field: DROP for dropping a connection, OPEN
for opening a connection, CLOSE for closing a connection, OPEN-INBOUND for an inbound session opened to the
local computer, and INFO-EVENTS-LOST for events processed by the Windows Firewall but which were not
recorded in the Security Log.
For information about configuring the Windows Firewall Security log, please refer to Configure the Windows
Defender Firewall with Advanced Security Log on Microsoft Docs.
This example configuration collects and parses firewall logs using the im_file and xm_w3c modules.
nxlog.conf
1 define EMPTY_EVENT_REGEX /(^$|^\s+$)/
2
3 <Extension w3c_parser>
4 Module xm_w3c
5 </Extension>
6
7 <Input pfirewall>
8 Module im_file
9 File 'C:\Windows\system32\LogFiles\Firewall\pfirewall.log'
10 InputType w3c_parser
11 Exec if $raw_event =~ %EMPTY_EVENT_REGEX% drop();
12 </Input>
900
Chapter 117. Windows Firewall NXLog User Guide
With auditpol.exe
Finally, the following command can be used to enable Windows Firewall audit logs.
After audit logging is enabled, audit events can be viewed in the Security event log or collected with NXLog. For a
full list of Windows Security Audit events, download the Windows security audit events spreadsheet from the
Microsoft Download Center.
Example 529. Collecting Windows Firewall and Advanced Security Events from the EventLog
This example collects Windows Firewall events from the EventLog using the im_msvistalog module.
1 <Input WinFirewallEventLog>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0">
6 <Select Path="Microsoft-Windows-Windows Firewall With Advanced
7 Security/ConnectionSecurity">*</Select>
8 <Select Path="Microsoft-Windows-Windows Firewall With Advanced
9 Security/ConnectionSecurityVerbose">*</Select>
10 <Select Path="Microsoft-Windows-Windows Firewall With Advanced
11 Security/Firewall">*</Select>
12 <Select Path="Microsoft-Windows-Windows Firewall With Advanced
13 Security/FirewallVerbose">*</Select>
14 <Select Path="Network Isolation Operational">*</Select>
15 </Query>
16 </QueryList>
17 </QueryXML>
18 </Input>
901
NXLog User Guide Chapter 117. Windows Firewall
Example 530. Collecting Windows Firewall and Advanced Security Traces from ETW
This configuration uses the im_etw module to collect Windows Firewall related traces from Event Tracing for
Windows.
nxlog.conf
1 <Input etw>
2 Module im_etw
3 Provider Microsoft-Windows-Firewall
4 </Input>
5
6 <Input etw2>
7 Module im_etw
8 Provider Microsoft-Windows-Windows Firewall With Advanced Security
9 </Input>
902
Chapter 118. Windows Group Policy NXLog User Guide
There are several ways Group Policy related logs can be acquired.
• Group Policy Operational logs and Security logs from Windows Event Log
• Event Tracing for Windows (ETW)
• File-based logs found in the file system
This topic covers the methods that can be used to collect these logs with NXLog.
The Group Policy Operational logs are displayed in the Operational object under the Applications and Services
> Microsoft > Windows > GroupPolicy directory in Event Viewer.
Group Policy stores some events in the Security channel of the Windows Event Log. These events are related to
the access, deletion, modification and creation of objects.
Example 531. Collecting Group Policy Logs from Windows Event Log
The following configuration uses the im_msvistalog module to collect Group Policy logs from the Security
channel. It includes a custom query that will filter for events based on specified EventIDs.
nxlog.conf
1 <Input in>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0" Path="Security">
6 <Select Path="Security">
7 *[System[(EventID=4663 or EventID=5136 or \
8 EventID=5137 or EventID=5141)]]
9 </Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 </Input>
The Microsoft-Windows-GroupPolicy provider supplies Group Policy related logs via an event tracing session
that can be collected via ETW. It gets the logs from the same source as Windows Event Log provides in the
previous example, however the im_etw module is capable of collecting ETW trace data then forwarding it without
saving the data to disk, which results in improved efficiency. Also, there are slight differences in the level of
verbosity, therefore it is worth considering both options and picking the one best suits your environment.
The following configuration uses the im_etw module to collect Group Policy logs from an ETW provider.
nxlog.conf
1 <Input in>
2 Module im_etw
3 Provider Microsoft-Windows-GroupPolicy
4 </Input>
Group Policy stores Group Policy Client Service (GPSVC) and Group Policy Management Console (GPMC) logs, in
903
NXLog User Guide Chapter 118. Windows Group Policy
The following configuration uses the im_file module to collect GPMC and GPSVC logs from the above
mentioned %windir%\debug\usermode directory. Since these logs are encoded in UTF-16LE, they need to
be converted into UTF-8 using the xm_charconv extension module.
nxlog.conf (truncated)
1 <Extension _charconv>
2 Module xm_charconv
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 define GroupPolicy /(?x)\w+\((?<PID>[\w\d]{3,4}). \
10 (?<TID>[\w\d]{3,4})\)\s+ \
11 (?<time>[\d\:]+)\s+ \
12 (?<Message>.*)/
13
14 <Input in>
15 Module im_file
16 File 'C:\Windows\debug\usermode\gpsvc.log'
17 File 'C:\Windows\debug\usermode\gpmc.log'
18 <Exec>
19 #Query the current filename
20 if file_name() =~ /^.*\\(.*)$/ $FileName = $1;
21
22 # Convert character encoding from UTF-16LE to UTF-8
23 $raw_event = convert($raw_event, 'UTF-16LE', 'UTF-8');
24
25 #Parse $raw_event
26 if $raw_event =~ %GroupPolicy%
27
28 #Query year, month and day details from the current system
29 [...]
904
Chapter 119. Windows Management Instrumentation (WMI) NXLog User Guide
WMI event logging uses Event Tracing for Windows (ETW). These logs can be collected via Windows EventLog or
ETW. For Windows versions prior to Windows Vista and Windows Server 2008, it is also possible to read from
WMI log files.
• 5857: Operation_StartedOperational
• 5858: Operation_ClientFailure
• 5859: Operation_EssStarted
• 5860: Operation_TemporaryEssStarted
• 5861: Operation_ESStoConsumerBinding
905
NXLog User Guide Chapter 119. Windows Management Instrumentation (WMI)
The following configuration will collect and parse these events from Microsoft-Windows-WMI-
Activity/Operational using the im_msvistalog module. The xm_xml module is used to further parse the
XML data in the $UserData field.
nxlog.conf
1 <Extension _xml>
2 Module xm_xml
3 </Extension>
4
5 <Input in>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id="0">
10 <Select Path="Microsoft-Windows-WMI-Activity/Operational">*</Select>
11 </Query>
12 </QueryList>
13 </QueryXML>
14 Exec if $UserData parse_xml($UserData);
15 </Input>
906
Chapter 119. Windows Management Instrumentation (WMI) NXLog User Guide
Output Sample
{
"EventTime": "2019-02-24T21:19:36.603548+01:00",
"Hostname": "Host.DOMAIN.local",
"Keywords": "4611686018427387904",
"EventType": "ERROR",
"SeverityValue": 4,
"Severity": "ERROR",
"EventID": 5858,
"SourceName": "Microsoft-Windows-WMI-Activity",
"ProviderGuid": "{1418EF04-B0B4-4623-BF7E-D74AB47BBDAA}",
"Version": 0,
"TaskValue": 0,
"OpcodeValue": 0,
"RecordNumber": 7314,
"ActivityID": "{3459A8FD-CC70-0000-47C6-593470CCD401}",
"ExecutionProcessID": 1020,
"ExecutionThreadID": 8840,
"Channel": "Microsoft-Windows-WMI-Activity/Operational",
"Domain": "NT AUTHORITY",
"AccountName": "SYSTEM",
"UserID": "S-1-5-18",
"AccountType": "User",
"Message": "Id = {3459A8FD-CC70-0000-47C6-593470CCD401}; ClientMachine = HOST; User = NT
AUTHORITY\\SYSTEM; ClientProcessId = 3640; Component = Unknown; Operation = Start
IWbemServices::ExecQuery - root\\cimv2 : Select * from Win32_Service Where Name = 'MpsSvc';
ResultCode = 0x80041032; PossibleCause = Unknown",
"Opcode": "Info",
"UserData": "<Operation_ClientFailure
xmlns='http://manifests.microsoft.com/win/2006/windows/WMI'><Id>{3459A8FD-CC70-0000-47C6-
593470CCD401}</Id><ClientMachine>HOST</ClientMachine><User>NT AUTHORITY
\\SYSTEM</User><ClientProcessId>3640</ClientProcessId><Component>Unknown</Component><Operation>
Start IWbemServices::ExecQuery - root\\cimv2 : Select * from Win32_Service Where Name =
'MpsSvc'</Operation><ResultCode>0x80041032</ResultCode><PossibleCause>Unknown</PossibleCause></
Operation_ClientFailure>",
"EventReceivedTime": "2019-02-24T21:19:38.104568+01:00",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog",
"Operation_ClientFailure.Id": "{3459A8FD-CC70-0000-47C6-593470CCD401}",
"Operation_ClientFailure.ClientMachine": "HOST",
"Operation_ClientFailure.User": "NT AUTHORITY\\SYSTEM",
"Operation_ClientFailure.ClientProcessId": "3640",
"Operation_ClientFailure.Component": "Unknown",
"Operation_ClientFailure.Operation": "Start IWbemServices::ExecQuery - root\\cimv2 : Select *
from Win32_Service Where Name = 'MpsSvc'",
"Operation_ClientFailure.ResultCode": "0x80041032",
"Operation_ClientFailure.PossibleCause": "Unknown"
}
907
NXLog User Guide Chapter 119. Windows Management Instrumentation (WMI)
The following configuration uses the im_etw module to collect ETW logs from the Microsoft-Windows-
WMI-Activity provider.
nxlog.conf
1 <Input etw_in>
2 Module im_etw
3 Provider Microsoft-Windows-WMI-Activity
4 </Input>
Output Sample
{
"SourceName": "Microsoft-Windows-WMI-Activity",
"ProviderGuid": "{1418EF04-B0B4-4623-BF7E-D74AB47BBDAA}",
"EventID": 100,
"Version": 0,
"Channel": 18,
"OpcodeValue": 0,
"TaskValue": 0,
"Keywords": "2305843009213693952",
"EventTime": "2019-03-04T19:48:48.842576+01:00",
"ExecutionProcessID": 1500,
"ExecutionThreadID": 8104,
"ActivityID": "{AF4CFCDC-66C1-4A9A-B7D7-13ECD1AAE01A}",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Domain": "NT AUTHORITY",
"AccountName": "SYSTEM",
"UserID": "S-1-5-18",
"AccountType": "User",
"ComponentName": "MI_Client",
"MessageDetail": "Operation Enumerate Instances: session=0000008F1C752638,
operation=0000008F1D03DCF0, internal-operation=0000008F1D63ED90, namespace=root\\Microsoft
\\Windows\\Storage\\SM, classname=MSFT_SMStorageVolume",
"FileName": "admin\\wmi\\wmiv2\\client\\api\\operation.c:2008",
"EventReceivedTime": "2019-03-04T19:48:49.888767+01:00",
"SourceModuleName": "etw_in",
"SourceModuleType": "im_etw"
}
908
Chapter 119. Windows Management Instrumentation (WMI) NXLog User Guide
This configuration collects and parses events from the three WMI log files.
nxlog.conf
1 <Input in>
2 Module im_file
3 File 'C:\WINDOWS\system32\wbem\Logs\wmiprov.log'
4 File 'C:\WINDOWS\system32\wbem\Logs\ntevt.log'
5 File 'C:\WINDOWS\system32\wbem\Logs\dsprovider.log'
6 <Exec>
7 file_name() =~ /(?<Filename>[^\\]+)$/;
8 if $raw_event =~ /^\((?<EventTime>.+)\.\d{7}\) : (?<Message>.+)$/
9 $EventTime = strptime($EventTime, "%a %b %d %H:%M:%S %Y");
10 </Exec>
11 </Input>
909
NXLog User Guide Chapter 120. Windows PowerShell
By default, Windows services run under the NT AUTHORITY\SYSTEM user account. Depending on the purpose of
a PowerShell script, its operations may require additional permissions. In this case, either change the NXLog
service account (see Running Under a Custom Account on Windows) or add permissions as required to the
SYSTEM account.
910
Chapter 120. Windows PowerShell NXLog User Guide
This configuration uses the im_exec module to execute powershell.exe with the specified arguments,
including the path to the script. The script creates an event and writes it to standard output in JSON format.
The xm_json parse_json() procedure is used to parse the JSON so all the fields are available in the event
record.
The script shows header examples for running the script under a different architecture than the NXLog
agent. Also, a simple file-based position cache is included to demonstrate how a script can resume from the
previous position when the agent or module instance is stopped and started again.
Because the end value of one poll and the start value of the next poll are equal, an actual source read
should not include exact matches for both start and end values (to prevent reading duplicate events). For
example, either the start value should be excluded ($start < $event ≤ $end) or the end value ($start ≤
$event < $end).
This example requires PowerShell 3 or later to transport structured data in JSON format. If
NOTE structured data is required with an earlier version of PowerShell, CSV format could be used
instead; see the next example.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 envvar systemroot
6 <Input powershell>
7 Module im_exec
8 Command "%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe"
9 # Use "-Version" to select a specific PowerShell version.
10 #Arg "-Version"
11 #Arg "3"
12 # Bypass the system execution policy for this session only.
13 Arg "-ExecutionPolicy"
14 Arg "Bypass"
15 # Skip loading the local PowerShell profile.
16 Arg "-NoProfile"
17 # This specifies the path to the PowerShell script.
18 Arg "-File"
19 Arg "C:\ps_input.ps1"
20 # Any additional arguments are passed to the PowerShell script.
21 Arg "arg1"
22 <Exec>
23 # Parse JSON
24 parse_json();
25
26 # Convert $EventTime field to datetime
27 $EventTime = parsedate($EventTime);
28 </Exec>
29 </Input>
911
NXLog User Guide Chapter 120. Windows PowerShell
ps_input.ps1 (truncated)
#Requires -Version 3
# Use this if you need 64-bit PowerShell (has no effect on 32-bit systems).
#if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
# Write-Debug "Running 64-bit PowerShell."
# &"$env:SYSTEMROOT\SysNative\WindowsPowerShell\v1.0\powershell.exe" `
# -NonInteractive -NoProfile -ExecutionPolicy Bypass `
# -File "$($myInvocation.InvocationName)" $args
# exit $LASTEXITCODE
#}
PowerShell 2 does not support JSON. Instead, events can be formatted as CSV and parsed with an xm_csv
module instance.
912
Chapter 120. Windows PowerShell NXLog User Guide
In this example, the PowerShell script generates output strings in CSV format. The xm_csv parse_csv()
procedure is used to parse the CSV strings into fields in the event record. Note that the fields must be
provided, sorted by name, in the xm_csv Fields directive (and corresponding types should be provided via
the FieldTypes directive).
For best results with structured data, use JSON with PowerShell 3 or later (see the
WARNING
previous example).
nxlog.conf
1 <Extension csv_parser>
2 Module xm_csv
3 Fields Arguments, EventTime, Message
4 FieldTypes string, datetime, string
5 </Extension>
6
7 envvar systemroot
8 <Input powershell>
9 Module im_exec
10 Command "%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe"
11 Arg "-Version"
12 Arg "2"
13 Arg "-ExecutionPolicy"
14 Arg "Bypass"
15 Arg "-NoProfile"
16 Arg "-File"
17 Arg "C:\ps2_input.ps1"
18 Exec csv_parser->parse_csv();
19 </Input>
ps2_input.ps1 (truncated)
#Requires -Version 2
$count = 0
while($true) {
$count += 1
$now = [System.DateTime]::UtcNow
913
NXLog User Guide Chapter 120. Windows PowerShell
This configuration uses om_exec to execute powershell.exe with the specified arguments, including the
path to the script. The script reads events on standard input.
This configuration requires PowerShell 3 or later for its JSON support and to correctly read
NOTE
lines from standard input.
See the Using PowerShell to Generate Logs example above for more details about
TIP powershell.exe arguments and PowerShell code for explicitly specifying a 32-bit or 64-bit
environment.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 envvar systemroot
6 <Output powershell>
7 Module om_exec
8 Command "%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe"
9 Arg "-ExecutionPolicy"
10 Arg "Bypass"
11 Arg "-NoProfile"
12 Arg "-File"
13 Arg "C:\ps_output.ps1"
14 Exec to_json();
15 </Output>
ps_output.ps1
#Requires -Version 3
while($line = [Console]::In.ReadLine()) {
# Convert from JSON
$record = $line | ConvertFrom-Json
Because include_stdout does not support arguments, it is simplest to use a batch/PowerShell polyglot script for
this purpose. For another example, see Automatic retrieval of IIS site log locations.
The Command Prompt may print '@' is not recognized if a Unicode byte order mark
TIP (BOM) is included in the batch file. To fix this, use Notepad and select the ANSI encoding when
saving the file.
914
Chapter 120. Windows PowerShell NXLog User Guide
This configuration uses PowerShell code to generate the File directive for the Input instance.
nxlog.conf
1 <Input in>
2 Module im_file
3 include_stdout C:\include.cmd
4 </Input>
include.cmd (truncated)
@( Set "_= (
REM " ) <#
)
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
set powershell=powershell.exe
REM Use this if you need 64-bit PowerShell (has no effect on 32-bit systems).
REM if defined PROCESSOR_ARCHITEW6432 (
REM set powershell=%SystemRoot%\SysNative\WindowsPowerShell\v1.0\powershell.exe
REM )
In addition to the sections below, see Securing PowerShell in the Enterprise, Greater Visibility Through
PowerShell Logging, and PowerShell ♥ the Blue Team. Also see the Command line process auditing article on
Microsoft Docs, the Windows Command Line Auditing and Sysmon chapters, which can be used to generate
events for command line process creation (but not for commands executed through the PowerShell engine).
Module logging can be enabled by setting the LogPipelineExecutionDetails property of a module to True. Or this
property can be enabled for selected modules through Group Policy as follows.
915
NXLog User Guide Chapter 120. Windows PowerShell
3. Select Enabled. Then click the [Show…] button and enter the modules for which to enable logging. Use an
asterisk (*) to enable logging for all modules.
916
Chapter 120. Windows PowerShell NXLog User Guide
This configuration collects all events with ID 4103 from the Windows PowerShell Operational channel. First,
the key-value pairs from the ContextInfo field are parsed to remove the \n and \r\n characters where
required, after that, the ContextInfo_ prefix is added to enhance visibility. In addition, the original
Message and ContextInfo fields are removed with their corresponding content as they are available
elsewhere in the output. Finally, the logs are converted to JSON.
nxlog.conf
1 <Extension kvp>
2 Module xm_kvp
3 KVPDelimiter ,
4 KVDelimiter =
5 </Extension>
6
7 <Extension json>
8 Module xm_json
9 </Extension>
10
11 <Input in>
12 Module im_msvistalog
13 <QueryXML>
14 <QueryList>
15 <Query Id="0" Path="Microsoft-Windows-PowerShell/Operational">
16 <Select Path="Microsoft-Windows-PowerShell/Operational">
17 *[System[EventID=4103]]</Select>
18 </Query>
19 </QueryList>
20 </QueryXML>
21 <Exec>
22 if defined($ContextInfo)
23 {
24 $ContextInfo = replace($ContextInfo, "\r\n", ",");
25 $ContextInfo = replace($ContextInfo, "\n", ",");
26 $ContextInfo = replace($ContextInfo, " ", "");
27 kvp->parse_kvp($ContextInfo, "ContextInfo_");
28 delete($ContextInfo);
29 delete($Message);
30 }
31 json->to_json();
32 </Exec>
33 </Input>
917
NXLog User Guide Chapter 120. Windows PowerShell
Output Sample
{
"EventTime": "2020-01-29T05: 30: 45.727799-08: 00",
"Hostname": "NXLog-Server",
"Keywords": "0",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 4103,
"SourceName": "Microsoft-Windows-PowerShell",
"ProviderGuid": "{A0C1853B-5C40-4B15-8766-3CF1C58F985A}",
"Version": 1,
"TaskValue": 106,
"OpcodeValue": 20,
"RecordNumber": 170,
"ActivityID": "{9C1FE60B-D6F2-0000-3316-209CF2D6D501}",
"ExecutionProcessID": 3648,
"ExecutionThreadID": 1060,
"Channel": "Microsoft-Windows-PowerShell/Operational",
"Domain": "NXLog-Server",
"AccountName": "Administrator",
"UserID": "S-1-5-21-2463765617-934790487-2583750676-500",
"AccountType": "User",
"Category": "Executing Pipeline",
"Opcode": "To be used when operation is just executing a method",
"Payload": "Update-Help has completed successfully.",
"EventReceivedTime": "2020-01-29T05: 30: 47.161585-08: 00",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog",
"ContextInfo_Severity": "Informational",
"ContextInfo_Host Name": "ConsoleHost",
"ContextInfo_Host Version": "5.1.17763.592",
"ContextInfo_Host ID": "67d049eb-f3d6-4718-8cd2-b9dae30c4c7b",
"ContextInfo_Host Application": "C: \\Windows\\System32\\WindowsPowerShell\\v1.0
\\powershell.exe",
"ContextInfo_Engine Version": "5.1.17763.592",
"ContextInfo_Runspace ID": "3145a9e1-18e3-4fa1-8700-fc78c783684b",
"ContextInfo_Pipeline ID": 6,
"ContextInfo_Command Name": "Update-Help",
"ContextInfo_Command Type": "Cmdlet",
"ContextInfo_Script Name": null,
"ContextInfo_Command Path": null,
"ContextInfo_Sequence Number": 79,
"ContextInfo_User": "NXLog-Server\\Administrator",
"ContextInfo_Connected User": null,
"ContextInfo_Shell ID": "Microsoft.PowerShell"
}
918
Chapter 120. Windows PowerShell NXLog User Guide
3. Select Enabled. Optionally, check the Log script block invocation start/stop events option (this will
generate a high volume of event logs).
919
NXLog User Guide Chapter 120. Windows PowerShell
The following configuration collects events with IDs 4104, 4105, and 4106 from the Windows PowerShell
Operational channel. Verbose level events are excluded.
nxlog.conf
1 <Input script_block_logging>
2 Module im_msvistalog
3 <QueryXML>
4 <QueryList>
5 <Query Id="0" Path="Microsoft-Windows-PowerShell/Operational">
6 <Select Path="Microsoft-Windows-PowerShell/Operational">
7 *[System[(Level=0 or Level=1 or Level=2 or Level=3 or Level=4)
8 and ((EventID >= 4104 and EventID <= 4106))]]
9 </Select>
10 </Query>
11 </QueryList>
12 </QueryXML>
13 </Input>
120.2.3. Transcription
PowerShell provides "over-the-shoulder" transcription of PowerShell sessions with the Start-Transcript cmdlet.
With PowerShell 5, system-wide transcription can be enabled via Group Policy; this is equivalent to calling the
Start-Transcript cmdlet on each PowerShell session. Transcriptions are written to the current user’s Documents
directory unless a system-level output directory is set in the policy settings.
920
Chapter 120. Windows PowerShell NXLog User Guide
921
NXLog User Guide Chapter 120. Windows PowerShell
This configuration reads and parses transcript files written to the TRANSCRIPTS_DIR directory (which
should be set appropriately). Headers, footers, and commands are parsed as separate events. $File and
$EventTime fields are set for each event (invocation headers must be enabled for command timestamps).
$Command and $Output fields are added for command events. Fields from the header entries are parsed
with xm_kvp and added to the event record. Finally, the logs are converted to JSON format and forwarded
via TCP.
The HeaderLine below must be changed if invocation headers are not enabled. See the
NOTE
comment in the configuration.
nxlog.conf (truncated)
1 define TRANSCRIPTS_DIR C:\powershell
2
3 <Extension transcript_parser>
4 Module xm_multiline
5 # Use this if invocation headers are ON (recommended)
6 HeaderLine /^\*{22}$/
7 # Use this if invocation headers are OFF (not recommended)
8 #HeaderLine /^(\*{22}$|PS[^>]*>)/
9 <Exec>
10 $raw_event =~ s/^\xEF\xBB\xBF//;
11 if get_var('include_next_record') and $raw_event =~ /^\*{22}$/
12 {
13 set_var('include_next_record', FALSE);
14 $raw_event =~ s/^\*//;
15 }
16 else if $raw_event =~ /^Command start time: \d{14}$/
17 set_var('include_next_record', TRUE);
18 </Exec>
19 </Extension>
20
21 <Extension transcript_header_parser>
22 Module xm_kvp
23 KVPDelimiter \n
24 </Extension>
25
26 <Input transcription>
27 Module im_file
28 File '%TRANSCRIPTS_DIR%\\*PowerShell_transcript.*'
29 [...]
The following output shows the first two events of the log sample above.
922
Chapter 120. Windows PowerShell NXLog User Guide
Output Sample
{
"EventReceivedTime": "2017-10-30 22:32:49",
"SourceModuleName": "transcription",
"SourceModuleType": "im_file",
"File": "C:\\powershell\\\\20171030\\PowerShell_transcript.WIN-
FT17VBNL4B2.LcxuCZbr.20171030223248.txt",
"Message": "Windows PowerShell transcript start\r\nStart time: 20171030223248\r\nUsername:
WIN-FT17VBNL4B2\\Administrator\r\nRunAs User: WIN-FT17VBNL4B2\\Administrator\r\nMachine: WIN-
FT17VBNL4B2 (Microsoft Windows NT 10.0.14393.0)\r\nHost Application: C:\\Windows\\system32
\\WindowsPowerShell\\v1.0\\PowerShell.exe\r\nProcess ID: 4268\r\nPSVersion: 5.1.14393.1770
\r\nPSEdition: Desktop\r\nPSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.1770
\r\nBuildVersion: 10.0.14393.1770\r\nCLRVersion: 4.0.30319.42000\r\nWSManStackVersion: 3.0
\r\nPSRemotingProtocolVersion: 2.3\r\nSerializationVersion: 1.1.0.1",
"Start time": "20171030223248",
"Username": "WIN-FT17VBNL4B2\\Administrator",
"RunAs User": "WIN-FT17VBNL4B2\\Administrator",
"Machine": "WIN-FT17VBNL4B2 (Microsoft Windows NT 10.0.14393.0)",
"Host Application": "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe",
"Process ID": "4268",
"PSVersion": "5.1.14393.1770",
"PSEdition": "Desktop",
"PSCompatibleVersions": "1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.1770",
"BuildVersion": "10.0.14393.1770",
"CLRVersion": "4.0.30319.42000",
"WSManStackVersion": "3.0",
"PSRemotingProtocolVersion": "2.3",
"SerializationVersion": "1.1.0.1",
"EventTime": "2017-10-30 22:32:48"
}
{
"EventReceivedTime": "2017-10-30 22:32:56",
"SourceModuleName": "transcription",
"SourceModuleType": "im_file",
"File": "C:\\powershell\\\\20171030\\PowerShell_transcript.WIN-
FT17VBNL4B2.LcxuCZbr.20171030223248.txt",
"Command": "echo test",
"EventTime": "2017-10-30 22:32:55",
"Output": "test",
"Message": "Command start time: 20171030223255\r\n**********************\r\nPS C:\\Users
\\Administrator> echo test\r\ntest"
}
923
NXLog User Guide Chapter 121. Microsoft Windows Update
The event logs related to Windows Update are accessible in two ways depending on the version of your
operating system:
• Via Event Tracing for Windows (ETW), for Windows 10, Windows Server 2016 and Windows Server 2019.
• Via the file system, in the the earlier versions of Windows.
The following configuration collects Windows Update logs using the im_etw module. The collected logs are
then converted to JSON using the xm_json extension module.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input in_etw>
6 Module im_etw
7 Provider Microsoft-Windows-WindowsUpdateClient
8 Exec to_json();
9 </Input>
Output Sample
{
"SourceName": "Microsoft-Windows-WindowsUpdateClient",
"ProviderGuid": "{945A8954-C147-4ACD-923F-40C45405A658}",
"EventID": 38,
"Version": 0,
"Channel": 16,
"OpcodeValue": 17,
"TaskValue": 1,
"Keywords": "4611686018427388544",
"EventTime": "2019-06-06T15:08:01.098200+02:00",
"ExecutionProcessID": 820,
"ExecutionThreadID": 2440,
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Domain": "NT AUTHORITY",
"AccountName": "SYSTEM",
"UserID": "S-1-5-18",
"AccountType": "User",
"EventReceivedTime": "2019-06-06T15:08:01.847001+02:00",
"SourceModuleName": "in_etw",
"SourceModuleType": "im_etw"
}
924
Chapter 121. Microsoft Windows Update NXLog User Guide
Although this log file is deprecated, it can still be generated as described in the Generating
NOTE
WindowsUpdate.log Microsoft article.
Example 545. Collecting Windows Update Logs from Microsoft Windows Server 2008 and 2012
The following configuration collects and parses logs using the im_file module. The parser section is based
on the description of the Windows Update log files section of the Microsoft documentation.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 define windowsupdate /(?x)(?<Date>([\d\-]+))\s+ \
6 (?<Time>([\d\:]+))\s+ \
7 (?<PID>\d{3,5})\s+ \
8 (?<TID>([\d\w]+))\s+ \
9 (?<Category>(\w+))\s+ \
10 (?<Message>(.*)) /
11
12 <Input windowsupdate>
13 Module im_file
14 File 'C:\Windows\WindowsUpdate.log'
15 <Exec>
16 $raw_event =~ %windowsupdate%;
17 $EventTime = ($Date + ' ' + $Time);
18 to_json();
19 </Exec>
20 </Input>
Input Sample
2019-06-06 18:22:14:390 1012 1080 DnldMgr PurgeContentForPatchUpdates removing unused
directory "b7c04a03c3650087ddea456a018dba62"
Output Sample
{
"EventReceivedTime": "2019-06-06T18:22:14.843037+02:00",
"SourceModuleName": "windowsupdate",
"SourceModuleType": "im_file",
"Category": "DnldMgr",
"Date": "2019-06-06",
"Message": "PurgeContentForPatchUpdates removing unused directory
\"b7c04a03c3650087ddea456a018dba62\"",
"PID": "1012",
"TID": "1080",
"Time": "18:22:14:390",
"EventTime": "2019-06-06 18:22:14:390"
}
925
NXLog User Guide Chapter 122. Windows USB Auditing
This section discusses the possibilities of collecting USB related events in a Microsoft Windows environment
using NXLog.
There are four ways USB activity related events can be tracked down.
They are generated every time when a device is plugged in. Tracking these USB related events are useful for
Audit purposes.
They can be used to monitor object manipulation, such as creation, deletion as well as other changes. This can
be useful for monitoring for possible data leaks.
These two events can be turned on in the Local Security Policy or by the auditpol tool with the command below
in Windows PowerShell.
926
Chapter 122. Windows USB Auditing NXLog User Guide
The following command could be used to check the status of subcategories if necessary.
Event 4663 is the most useful. It is the event that tells what exactly happened on the object. What has been
accessed, what process did it and what kind of operation it was.
DriverFrameworks-UserMode (not Connection 1003, 1004, 2000, 2001, 2003, 2004, 2005, 2006, 2010,
enabled by default) 2100, 2101, 2105, 2016
Ejection 1006, 1008, 2100, 2101, 2102, 2105, 2106, 2900, 2901
In Event Viewer (eventvwr) under Applications and Services Logs › Microsoft › Windows › DriverFrameworks-
UserMode\Operational, right-click on Operational and select Enable Log.
1. Enable a Remote Administration exception on the firewall of the client computers via a GPO. The following
needs to be enabled. [Computer Configuration\Administrative Templates\Network\Network
Connections\Windows Firewall\Domain Profile\Windows Firewall: Allow inbound remote
administration exception]
2. Prepare a text file for the client computer names. For example, c:\computers.txt.
927
NXLog User Guide Chapter 122. Windows USB Auditing
928
Chapter 122. Windows USB Auditing NXLog User Guide
This configuration uses the im_msvistalog module to collect USB events. EventIDs that are useful from the
audit perspective are listed in the configuration define lines.
nxlog.conf (truncated)
1 <Extension _xml>
2 Module xm_xml
3 </Extension>
4
5 # StorSvc Diagnostic
6 define ID1 1001
7 # PnP detailed tracking
8 define ID2 6416
9 # Partition Diagnostic
10 define ID3 1006
11 # NTFS
12 define ID4 142
13 # DriverFw preconnection
14 define ID5 1003
15 # DriverFw connection-related
16 define ID6 2003
17 # DriverFw removal-related
18 define ID7 1008
19 # System: DriverFramework-Usermode
20 define ID8 10000
21 # System: UserPNP
22 define ID9 20001
23 #Object Access Audit
24 define ID10 4656
25
26 <Input in>
27 Module im_msvistalog
28 # For Windows 2003 and earlier, use the im_mseventlog module.
29 [...]
929
NXLog User Guide Chapter 122. Windows USB Auditing
Output Sample
{
"EventTime": "2019-10-19T20:41:06.700337+02:00",
"Hostname": "Host",
"Keywords": "9223372036854775808",
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"EventID": 1008,
"SourceName": "Microsoft-Windows-DriverFrameworks-UserMode",
"ProviderGuid": "{2E35AAEB-857F-4BEB-A418-2E6C0E54D988}",
"Version": 1,
"TaskValue": 18,
"OpcodeValue": 2,
"RecordNumber": 42756,
"ExecutionProcessID": 908,
"ExecutionThreadID": 504,
"Channel": "Microsoft-Windows-DriverFrameworks-UserMode/Operational",
"Domain": "NT AUTHORITY",
"AccountName": "SYSTEM",
"UserID": "S-1-5-18",
"AccountType": "User",
"Message": "The host process ({1208e11e-4339-4c06-86bb-7430fd254ee6}) has been shutdown.",
"Category": "Shutdown of a driver host process.",
"Opcode": "Stop",
"UserData": "<UMDFDriverManagerHostShutdown
xmlns='http://www.microsoft.com/DriverFrameworks/UserMode/Event'><LifetimeId>{1208e11e-4339-
4c06-86bb-
7430fd254ee6}</LifetimeId><TerminateStatus>0</TerminateStatus><ExitCode>0</ExitCode></UMDFDrive
rManagerHostShutdown>",
"EventReceivedTime": "2019-10-19T20:41:08.115696+02:00",
"SourceModuleName": "in",
"SourceModuleType": "im_msvistalog",
"UMDFDriverManagerHostShutdown.LifetimeId": "{1208e11e-4339-4c06-86bb-7430fd254ee6}",
"UMDFDriverManagerHostShutdown.TerminateStatus": "0",
"UMDFDriverManagerHostShutdown.ExitCode": "0"
}
Provider Details
Provider Details
930
Chapter 122. Windows USB Auditing NXLog User Guide
Provider Details
Provider Details
Microsoft-Windows-USB-CCID Monitors Smart Card readers using USB to connect to the computer
Microsoft-Windows-Smartcard-Trigger Triggers a log when inserting and removing a USB smart card reader
This configuration uses the im_etw module to collect logs when a USB Smart Card reader is inserted.
nxlog.conf
1 <Input etw>
2 Module im_etw
3 Provider Microsoft-Windows-Smartcard-Trigger
4 </Input>
Output Sample
{
"SourceName": "Microsoft-Windows-Smartcard-Trigger",
"ProviderGuid": "{AEDD909F-41C6-401A-9E41-DFC33006AF5D}",
"EventID": 1000,
"Version": 0,
"ChannelID": 0,
"OpcodeValue": 0,
"TaskValue": 0,
"Keywords": "0",
"EventTime": "2019-12-05T14:12:11.453805+01:00",
"ExecutionProcessID": 13180,
"ExecutionThreadID": 7608,
"EventType": "INFO",
"SeverityValue": 2,
"Severity": "INFO",
"Domain": "NT AUTHORITY",
"AccountName": "LOCAL SERVICE",
"UserID": "S-1-5-19",
"AccountType": "Well Known Group",
"Flags": "EXTENDED_INFO|IS_64_BIT_HEADER|PROCESSOR_INDEX (577)",
"ScDeviceEnumGuid": "{5a236687-d307-44e2-9241-e1c6c27ceb28}",
"EventReceivedTime": "2019-12-05T14:12:13.457624+01:00",
"SourceModuleName": "etw",
"SourceModuleType": "im_etw"
}
This information is stored in the registry keys under the following three registry paths.
• "HKLM\SYSTEM\CurrentControlSet\Enum\USB\"
931
NXLog User Guide Chapter 122. Windows USB Auditing
• "HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR\"
• "HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\"
The first two stores information about the plugged in USB devices. The third on stores additional information as
USB drives are recognized as disks and mounted as a drive volume in the system. For more information, see the
USB Device Registry Entries documentation from Microsoft.
TIP These events could be correlated based on the serial numbers of the USB devices.
This configuration uses the im_regmon module to collect USB related events from the Windows Registry. It
scans the registry every 60 second.
nxlog.conf
1 <Input in>
2 Module im_regmon
3 RegValue 'HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\*'
4 RegValue 'HKLM\SYSTEM\CurrentControlSet\Enum\USB\*'
5 RegValue 'HKLM\SYSTEM\CurrentControlSet\Enum\USBSTOR\*'
6 Recursive TRUE
7 ScanInterval 60
8 </Input>
Output Sample
{
"EventTime": "2019-10-20T11:07:56.473658+02:00",
"Hostname": "Host",
"EventType": "CHANGE",
"RegistryValueName": "HKLM\\SYSTEM\\CurrentControlSet\\Enum\\USBSTOR
\\Disk&Ven_Kingston&Prod_DataTraveler_3.0&Rev_\\60A44C413A8CF320B9110053&0\\Properties\\{83da63
26-97a6-4088-9453-a1923f573b29}\\0066\\",
"PrevValueSize": 8,
"ValueSize": 8,
"DigestName": "SHA1",
"PrevDigest": "a477f34abec7da133ad5ff2dcf67b3b7e089d2d6",
"Digest": "e47f5d5668fa31237f198a2e4cb9bc78003f3cc8",
"Severity": "WARNING",
"SeverityValue": 3,
"EventReceivedTime": "2019-10-20T11:07:56.473658+02:00",
"SourceModuleName": "in",
"SourceModuleType": "im_regmon"
}
The file is located in the C:\Windows\INF directory. NXLog can read, parse and forward the logs contained in this
file.
932
Chapter 122. Windows USB Auditing NXLog User Guide
This configuration uses the im_file module to read the events from the SetupAPI.dev.log file.
nxlog.conf
1 <Input in>
2 Module im_file
3 File 'C:\Windows\INF\SetupAPI.dev.log'
4 </Input>
933
NXLog User Guide Chapter 123. Zeek (formerly Bro) Network Security Monitor
File Description
Zeek produces human-readable logs in a format similar to W3C. Each log file uses a different set of fields.
934
Chapter 123. Zeek (formerly Bro) Network Security Monitor NXLog User Guide
dns.log Sample
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path dns
#open 2020-05-27-22-00-01
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p proto
trans_id rtt query qclass qclass_name qtype qtype_name rcode rcode_name
AA TC RD RA Z answers TTLs rejected
#types time string addr port addr port enum count interval string
count string count string count string bool bool bool bool count
vector[string] vector[interval] bool
1590634800.248362 C1ggH7liCnwAfLjw9 192.168.1.7 53743 192.168.1.1 53 udp
18876 - 250.255.255.239.in-addr.arpa 1 C_INTERNET 12 PTR 3
NXDOMAIN F F T F 0 - - F
1590634800.259227 C1ggH7liCnwAfLjw9 192.168.1.7 53743 192.168.1.1 53 udp
18876 - 250.255.255.239.in-addr.arpa 1 C_INTERNET 12 PTR 3
NXDOMAIN F F T F 0 - - F
1590634800.274483 CTQxOg2sSOuUO5AZy8 192.168.1.7 47182 192.168.1.1 53 udp
48442 - 7.1.168.192.in-addr.arpa 1 C_INTERNET 12 PTR 3
NXDOMAIN F F T F 0 - - F
For more information about Zeek logging, see the Zeek Manual.
NOTE The following configurations have been tested with Zeek version 3.0.6 LTS.
935
NXLog User Guide Chapter 123. Zeek (formerly Bro) Network Security Monitor
This configuration reads Zeek logs from a directory, parses with xm_w3c, and writes out events in JSON
format.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension w3c_parser>
6 Module xm_w3c
7 </Extension>
8
9 <Input zeek>
10 Module im_file
11 File '/opt/zeek/logs/current/*.log'
12 InputType w3c_parser
13 </Input>
14
15 <Output zeek_json>
16 Module om_file
17 File '/tmp/zeek_logs.json'
18 Exec to_json();
19 </Output>
The following output from this configuration represents a sample event logged by Zeek after being parsed
by NXLog and converted to JSON format. Spacing and line breaks have been added for readability.
Output sample
{
"ts": "1590636144.680688",
"uid": "C1InwK3K6fhY6YdvRe",
"id.orig_h": "192.168.1.7",
"id.orig_p": "45500",
"id.resp_h": "35.222.85.5",
"id.resp_p": "80",
"version": "1",
"cipher": "GET",
"curve": "connectivity-check.ubuntu.com",
"server_name": "/",
"resumed": null,
"last_alert": "1.1",
"next_protocol": null,
"established": null,
"cert_chain_fuids": "0",
"client_cert_chain_fuids": "0",
"subject": "204",
"issuer": "No Content",
"client_subject": null,
"client_issuer": null,
"validation_status": "(empty)",
"EventReceivedTime": "2020-05-27T22:22:26.917647-05:00",
"SourceModuleName": "zeek",
"SourceModuleType": "im_file"
}
The xm_w3c module is recommended because it supports reading the field list from the W3C-style log file
936
Chapter 123. Zeek (formerly Bro) Network Security Monitor NXLog User Guide
header. For NXLog Community Edition, the xm_csv module could be used instead to parse Zeek logs. A separate
instance of xm_csv must be configured for each log type.
937
NXLog User Guide Chapter 123. Zeek (formerly Bro) Network Security Monitor
This example has separate xm_csv module instances for the DNS and DHCP log types. Additional CSV
parsers could be added for the remaining Zeek log types.
nxlog.conf (truncated)
1 <Extension csv_parser_dns>
2 Module xm_csv
3 Fields ts, uid id.orig_h, id.orig_p, id.resp_h, id.resp_p, proto, \
4 trans_id, rtt query, qclass, qclass_name, qtype, qtype_name, \
5 rcode, rcode_name, AA, TC, RD, RA, Z, answers, TTLs, rejected
6 Delimiter \t
7 </Extension>
8
9 <Extension csv_parser_dhcp>
10 Module xm_csv
11 Fields ts, uid, id.orig_h, id.orig_p, id.resp_h, id.resp_p, mac, \
12 assigned_ip, lease_time, trans_id
13 Delimiter \t
14 </Extension>
15
16 # xm_fileop provides the `file_basename()` function
17 <Extension _fileop>
18 Module xm_fileop
19 </Extension>
20
21 <Extension json>
22 Module xm_json
23 </Extension>
24
25 <Input zeek>
26 Module im_file
27 File '/opt/zeek/spool/zeek/*.log'
28 <Exec>
29 [...]
The following output from this configuration represents a sample event logged by Zeek after being parsed
by NXLog and converted to JSON format. Spacing and line breaks have been added for readability.
938
Chapter 123. Zeek (formerly Bro) Network Security Monitor NXLog User Guide
Output sample
{
"EventReceivedTime": "2020-05-29 10:55:51",
"SourceModuleName": "zeek",
"SourceModuleType": "im_file",
"ts": "1590767749.877652",
"uid": "CAhAIX1Dl5KFfnhKbi",
"id.orig_h": "192.168.1.7",
"id.orig_p": "42157",
"id.resp_h": "192.168.1.1",
"id.resp_p": "53",
"proto": "udp",
"trans_id": "56765",
"rtt": "0.051801",
"query": "zeek.org",
"qclass": "1",
"qclass_name": "C_INTERNET",
"qtype": "1",
"qtype_name": "A",
"rcode": "0",
"rcode_name": "NOERROR",
"AA": "F",
"TC": "F",
"RD": "T",
"RA": "T",
"Z": "0",
"answers": "192.0.78.212,192.0.78.150",
"TTLs": "60.000000,60.000000",
"rejected": "F"
}
939
NXLog User Guide
Troubleshooting
940
Chapter 124. Internal Logs NXLog User Guide
These internal messages are written to the file defined in the LogFile directive in nxlog.conf. On Windows that
file is C:\Program Files\nxlog\data\nxlog.log; on Linux, /opt/nxlog/var/log/nxlog/nxlog.log. If this
directive is not specified, internal logging is disabled.
Some Windows applications (WordPad, for example) cannot open the log file while the NXLog
NOTE process is running because of exclusive file locking. Use a viewer that does not lock the file, like
Notepad.
• On all systems, set the LogLevel directive to DEBUG, then restart NXLog.
941
NXLog User Guide Chapter 124. Internal Logs
Example 550. Writing Specific Fields and Values to the Internal Log
This configuration uses the log_info() procedure to send values to the internal log. Log messages are
accepted over UDP on port 514. If keyword is found in the unparsed message, an INFO level message will
be generated.
nxlog.conf
1 <Input in>
2 Module im_udp
3 Port 514
4 <Exec>
5 if $raw_event =~ /keyword/
6 log_info("FOUND KEYWORD IN MSG: [" + $raw_event + "]");
7 </Exec>
8 </Input>
942
Chapter 124. Internal Logs NXLog User Guide
In this configuration, the to_json() procedure from the xm_json module is used to send all the fields to the
internal log.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input in>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 <Exec>
14 parse_syslog_bsd();
15
16 # Dump $raw_event
17 log_info("raw_event is: " + $raw_event);
18
19 # Dump fields in JSON
20 log_info("Other fields are: " + to_json());
21 </Exec>
22 </Input>
Output Sample
{
"MessageSourceAddress": "127.0.0.1",
"EventReceivedTime": "2012-05-18 13:11:35",
"SourceModuleName": "in",
"SourceModuleType": "im_tcp",
"SyslogFacilityValue": 3,
"SyslogFacility": "DAEMON",
"SyslogSeverityValue": 3,
"SyslogSeverity": "ERR",
"SeverityValue": 4,
"Severity": "ERROR",
"Hostname": "host",
"EventTime": "2010-10-12 12:49:06",
"SourceName": "app",
"ProcessID": "12345",
"Message": "test message"
}
943
NXLog User Guide Chapter 124. Internal Logs
The status is the most important piece of information in the dumped log entries. A status of
PAUSED means the input module is not able to send because the output module queue is full. In
NOTE
such a case the queuesize for the corresponding output(s) would be over 99. A status of
STOPPED means the module is fully stopped, usually due to an error.
Local logging is more fault-tolerant than routed logging, and is therefore recommended for
TIP
troubleshooting.
It is not possible to use a log level higher than INFO with the im_internal module. DEBUG level
NOTE
messages can only be written to the local log file.
944
Chapter 124. Internal Logs NXLog User Guide
In this example configuration, the file_write() procedure (from the xm_fileop module) is used to dump
information to an external file.
nxlog.conf
1 <Extension _fileop>
2 Module xm_fileop
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input in>
10 Module im_tcp
11 Host 0.0.0.0
12 Port 1514
13 <Exec>
14 parse_syslog_bsd();
15
16 # Debug $SyslogSeverity and $Hostname fields
17 file_write("/tmp/debug.txt",
18 "Severity: " + $SyslogSeverity +
19 ", Hostname: " + $Hostname + "\n");
20 </Exec>
21 </Input>
945
NXLog User Guide Chapter 125. Common Issues
This issue occurs because the NXLog configuration file has been saved in either UTF-16 text encoding, or UTF-8
text encoding with a BOM header.
Open the configuration file in a text editor and save it using ASCII encoding or plain UTF-8.
TIP On Windows, you can use Notepad to correct the text encoding of this file.
This error occurs because NXLog does not have permission to read the file with the configured User and Group.
See the Reading Rsyslog Log Files for more information about using NXLog to read files from the /var/log
directory.
2020-01-10 13:43:30 WARNING ignoring source as it cannot be subscribed to (error code: 5)↵
When this error occurs, the user needs to be granted access to read the specified channel for NXLog to be able
to collect events from it.
For default Event Log channels, it is sufficient to add the user to the built-in Event Log Readers group by following
these steps:
1. Open the Computer Management MMC snap-in by going to the Windows Start menu, type
compmgmt.msc and press Enter.
2. Expand System Tools > Local Users and Groups > Groups.
3. Double-click on the Event Log Readers group and add the NXLog user to it.
If the error persists, permission needs to be granted using the Windows Registry.
1. The first step is to retrieve the SID of the NXLog user. From a command prompt run the following command:
946
Chapter 125. Common Issues NXLog User Guide
2. Open the Registry Editor by going to the Windows Start menu, type regedit and press Enter.
3. Expand the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels
4. From the list of keys, find the channel shown in the error and click on it.
5. In the right pane, double click on the ChannelAccess value to modify it.
6. Permissions are specified using the Security Descriptor Definition Language (SDDL) and need to be
appended to the existing value. Add the following permission to give read access to the user:
(A;;0x1;;;<user-sid>)
Where A means Allow, 0x1 means Read, and <user-sid> needs to be replaced with the SID retrieved in step
1.
There may be channels which are saved in a different registry key than the one specified above.
NOTE
In such cases research has to be made to determine the location of the respective channel.
These steps require altering the Windows Registry and should be executed with care. Incorrect
NOTE
modifications could potentially render the system unusable.
• Check that no firewall, gateway, or other network issue is blocking the connection
• Verify that the system can resolve the host name used in the Host directive of the configuration file
947
NXLog User Guide Chapter 125. Common Issues
ERROR SSL certificate verification failed: self signed certificate (err: 18)
The first step in solving such problems is to set the AllowUntrusted directive to TRUE and restart the agent. The
manager instance should establish connection with the agent.
Additionally, CA and certificate files can be verified using the openssl tool. To verify the CA file, use the command
below:
To verify the server’s certificate against the CA certificate specified by the CAFile directive, use the following
command:
Instead of the CA file, the path to the CA directory can be specified per the command below:
The following error is generated by the agent when it presents a certificate that cannot be verified by NXLog
Manager:
ERROR remote ssl socket was reset? (SSL_ERROR_SSL with errno=9); End of file found
Certificates created with an incorrect or incompatible "certificate purpose" produce the following error:
ERROR SSL certificate verification failed: unsupported certificate purpose (err: 26)
The default json codec in Logstash sometimes fails to parse log entries passed from NXLog. Switch to the
json_lines codec for better reliability.
948
Chapter 125. Common Issues NXLog User Guide
This error occurs when attempting to access a field from the Exec directive of a Schedule block. The log data is
not available in the current context. Log data is never available to a scheduled Exec directive because its
execution is not triggered by a log message.
An attempt to access a field can occur directly with a field assignment, or indirectly by calling a function or
procedure that accesses log data.
In some cases, it is preferred for NXLog to continue sending logs to the remaining active output and discard logs
for the failed output. The simplest solution is to disable flow control. This can be done globally with the global
FlowControl directive, or for the corresponding Input (and Processor, if any) modules only, with the module
FlowControl directive.
With flow control disabled, an Input or Processor module will continue to process logs even if
NOTE
the next module’s buffers are full (and the logs will be dropped).
To retain the improved message durability provided by flow control, it is possible to instead explicitly specify
when to drop logs by using a separate route for each output that may fail. Add a pm_buffer module instance to
that route, and configure the buffer to drop logs when it reaches a certain size. The output that follows the buffer
can fail without causing any Input or Processor module before the buffer to pause processing. For examples, see
the Using Buffers section.
On Linux, run the following command to see, for example, which files NXLog has open:
$ lsof -u nxlog
On Systems not using /proc, check the system’s open file limit with:
949
NXLog User Guide Chapter 125. Common Issues
$ sysctl kern.maxfiles
or with:
$ sysctl fs.file-max
There is no Windows equivalent to lsof. You can use Windows Process Explorer from
NOTE
Microsoft’s Windows Sysinternals to inspect which program has files or directories open.
This scenario requires edits to the service file or an override. To check NXLog’s system limits use the following
command:
On Systems not using /proc, check the system’s open file limit:
$ sysctl kern.maxfiles
1 [Service]
2 LimitNOFILE=100000
$ systemctl daemon-reload
• Open the log file with an application that does not use exclusive locking (such as Notepad)
or
950
Chapter 126. Debugging NXLog NXLog User Guide
1. Remove the User and Group directives from the configuration. NXLog needs to be running as root:root to
produce a core dump.
2. Use ulimit to remove the core file size limit.
# ulimit -c unlimited
# /opt/nxlog/bin/nxlog -f
4. Find the NXLog process and kill it with the SIGABRT signal.
# ls -l /opt/nxlog/var/spool/nxlog/
total 26708
-rw------- 1 root root 27348992 Oct 30 08:51 core
6. If the core dump file was created successfully, run NXLog again as root in order to catch the next crash.
# /opt/nxlog/bin/nxlog -f
NOTE ProcDump runs on Windows Vista and higher, and Windows Server 2008 and higher.
For example, run the following to write a full dump of the nxlog process when its handle count exceeds 10,000:
951
NXLog User Guide Chapter 126. Debugging NXLog
The NXLog debug symbols package is currently only available for Linux. This package is not
NOTE
included with NXLog by default, but can be provided on request.
2. Install Valgrind.
3. Set the NoFreeOnExit directive to TRUE in the NXLog configuration file. This directive ensures that modules
are not unloaded when NXLog is stopped, which allows Valgrind to properly resolve backtraces into modules.
4. Start NXLog under Valgrind with the following command. If User is set to nxlog in the configuration, then the
command must be executed with su, otherwise Valgrind will not be able to create the massif.out file at the
end of the sampling process.
# cd /tmp
# su -lc "valgrind --tool=massif --pages-as-heap=yes /opt/nxlog/bin/nxlog -f" nxlog
5. Let NXLog run for a while until the Valgrind process shows the memory increase, then interrupt it with
Ctrl+C. The output is written to /tmp/massif.out.xxxx.
6. Send the massif.out.xxxx file with a bug report.
7. Optionally, create a report from the massif.out.xxxx file with the ms_print command:
# ms_print massif.out.xxxx
The output of the ms_print report contains an ASCII chart at the top showing the increase in memory usage.
The chart shows the sample number with the highest memory usage, marked with (peak). This is normally
at the end of the chart (the last sample). The backtrace from this sample indicates where the most memory is
allocated.
Once a potential source of excessive memory use has been determined, use DebugView from Microsoft
Sysinternals to inspect the application’s debug output.
952
NXLog User Guide
953
NXLog User Guide Chapter 127. Man Pages
SYNOPSIS
nxlog [-c conffile] [-f]
DESCRIPTION
NXLog can process high volumes of event logs from many different sources. Supported types of log processing
include rewriting, correlating, alerting, filtering, and pattern matching. Additional features include scheduling, log
file rotation, buffering, and prioritized processing. After processing, NXLog can store or forward event logs in any
of many supported formats. Inputs, outputs, and processing are implemented with a modular architecture and a
powerful configuration language.
While the details provided here apply to NXLog installations on Linux and other UNIX-style operating systems in
particular, a few Windows-specific notes are included.
OPTIONS
-c conffile, --conf conffile
Specify an alternate configuration file conffile. To change the configuration file used by the NXLog service on
Windows, modify the service parameters.
-f, --foreground
Run in foreground, do not daemonize.
-q, --quiet
Suppress output to STDOUT/STDERR.
-h, --help
Print help.
-r, --reload
Reload configuration of a running instance.
-s, --stop
Send stop signal to a running instance.
-v, --verify
Verify configuration file syntax.
SIGNALS
Various signals can be used to control the NXLog process. Some corresponding Windows control codes are also
available; these are shown in parentheses where applicable.
954
Chapter 127. Man Pages NXLog User Guide
SIGHUP
This signal causes NXLog to reload the configuration and restart the modules. On Windows, "sc stop nxlog"
and "sc start nxlog" can be used instead.
SIGUSR1 (200)
This signal generates an internal log message with information about the current state of NXLog and its
configured module instances. The message will be generated with INFO log level, written to the log file (if
configured with LogFile), and available via the im_internal module.
SIGUSR2 (201)
This signal causes NXLog to switch to the DEBUG log level. This is equivalent to setting the LogLevel directive
to DEBUG but does not require NXLog to be restarted.
SIGINT/SIGQUIT/SIGTERM
NXLog will exit if it receives one of these signals. On Windows, "sc stop nxlog" can be used instead.
On Linux/UNIX, a signal can be sent with the kill command. The following, for example, sends the SIGUSR1
signal:
On Windows, a signal can be sent with the sc command. The following, for example, sends the 200 signal:
FILES
/opt/nxlog/bin/nxlog
The main NXLog executable
/opt/nxlog/bin/nxlog-stmnt-verifier
This tool can be used to check NXLog Language statements. All statements are read from standard input and
then validated. If a statement is invalid, the tool prints an error to standard error and exits non-zero.
/opt/nxlog/etc/nxlog.conf
The default configuration file
/opt/nxlog/lib/nxlog/modules
The NXLog modules are located in this directory, by default. See the ModuleDir directive.
/opt/nxlog/spool/nxlog
If PersistLogqueue is set to TRUE, module queues are stored in this directory. See also LogqueueDir and
SyncLogqueue.
/opt/nxlog/spool/nxlog/configcache.dat
This is the position cache file where positions are saved. See the NoCache directive, in addition to CacheDir,
CacheFlushInterval, and CacheSync.
/opt/nxlog/var/run/nxlog/nxlog.pid
The process ID (PID) of the currently running NXLog process is written to this file. See the PidFile directive.
ENVIRONMENT
To access environment variables in the NXLog configuration, use the envvar directive.
955
NXLog User Guide Chapter 127. Man Pages
SEE ALSO
nxlog-processor(8)
COPYRIGHT
Copyright © Copyright © NXLog Ltd. 2021
The NXLog Community Edition is licensed under the NXLog Public License. The NXLog Enterprise Edition is not
free and has a commercial license.
127.2. nxlog-processor(8)
NAME
nxlog-processor - performs batch log processing
SYNOPSIS
nxlog-processor [-c conffile] [-v]
DESCRIPTION
The nxlog-processor tool is similar to the NXLog daemon and uses the same configuration file. However, it runs
in the foreground and exits after all input log data has been processed. Common input sources are files and
databases. This tool is useful for log processing tasks such as:
While the details provided here apply to NXLog installations on Linux and other UNIX-style operating systems in
particular, a few Windows-specific notes are included.
OPTIONS
-c conffile, --conf conffile
Specify an alternate configuration file conffile.
-h, --help
Print help.
-v, --verify
Verify configuration file syntax.
FILES
956
Chapter 127. Man Pages NXLog User Guide
/opt/nxlog/bin/nxlog-processor
The main NXLog-processor executable
/opt/nxlog/bin/nxlog-stmnt-verifier
This tool can be used to check NXLog Language statements. All statements are read from standard input and
then validated. If a statement is invalid, the tool prints an error to standard error and exits non-zero.
/opt/nxlog/etc/nxlog.conf
The default configuration file
/opt/nxlog/spool/nxlog/configcache.dat
This is the position cache file where positions are saved. To disable position caching, as may be desirable
when using nxlog-processor, set the NoCache directive to TRUE.
ENVIRONMENT
To access environment variables in the NXLog configuration, use the envvar directive.
SEE ALSO
nxlog(8)
COPYRIGHT
Copyright © Copyright © NXLog Ltd. 2021
The NXLog Community Edition is licensed under the NXLog Public License. The NXLog Enterprise Edition is not
free and has a commercial license.
957
NXLog User Guide Chapter 128. Configuration
A configuration is valid without any module instances specified, however for NXLog to process data the
configuration should contain at least one input module instance and at least one output module instance. If no
route is specified, a route will be automatically generated; this route will connect all input module instances and
all output module instances in a single path.
A module instance name may contain letters, digits, periods (.), and underscores (_). The first character in a
module instance name must be a letter or an underscore. The corresponding regular expression is [a-zA-
Z_][a-zA-Z0-9._]*.
A route instance name may contain letters, digits, periods (.), and underscores (_). The first character in a route
instance name must be a letter, a digit, or an underscore. The corresponding regular expression is [a-zA-Z0-
9_][a-zA-Z0-9._]*.
Any text written on the line after the hash mark (\#) is ignored and treated as a comment. To learn more
configuration tips, read the Configuration Overview section of the User Guide.
define
Use this directive to configure a constant or macro to be used later. Refer to a define by surrounding the
name with percent signs (%). Enclose a group of statements with curly braces ({}).
This configuration shows three example defines: BASEDIR is a constant, IMPORTANT is a statement, and
WARN_DROP is a group of statements.
nxlog.conf
1 define BASEDIR /var/log
2 define IMPORTANT if $raw_event =~ /important/ \
3 $Message = 'IMPORTANT ' + $raw_event;
4 define WARN_DROP { log_warning("dropping message"); drop(); }
5
6 <Input messages>
7 Module im_file
8 File '%BASEDIR%/messages'
9 </Input>
10
11 <Input proftpd>
12 Module im_file
13 File '%BASEDIR%/proftpd.log'
14 <Exec>
15 %IMPORTANT%
16 if $raw_event =~ /dropme/ %WARN_DROP%
17 </Exec>
18 </Input>
958
Chapter 128. Configuration NXLog User Guide
envvar
This directive works like define, except that the value is retrieved from the environment.
This example is like the previous one, but BASEDIR is fetched from the environment instead.
nxlog.conf
1 envvar BASEDIR
2
3 <Input in>
4 Module im_file
5 File '%BASEDIR%/messages'
6 </Input>
include
This directive allows a specified file or files to be included in the current NXLog configuration. Wildcarded
filenames are supported.
The SpoolDir directive only takes effect after the configuration is parsed, so relative paths
NOTE specified with the include directive must be relative to the working directory NXLog was
started from.
The examples below provide various ways of using the include directive.
nxlog.conf
1 include modules/module1.conf
In the case, when multiple .conf files are to be defined, they can be saved in the nxlog.d directory and then
automatically included in the NXLog configuration along with the nxlog.conf file. Adding .conf files into the
nxlog.d directory extends the NXLog configuration, while no modification for the nxlog.conf file is needed.
This example includes all matching files from the nxlog.d directory and uses absolute paths on Unix-
like systems and Windows.
nxlog.conf
1 include /etc/nxlog.d/*.conf
nxlog.conf
1 include C:\Program Files\nxlog\conf\nxlog.d\*.conf
959
NXLog User Guide Chapter 128. Configuration
include_stdout
This directive accepts the name of an external command or script. Configuration content will be read from
the command’s standard output. Command arguments are not supported.
This directive executes the custom script, which fetches the configuration.
nxlog.conf
1 include_stdout /opt/nxset/etc/fetch_conf.sh
BatchFlushInterval
This directive specifies the timeout, in seconds, before a record-batch will be forwarded to the next module in
the route, even if the batch has accumulated fewer than the maximum number of records given by the
BatchSize directive. If this directive is not specified, it defaults to 0.1 (100 milliseconds). It can also be
overriden per-module, by the BatchFlushInterval module level directive.
CacheDir
This directive specifies a directory where the cache file (configcache.dat) should be written. This directive
has a compiled-in value which is used by default.
CacheFlushInterval
This directive specifies how often the in-memory position cache should be flushed to the cache file. The value
of 0 indicates that the cache should only be flushed to the file when the agent shuts down; if the server or
agent crashes, the current position cache will be lost. A positive integer indicates the length of the interval
between flushes of the cache, in seconds. The string always specifies that the cache should be flushed to file
immediately when a module sets a value. If this directive is not specified the default value of 5 seconds is
used. See also the CacheSync directive below.
CacheInvalidationTime
NXLog persists saved positions in cache that is written the disk. To prevent the cache growing indefinitely an
invalidation period is used. This directive defines the invalidation period. If the last modification time of an
entry exceeds the value set with this directive, the entry is discarded when the cache is read from disk. This
directive accepts a positive Integer value. If the directive is not specified, the default value of 864000 (10 days)
is used.
CacheSync
When the in-memory position cache is flushed to the cache file, the cache may not be immediately written to
the disk due to file system buffering. When this directive is set to TRUE, the cache file is synced to disk
immediately when it is written. The default is FALSE. CacheSync has no effect if CacheFlushInterval is set to
the default of 0. Setting this to TRUE when CacheFlushInterval is set to always greatly reduces performance,
though only this guarantees crash-safe operation.
Capabilities
This directive allows you to define Linux capabilities that NXLog must not drop after it has started.
For security reasons, NXLog drops nearly all capabilities during startup, and as a trade-off, losing the ability to
960
Chapter 128. Configuration NXLog User Guide
use them later in its life cycle. This can only be troublesome in some rare scenarios, for example when NXLog
is started with an empty configuration, but configuration changes are later added by NXLog Manager that
requires binding to a new privileged port. In this case the binding fails. Specifying the required capabilities
upfront using this configuration directive eliminates this problem.
For examples on usage, see the Setting Linux Capabilities section in the NXLog User Guide.
DateFormat
This directive can be used to change the default date format as it appears in the LogFile, in the $raw_event
generated by the modules, and when a datetime type value is converted to a string. The following values are
accepted (corresponding to the formats accepted by the NXLog strftime() function):
• YYYY-MM-DDThh:mm:ssTZ
• YYYY-MM-DDThh:mm:ss.sTZ
• YYYY-MM-DD hh:mm:ssTZ
• YYYY-MM-DD hh:mm:ss.sTZ
• YYYY-MM-DDThh:mm:ssUTC
• YYYY-MM-DDThh:mm:ss.sUTC
• YYYY-MM-DD hh:mm:ssUTC
• YYYY-MM-DD hh:mm:ss.sUTC
EscapeGlobPatterns
This boolean directive specifies whether the backslash (\) character in glob patterns or wildcarded entries
should be enabled as an escape sequence. If set to TRUE, this directive implies that the backslash character (
\) needs to be escaped by another backslash character (\\). File and directory patterns on Windows do not
require escaping and are processed as non-escaped even if this directive is set to TRUE. The default is FALSE.
This directive is used in im_file, im_fim, and im_regmon modules.
FlowControl
This optional boolean directive specifies the flow control default for input and processor module instances.
Output module instances do not inherit from this directive. By default, the global FlowControl value is TRUE.
See the description of the module level FlowControl directive for more information.
FlowControlFIFO
This bolean directive, when set to TRUE, which is also the default, enables FIFO mode for modules that have
flow control disabled. In this mode, when the log queue of a module is full, older records will be dropped in
order to make room for newer ones. When set to FALSE, the old behavior is in effect: while the log queue is
full, no records will be dropped, but new incoming records will be discarded instead.
GenerateDateInUTC
If set to TRUE, this boolean directive specifies that UTC should be used when generating dates in the format
YYYY-MM-DD hh:mm:ss. If set to FALSE, local time will be used when generating dates in this format. The
default is FALSE. See also ParseDateInUTC.
Group
Similar to User, NXLog will set the group ID to run under. The group can be specified by name or numeric ID.
This directive has no effect when running on the Windows platform or with nxlog-processor(8).
961
NXLog User Guide Chapter 128. Configuration
IgnoreErrors
If set to FALSE, NXLog will stop when it encounters a problem with the configuration file (such as an invalid
module directive) or if there is any other problem which would prevent all modules functioning correctly. If
set to TRUE, NXLog will start after logging the problem. The default value is TRUE.
LogFile
NXLog will write its internal log to this file. If this directive is not specified, self logging is disabled. Note that
the im_internal module can also be used to direct internal log messages to files or different output
destinations, but this does not support log level below INFO. This LogFile directive is especially useful for
debugging.
LogLevel
This directive has five possible values: CRITICAL, ERROR, WARNING, INFO, and DEBUG. It will set both the logging
level used for LogFile and the standard output if NXLog is started in the foreground. The default LogLevel is
INFO. This directive can also be used at the module level.
LogqueueDir
This directive specifies the directory where the files of the persistent queues are stored, for Processor and
Output module instances. Even if PersistLogqueue is set to FALSE, NXLog will persist in-memory queues to
the LogqueueDir on shutdown. If not specified, the default is the value of CacheDir. This directive can also be
used at the module level to specify a log queue directory for a specific module instance.
LogqueueSize
This directive controls the size of the log queue for all Processor and Output module instances. The default is
100 record batches. See the module-level LogQueueSize for more information.
ModuleDir
By default the NXLog binaries have a compiled-in value for the directory to search for loadable modules. This
can be overridden with this directive. The module directory contains sub-directories for each module type
(extension, input, output, and processor), and the module binaries are located in those.
NoCache
Some modules save data to a cache file which is persisted across a shutdown/restart. Modules such as im_file
will save the file position in order to continue reading from the same position after a restart as before. This
caching mechanism can be explicitly turned off with this directive. This is mostly useful with nxlog-
processor(8) in offline mode. If this boolean directive is not specified, it defaults to FALSE (caching is enabled).
Note that many input modules, such as im_file, provide a SavePos directive that can be used to disable the
position cache for a specific module instance. SavePos has no effect if the cache is disabled globally with
NoCache TRUE.
NoFreeOnExit
This directive is for debugging. When set to TRUE, NXLog will not free module resources on exit, allowing
valgrind to show proper stack trace locations in module function calls. The default value is FALSE.
Panic
A panic condition is a critical state which usually indicates a bug. Assertions are used in NXLog code for
checking conditions where the code will not work unless the asserted condition is satisfied, and for security.
Failing assertions result in a panic and suggest a bug in the code. A typical case is checking for NULL pointers
before pointer dereference. This directive can take three different values: HARD, SOFT, or OFF. HARD will cause
an abort in case the assertion fails. This is how most C based programs work. SOFT will cause an exception to
be thrown at the place of the panic/assertion. In case of NULL pointer checks this is identical to a
NullPointerException in Java. It is possible that NXLog can recover from exceptions and can continue to
process log messages, or at least the other modules can. In case of assertion failure the location and the
condition is printed at CRITICAL log level in HARD mode and ERROR log level in SOFT mode. If Panic is set to
OFF, the failing condition is printed in the logs but the execution will continue on the normal code path. Most
of the time this will result in a segmentation fault or other undefined behavior, though in some cases turning
962
Chapter 128. Configuration NXLog User Guide
off a buggy assertion or panic will solve the problems caused by it in HARD/SOFT mode. The default value for
Panic is SOFT.
ParseDateInUTC
If set to TRUE, this boolean directive specifies that dates in the format YYYY-MM-DD hh:mm:ss should be
parsed as UTC. If set to FALSE, dates in this format are assumed to be in local time. The default is FALSE. See
also GenerateDateInUTC.
PersistLogqueue
This boolean directive specifies that log queues of Processor and Output module instances should be disk-
based. See the module level PersistLogqueue directive for more information.
PidFile
Under Unix operating systems, NXLog writes a PID file as other system daemons do. The default PID file can
be overridden with this directive in case multiple daemon instances need to be running. This directive has no
effect when running on the Windows platform or with nxlog-processor(8).
ReadTimeout
This directive is specific to nxlog-processor(8). It controls the exit condition of nxlog-processor(8). Its value is a
timeout in seconds. If nxlog-processor(8) gets no data to process during this period then it will stop waiting
for more data and will exit. The default value is 0.05 s. For any non-negative value which is less than 0.05 this
will be 0.05. In case nxlog-processor(8) is configured to read data from the network it is recommended to set
this to higher value.
RootDir
NXLog will set its root directory to the value specified with this directive. If SpoolDir is also set, this will be
relative to the value of RootDir (chroot() is called first). This directive has no effect when running on the
Windows platform or with the nxlog-processor(8).
SpoolDir
NXLog will change its working directory to the value specified with this directive. This is useful with files
created through relative filenames (for example, with om_file) and in case of core dumps. This directive has
no effect with the nxlog-processor(8).
StringLimit
To protect against memory exhaustion (and possibly a denial-of-service) caused by over-sized strings, there is
a limit on the length of each string (in bytes). The default value is 5242880 bytes (strings will be truncated at 5
MiB).
SuppressRepeatingLogs
Under some circumstances it is possible for NXLog to generate an extreme amount of internal logs consisting
of the same message due to an incorrect configuration or a software bug. In this case, the LogFile can quickly
consume the available disk space. With this directive, NXLog will write at most 2 lines per second if the same
message is generated successively, by logging "last message repeated n times" messages. If this boolean
directive is not specified, it defaults to TRUE (suppression of repeating messages is enabled).
SyncLogqueue
When this directive is set to TRUE and PersistLogqueue is enabled, the disk-based queues of Processor and
Output module instances will be immediately synced after each new entry is added to the queue. This greatly
reduces performance but makes the queue more reliable and crash-safe. This directive can also be used at
the module level.
Threads
This directive specifies the number of worker threads to use. The number of the worker threads is calculated
and set to an optimal value if this directive is not defined. Do not set this unless you know what you are
doing.
963
NXLog User Guide Chapter 128. Configuration
User
NXLog will drop to the user specified with this directive. This is useful if NXLog needs privileged access to
some system resources (such as kernel messages or to bind a port below 1024). On Linux systems NXLog will
use capabilities to access these resources. In this case NXLog must be started as root. The user can be
specified by name or numeric ID. This directive has no effect when running on the Windows platform or with
nxlog-processor(8).
Module
This mandatory directive specifies which binary should be loaded. The module binary has a .so extension on
Unix and a .dll on Windows platforms and resides under the ModuleDir location. Each module binary name
is prefixed with im_, pm_, om_, or xm_ (for input, processor, output, and extension, respectively). It is possible for
multiple instances to use the same loadable binary. In this case the binary is only loaded once but
instantiated multiple times. Different module instances may have different configurations.
BatchSize
For input and processor modules, specifies how many records will be collected by the module, and forwarded
together as a batch to the next module in the route. See the description of the global BatchSize directive for
more information.
BatchFlushInterval
For input and processor modules, specifies the timeout before a record-batch is forwarded to the next
module in the route. See the description of the global BatchFlushInterval directive for more information.
BufferSize
This directive specifies the size of the read or write buffer (in bytes) used by the Input or Output module,
respectively. The BufferSize directive is only valid for Input and Output module instances. The default buffer
size is 65000 bytes.
FlowControl
This optional boolean directive specifies whether the module instance should use flow control. FlowControl
is only valid for input, processor, and output modules. For input and processor modules, the FlowControl
default is inherited from the global FlowControl directive (which defaults to TRUE). To maintain backward
compatibility, the FlowControl default for output modules is TRUE regardless of the global FlowControl value.
Under normal conditions, when all module instances are operating normally and buffers are not full, flow
control has no effect. However, if a module becomes blocked and is unable to process events, flow control
will automatically suspend module instances as necessary to prevent events from being lost. For example,
consider a route with im_file and om_tcp. If a network error blocks the output, NXLog will stop reading events
from file until the network error is resolved. If flow control is disabled, NXLog will continue reading from file
and processing events; the events will be discarded when passed to the output module.
In most cases, flow control should be left enabled, but it may be necessary to disable it in certain scenarios. It
is recommended to leave flow control enabled globally and only specify the FlowControl directive in two
cases. First, set FlowControl FALSE on any input module instance that should never be suspended. Second,
if a route contains multiple output instances, it may be desirable to continue sending events to other outputs
even if one output becomes blocked—set FlowControl FALSE on the output(s) where events can be
discarded to prevent the route from being blocked.
Internally, flow control takes effect when the log queue of the next module instance in the route becomes full.
If flow control is enabled, the instance suspends. If flow control is disabled, events are discarded. If the next
module in the route is an output module, both FlowControl values are consulted—flow control is enabled
964
Chapter 128. Configuration NXLog User Guide
InputType
This directive specifies the name of the registered input reader function to be used for parsing raw events
from input data. Names are treated case insensitively. This directive is only available for stream oriented
input modules: im_file, im_exec, im_ssl, im_tcp, im_udp, im_uds, and im_pipe. These modules work by filling
an input buffer with data read from the source. If the read operation was successful and data is available
from the source, the module calls the specified callback function. If this is not explicitly specified, the module
default will be used. Note that im_udp may only work properly if log messages do not span multiple packets
and are within the UDP message size limit. Otherwise the loss of a packet may lead to parsing errors.
Modules may provide custom input reader functions. Once they are registered into the NXLog core, the
modules listed above will be able to use these functions. This makes it easier to implement custom protocols
because they can be developed without concern for the transport layer.
The following input reader functions are provided by the NXLog core:
Binary
The input is parsed in the NXLog binary format, which preserves the parsed fields of the event records.
The LineBased reader will automatically detect event records in the NXLog binary format, so it is only
recommended to configure InputType to Binary if compatibility with other logging software is not
required.
Dgram
Once the buffer is filled with data, it is considered to be one event record. This is the default for the
im_udp input module, since UDP Syslog messages arrive in separate packets.
LineBased
The input is assumed to contain event records separated by newlines. It can handle both CRLF (Windows)
and LF (Unix) line-breaks. Thus if an LF (\n) or CRLF (\r\n) is found, the function assumes that it has
reached the end of the event record. If the input begins with the UTF-8 byte order mark (BOM) sequence
(0xEF,0xBB,0xBF), that sequence is automatically skipped.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 Port 2345
4 InputType Binary
5 </Input>
With the im_file module, this directive also supports one or more data converters to process input data
before reading.
Data converters are processed sequentially from left to right, thus the order they are specified in is
important. The following example shows the syntax of the InputType directive with two data converters and
the input reader function:
965
NXLog User Guide Chapter 128. Configuration
1 InputType <InstanceName>.<DataConverter1>, \
2 <InstanceName>.<DataConverter2>, \
3 <InputReaderFunction>
Where <InstanceName> is the given name of an extension module instance and <DataConverter> is the
name of the data converter being invoked. Currently, data converters are available in the xm_crypto and
xm_zlib modules. The InputType directive can contain multiple data conversion operations from the same
extension module.
For more details, see the documentation on the xm_crypto and xm_zlib modules.
This configuration contains one instance of the xm_zlib module to decompress the input data and one
instance of the xm_crypto module to decrypt it.
The result is read by the im_file module using the LineBased function.
nxlog.conf
1 <Extension cryptography>
2 Module xm_crypto
3 UseSalt TRUE
4 PasswordFile /path/to/passwordfile
5 </Extension>
6
7 <Extension gzip>
8 Module xm_zlib
9 Format gzip
10 CompressionLevel 9
11 CompBufSize 16384
12 DecompBufsize 16384
13 </Extension>
14
15 <Input from_file>
16 Module im_file
17 File '/tmp/input'
18 InputType cryptography.aes_decrypt, gzip.decompress, LineBased
19 </Input>
LogLevel
This directive can be used to override the value of the global LogLevel. This can be useful for debugging
purposes when DEBUG is set at the module level, or a noisy module can be silenced when set to CRITICAL or
ERROR.
1 <Input fim>
2 Module im_fim
3 LogLevel Debug
4 ...
5 </Input>
LogqueueDir
This directive specifies the directory where the files of the persistent queue are stored. LogqueueDir is only
valid for Processor and Output module instances. See the description of the global LogqueueDir for more
information.
966
Chapter 128. Configuration NXLog User Guide
LogqueueSize
Every Processor and Output instance has an input log queue for events waiting to be processed by that
module. The size of the queue is measured in batches of event records, and can be set with this
directive—the default is 100 batches. When the log queue of a module instance is full and FlowControl is
enabled for the preceeding module, the preceeding module will be suspended. If flow control is not enabled
for the preceeding module, events will be discarded. This directive is only valid for Processor and Output
module instances. This directive can be used at the global level to affect all modules.
OutputType
This directive specifies the name of the registered output writer function to be used for formatting raw events
when storing or forwarding output. Names are treated case insensitively. This directive is only available for
stream oriented output modules: om_exec, om_file, om_pipe, om_redis, om_ssl, om_tcp, om_udp,
om_udpspoof, om_uds, and om_zmq. These modules work by filling the output buffer with data to be written
to the destination. The specified callback function is called before the write operation. If this is not explicitly
specified, the module default will be used.
Modules may provide custom output formatter functions. Once they are registered into the NXLog core, the
modules listed above will be able to use these functions. This makes it easier to implement custom protocols
because they can be developed without concern for the transport layer.
The following output writer functions are provided by the NXLog core:
Binary
The output is written in the NXLog binary format which preserves parsed fields of the event records.
Dgram
Once the buffer is filled with data, it is considered to be one event record. This is the default for the
om_udp, om_udpspoof, om_redis, and om_zmq output modules.
LineBased
The output will contain event records separated by newlines. The record terminator is CRLF (\r\n) on
Windows and LF (\n) on Unix.
LineBased_CRLF
The output will contain event records separated by Windows style newlines where the record terminator is
CRLF (\r\n).
LineBased_LF
The output will contain event records separated by Unix style newlines where the record terminator is LF
(\n).
nxlog.conf
1 <Output tcp>
2 Module om_tcp
3 Port 2345
4 Host localhost
5 OutputType Binary
6 </Output>
With the om_file module, this directive also supports one or more data converters to process output data
after writing.
967
NXLog User Guide Chapter 128. Configuration
Data converters are processed sequentially from left to right, thus the order they are specified in is
important. The following example shows the syntax of the OutputType directive with two data converters and
the output writer function:
1 OutputType <OutputWriterFunction>, \
2 <InstanceName>.<DataConverter1>, \
3 <InstanceName>.<DataConverter2>
Where <InstanceName> is the given name of an extension module instance and <DataConverter> is the
name of the data converter being invoked. Currently, tdata converters are available in the xm_crypto and
xm_zlib modules. The OutputType directive can contain multiple data conversion operations from the same
extension module.
NOTE Rotation of files is done automatically when encrypting log data with the xm_crypto module.
For more details, see the the documentation of the xm_crypto and xm_zlib modules.
This configuration writes the data using the LineBased function of the om_file module. It also contains
one instance of the xm_zlib module to compress the output data and one instance of the xm_crypto
module to encrypt them.
nxlog.conf
1 <Extension gzip>
2 Module xm_zlib
3 Format gzip
4 CompressionLevel 9
5 CompBufSize 16384
6 DecompBufsize 16384
7 </Extension>
8
9 <Extension cryptography>
10 Module xm_crypto
11 UseSalt TRUE
12 PasswordFile /path/to/passwordfile
13 </Extension>
14
15 <Input from_tcp>
16 Module im_tcp
17 Host 192.168.31.11
18 Port 10500
19 </Input>
20
21 <Output to_file>
22 Module om_file
23 File '/tmp/output'
24 OutputType LineBased, gzip.compress, cryptography.aes_encrypt
25 </Output>
PersistLogqueue
When a module passes an event to the next module along the route, it puts it into the next module’s queue.
This queue can be either a memory-based or disk-based (persistent) queue. When this directive is set to
TRUE, the module will use a persistent (disk-based) queue. With the default value of FALSE, the module’s
incoming log queue will not be persistent (will be memory-based); however, in-memory log queues will still be
persisted to disk on shutdown. This directive is only valid for Processor and Output module instances. This
directive can also be used at the global level.
968
Chapter 128. Configuration NXLog User Guide
SyncLogqueue
When this directive is set to TRUE and PersistLogqueue is enabled, the disk-based queue will be immediately
synced after each new entry is added to the queue. This greatly reduces performance but makes the queue
more reliable and crash-safe. This directive is only valid for Processor and Output module instances. This
directive can be used at the global level to affect all modules.
128.3.1. Exec
The Exec directive/block contains statements in the NXLog language which are executed when a module receives
a log message. This directive is available in all input, processor, and output modules. It is not available in most
extension modules because these do not handle log messages directly (the xm_multiline and xm_rewrite
modules do provide Exec directives).
This statement assigns a value to the $Hostname field in the event record.
nxlog.conf
1 Exec $Hostname = 'myhost';
Each directive must be on one line unless it contains a trailing backslash (\) character.
nxlog.conf
1 Exec if $Message =~ /something interesting/ \
2 log_info("found something interesting"); \
3 else \
4 log_debug("found nothing interesting");
More than one Exec directive or block may be specified. They are executed in the order of appearance. Each
Exec directive must contain a full statement. Therefore it is not possible to split the lines in the previous example
into multiple Exec directives. It is only possible to split the Exec directive if it contains multiple statements.
nxlog.conf
1 Exec log_info("first"); \
2 log_info("second");
nxlog.conf
1 Exec log_info("first");
2 Exec log_info("second");
The Exec directive can also be used as a block. To use multiple statements spanning more than one line, it is
recommended to use the <Exec> block instead. When using a block, it is not necessary to use the backslash (\)
character for line continuation.
969
NXLog User Guide Chapter 128. Configuration
This example shows two equivalent uses of Exec, first as a directive, then as a block.
nxlog.conf
1 Exec log_info("first"); \
2 log_info("second");
The following Exec block is equivalent. Notice the backslash (\) is omitted.
nxlog.conf
1 <Exec>
2 log_info("first");
3 log_info("second");
4 </Exec>
128.3.2. Schedule
The Schedule block can be used to execute periodic jobs, such as log rotation or any other task. Scheduled jobs
have the same priority as the module. The Schedule block has the following directives:
Every
In addition to the crontab format it is possible to schedule execution at periodic intervals. With the crontab
format it is not possible to run a job every five days for example, but this directive enables it in a simple way.
It takes a positive integer value with an optional unit. The unit can be one of the following: sec, min, hour,
day, or week. If the unit is not specified, the value is assumed to be in seconds. The Every directive cannot be
used in combination with RunCount 1.
Exec
The mandatory Exec directive takes one or more NXLog statements. This is the code which is actually being
scheduled. Multiple Exec directives can be specified within one Schedule block. See the module-level Exec
directive, this behaves the same. Note that it is not possible to use fields in statements here because
execution is not triggered by log messages.
First
This directive sets the first execution time. If the value is in the past, the next execution time is calculated as if
NXLog has been running since and jobs will not be run to make up for missed events in the past. The directive
takes a datetime literal value.
RunCount
This optional directive can be used to specify a maximum number of times that the corresponding Exec
statement(s) should be executed. For example, with RunCount 1 the statement(s) will only be executed once.
When
This directive takes a value similar to a crontab entry: five space-separated definitions for minute, hour, day,
month, and weekday. See the crontab(5) manual for the field definitions. It supports lists as comma
separated values and/or ranges. Step values are also supported with the slash. Month and week days are not
supported, these must be defined with numeric values. The following extensions are also supported:
970
Chapter 128. Configuration NXLog User Guide
This example shows two scheduled Exec statements in a im_tcp module instance. The first is executed
every second, while the second uses a crontab(5) style value.
nxlog.conf
1 <Input in>
2 Module im_tcp
3 Port 2345
4
5 <Schedule>
6 Every 1 sec
7 First 2010-12-17 00:19:06
8 Exec log_info("scheduled execution at " + now());
9 </Schedule>
10
11 <Schedule>
12 When 1 */2 2-4 * *
13 Exec log_info("scheduled execution at " + now());
14 </Schedule>
15 </Input>
Path
The data flow is defined by the Path directive. First the instance names of Input modules are specified. If
more than one Input reads log messages which feed data into the route, then these must be separated by
commas. The list of Input modules is followed by an arrow (=>). Either processor modules or output modules
follow. Processor modules must be separated by arrows, not commas, because they operate in series, unlike
Input and Output modules which work in parallel. Output modules are separated by commas. The Path must
specify at least an Input and an Output. The syntax is illustrated by the following:
Path INPUT1[, INPUT2...] => [PROCESSOR1 [=> PROCESSOR2...] =>] OUTPUT1[, OUTPUT2...]
971
NXLog User Guide Chapter 128. Configuration
nxlog.conf
1 <Input in1>
2 Module im_null
3 </Input>
4
5 <Input in2>
6 Module im_null
7 </Input>
8
9 <Processor p1>
10 Module pm_null
11 </Processor>
12
13 <Processor p2>
14 Module pm_null
15 </Processor>
16
17 <Output out1>
18 Module om_null
19 </Output>
20
21 <Output out2>
22 Module om_null
23 </Output>
24
25 <Route 1>
26 # Basic route
27 Path in1 => out1
28 </Route>
29
30 <Route 2>
31 # Complex route with multiple input/output/processor modules
32 Path in1, in2 => p1 => p2 => out1, out2
33 </Route>
Priority
This directive takes an integer value in the range of 1-100 as a parameter, and the default is 10. Log messages
in routes with a lower Priority value will be processed before others. Internally, this value is assigned to each
module part of the route. The events of the modules are processed in priority order by the NXLog engine.
Modules of a route with a lower Priority value (higher priority) will process log messages first.
972
Chapter 128. Configuration NXLog User Guide
This configuration prioritizes the UDP route over the TCP route in order to minimize loss of UDP Syslog
messages when the system is busy.
nxlog.conf
1 <Input tcpin>
2 Module im_tcp
3 Host localhost
4 Port 514
5 </Input>
6
7 <Input udpin>
8 Module im_udp
9 Host localhost
10 Port 514
11 </Input>
12
13 <Output tcpfile>
14 Module om_file
15 File "/var/log/tcp.log"
16 </Output>
17
18 <Output udpfile>
19 Module om_file
20 File "/var/log/udp.log"
21 </Output>
22
23 <Route udp>
24 Priority 1
25 Path udpin => udpfile
26 </Route>
27
28 <Route tcp>
29 Priority 2
30 Path tcpin => tcpfile
31 </Route>
973
NXLog User Guide Chapter 129. Language
Unknown
This is a special type for values where the type cannot be determined at compile time and for uninitialized
values. The undef literal and fields without a value also have an unknown type. The unknown type can also be
thought of as "any" in case of function and procedure API declarations.
Boolean
A boolean value is TRUE, FALSE or undefined. Note that an undefined value is not the same as a FALSE value.
Integer
An integer can hold a signed 64 bit value in addition to the undefined value. Floating point values are not
supported.
String
A string is an array of characters in any character set. The binary type should be used for values where the
NUL byte can also occur. An undefined string is not the same as an empty string. Strings have a limited length
to prevent resource exhaustion problems, this is a compile-time value currently set to 1M.
Datetime
A datetime holds a microsecond value of time elapsed since the Epoch. It is always stored in UTC/GMT.
IP Address
The ipaddr type can store IP addresses in an internal format. This type is used to store both dotted-quad IPv4
addresses (for example, 192.168.1.1) and IPv6 addresses (for example,
2001:0db8:85a3:0000:0000:8a2e:0370:7334).
Regular expression
A regular expression type can only be used with the =~ or !~ operators.
Binary
This type can hold an array of bytes.
Variadic arguments
This is a special type only used in function and procedure API declarations to indicate variadic arguments.
JSON string
A specific format of json-string.
JSON string is not yet a separate data type and is just a simple string. It was described
NOTE
separately to specify the string format.
JSON map
A specific format for json-string. Presents as an object description for specific json-array.
129.2. Expressions
129.2.1. Literals
974
Chapter 129. Language NXLog User Guide
Undef
The undef literal has an unknown type. It can be also used in an assignment to unset the value of a field.
1 $ProcessID = undef;
Boolean
A boolean literal is either TRUE or FALSE. It is case-insensitive, so True, False, true, and false are also valid.
Integer
An integer starts with a minus (-) sign if it is negative. A "0X" or "0x" prepended modifier indicates a
hexadecimal notation. The "K", "M" and "G" modifiers are also supported; these mean Kilo (1024), Mega
(1024^2), or Giga (1024^3) respectively when appended.
This statement uses a modifier to set the $Limit field to 44040192 (42×1024^2).
1 $Limit = 42M;
String
String literals are quoted characters using either single or double quotes. String literals specified with double
quotes can contain the following escape sequences.
\\
The backslash (\) character.
\"
The double quote (") character.
\n
Line feed (LF).
\r
Carriage return (CR).
\t
Horizontal tab.
\b
Audible bell.
\xXX
A single byte in the form of a two digit hexadecimal number. For example the line-feed character can also
be expressed as \x0A.
String literals in single quotes do not process the escape sequences: "\n" is a single
NOTE character (LF) while '\n' is two characters. The following comparison is FALSE for this
reason: "\n" == '\n'.
975
NXLog User Guide Chapter 129. Language
Extra care should be taken with the backslash when using double quoted string literals to
NOTE specify file paths on Windows. For more information about the possible complications,
see this note for the im_file File directive.
Datetime
A datetime literal is an unquoted representation of a time value expressing local time in the format of YYYY-
MM-DD hh:mm:ss.
This statement sets the $EventTime field to the specified datetime value.
IP Address
An IP address literal can be expressed in the form of a dotted quad notation for IPv4 (192.168.1.1) or by
using 8 colon-separated (:) groups of 16-bit hexadecimal values for IPv6
(2001:0db8:85a3:0000:0000:8a2e:0370:7334).
Regular expressions must be used with one of the =~ and !~ operators, and must be quoted with slashes (/) as in
Perl. Captured sub-strings are accessible through numeric reference, and the full subject string is placed into $0.
If the regular expression matches the $Message field, the log_info() procedure is executed. The captured
sub-string is used in the logged string ($1).
It is also possible to use named capturing such that the resulting field name is defined in the regular expression.
This statement causes the same behavior as the previous example, but it uses named capturing instead.
Substitution is supported with the s/// operator. Variables and captured sub-string references cannot be used
inside the regular expression or the substitution operator (they will be treated literally).
976
Chapter 129. Language NXLog User Guide
g
The /g modifier can be used for global replacement.
If any whitespace is found in the $SourceName field, it is replaced with underscores (_) and a log
message is generated.
s
The dot (.) normally matches any character except newline. The /s modifier causes the dot to match all
characters including line terminator characters (LF and CRLF).
The regular expression in this statement will match a message that begins and ends with the given
keywords, even if the message spans multiple lines.
m
The /m modifier can be used to treat the string as multiple lines (^ and $ match newlines within data).
i
The /i modifier does case insensitive matching.
129.2.3. Fields
See Fields for a list of fields provided by the NXLog core. Additional fields are available through input modules.
Fields are referenced in the NXLog language by prepending a dollar sign ($) to the field name.
Field names are case-insensitive. For example, the $SourceModuleName and $sourcemodulename field names
are equivalent.
Normally, a field name may contain letters, digits, the period (.), and the underscore (_). Additionally, field names
must begin with a letter or an underscore. The corresponding regular expression is:
[a-zA-Z_][a-zA-Z0-9._]*
However, those restrictions are relaxed if the field name is specified with curly braces ({}). In this case, the field
name may also contain hyphens (-), parentheses (()), and spaces. The field name may also begin with any one
of the allowed characters. The regular expression in this case is:
[a-zA-Z0-9._() -]+
977
NXLog User Guide Chapter 129. Language
This statement generates an internal log message indicating the time when the message was received by
NXLog.
This statement uses curly braces ({}) to refer to a field with a hyphenated name.
129.2.4. Operations
not
The not operator expects a boolean value. It will evaluate to undef if the value is undefined. If it receives an
unknown value which evaluates to a non-boolean, it will result in a run-time execution error.
defined
The defined operator will evaluate to TRUE if the operand is defined, otherwise FALSE.
If the $EventTime field has not been set (due perhaps to failed parsing), it will be set to the current time.
=~
This is the regular expression match operation as in Perl. This operation takes a string and a regular
expression operand and evaluates to a boolean value which will be TRUE if the regular expression matches
978
Chapter 129. Language NXLog User Guide
the subject string. Captured sub-strings are accessible through numeric reference (such as $1) and the full
subject string is placed into $0. Regular expression based string substitution is supported with the s///
operator. For more details, see Regular Expressions.
A log message will be generated if the $Message field matches the regular expression.
!~
This is the opposite of =~: the expression will evaluate to TRUE if the regular expression does not match on
the subject string. It can be also written as not LEFT_OPERAND =~ RIGHT_OPERAND. The s/// substitution
operator is supported.
A log message will be generated if the $Message field does not match the regular expression.
==
This operator compares two values for equality. Comparing a defined value with an undefined results in
undef.
!=
This operator compares two values for inequality. Comparing a defined value with an undefined results in
undef.
979
NXLog User Guide Chapter 129. Language
<
This operation will evaluate to TRUE if the left operand is less than the right operand, and FALSE otherwise.
Comparing a defined value with an undefined results in undef.
<=
This operation will evaluate to TRUE if the left operand is less than or equal to the right operand, and FALSE
otherwise. Comparing a defined value with an undefined results in undef.
>
This operation will evaluate to TRUE if the left operand is greater than the right operand, and FALSE
otherwise. Comparing a defined value with an undefined results in undef.
980
Chapter 129. Language NXLog User Guide
>=
This operation will evaluate to TRUE if the left operand is greater than or equal to the right operand, and
FALSE otherwise. Comparing a defined value with an undefined results in undef.
and
This operation evaluates to TRUE if and only if both operands are TRUE. The operation will evaluate to undef
if either operand is undefined.
A log message will be generated only if both $SeverityValue equals 1 and $FacilityValue equals 2.
or
This operation evaluates to TRUE if either operand is TRUE. The operation will evaluate to undef if both
operands are undefined.
+
This operation will result in an integer if both operands are integers. If either operand is a string, the result
will be a string where non-string typed values are converted to strings. In this case it acts as a concatenation
operator, like the dot (.) operator in Perl. Adding an undefined value to a non-string will result in undef.
981
NXLog User Guide Chapter 129. Language
• datetime + integer = datetime (Add the number of seconds in the right value to the datetime stored
in the left value.)
• integer + datetime = datetime (Add the number of seconds in the left value to the datetime stored
in the right value.)
-
Subtraction. The result will be undef if either operand is undefined.
• datetime - datetime = integer (Subtract two datetime types. The result is the difference between to
two expressed in microseconds.)
• datetime - integer = datetime (Subtract the number of seconds from the datetime stored in the left
value.)
*
Multiply an integer with another. The result will be undef if either operand is undefined.
/
Divide an integer with another. The result will be undef if either operand is undefined. Since the result is an
integer, a fractional part is lost.
982
Chapter 129. Language NXLog User Guide
%
The modulo operation divides an integer with another and returns the remainder. The result will be undef if
either operand is undefined.
IN
This operation will evaluate to TRUE if the left operand is equal to any of the expressions in the list on the
right, and FALSE otherwise. Comparing a undefined value results in undef.
Example 595. IN
A log message will be generated if $EventID is equal to any one of the values in the list.
NOT IN
This operation is equivalent to NOT expr IN expr_list.
A log message will be generated if $EventID is not equal to any of the values in the list.
The $Important field is set to TRUE if $SeverityValue is greater than 2, or FALSE otherwise.
129.2.5. Functions
See Functions for a list of functions provided by the NXLog core. Additional functions are available through
modules.
983
NXLog User Guide Chapter 129. Language
This statement uses the now() function to set the field to the current time.
1 $EventTime = now();
This statement calls the file_name() and file_size() functions of a defined om_file instance named out in
order to log the name and size of its currently open output file.
129.3. Statements
The following elements can be used in statements. There is no loop operation (for or while) in the NXLog
language.
129.3.1. Assignment
The assignment operation is declared with an equal sign (=). It loads the value from the expression evaluated on
the right into a field on the left.
This statement sets the $EventReceivedTime field to the value returned by the now() function.
1 $EventReceivedTime = now();
129.3.2. Block
A block consists of one or more statements within curly braces ({}). This is typically used with conditional
statements as in the example below.
129.3.3. Procedures
See Procedures for a list of procedures provided by the NXLog core. Additional procedures are available through
modules.
984
Chapter 129. Language NXLog User Guide
This statement calls the parse_csv() procedure of a defined xm_csv module instance named csv_parser.
1 csv_parser->parse_csv();
129.3.4. If-Else
A conditional statement starts with the if keyword followed by a boolean expression and a statement. The else
keyword, followed by another statement, is optional. Brackets around the expression are also optional.
Like Perl, the NXLog language does not have a switch statement. Instead, this can be accomplished by using
conditional if-else statements.
985
NXLog User Guide Chapter 129. Language
The generated log message various based on the value of the $value field.
1 if ( $value == 1 )
2 log_info("1");
3 else if ( $value == 2 )
4 log_info("2");
5 else if ( $value == 3 )
6 log_info("3");
7 else
8 log_info("default");
NOTE The Perl elsif and unless keywords are not supported.
129.4. Variables
A module variable can only be accessed from the same module instance where it was created. A variable is
referenced by a string value and can store a value of any type.
COUNT
Added values are aggregated, and the value of the counter is increased if only positive integers are added
until the counter is destroyed or indefinitely if the counter has no expiry.
COUNTMIN
This calculates the minimum value of the counter.
COUNTMAX
This calculates the maximum value of the counter.
AVG
This algorithm calculates the average over the specified interval.
AVGMIN
This algorithm calculates the average over the specified interval, and the value of the counter is always the
lowest which was ever calculated during the lifetime of the counter.
AVGMAX
Like AVGMIN, but this returns the highest value calculated during the lifetime of the counter.
RATE
This calculates the value over the specified interval. It can be used to calculate events per second (EPS) values.
RATEMIN
This calculates the value over the specified interval, and returns the lowest rate calculated during the lifetime
of the counter.
986
Chapter 129. Language NXLog User Guide
RATEMAX
Like RATEMIN, but this returns the highest rate calculated during the lifetime of the counter.
GRAD
This calculates the change of the rate of the counter over the specified interval, which is the gradient.
GRADMIN
This calculates the gradient and returns the lowest gradient calculated during the lifetime of the counter.
GRADMAX
Like GRADMIN, but this returns the highest gradient calculated during the lifetime of the counter.
129.6. Fields
The following fields are used by core.
129.7. Functions
The following functions are exported by core.
987
NXLog User Guide Chapter 129. Language
boolean dropped()
Return TRUE if the currently processed event has already been dropped.
integer get_rand()
Return a random integer value.
string get_uuid()
Return a UUID string.
988
Chapter 129. Language NXLog User Guide
ipaddr host_ip()
Return the first non-loopback IP address the hostname resolves to.
string hostname()
Return the hostname (short form).
string hostname_fqdn()
Return the FQDN hostname. This function will return the short form if the FQDN hostname cannot be
determined.
datetime now()
Return the current time.
989
NXLog User Guide Chapter 129. Language
string nxlog_version()
Return the NXLog version string.
RFC 1123
RFC 1123 compliant dates are also supported, including a couple others which are similar such as those
defined in RFC 822, RFC 850, and RFC 1036.
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sun, 06 Nov 94 08:49:37 GMT ; RFC 822
Sun, 6 Nov 94 08:49:37 GMT ; RFC 822
Sun, 6 Nov 94 08:49:37 GMT ; RFC 822
Sun, 06 Nov 94 08:49 GMT ; Unknown
Sun, 6 Nov 94 08:49 GMT ; Unknown
Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85]
Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85]
Mon, 7 Jan 2002 07:21:22 GMT ; Unknown [Postfix]
Sun, 06-Nov-1994 08:49:37 GMT ; RFC 850 with four digit years
The above formats are also recognized when the leading day of week and/or the timezone are omitted.
Apache/NCSA date
This format can be found in Apache access logs and other sources.
24/Aug/2009:16:08:57 +0200
990
Chapter 129. Language NXLog User Guide
1977-09-06 01:02:03
1977-09-06 01:02:03.004
1977-09-06T01:02:03.004Z
1977-09-06T01:02:03.004+02:00
2011-5-29 0:3:21
2011-5-29 0:3:21+02:00
2011-5-29 0:3:21.004
2011-5-29 0:3:21.004+02:00
Windows timestamps
20100426151354.537875
20100426151354.537875-000
20100426151354.537875000
3/13/2017 8:42:07 AM ; Microsoft DNS Server
Integer timestamp
This format is XXXXXXXXXX.USEC. The value is expressed as an integer showing the number of seconds
elapsed since the epoch UTC. The fractional microsecond part is optional.
1258531221.650359
1258531221
BIND9 timestamps
23-Mar-2017 06:38:30.143
23-Mar-2017 06:38:30
2017-Mar-23 06:38:30.143
2017-Mar-23 06:38:30
991
NXLog User Guide Chapter 129. Language
• YYYY-MM-DD hh:mm:ss,
• YYYY-MM-DDThh:mm:ssTZ,
• YYYY-MM-DDThh:mm:ss.sTZ,
• YYYY-MM-DD hh:mm:ssTZ,
• YYYY-MM-DD hh:mm:ss.sTZ,
• YYYY-MM-DDThh:mm:ssUTC,
• YYYY-MM-DDThh:mm:ss.sUTC,
• YYYY-MM-DD hh:mm:ssUTC,
• YYYY-MM-DD hh:mm:ss.sUTC, or
• a format string accepted by the C strftime() function (see the strftime(3) manual or the Windows strftime
reference for the format specification).
992
Chapter 129. Language NXLog User Guide
129.8. Procedures
The following procedures are exported by core.
add_to_route(string routename);
Copy the currently processed event data to the route specified. This procedure makes a copy of the data. The
original will be processed normally. Note that flow control is explicitly disabled when moving data with
add_to_route() and the data will not be added if the queue of the target module(s) is full.
The interval parameter is optional for COUNT type statistical counters. It is mandatory for all other types.
This procedure will do nothing if a counter with the specified name already exists.
create_stat(string statname, string type, integer interval, datetime time, integer lifetime);
Create a module statistical counter with the specified name to be calculated over interval seconds and the
time value specified in the time argument. The statistical counter will expire after lifetime seconds.
create_stat(string statname, string type, integer interval, datetime time, datetime expiry);
Create a module statistical counter with the specified name to be calculated over interval seconds and the
time value specified in the time argument. The statistical counter will expire at expiry.
create_var(string varname);
Create a module variable with the specified name. The variable will be created with an infinite lifetime.
993
NXLog User Guide Chapter 129. Language
delete(unknown arg);
Delete the field from the event. For example, delete($field). Note that $field = undef is not the same,
though after both operations the field will be undefined.
delete(string arg);
Delete the field from the event. For example, delete("field").
delete_all();
Delete all of the fields from the event except raw_event field.
delete_stat(string statname);
Delete a module statistical counter with the specified name. This procedure will do nothing if a counter with
the specified name does not exist (e.g. was already deleted).
delete_var(string varname);
Delete the module variable with the specified name if it exists.
drop();
Drop the event record that is currently being processed. Any further action on the event record will result in a
"missing record" error.
duplicate_guard();
Guard against event duplication.
module_restart();
Issue module_stop and then a module_start events for the calling module.
module_start();
Issue a module_start event for the calling module.
module_stop();
Issue a module_stop event for the calling module.
994
Chapter 129. Language NXLog User Guide
reroute(string routename);
Move the currently processed event data to the route specified. The event data will enter the route as if it was
received by an input module there. Note that flow control is explicitly disabled when moving data with
reroute() and the data will be dropped if the queue of the target module(s) is full.
sleep(integer interval);
Sleep the specified number of microseconds. This procedure is provided for testing purposes primarily. It can
be used as a poor man’s rate limiting tool, though this use is not recommended.
995
NXLog User Guide Chapter 130. Extension Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Note that although the module can both initiate and accept connections, the direction of the HTTP(S) requests is
always the same i.e. requests are sent to the module and it returns an HTTP(S) response.
130.1.1. Configuration
The xm_admin module accepts the following directives in addition to the common module directives.
Connect
This directive instructs the module to connect to a remote socket. The argument must be an IP address when
SocketType is set to TCP or SSL. Otherwise it must be a name of a socket for UDS. Connect cannot be used
together with the Listen directive. Multiple xm_admin instances may be configured if multiple administration
ports are required.
Listen
This directive instructs the module to accept connections. The argument must be an IP address when
SocketType is TCP or SSL. Otherwise it must be the name of a socket for UDS. Listen cannot be used together
with the Connect directive. Multiple xm_admin instances may be configured if multiple administration ports
are required. If neither Listen nor Connect are specified, the module will listen with SocketType TCP on
127.0.0.1.
Port
This specifies the port number used with the Listen or Connect modes. The default port is 8080.
ACL
This block defines directories which can be used with the GetFile and PutFile web service requests. The name
of the ACL is used in these requests together with the filename. The filename can contain only characters [a-
zA-Z0-9-._], so these file operations will only work within the specified directory. Example of usage is in the
Examples section.
AllowRead
If set to TRUE, GetFile requests are allowed.
996
Chapter 130. Extension Modules NXLog User Guide
AllowWrite
If set to TRUE, PutFile requests are allowed.
Directory
The name of the directory where the files are saved to or loaded from.
AllowIP
This optional directive can be used to specify an IP address or a network that is allowed to connect. The
directive can be specified more than once to add different IPs or networks to the whitelist. The following
formats can be used:
AllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE the remote host will be able to connect with unknown and self-signed certificates. The default
value is FALSE: all connections must present a trusted certificate. This directive is only valid if SocketType is
set to SSL.
CADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote socket. The certificate filenames in this directory must be in the OpenSSL
hashed format. This directive is only valid if SocketType is set to SSL. A remote host’s self-signed certificate
(which is not signed by a CA) can also be trusted by including a copy of the certificate in this directory.
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote socket. This directive is only valid if SocketType is set to SSL. To trust a self-signed certificate
presented by the remote (which is not signed by a CA), provide that certificate instead.
CAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is mutually exclusive with the CADir and CAFile directives.
CertFile
This specifies the path of the certificate file to be used for SSL connections. This directive is only valid if
SocketType is set to SSL.
CertKeyFile
This specifies the path of the certificate key file to be used for SSL connections. This directive is only valid if
SocketType is set to SSL.
CertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows and is mutually exclusive with the
CertFile and CertKeyFile.
997
NXLog User Guide Chapter 130. Extension Modules
CRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote socket. The certificate filenames in this directory must be in the
OpenSSL hashed format. This directive is only valid if SocketType is set to SSL.
CRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote socket. This directive is only valid if SocketType is set to SSL.
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is only valid if SocketType is set to SSL. This directive is not needed for password-less private keys.
Labels
This directive allows custom key value pairs to be defined with static or dynamic values. Labels are very useful
to provide supplementary details about agents, such as the display name, operating system, local contact
information and so on. Labels are returned as part of the response to a ServerInfo request.
Label values can be set statically by specifying a string, a defined constant, or an environment variable in the
<labels> block. They can also be set dynamically, for example at start-up with a script executed using the
include_stdout directive, or at run-time before each response is sent. Setting labels is demonstrated in the
Examples section.
Reconnect
This directive has been deprecated as of version 2.4. The module will try to reconnect automatically at
increasing intervals on all errors.
RequireCert
This boolean directive specifies that the remote host must present a certificate. If set to TRUE and a certificate
is not presented during the connection handshake, the connection will be refused. The default value is TRUE:
each connection must use a certificate. This directive is only valid if SocketType is set to SSL.
SocketType
This directive sets the connection type. It can be one of the following:
SSL
TLS/SSL for secure network connections
TCP
TCP, the default if SocketType is not explicitly specified
UDS
Unix domain socket
SSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
SSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the SSLProtocol directive is
set to TLSv1.3. Use the same format as in the SSLCipher directive.
SSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (compression is disabled).
998
Chapter 130. Extension Modules NXLog User Guide
Some Linux packages (for example, Debian) use the OpenSSL library and may not support
the zlib compression mechanism. The module will emit a warning on startup if the
NOTE
compression support is missing. The generic deb/RPM packages are bundled with a zlib-
enabled libssl library.
SSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols are allowed. Note that the OpenSSL library shipped by Linux distributions
may not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
GetFile
Download a file from the NXLog agent. This requires an ACL to be specified in the NXLog agent configuration.
GetFile requires the following parameters:
filetype
A value corresponding to the given-name of a defined ACL.
filename
The name of the file being requested.
GetLog
Download the log file from the NXLog agent. GetLog accepts the following parameters:
size
The amount of data to get in bytes. If the log file is bigger than the specified size, the last n bytes are
returned. When this parameter is not specified the entire log file is returned.
ModuleInfo
Request information about a module instance. ModuleInfo requires the following parameters:
name
The user-defined name of the module.
ModuleRestart
Restart a module instance. ModuleInfo requires the following parameters:
name
The user-defined name of the module.
ModuleStart
Start a module instance. ModuleStart requires the following parameters:
name
The user-defined name of the module.
ModuleStop
Stop a module instance. ModuleStop requires the following parameters:
999
NXLog User Guide Chapter 130. Extension Modules
name
The user-defined name of the module.
PutFile
Upload a file to the NXLog agent, such as a configuration file, certificate or certificate key, pattern database,
correlation rule file, etc. Using this method NXLog can be reconfigured from a remote host. PutFile requires
an ACL to be specified in the NXLog agent configuration. By default an NXLog agent installation defines two
ACLs in managed.conf, one named conf which allows reading and writing to its configuration directory, and
the other named cert which allows reading and writing to its certificates directory. The NXLog Manager uses
the conf and cert ACLs to reconfigure an agent remotely. PutFile requires the following parameters:
filetype
A value corresponding to the given-name of a defined ACL.
filename
The name of the file.
file
A string containing the content of the file.
ServerInfo
Request information about the server. This will also return info about all module instances.
ServerRestart
Restart all modules of the server.
ServerStart
Start all modules of the server, the opposite of ServerStop.
ServerStop
Stop all modules of the server. Note that the NXLog process will not exit, otherwise it would be impossible to
start it again remotely. Extension modules are not stopped for the same reason.
Refer to the Request - Response Format and Request - Response Examples sections below for examples of how
to use these methods.
1000
Chapter 130. Extension Modules NXLog User Guide
When using SOAP, the HTTP POST request must include the Content-Type HTTP header with the value set
as text/xml. The following is an example header:
POST / HTTP/1.1
Host: 192.168.1.123:8080
Content-Type: text/xml; charset=utf-8
Content-Length: nnn
The request details are added to the SOAP Body element and the XML needs to be sent in the body of the
POST request as raw data. The following is a SOAP request for ServerInfo.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:serverInfo xmlns:adm="http://log4ensics.com/2010/AdminInterface"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: nnnn
The response body will include the requested data in XML format as follows:
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:serverInfoReply xmlns:adm='http://log4ensics.com/2010/AdminInterface'>
<started>1607103334282303</started>
<load>0.2000</load>
<pid>15519</pid>
<mem>12709888</mem>
<version>5.1.6133</version>
<os>Linux</os>
<systeminfo>OS: Linux, Hostname: voyager, Release: 4.4.0-96-generic, Version: #119-Ubuntu
SMP Tue Sep 12 14:59:54 UTC 2017, Arch: x86_64, 4 CPU(s), 15.7Gb memory</systeminfo>
<hostname>voyager</hostname>
<servertime>1508405764586118</servertime>
<modules></modules>
<labels></labels>
</adm:serverInfoReply>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
1001
NXLog User Guide Chapter 130. Extension Modules
When using JSON, the HTTP POST request must include the Content-Type HTTP header with the value set
as application/json. The following is an example header:
POST / HTTP/1.1
Host: 192.168.1.123:8080
Content-Type: application/json; charset=utf-8
Content-Length: nnn
The request details need to be included in a JSON object with key name msg. This object should contain the
following key/values:
command
String value containing the name of the method being requested. This value is required.
params
JSON object containing the required parameters for the method being requested. May be omitted for
methods that do not require additional parameters.
The JSON object needs to be sent in the body of the POST request as raw data. The following is a JSON
request for ServerInfo.
{
"msg": {
"command": "serverInfo"
}
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: nnnn
The response body will include the requested data in JSON format as follows:
{
"response": "serverInfoReply",
"status": "success",
"data": {
"server-info": {
"started": 1607103334282303,
"load": 0.05999999865889549,
"pid": 15519,
"mem": 12742656,
"os": "Linux",
"version": "5.1.6133",
"systeminfo": "OS: Linux, Hostname: voyager, Release: 4.4.0-96-generic, Version: #119-
Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017, Arch: x86_64, 4 CPU(s), 15.7Gb memory",
"hostname": "voyager",
"servertime": 1508406647673758,
"modules": {},
"labels": {}
}
}
}
1002
Chapter 130. Extension Modules NXLog User Guide
For more SOAP and JSON request examples, see the Request - Response examples below.
The following is an example of a PutFile request using SOAP. The request creates a file on the agent called
test.txt in the location specified in the ACL named "temp".
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:putFile xmlns:adm="http://log4ensics.com/2010/AdminInterface">
<filetype>temp</filetype>
<filename>test.txt</filename>
<file>File Content
A newline
</file>
</adm:putFile>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:putFileReply xmlns:adm='http://log4ensics.com/2010/AdminInterface'/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
1003
NXLog User Guide Chapter 130. Extension Modules
The following is an example of a ModuleInfo request using SOAP. The request is being made for an om_file
module with the name output_file.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:moduleInfo xmlns:adm="http://log4ensics.com/2010/AdminInterface">
<name>output_file</name>
</adm:moduleInfo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:moduleInfoReply xmlns:adm='http://log4ensics.com/2010/AdminInterface'>
<module-name>output_file</module-name>
<evt-recvd>120</evt-recvd>
<evt-drop>0</evt-drop>
<evt-fwd>120</evt-fwd>
<queuesize>0</queuesize>
<queuelimit>100</queuelimit>
<batchsize>0</batchsize>
<status>3</status>
<module-type>3</module-type>
<module>om_file</module>
</adm:moduleInfoReply>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
1004
Chapter 130. Extension Modules NXLog User Guide
The following is an example of a GetLog request using SOAP. The request specifies that the last 240 bytes of
the log file should be returned.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:getLog xmlns:adm="http://log4ensics.com/2010/AdminInterface">
<size>200</size>
</adm:getLog>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<adm:getLogReply xmlns:adm='http://log4ensics.com/2010/AdminInterface'>
<logfile>p_listen] connection closed from 10.0.0.100:51701
2020-12-02 15:54:03
INFO [xm_admin|tcp_listen] connection accepted from 10.0.0.100:51705
2020-12-02 15:54:03
INFO [xm_admin|tcp_listen] getLog called
</logfile>
</adm:getLogReply>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The following is an example of a PutFile request using JSON. The request creates a file on the agent called
test.txt in the location specified in the ACL named "temp".
{
"msg": {
"command": "putFile",
"params": {
"filetype": "temp",
"filename": "test.txt",
"file": "File content\nA newline"
}
}
}
The file parameter needs to be a JSON escaped string, i.e. characters like newline, tab,
NOTE double quotes and backslash should be replaced with their corresponding escaped
sequence.
{
"response": "putFileReply",
"status": "success",
"data": {}
}
1005
NXLog User Guide Chapter 130. Extension Modules
The following is an example of a ModuleInfo request using JSON. The request is being made for an om_file
module with the name output_file.
{
"msg": {
"command": "moduleInfo",
"params": {
"name": "output_file"
}
}
}
{
"response": "moduleInfoReply",
"status": "success",
"data": {
"outfile": {
"module_name": "output_file",
"evt-recvd": 120,
"evt-drop": 0,
"evt-fwd": 120,
"queuesize": 0,
"queuelimit": 100,
"batchsize": 0,
"status": 3,
"module-type": 3,
"module": "om_file",
"variables": {}
}
}
}
1006
Chapter 130. Extension Modules NXLog User Guide
The following is an example of a GetLog request using JSON. The request specifies that the last 240 bytes of
the log file should be returned.
{
"msg": {
"command": "getLog",
"params": {
"size": 200
}
}
}
{
"response": "getLogReply",
"status": "success",
"data": {
"logfile": "p_listen] connection closed from 10.0.0.100:51705\n2020-12-02 15:54:17 INFO
[xm_admin|tcp_listen] connection accepted from 10.0.0.100:51706\n2020-12-02 15:54:17 INFO
[xm_admin|tcp_listen] getLog called\n"
}
}
This ACL is named "conf" and allows both GetFile and PutFile requests on the specified directory.
nxlog.conf
1 <ACL conf>
2 Directory /var/run/nxlog/configs
3 AllowRead TRUE
4 AllowWrite TRUE
5 </ACL>
1007
NXLog User Guide Chapter 130. Extension Modules
Static configuration is set with the define string, environment variable envvar, and describing key value
pairs inside the <labels> block.
Dynamic configuration is achieved via the start-up script of the include_stdout directive and run-time
function set with the host label.
nxlog.conf
1 define BASE /opt/nxlog_new
2 envvar NXLOG_OS
3
4 <Extension admin>
5 Module xm_admin
6 ...
7 <labels>
8 os_name "Debian"
9 agent_base %BASE%
10 os %NXLOG_OS%
11 include_stdout /path/to/labels.sh
12 host hostname_fqdn()
13 </labels>
14 </Extension>
1008
Chapter 130. Extension Modules NXLog User Guide
nxlog.conf (truncated)
1 <Extension ssl_connect>
2 Module xm_admin
3 Connect 192.168.1.1
4 Port 4041
5 SocketType SSL
6 CAFile %CERTDIR%/ca.pem
7 CertFile %CERTDIR%/client-cert.pem
8 CertKeyFile %CERTDIR%/client-key.pem
9 KeyPass secret
10 AllowUntrusted FALSE
11 RequireCert TRUE
12 Reconnect 60
13 <ACL conf>
14 Directory %CONFDIR%
15 AllowRead TRUE
16 AllowWrite TRUE
17 </ACL>
18 <ACL cert>
19 Directory %CERTDIR%
20 AllowRead TRUE
21 AllowWrite TRUE
22 </ACL>
23 </Extension>
24
25 <Extension tcp_listen>
26 Module xm_admin
27 Listen localhost
28 Port 8080
29 [...]
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.2.1. Configuration
The xm_aixaudit module accepts the following directive in addition to the common module directives.
EventsConfigFile
This optional directive contains the path to the file with a list of audit events. This file should contain events in
AuditEvent = FormatCommand format. The AuditEvent is a reference to the audit object which is defined
under the /etc/security/audit/objects path. The FormatCommand defines the auditpr output for the
object. For more information, see the The Audit Subsystem in AIX section on the IBM website.
1009
NXLog User Guide Chapter 130. Extension Modules
130.2.2. Fields
The following fields are used by xm_aixaudit.
130.2.3. Examples
1010
Chapter 130. Extension Modules NXLog User Guide
This configuration reads AIX audit logs from file and parses them with the InputType registered by
xm_aixaudit.
nxlog.conf
1 <Extension aixaudit>
2 Module xm_aixaudit
3 EventsConfigFile modules/extension/aixaudit/events
4 </Extension>
5
6 <Input in>
7 Module im_file
8 File "/audit/audit3.bin"
9 InputType aixaudit
10 ReadFromLast FALSE
11 Exec delete($EventReceivedTime);
12 Exec delete($Login);
13 Exec delete($WPARname);
14 Exec delete($Real);
15 Exec to_json();
16 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.3.1. Configuration
The xm_asl module accepts only the common module directives.
130.3.2. Fields
The following fields are used by xm_asl.
1011
NXLog User Guide Chapter 130. Extension Modules
0/EMERGENCY 5/CRITICAL
1/ALERT 5/CRITICAL
2/CRITICAL 5/CRITICAL
3/ERROR 4/ERROR
4/WARNING 3/WARNING
5/NOTICE 2/INFO
6/INFO 2/INFO
7/DEBUG 1/DEBUG
130.3.3. Examples
1012
Chapter 130. Extension Modules NXLog User Guide
This example uses an im_file module instance to read an ASL log file and the InputType provided by xm_asl
to parse the events. The various Fields are added to the event record.
nxlog.conf
1 <Extension asl_parser>
2 Module xm_asl
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File "tmp/input.asl"
8 InputType asl_parser
9 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
On Solaris, the device file is not available and the BSM log files must be read and parsed with im_file and
xm_bsm as shown in the example below.
To properly read BSM Audit Logs from a device file, such as /dev/auditpipe, the im_bsm
WARNING module must be used. Do not use the xm_bsm module in combination with im_file to read
BSM logs from a device file.
130.4.1. Setup
For information about setting up BSM Auditing, see the corresponding documentation:
130.4.2. Configuration
The xm_bsm module accepts the following directives in addition to the common module directives.
EventFile
This optional directive can be used to specify the path to the audit event database containing a mapping
between event names and numeric identifiers. The default location is /etc/security/audit_event which is
used when the directive is not specified.
1013
NXLog User Guide Chapter 130. Extension Modules
130.4.3. Fields
The following fields are used by xm_bsm.
1014
Chapter 130. Extension Modules NXLog User Guide
1015
NXLog User Guide Chapter 130. Extension Modules
1016
Chapter 130. Extension Modules NXLog User Guide
1017
NXLog User Guide Chapter 130. Extension Modules
130.4.4. Examples
1018
Chapter 130. Extension Modules NXLog User Guide
This configuration reads BSM audit logs from file and parses them with the InputType registered by
xm_bsm.
nxlog.conf
1 <Extension bsm_parser>
2 Module xm_bsm
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File '/var/audit/*'
8 InputType bsm_parser
9 </Input>
CEF uses Syslog as a transport. For this reason the xm_syslog module must be used in
NOTE conjunction with xm_cef in order to parse or generate the additional Syslog header, unless the
CEF data is used without Syslog. See examples for both cases below.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.5.1. Configuration
The xm_cef module accepts the following directive in addition to the common module directives.
IncludeHiddenFields
This boolean directive specifies that the to_cef() function or the to_cef() procedure should inlude fields having
a leading dot (.) or underscore (_) in their names. The default is TRUE. If IncludeHiddenFields is set to TRUE,
then generated CEF text will contain these otherwise excluded fields as extension fields.
130.5.2. Functions
The following functions are exported by xm_cef.
string to_cef()
Convert the specified fields to a single CEF formatted string.
Note that directive IncludeHiddenFields has an effect on extension fields in the output.
130.5.3. Procedures
The following procedures are exported by xm_cef.
parse_cef();
Parse the $raw_event field as CEF input.
1019
NXLog User Guide Chapter 130. Extension Modules
parse_cef(string source);
Parse the given string as CEF format.
to_cef();
Format the specified fields as CEF and put this into the $raw_event field. The CEF header fields can be
overridden by values contained in the following NXLog fields: $CEFVersion, $CEFDeviceVendor,
$CEFDeviceProduct, $CEFDeviceVersion, $CEFSignatureID, $CEFName, and $CEFSeverity.
Note that directive IncludeHiddenFields has an effect on extension fields in the output.
130.5.4. Fields
The following fields are used by xm_cef.
In addition to the fields listed below, the parse_cef() procedure will create a field for every key-value pair
contained in the Extension CEF field, such as $act, $cnt, $dhost, etc.
This field takes the value of the Severity CEF header field.
130.5.5. Examples
1020
Chapter 130. Extension Modules NXLog User Guide
Example 620. Sending Windows Event Log events formatted in CEF over UDP
This configuration collects both Windows Event Log and NXLog internal messages, converts them to CEF
with Syslog headers, and forwards the logs via UDP.
nxlog.conf
1 <Extension cef>
2 Module xm_cef
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input internal>
10 Module im_internal
11 </Input>
12
13 <Input eventlog>
14 Module im_msvistalog
15 </Input>
16
17 <Output udp_output>
18 Module om_udp
19 Host 192.168.168.2:1514
20 Exec $Message = to_cef(); to_syslog_bsd();
21 </Output>
The following configuration receives CEF logs over UDP and converts the parsed data into JSON.
nxlog.conf
1 <Extension cef>
2 Module xm_cef
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Extension json>
10 Module xm_json
11 </Extension>
12
13 <Input udp_input>
14 Module im_udp
15 ListenAddr 0.0.0.0:1514
16 Exec parse_syslog(); parse_cef($Message);
17 </Input>
18
19 <Output file_output>
20 Module om_file
21 File "cef2json.log"
22 Exec to_json();
23 </Output>
1021
NXLog User Guide Chapter 130. Extension Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.6.1. Configuration
The xm_charconv module accepts the following directives in addition to the common module directives.
AutodetectCharsets
This optional directive accepts a comma-separated list of character set names. When auto is specified as the
source encoding for convert() or convert_fields(), these character sets will be tried for conversion. This
directive is not related to the LineReader directive or the corresponding InputType registered when
LineReader is specified.
BigEndian
This optional boolean directive specifies the endianness to use during the encoding conversion. If this
directive is not specified, it defaults to the host’s endianness. This directive only affects the registered
InputType, and is only applicable if the LineReader directive is set to a non-Unicode encoding and the
CharBytes directive is set to 2 or 4.
CharBytes
This optional integer directive specifies the byte-width of the encoding to use during conversion. Accepted
values are 1 (the default), 2, and 4. Most variable width encodings will work with the default value. This
directive only affects the registered InputType and is only applicable if the LineReader directive is set to a
non-Unicode encoding.
LineReader
If this optional directive is specified with an encoding, an InputType will be registered using the name of the
xm_charconv module instance. The following Unicode encodings are supported: UTF-8, UCS-2, UCS-2BE, UCS-
2LE, UCS-4, UCS-4BE, UCS-4LE, UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, and UTF-7. For
other encodings, it may be necessary to also set the BigEndian and/or CharBytes directives.
130.6.2. Functions
The following functions are exported by xm_charconv.
130.6.3. Procedures
The following procedures are exported by xm_charconv.
1022
Chapter 130. Extension Modules NXLog User Guide
130.6.4. Examples
Example 622. Character set auto-detection of various input encodings
This configuration shows an example of character set auto-detection. The input file can contain lines with
different encodings, and the module normalizes output to UTF-8.
nxlog.conf
1 <Extension converter>
2 Module xm_charconv
3 AutodetectCharsets utf-8, euc-jp, utf-16, utf-32, iso8859-2
4 </Extension>
5
6 <Input filein>
7 Module im_file
8 File "tmp/input"
9 Exec convert_fields("auto", "utf-8");
10 </Input>
This configuration uses the InputType registered via the LineReader directive to read a file with the ISO-
8859-2 encoding.
nxlog.conf
1 <Extension converter>
2 Module xm_charconv
3 LineReader ISO-8859-2
4 </Extension>
5
6 <Input filein>
7 Module im_file
8 File "tmp/input/iso-8859-2.in"
9 InputType converter
10 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The pm_transformer module provides a simple interface to parse and generate CSV format, but the xm_csv
module exports an API that can be used to solve more complex tasks involving CSV-formatted data.
It is possible to use more than one xm_csv module instance with different options in order to
support different CSV formats in the same configuration file. For this reason, functions and
NOTE
procedures exported by this module are public and must be referenced by the module instance
name.
1023
NXLog User Guide Chapter 130. Extension Modules
130.7.1. Configuration
The xm_csv module accepts the following directives in addition to the common module directives. The Fields
directive is required.
Fields
This mandatory directive accepts a comma-separated list of fields which will be populated when parsing the
input data. Field names with or without the dollar sign ($) are accepted. The fields will be stored as strings
unless their types are explicitly specified with the FieldTypes directive.
Delimiter
This optional directive specifies the character to be used as the delimiter to separate fields. See the section
on Specifying Delimiter Characters for more information. The default delimiter character is the comma (,).
Note that there should not be a delimiter after the last field.
EscapeChar
This optional directive specifies the character to be used to escape special characters. See the section on
Specifying Escape Characters for more information. The escape character is used to prefix the following
characters: the escape character itself, the quote character, and the delimiter character. If EscapeControl is
TRUE, the newline (\n), carriage return (\r), tab (\t), and backspace (\b) control characters are also escaped.
The default escape character is the backslash character (\).
EscapeControl
If this optional boolean directive is set to TRUE, control characters are also escaped. See the EscapeChar
directive for details. The default is TRUE: control characters are escaped. Note that this is necessary to allow
single line CSV field lists which contain line-breaks.
FieldTypes
This optional directive specifies a list of field types corresponding to the field names defined in the Fields
directive. If specified it must match the same number of fields. If this directive is omitted, all fields will be
stored as strings. This directive has no effect on the fields-to-CSV conversion.
QuoteChar
This optional directive specifies the character to be used to quote/enclose fields. See the section on
Specifying Quote Characters for more information. If QuoteOptional is TRUE, then only string type fields are
quoted. The default is the double-quote character (").
QuoteMethod
This optional directive accepts the following values:
All
All fields will be quoted.
None
None of the fields will be quoted. This can be problematic if a field value, which is typically text that can
contain any character, contains the delimiter character. When using this option, make sure that if the
delimiter is found in the field value it is escaped or replaced with another character.
String
Only string type fields will be quoted. This has the same effect as QuoteOptional set to TRUE and is the
default behavior if the QuoteMethod directive is not specified.
Note that this directive only effects CSV generation when using to_csv(). The CSV parser can automatically
detect the quotation.
1024
Chapter 130. Extension Modules NXLog User Guide
QuoteOptional
This directive has been deprecated in favor of QuoteMethod, which should be used instead.
StrictMode
If this optional boolean directive is set to TRUE, the CSV parser will fail to parse CSV lines that do not contain
the required number of fields. When this is set to FALSE and the input contains fewer fields than specified in
the Fields directive, the rest of the fields will be unset. The default value is FALSE.
UndefValue
This optional directive specifies a string which will be treated as an undefined value. This is particularly useful
when parsing the W3C format where the dash (-) marks an omitted field.
Delimiter ;
Control characters
The following non-printable characters can be specified with escape sequences:
\a
audible alert (bell)
\b
backspace
\t
horizontal tab
\n
newline
\v
vertical tab
\f
formfeed
\r
carriage return
Delimiter \t
1025
NXLog User Guide Chapter 130. Extension Modules
Delimiter ';'
Delimiter '\'
Delimiter "\"
Delimiter 0x20
130.7.2. Functions
The following functions are exported by xm_csv.
string to_csv()
Convert the specified fields to a single CSV formatted string.
130.7.3. Procedures
The following procedures are exported by xm_csv.
parse_csv();
Parse the $raw_event field as CSV input.
parse_csv(string source);
Parse the given string as CSV format.
to_csv();
Format the specified fields as CSV and put this into the $raw_event field.
130.7.4. Examples
1026
Chapter 130. Extension Modules NXLog User Guide
This example shows that the xm_csv module can not only parse and create CSV formatted input and output,
but with multiple xm_csv module instances it is also possible to reorder, add, remove, or modify fields to
output data in a different CSV format.
nxlog.conf
1 <Extension csv1>
2 Module xm_csv
3 Fields $id, $name, $number
4 FieldTypes integer, string, integer
5 Delimiter ,
6 </Extension>
7
8 <Extension csv2>
9 Module xm_csv
10 Fields $id, $number, $name, $date
11 Delimiter ;
12 </Extension>
13
14 <Input in>
15 Module im_file
16 File "tmp/input"
17 <Exec>
18 csv1->parse_csv();
19 $date = now();
20 if not defined $number $number = 0;
21 csv2->to_csv();
22 </Exec>
23 </Input>
24
25 <Output out>
26 Module om_file
27 File "tmp/output"
28 </Output>
Input Sample
1,"John K.",42
2,"Joe F.",43
Output Sample
1;42;"John K.";2011-01-15 23:45:20
2;43;"Joe F.";2011-01-15 23:45:20
130.8.1. Configuration
The xm_crypto module accepts the following directives in addition to the common module directives.
1027
NXLog User Guide Chapter 130. Extension Modules
Password
This optional directive specifies a password to be used by the aes_encrypt and aes_decrypt data converters
while processing data. This directive is mutually exclusive with the PasswordFile directive.
PasswordFile
This optional directive specifies a path to a file which stores the password to be used by the aes_encrypt and
aes_decrypt data converters while processing data. This directive is mutually exclusive with the Password
directive.
UseSalt
This optional Boolean directive specifies whether to use a randomly-generated combination of characters for
encryption and decryption. The default value is TRUE.
Iter
This optional directive enhances security by enabling the PBKDF2 algorithm and setting the iteration count
during the key generation. For more details, see the EVP_BytesToKey section on the OpenSSL website. The
default value is 0.
<InstanceName>.<DataConverterName>
Where <InstanceName> is the given name of the xm_crypto instance and <DataConverterName> is the name of
the converter being invoked.
The following data converters are available to encrypt and decrypt log data.
aes_encrypt
This data converter is used to encrypt log data. It should be specified in the OutputType directive after the
output writer function. The encrypted result is similar to running the following OpenSSL command:
openssl enc -aes256 -md sha256 -pass pass:password -in input_filename -out output_encrypted_filename
Rotation of files is done automatically when encrypting log data with the aes_encrypt data
NOTE converter. The rotation pattern is original_file -→ original_file.1 -→
original_file.2 -→ original_file.n. There is no built-in removal or cleanup of files.
aes_decrypt
This data converter is used to decrypt log data. It should be specified in the InputType directive before the
input reader function. The decrypted result is similar to running the following OpenSSL command:
openssl enc -aes256 -d -md sha256 -pass pass:password -in encrypted_filename -out
output_decrypted_filename
130.8.3. Examples
The examples below describe various ways of processing logs with the xm_crypto module.
1028
Chapter 130. Extension Modules NXLog User Guide
The following configuration uses the im_file module to read log messages. The aes_encrypt data converter
encrypts data at the output and saves the results to a file.
nxlog.conf
1 <Extension cryptography>
2 Module xm_crypto
3 Password <PASSWORD>
4 </Extension>
5
6 <Input input_file>
7 Module im_file
8 File '/tmp/input'
9 </Input>
10
11 <Output output_file>
12 Module om_file
13 File '/tmp/output'
14 OutputType LineBased, cryptography.aes_encrypt
15 </Output>
The following configuration uses the aes_decrypt data converter to decrypt log messages at the input. The
result is saved to a file.
nxlog.conf
1 <Extension cryptography>
2 Module xm_crypto
3 UseSalt TRUE
4 PasswordFile /path/to/passwordfile
5 </Extension>
6
7 <Input input_file>
8 Module im_file
9 File '/tmp/input'
10 InputType cryptography.aes_decrypt, LineBased
11 </Input>
12
13 <Output output_file>
14 Module om_file
15 File '/tmp/output'
16 </Output>
1029
NXLog User Guide Chapter 130. Extension Modules
The configuration below uses the aes_decrypt data converter to decrypt input data. The Exec directive in
the input instance runs the to_syslog_ietf() procedure to convert messages to the IETF Syslog format. The
result is encrypted with the aes_encrypt converter in the output instance and saved to a file.
1 <Extension cryptography>
2 Module xm_crypto
3 UseSalt TRUE
4 PasswordFile /path/to/passwordfile
5 </Extension>
6
7 <Extension syslog>
8 Module xm_syslog
9 </Extension>
10
11 <Input input_file>
12 Module im_file
13 File '/tmp/input'
14 InputType cryptography.aes_decrypt, LineBased
15 Exec to_syslog_ietf();
16 </Input>
17
18 <Output output_file>
19 Module om_file
20 File '/tmp/output'
21 OutputType LineBased, cryptography.aes_encrypt
22 </Output>
Data conversion operations can be chained together to create a workflow. For example, the xm_zlib module
functionality can be combined with the xm_crypto module to perform compression and encryption operations on
log files.
Data converters are processed sequentially from left to right, thus the order that they are specified in is
important. When specifying data converters, decryption should always occur before decompression in input
instances, while compression should always precede encryption in output instances, as illustrated in the
following table.
Compression +
Encryption OutputType LineBased compress aes_encrypt
Decompression +
Decryption InputType aes_decrypt decompress LineBased
1030
Chapter 130. Extension Modules NXLog User Guide
The configuration below processes a zlib-compressed and encrypted log file. The input instance decrypts
the file using the aes_decrypt converter of the xm_crypto module, and then decompresses it using the
decompress converter of the xm_zlib module. Each log record is processed and if it contains the info string
it is passed on to the output instance.
The processed log data is written to a file by the output instance. The data is compressed using the
compress converter and finally encrypted using the aes_encrypt converter.
1 <Extension zlib>
2 Module xm_zlib
3 Format zlib
4 CompressionLevel 9
5 CompBufSize 16384
6 DecompBufSize 16384
7 </Extension>
8
9 <Extension cryptography>
10 Module xm_crypto
11 UseSalt TRUE
12 Password <PASSWORD>
13 </Extension>
14
15 <Input input_file>
16 Module im_file
17 File '/tmp/input'
18 InputType cryptography.aes_decrypt, zlib.decompress, LineBased
19 Exec if not ($raw_event =~ /info/) drop();
20 </Input>
21
22 <Output output_file>
23 Module om_file
24 File '/tmp/output'
25 OutputType LineBased, zlib.compress, cryptography.aes_encrypt
26 </Output>
For more information and examples on combined data conversion operations see the topic on Compression and
Encryption.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The im_exec and om_exec modules also provide support for running external programs, though
the purpose of these is to pipe data to and read data from programs. The procedures provided
NOTE
by the xm_exec module do not pipe log message data but are intended for multiple invocations.
Data can still be passed to the executed script/program as command line arguments.
1031
NXLog User Guide Chapter 130. Extension Modules
130.9.1. Configuration
The xm_exec module accepts only the common module directives.
130.9.2. Functions
The following functions are exported by xm_exec.
130.9.3. Procedures
The following procedures are exported by xm_exec.
130.9.4. Examples
Example 629. NXLog Acting as a Cron Daemon
This xm_exec module instance will run the command every second without waiting for it to terminate.
nxlog.conf
1 <Extension exec>
2 Module xm_exec
3 <Schedule>
4 Every 1 sec
5 Exec exec_async("/bin/true");
6 </Schedule>
7 </Extension>
1032
Chapter 130. Extension Modules NXLog User Guide
If the $raw_event field matches the regular expression, an email will be sent.
nxlog.conf
1 <Extension exec>
2 Module xm_exec
3 </Extension>
4
5 <Input tcp>
6 Module im_tcp
7 ListenAddr 0.0.0.0:1514
8 <Exec>
9 if $raw_event =~ /alertcondition/
10 {
11 exec_async("/bin/sh", "-c", 'echo "' + $Hostname +
12 '\n\nRawEvent:\n' + $raw_event +
13 '"|/usr/bin/mail -a "Content-Type: text/plain; charset=UTF-8" -s "ALERT" ' +
14 'user@domain.com');
15 }
16 </Exec>
17 </Input>
18
19 <Output file>
20 Module om_file
21 File "/var/log/messages"
22 </Output>
23
24 <Route tcp_to_file>
25 Path tcp => file
26 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.10.1. Configuration
The xm_filelist module accepts the following directives in addition to the common module directives. The File
directive is required.
File
The mandatory File directive specifies the path to the file that will be read into memory. This directive may be
specified more than once if multiple files need to be loaded.
1033
NXLog User Guide Chapter 130. Extension Modules
CheckInterval
This optional directive specifies the frequency with which the files are checked for modifications, in seconds.
The default value is 5 seconds. File checks are disabled if CheckInterval is set to 0.
130.10.2. Functions
The following functions are exported by xm_filelist.
130.10.3. Examples
Example 631. Dropping Events From Whitelisted Hosts
The following configuration loads a list of whitelisted hostnames using the xm_filelist module. The input
instance processes Syslog messages and uses the matches function to check if the $Hostname field is found
in the loaded list. If it is, the record is discarded using the drop procedure.
<Extension hosts_list>
Module xm_filelist
File /path/to/hosts/whitelist
</Extension>
<Input in>
Module im_file
File '/path/to/log/file'
Exec parse_syslog();
Exec if hosts_list->matches($Hostname, TRUE) drop();
</Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1034
Chapter 130. Extension Modules NXLog User Guide
Rotating, renaming, or removing the file written by om_file is also supported with the help of the
NOTE
om_file reopen() procedure.
130.11.1. Configuration
The xm_fileop module accepts only the common module directives.
130.11.2. Functions
The following functions are exported by xm_fileop.
string dir_temp_get()
Return the name of a directory suitable as a temporary storage location.
1035
NXLog User Guide Chapter 130. Extension Modules
130.11.3. Procedures
The following procedures are exported by xm_fileop.
dir_make(string path);
Create a directory recursively (like mkdir -p). It succeeds if the directory already exists. An error is logged if
the operation fails.
dir_remove(string file);
Remove the directory from the filesystem.
file_cycle(string file);
Do a cyclic rotation on file. The file will be moved to "file.1". If "file.1" already exists it will be moved to "file.2",
and so on. Wildcards are supported in the file path and filename. The backslash (\) must be escaped if used
as the directory separator with wildcards (for example, C:\\test\\*.log). This procedure will reopen the
LogFile if it is cycled. An error is logged if the operation fails.
file_remove(string file);
Remove file. It is possible to specify a wildcard in the filename (but not in the path). The backslash (\) must be
escaped if used as the directory separator with wildcards (for example, C:\\test\\*.log). This procedure
will reopen the LogFile if it is removed. An error is logged if the operation fails.
1036
Chapter 130. Extension Modules NXLog User Guide
file_touch(string file);
Update the last modification time of file or create the file if it does not exist. An error is logged if the operation
fails.
file_truncate(string file);
Truncate file to zero length. If the file does not exist, it will be created. An error is logged if the operation fails.
130.11.4. Examples
Example 632. Rotation of the Internal LogFile
In this example, the internal log file is rotated based on time and size.
nxlog.conf
1 #define LOGFILE C:\Program Files (x86)\nxlog\data\nxlog.log
2 define LOGFILE /var/log/nxlog/nxlog.log
3
4 <Extension fileop>
5 Module xm_fileop
6
7 # Check the log file size every hour and rotate if larger than 1 MB
8 <Schedule>
9 Every 1 hour
10 Exec if (file_size('%LOGFILE%') >= 1M) \
11 file_cycle('%LOGFILE%', 2);
12 </Schedule>
13
14 # Rotate log file every week on Sunday at midnight
15 <Schedule>
16 When @weekly
17 Exec file_cycle('%LOGFILE%', 2);
18 </Schedule>
19 </Extension>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Unlike Syslog format (with Snare Agent, for example), the GELF format contains structured data in JSON so that
1037
NXLog User Guide Chapter 130. Extension Modules
the fields are available for analysis. This is especially convenient with sources such as the Windows EventLog
which already generate logs in a structured format.
The xm_gelf module provides the following reader and writer functions.
InputType GELF_TCP
This input reader generates GELF for use with TCP (use with the im_tcp input module).
InputType GELF_UDP
This input reader generates GELF for use with UDP (use with the im_udp input module).
InputType GELF
This type is equivalent to the GELF_UDP reader.
OutputType GELF_TCP
This output writer generates GELF for use with TCP (use with the om_tcp output module).
OutputType GELF_UDP
This output writer generates GELF for use with UDP (use with the om_udp output module).
OutputType GELF
This type is equivalent to the GELF_UDP writer.
Configuring NXLog to process GELF input or output requires loading the xm_gelf extension module and then
setting the corresponding InputType or OutputType in the Input or Output module instance. See the examples
below.
The GELF output generated by this module includes all fields, except for the $raw_event field and any field
having a leading dot (.) or underscore (_).
130.12.1. Configuration
The xm_gelf module accepts the following directives in addition to the common module directives.
IncludeHiddenFields
This boolean directive specifies that the GELF output should include fields having a leading dot (.) or
underscore (_) in their names. The default is TRUE. If IncludeHiddenFields is set to TRUE, then the generated
GELF JSON will contain these otherwise excluded fields. In this case field name _fld1 will become __fld1 and
.fld2 will become _.fld2 in GELF JSON.
ShortMessageLength
This optional directive can be used to specify the length of the short_message field for the GELF output writers.
This defaults to 64 if the directive is not explicitly specified. If the field short_message or ShortMessage is
present, it will not be truncated.
UseNullDelimiter
If this optional boolean directive is TRUE, the GELF_TCP output writer will use the NUL delimiter. If this
directive is FALSE, it will use the newline delimiter. The default is TRUE.
130.12.2. Fields
The following fields are used by xm_gelf.
In addition to the fields listed below, if the GELF input contains custom user fields (those prefixed with the
character), those fields will be available without the prefix. For example, the GELF record
1038
Chapter 130. Extension Modules NXLog User Guide
{"_foo": "bar"} will generate the field $foo containing the value "bar".
130.12.3. Examples
Example 633. Parsing GELF Logs Collected via TCP
This configuration uses the im_tcp module to collect logs over TCP port 12201 and the xm_gelf module to
parse them.
nxlog.conf
1 <Extension gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input tcpin>
6 Module im_tcp
7 ListenAddr 0.0.0.0:12001
8 InputType GELF_TCP
9 </Input>
1039
NXLog User Guide Chapter 130. Extension Modules
The following configuration reads the Windows EventLog and sends it to a Graylog2 server in GELF format.
nxlog.conf
1 <Extension gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input eventlog>
6 # Use 'im_mseventlog' for Windows XP, 2000 and 2003
7 Module im_msvistalog
8 # Uncomment the following to collect specific event logs only
9 # but make sure not to leave any `#` as only <!-- --> style comments
10 # are supported inside the XML.
11 #Query <QueryList>\
12 # <Query Id="0">\
13 # <Select Path="Application">*</Select>\
14 # <Select Path="System">*</Select>\
15 # <Select Path="Security">*</Select>\
16 # </Query>\
17 # </QueryList>
18 </Input>
19
20 <Output udp>
21 Module om_udp
22 Host 192.168.1.1:12201
23 OutputType GELF_UDP
24 </Output>
25
26 <Route eventlog_to_udp>
27 Path eventlog => udp
28 </Route>
1040
Chapter 130. Extension Modules NXLog User Guide
In this example, custom application logs are collected and sent out in GELF, with custom fields set to make
the data more useful for the receiver.
nxlog.conf (truncated)
1 <Extension gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Input file>
6 Module im_file
7 File "/var/log/app*.log"
8
9 <Exec>
10 # Set the $EventTime field usually found in the logs by
11 # extracting it with a regexp. If this is not set, the current
12 # system time will be used which might be a little off.
13 if $raw_event =~ /(\d\d\d\d\-\d\d-\d\d \d\d:\d\d:\d\d)/
14 $EventTime = parsedate($1);
15
16 # Explicitly set the Hostname. This defaults to the system's
17 # hostname if unset.
18 $Hostname = 'myhost';
19
20 # Now set the severity level to something custom. This defaults
21 # to 'INFO' if unset. We can use the following numeric values
22 # here which are the standard Syslog values: ALERT: 1, CRITICAL:
23 # 2, ERROR: 3, WARNING: 4, NOTICE: 5, INFO: 6, DEBUG: 7
24 if $raw_event =~ /ERROR/ $SyslogSeverityValue = 3;
25 else $SyslogSeverityValue = 6;
26
27 # Set a field to contain the name of the source file
28 $FileName = file_name();
29 [...]
1041
NXLog User Guide Chapter 130. Extension Modules
With this configuration, NXLog will read a CSV file containing three fields and forward the data in GELF so
that the fields will be available on the server.
nxlog.conf
1 <Extension gelf>
2 Module xm_gelf
3 </Extension>
4
5 <Extension csv>
6 Module xm_csv
7 Fields $name, $number, $location
8 FieldTypes string, integer, string
9 Delimiter ,
10 </Extension>
11
12 <Input file>
13 Module im_file
14 File "/var/log/app/csv.log"
15 Exec csv->parse_csv();
16 </Input>
17
18 <Output udp>
19 Module om_udp
20 Host 192.168.1.1:12201
21 OutputType GELF_UDP
22 </Output>
23
24 <Route csv_to_gelf>
25 Path file => udp
26 </Route>
130.13. Go (xm_go)
This module provides support for processing NXLog log data with methods written in the Go language. The file
specified by the ImportLib directive should contain one or more methods which can be called from the Exec
directive of any module. See also the im_go and om_go modules.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
For the system requirements, installation details and environmental configuration requirements
NOTE of Go, see the Getting Started section in the Go documentation. The Go environment is only
needed for compiling the Go file. NXLog does not need the Go environment for its operation.
The Go script imports the NXLog module, and will have access to the following classes and functions.
class nxModule
This class is instantiated by NXLog and can be accessed via the nxLogdata.module attribute. This can be used
to set or access variables associated with the module (see the example below).
nxmodule.NxLogdataNew(*nxLogdata)
This function creates a new log data record.
1042
Chapter 130. Extension Modules NXLog User Guide
nxmodule.Post(ld *nxLogdata)
This function puts log data struct for further processing.
nxmodule.AddEvent()
This function adds a READ event to NXLog and allows to call it later.
nxmodule.AddEventDelayed(mSec C.int)
This function adds a delayed READ event to NXLog and allows to call it later.
class nxLogdata
This class represents an event. It is instantiated by NXLog and passed to the method specified by the go_call()
function.
nxlogdata.Delete(field string)
This function removes the field from logdata.
nxlogdata.Fields() []string
This function returns an array of fields names in the logdata record.
module
This attribute is set to the module object associated with the event.
130.13.3. Configuration
The xm_go module accepts the following directives in addition to the common module directives.
1043
NXLog User Guide Chapter 130. Extension Modules
ImportLib
This mandatory directive specifies the file containing the Go code compiled into a shared library .so file.
Exec
This mandatory directive uses the go_call(function) which must accept an nxLogData() object as its only
argument. For this directive, any number of go_call(function) may be defined as displayed below.
In this Go file template, a simple function is called via the go_call("process"); argument using the Exec
directive.
In this Go file template, a multi-argument function is called via the go_call("process", "arg1",
"arg2", …, "argN") argument using the Exec directive.
130.13.5. Examples
1044
Chapter 130. Extension Modules NXLog User Guide
This configuration calls the go_call process in the compiled external go language shared object file to
mask the IPv4 addresses in the input file, so all of them looks x.x.x.x in the output file.
nxlog.conf
1 <Extension ext>
2 Module xm_go
3 ImportLib "file/process.so"
4 </Extension>
5
6 <Input in1>
7 Module im_file
8 File "file/input.txt"
9 </Input>
10
11 <Output out>
12 Module om_file
13 File "file/output.txt"
14 Exec go_call("process");
15 </Output>
Input Sample
Sep 30 14:20:24 mephisto vmnet-dhcpd: Configured subnet: 192.168.169.0↵
Sep 30 14:20:24 mephisto vmnet-dhcpd: Setting vmnet-dhcp IP address: 192.168.169.254↵
Sep 30 14:20:24 mephisto vmnet-dhcpd: Recving on VNet/vmnet1/192.168.169.0↵
Sep 30 14:20:24 mephisto kernel: /dev/vmnet: open called by PID 3243 (vmnet-dhcpd)↵
Sep 30 14:20:24 mephisto vmnet-dhcpd: Sending on VNet/vmnet1/192.168.169.0↵
Output Sample
Sep 30 14:20:24 mephisto vmnet-dhcpd: Configured subnet: x.x.x.x↵
Sep 30 14:20:24 mephisto vmnet-dhcpd: Setting vmnet-dhcp IP address: x.x.x.x↵
Sep 30 14:20:24 mephisto vmnet-dhcpd: Recving on VNet/vmnet1/x.x.x.x↵
Sep 30 14:20:24 mephisto kernel: /dev/vmnet: open called by PID 3243 (vmnet-dhcpd)↵
Sep 30 14:20:24 mephisto vmnet-dhcpd: Sending on VNet/vmnet1/x.x.x.x↵
1045
NXLog User Guide Chapter 130. Extension Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.14.1. Configuration
The xm_grok module accepts the following directives in addition to the common module directives.
Pattern
This mandatory directive specifies a directory or file containing Grok patterns. Wildcards may be used to
specify multiple directories or files. This directive may be used more than once.
130.14.2. Functions
The following functions are exported by xm_grok.
130.14.3. Procedures
The following procedures are exported by xm_grok.
match_grok(string pattern);
Attempt to match and parse the $raw_event field of the current event with the specified pattern.
130.14.4. Examples
1046
Chapter 130. Extension Modules NXLog User Guide
This configuration reads Syslog events from file and parses them with the parse_syslog() procedure (this
sets the $Message field). Then the match_grok() function is used to attempt a series of matches on the
$Message field until one is successful. If no patterns match, an internal message is logged.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension grok>
6 Module xm_grok
7 Pattern modules/extension/grok/patterns2.txt
8 </Extension>
9
10 <Input in>
11 Module im_file
12 File 'test2.log'
13 <Exec>
14 parse_syslog();
15 if match_grok($Message, "%{SSH_AUTHFAIL_WRONGUSER}") {}
16 else if match_grok($Message, "%{SSH_AUTHFAIL_WRONGCREDS}") {}
17 else if match_grok($Message, "%{SSH_AUTH_SUCCESS}") {}
18 else if match_grok($Message, "%{SSH_DISCONNECT}") {}
19 else
20 {
21 log_info('Event did not match any pattern');
22 }
23 </Exec>
24 </Input>
patterns2.txt
USERNAME [a-zA-Z0-9_-]+
INT (?:[+-]?(?:[0-9]+))
BASE10NUM (?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))
NUMBER (?:%{BASE10NUM})
WORD \b\w+\b
GREEDYDATA .*
IP (?<![0-9])(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-
9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-
9]{1,2}))(?![0-9])
1047
NXLog User Guide Chapter 130. Extension Modules
declared with the public and static modifiers in the Java code to be accessible from NXLog, and the first
parameter must be of NXLog.Logdata type. See also the im_java and om_java modules.
For the system requirements, installation details and environmental configuration requirements
NOTE
of Java, see the Installing Java section in the Java documentation.
The NXLog Java class provides access to the NXLog functionality in the Java code. This class contains nested
classes Logdata and Module with log processing methods, as well as methods for sending messages to the
internal logger.
class NXLog.Logdata
This Java class provides the methods to interact with an NXLog event record object:
getField(name)
This method returns the value of the field name in the event.
setField(name, value)
This method sets the value of field name to value.
deleteField(name)
This method removes the field name from the event record.
getFieldnames()
This method returns an array with the names of all the fields currently in the event record.
getFieldtype(name)
This method retrieves the field type using the value from the name field.
class NXLog.Module
The methods below allow setting and accessing variables associated with the module instance.
saveCtx(key,value)
This method saves user data in the module data storage using values from the key and value fields.
loadCtx(key)
This method retrieves data from the module data storage using the value from the key field.
Below is the list of methods for sending messages to the internal logger.
NXLog.logInfo(msg)
This method sends the message msg to to the internal logger at INFO log level. It does the same as the core
log_info() procedure.
NXLog.logDebug(msg)
This method sends the message msg to to the internal logger at DEBUG log level. It does the same as the core
log_debug() procedure.
NXLog.logWarning(msg)
This method sends the message msg to to the internal logger at WARNING log level. It does the same as the
core log_warning() procedure.
NXLog.logError(msg)
This method sends the message msg to to the internal logger at ERROR log level. It does the same as the core
log_error() procedure.
1048
Chapter 130. Extension Modules NXLog User Guide
130.15.1. Configuration
The NXLog process maintains only one JVM instance for all xm_java, im_java or om_java running instances. This
means all Java classes loaded by the ClassPath directive will be available for all running instances.
The xm_java module accepts the following directives in addition to the common module directives.
ClassPath
This mandatory directive defines the path to the .class files or a .jar file. This directive should be defined at
least once within a module block.
VMOption
This optional directive defines a single Java Virtual Machine (JVM) option.
VMOptions
This optional block directive serves the same purpose as the VMOption directive, but also allows specifying
multiple Java Virtual Machine (JVM) instances, one per line.
JavaHome
This optional directive defines the path to the Java Runtime Environment (JRE). The path is used to search for
the libjvm shared library. If this directive is not defined, the Java home directory will be set to the build-time
value. Only one JRE can be defined for one or multiple NXLog Java instances. Defining multiple JRE instances
causes an error.
130.15.2. Procedures
The following procedures are exported by xm_java.
1049
NXLog User Guide Chapter 130. Extension Modules
Below is an example of module usage. The process1 and process2 methods of the Extension Java class
split log data into key-value pairs and add an additional field to each entry. The results are then converted
to JSON format.
nxlog.conf
1 <Extension ext>
2 Module xm_java
3 # Path to the compiled Java class
4 Classpath Extension.jar
5 </Extension>
6
7 <Output fileout>
8 Module om_file
9 File '/tmp/output'
10 # Calling the first method to split data into key-value pairs
11 Exec java_call("Extension.process1");
12 # Calling the second method and passing the additional parameter
13 Exec ext->call("Extension.process2", "test");
14 Exec to_json();
15 </Output>
1050
Chapter 130. Extension Modules NXLog User Guide
Extension.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
if (type.equals("CWD")) {
try {
NXLog.logInfo(String.format("type: %s", type));
Files.write(
Paths.get("tmp/processed"),
((String) ld.getField("raw_event") + "\n").getBytes(),
StandardOpenOption.APPEND,
StandardOpenOption.CREATE
);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
1051
NXLog User Guide Chapter 130. Extension Modules
Input sample
type=CWD msg=audit(1489999368.711:35724): cwd="/root/nxlog"↵
type=PATH msg=audit(1489999368.711:35724): item=0 name="/root/test" inode=528869 dev=08:01
mode=040755 ouid=0 ogid=0 rdev=00:00↵
type=SYSCALL msg=audit(1489999368.711:35725): arch=c000003e syscall=2 success=yes exit=3
a0=12dcc40 a1=90800 a2=0 a3=0 items=1 ppid=15391 pid=12309 auid=0 uid=0 gid=0 euid=0 suid=0
fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=583 comm="ls" exe="/bin/ls" key=(null)↵
Output Sample
{
"type":"CWD",
"msg":"audit(1489999368.711:35724):",
"cwd":"\"/root/nxlog\"",
"Stage":"test"
}
{
"type":"PATH",
"msg":"audit(1489999368.711:35724):",
"item":"0",
"name":"\"/root/test\"",
"inode":"528869",
"dev":"08:01",
"mode":"040755",
"ouid":"0",
"ogid":"0",
"rdev":"00:00",
"Stage":"test"
}
{
"type":"SYSCALL",
"msg":"audit(1489999368.711:35725):",
"arch":"c000003e",
"syscall":"2",
"success":"yes",
"exit":"3",
"a0":"12dcc40",
"a1":"90800",
"a2":"0",
"a3":"0",
"items":"1",
"ppid":"15391",
"pid":"12309",
"auid":"0",
"uid":"0",
"gid":"0",
"euid":"0",
"suid":"0",
"fsuid":"0",
"egid":"0",
"sgid":"0",
"fsgid":"0",
"tty":"pts4",
"ses":"583",
"comm":"\"ls\"",
"exe":"\"/bin/ls\"",
"key":"(null)",
"Stage":"test"
}
1052
Chapter 130. Extension Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.16.1. Configuration
The xm_json module accepts the following directives in addition to the common module directives.
DateFormat
This optional directive can be used to set the format of the datetime strings in the generated JSON. This
directive is similar to the global DateFormat, but is independent of it: this directive is defined separately and
has its own default. If this directive is not specified, the default is YYYY-MM-DDThh:mm:ss.sTZ.
DetectNestedJSON
This optional directive can be used to disable the autodetection of nested JSON strings when calling the
to_json() function or the to_json() procedure. For example, consider a field $key which contains the string
value of {"subkey":42}. If DetectNestedJSON is set to FALSE, to_json() will produce
{"key":"{\"subkey\":42}"}. If DetectNestedJSON is set to TRUE (the default), the result is
{"key":{"subkey":42}}—a valid nested JSON record.
Flatten
This optional boolean directive specifies that the parse_json() procedure should flatten nested JSON, creating
field names with dot notation. The default is FALSE. If Flatten is set to TRUE, the following JSON will populate
the fields $event.time and $event.severity:
{"event":{"time":"2015-01-01T00:00:00.000Z","severity":"ERROR"}}
ForceUTF8
This optional boolean directive specifies whether the generated JSON should be valid UTF-8. The JSON
specification requires JSON records to be UTF-8 encoded, and some tools fail to parse JSON if it is not valid
UTF-8. If ForceUTF8 is set to TRUE, the generated JSON will be validated and any invalid character will be
replaced with a question mark (?). The default is FALSE.
IncludeHiddenFields
This boolean directive specifies that the to_json() function or the to_json() procedure should inlude fields
having a leading dot (.) or underscore (_) in their names. The default is TRUE. If IncludeHiddenFields is set to
TRUE, then generated JSON will contain these otherwise excluded fields.
ParseDate
If this boolean directive is set to TRUE, xm_json will attempt to parse as a timestamp any string that appears
to begin with a 4-digit year (as a regular expression, ^[12][0-9]{3}-). If this directive is set to FALSE, xm_json
will not attempt to parse these strings. The default is TRUE.
PrettyPrint
If set to TRUE, this optional boolean directive specifies that the generated JSON should be pretty-printed,
where each key-value is printed on a new indented line. Note that this adds line-breaks to the JSON records,
which can cause parser errors in some tools that expect single-line JSON. If this directive is not specified, the
default is FALSE.
1053
NXLog User Guide Chapter 130. Extension Modules
UnFlatten
This optional boolean directive specifies that the to_json() procedure should generate nested JSON when field
names exist containing the dot (.). For example, if UnFlatten is set to TRUE, the two fields $event.time and
$event.severity will be converted to JSON as follows:
{"event":{"time":"2015-01-01T00:00:00.000Z","severity":"ERROR"}}
When UnFlatten is set to FALSE (the default if not specified), the following JSON would result:
{"event.time":"2015-01-01T00:00:00.000Z","event.severity":"ERROR"}
130.16.2. Functions
The following functions are exported by xm_json.
string to_json()
Convert the fields to JSON and return this as a string value. The $raw_event field and any field having a
leading dot (.) or underscore (_) will be automatically excluded unless IncludeHiddenFields directive is set to
TRUE.
130.16.3. Procedures
The following procedures are exported by xm_json.
parse_json();
Parse the $raw_event field as JSON input.
parse_json(string source);
Parse the given string as JSON format.
to_json();
Convert the fields to JSON and put this into the $raw_event field. The $raw_event field and any field having a
leading dot (.) or underscore (_) will be automatically excluded unless IncludeHiddenFields directive is set to
TRUE.
130.16.4. Examples
1054
Chapter 130. Extension Modules NXLog User Guide
The following configuration accepts Syslog (both BSD and IETF) via TCP and converts it to JSON.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input tcp>
10 Module im_tcp
11 ListenAddr 0.0.0.0:1514
12 Exec parse_syslog(); to_json();
13 </Input>
14
15 <Output file>
16 Module om_file
17 File "/var/log/json.txt"
18 </Output>
19
20 <Route tcp_to_file>
21 Path tcp => file
22 </Route>
Input Sample
<30>Sep 30 15:45:43 host44.localdomain.hu acpid: 1 client rule loaded↵
Output Sample
{
"MessageSourceAddress":"127.0.0.1",
"EventReceivedTime":"2011-03-08 14:22:41",
"SyslogFacilityValue":1,
"SyslogFacility":"DAEMON",
"SyslogSeverityValue":5,
"SyslogSeverity":"INFO",
"SeverityValue":2,
"Severity":"INFO",
"Hostname":"host44.localdomain.hu",
"EventTime":"2011-09-30 14:45:43",
"SourceName":"acpid",
"Message":"1 client rule loaded "
}
1055
NXLog User Guide Chapter 130. Extension Modules
The following configuration reads the Windows EventLog and converts it to the BSD Syslog format, with the
message part containing the fields in JSON.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input eventlog>
10 Module im_msvistalog
11 Exec $Message = to_json(); to_syslog_bsd();
12 </Input>
13
14 <Output tcp>
15 Module om_tcp
16 Host 192.168.1.1:1514
17 </Output>
18
19 <Route eventlog_json_tcp>
20 Path eventlog => tcp
21 </Route>
Output Sample
<14>Mar 8 14:40:11 WIN-OUNNPISDHIG Service_Control_Manager: {"EventTime":"2012-03-08
14:40:11","EventTimeWritten":"2012-03-08 14:40:11","Hostname":"WIN-
OUNNPISDHIG","EventType":"INFO","SeverityValue":2,"Severity":"INFO","SourceName":"Service
Control
Manager","FileName":"System","EventID":7036,"CategoryNumber":0,"RecordNumber":6788,"Message":"T
he nxlog service entered the running state. ","EventReceivedTime":"2012-03-08 14:40:12"}↵
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
It is quite common to have a different set of keys in each log line when accepting key-value formatted input
messages. Extracting values from such logs using regular expressions can be quite cumbersome. The xm_kvp
extension module automates this process.
Log messages containing key-value pairs typically look like one the following:
1056
Chapter 130. Extension Modules NXLog User Guide
Keys are usually separated from the value using an equal sign (=) or a colon (:); and the key-value pairs are
delimited with a comma (,), a semicolon (;), or a space. In addition, values and keys may be quoted and may
contain escaping. The module will try to guess the format, or the format can be explicitly specified using the
configuration directives below.
It is possible to use more than one xm_kvp module instance with different options in order to
NOTE support different KVP formats at the same time. For this reason, functions and procedures
exported by the module are public and must be referenced by the module instance name.
130.17.1. Configuration
The xm_kvp module accepts the following directives in addition to the common module directives.
DetectNumericValues
If this optional boolean directive is set to TRUE, the parse_kvp() procedure will try to parse numeric values as
integers first. The default is TRUE (numeric values will be parsed as integers and unquoted in the output).
Note that floating-point numbers will not be handled.
EscapeChar
This optional directive takes a single character (see below) as argument. It specifies the character used for
escaping special characters. The escape character is used to prefix the following characters: the EscapeChar
itself, the KeyQuoteChar, and the ValueQuoteChar. If EscapeControl is TRUE, the newline (\n), carriage return
(\r), tab (\t), and backspace (\b) control characters are also escaped. The default escape character is the
backslash (\).
EscapeControl
If this optional boolean directive is set to TRUE, control characters are also escaped. See the EscapeChar
directive for details. The default is TRUE (control characters are escaped). Note that this is necessary in order
to support single-line KVP field lists containing line-breaks.
IncludeHiddenFields
This boolean directive specifies that the to_kvp() function or the to_kvp() procedure should inlude fields
having a leading dot (.) or underscore (_) in their names. The default is TRUE. If IncludeHiddenFields is set to
TRUE, then generated text will contain these otherwise excluded fields.
KeyQuoteChar
This optional directive takes a single character (see below) as argument. It specifies the quote character for
enclosing key names. If this directive is not specified, the module will accept single-quoted keys, double-
quoted keys, and unquoted keys.
KVDelimiter
This optional directive takes a single character (see below) as argument. It specifies the delimiter character
used to separate the key from the value. If this directive is not set and the parse_kvp() procedure is used, the
module will try to guess the delimiter from the following: the colon (:) or the equal-sign (=).
KVPDelimiter
This optional directive takes a single character (see below) as argument. It specifies the delimiter character
used to separate the key-value pairs. If this directive is not set and the parse_kvp() procedure is used, the
module will try to guess the delimiter from the following: the comma (,), the semicolon (;), or the space.
QuoteMethod
This directive can be used to specify the quote method used for the values by to_kvp().
All
The values will be always quoted. This is the default.
1057
NXLog User Guide Chapter 130. Extension Modules
Delimiter
The value will be only enclosed in quotes if it contains the delimiter character.
None
The values will not be quoted.
ValueQuoteChar
This optional directive takes a single character (see below) as argument. It specifies the quote character for
enclosing key values. If this directive is not specified, the module will accept single-quoted values, double-
quoted values, and unquoted values. Normally, quotation is used when the value contains a space or the
KVDelimiter character.
Delimiter ;
Control characters
The following non-printable characters can be specified with escape sequences:
\a
audible alert (bell)
\b
backspace
\t
horizontal tab
\n
newline
\v
vertical tab
\f
formfeed
\r
carriage return
Delimiter \t
1058
Chapter 130. Extension Modules NXLog User Guide
Delimiter ';'
Delimiter '\'
Delimiter "\"
Delimiter 0x20
130.17.2. Functions
The following functions are exported by xm_kvp.
string to_kvp()
Convert the internal fields to a single key-value pair formatted string.
130.17.3. Procedures
The following procedures are exported by xm_kvp.
parse_kvp();
Parse the $raw_event field as key-value pairs and populate the internal fields using the key names.
parse_kvp(string source);
Parse the given string key-value pairs and populate the internal fields using the key names.
reset_kvp();
Reset the KVP parser so that the autodetected KeyQuoteChar, ValueQuoteChar, KVDelimiter, and
KVPDelimiter characters can be detected again.
to_kvp();
Format the internal fields as key-value pairs and put this into the $raw_event field.
Note that directive IncludeHiddenFields has an effect on fields included in the output.
1059
NXLog User Guide Chapter 130. Extension Modules
130.17.4. Examples
The following examples illustrate various scenarios for parsing KVPs, whether embedded, encapsulated (in
Syslog, for example), or alone. In each case, the logs are converted from KVP input files to JSON output files,
though obviously there are many other possibilities.
The following two lines of input are in a simple KVP format where each line consists of various keys with
values assigned to them.
Input Sample
Name=John, Age=42, Weight=84, Height=142
Name=Mike, Weight=64, Age=24, Pet=dog, Height=172
This input can be parsed with the following configuration. The parsed fields can be used in NXLog
expressions: a new field named $Overweight is added and set to TRUE if the conditions are met. Finally a
few automatically added fields are removed, and the log is then converted to JSON.
nxlog.conf (truncated)
1 <Extension kvp>
2 Module xm_kvp
3 KVPDelimiter ,
4 KVDelimiter =
5 EscapeChar \\
6 </Extension>
7
8 <Extension json>
9 Module xm_json
10 </Extension>
11
12 <Input filein>
13 Module im_file
14 File "modules/extension/kvp/xm_kvp5.in"
15 <Exec>
16 if $raw_event =~ /^#/ drop();
17 else
18 {
19 kvp->parse_kvp();
20 delete($EventReceivedTime);
21 delete($SourceModuleName);
22 delete($SourceModuleType);
23 if ( integer($Weight) > integer($Height) - 100 ) $Overweight = TRUE;
24 to_json();
25 }
26 </Exec>
27 </Input>
28 [...]
Output Sample
{"Name":"John","Age":42,"Weight":84,"Height":142,"Overweight":true}
{"Name":"Mike","Weight":64,"Age":24,"Pet":"dog","Height":172}
1060
Chapter 130. Extension Modules NXLog User Guide
Input Sample
<38>2010-10-12 21:01:29 10.0.1.1 CisACS_02_FailedAuth 1k1fg93nk 1 0 Message-Type=Authen
failed,User-Name=John,NAS-IP-Address=10.0.1.2,AAA Server=acs01↵
<38>2010-10-12 21:01:31 10.0.1.1 CisACS_02_FailedAuth 2k1fg63nk 1 0 Message-Type=Authen
failed,User-Name=Foo,NAS-IP-Address=10.0.1.2,AAA Server=acs01↵
These logs are in Syslog format with a set of values present in each record and an additional set of KVPs.
The following configuration can be used to process this and convert it to JSON.
nxlog.conf (truncated)
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Extension kvp>
10 Module xm_kvp
11 KVDelimiter =
12 KVPDelimiter ,
13 </Extension>
14
15 <Input cisco>
16 Module im_file
17 File "modules/extension/kvp/cisco_acs.in"
18 <Exec>
19 parse_syslog_bsd();
20 if ( $Message =~ /^CisACS_(\d\d)_(\S+) (\S+) (\d+) (\d+) (.*)$/ )
21 {
22 $ACSCategoryNumber = $1;
23 $ACSCategoryName = $2;
24 $ACSMessageId = $3;
25 $ACSTotalSegments = $4;
26 $ACSSegmentNumber = $5;
27 $Message = $6;
28 kvp->parse_kvp($Message);
29 [...]
Output Sample
{"SourceModuleName":"cisco","SourceModuleType":"im_file","SyslogFacilityValue":4,"SyslogFacilit
y":"AUTH","SyslogSeverityValue":6,"SyslogSeverity":"INFO","SeverityValue":2,"Severity":"INFO","
Hostname":"10.0.1.1","EventTime":"2010-10-12 21:01:29","Message":"Message-Type=Authen
failed,User-Name=John,NAS-IP-Address=10.0.1.2,AAA Server=acs01","ACSCategoryNumber":"02"
,"ACSCategoryName":"FailedAuth","ACSMessageId":"1k1fg93nk","ACSTotalSegments":"1","ACSSegmentNu
mber":"0","Message-Type":"Authen failed","User-Name":"John","NAS-IP-Address":"10.0.1.2","AAA
Server":"acs01"}
{"SourceModuleName":"cisco","SourceModuleType":"im_file","SyslogFacilityValue":4,"SyslogFacilit
y":"AUTH","SyslogSeverityValue":6,"SyslogSeverity":"INFO","SeverityValue":2,"Severity":"INFO","
Hostname":"10.0.1.1","EventTime":"2010-10-12 21:01:31","Message":"Message-Type=Authen
failed,User-Name=Foo,NAS-IP-Address=10.0.1.2,AAA Server=acs01","ACSCategoryNumber":"02"
,"ACSCategoryName":"FailedAuth","ACSMessageId":"2k1fg63nk","ACSTotalSegments":"1","ACSSegmentNu
mber":"0","Message-Type":"Authen failed","User-Name":"Foo","NAS-IP-Address":"10.0.1.2","AAA
Server":"acs01"}
1061
NXLog User Guide Chapter 130. Extension Modules
Input Sample
date="May 5 14:34:40 2009
MDT",fac=f_mail_filter,area=a_kmvfilter,type=t_mimevirus_reject,pri=p_major,pid=10174,ruid=0,eu
id=0,pgid=10174,logid=0,cmd=kmvfilter,domain=MMF1,edomain=MMF1,message_id=(null),srcip=66.74.18
4.9,mail_sender=<habuzeid6@…>,virus_name=W32/Netsky.c@MM!zip,reason="Message scan detected a
Virus in msg Unknown, message being Discarded, and not quarantined"↵
This can be parsed and converted to JSON with the following configuration.
nxlog.conf
1 <Extension kvp>
2 Module xm_kvp
3 KVPDelimiter ,
4 KVDelimiter =
5 EscapeChar \\
6 ValueQuoteChar "
7 </Extension>
8
9 <Extension json>
10 Module xm_json
11 </Extension>
12
13 <Input sidewinder>
14 Module im_file
15 File "modules/extension/kvp/sidewinder.in"
16 Exec kvp->parse_kvp(); delete($EventReceivedTime); to_json();
17 </Input>
18
19 <Output file>
20 Module om_file
21 File 'tmp/output'
22 </Output>
23
24 <Route sidewinder_to_file>
25 Path sidewinder => file
26 </Route>
Output Sample
{"SourceModuleName":"sidewinder","SourceModuleType":"im_file","date":"May 5 14:34:40 2009 MDT"
,"fac":"f_mail_filter","area":"a_kmvfilter","type":"t_mimevirus_reject","pri":"p_major","pid":1
0174,"ruid":0,"euid":0,"pgid":10174,"logid":0,"cmd":"kmvfilter","domain":"MMF1","edomain":"MMF1
","message_id":"(null)","srcip":"66.74.184.9","mail_sender":"<habuzeid6@…>","virus_name":"W32/N
etsky.c@MM!zip","reason":"Message scan detected a Virus in msg Unknown, message being
Discarded, and not quarantined"}
1062
Chapter 130. Extension Modules NXLog User Guide
URLs in HTTP requests frequently contain URL parameters which are a special kind of key-value pairs
delimited by the ampersand (&). Here is an example of two HTTP requests logged by the Apache web server
in the Combined Log Format.
Input Sample
192.168.1.1 - foo [11/Jun/2013:15:44:34 +0200] "GET /do?action=view&obj_id=2 HTTP/1.1" 200 1514
"https://localhost" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0"↵
192.168.1.1 - - [11/Jun/2013:15:44:44 +0200] "GET /do?action=delete&obj_id=42 HTTP/1.1" 401 788
"https://localhost" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Firefox/17.0"↵
The following configuration file parses the access log and extracts all the fields. The request parameters are
extracted into the $HTTPParams field using a regular expression, and then this field is further parsed using
the KVP parser. At the end of the processing all fields are converted to KVP format using the to_kvp()
procedure of the kvp2 instance.
nxlog.conf (truncated)
1 <Extension kvp>
2 Module xm_kvp
3 KVPDelimiter &
4 KVDelimiter =
5 </Extension>
6
7 <Extension kvp2>
8 Module xm_kvp
9 KVPDelimiter ;
10 KVDelimiter =
11 #QuoteMethod None
12 </Extension>
13
14 <Input apache>
15 Module im_file
16 File "modules/extension/kvp/apache_url.in"
17 <Exec>
18 if $raw_event =~ /(?x)^(\S+)\ (\S+)\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
19 \ HTTP.\d\.\d\"\ (\d+)\ (\d+)\ \"([^\"]+)\"\ \"([^\"]+)\"/
20 {
21 $Hostname = $1;
22 if $3 != '-' $AccountName = $3;
23 $EventTime = parsedate($4);
24 $HTTPMethod = $5;
25 $HTTPURL = $6;
26 $HTTPResponseStatus = $7;
27 $FileSize = $8;
28 $HTTPReferer = $9;
29 [...]
The two request parameters action and obj_id then appear at the end of the KVP formatted lines.
1063
NXLog User Guide Chapter 130. Extension Modules
Output Sample
SourceModuleName=apache;SourceModuleType=im_file;Hostname=192.168.1.1;AccountName=foo;EventTime
=2013-06-
11T13:44:34.000000Z;HTTPMethod=GET;HTTPURL=/do?action=view&obj_id=2;HTTPResponseStatus=200;File
Size=1514;HTTPReferer=https://localhost;HTTPUserAgent='Mozilla/5.0 (X11; Linux x86_64; rv:17.0)
Gecko/17.0 Firefox/17.0';HTTPParams=action=view&obj_id=2;action=view;obj_id=2;↵
SourceModuleName=apache;SourceModuleType=im_file;Hostname=192.168.1.1;EventTime=2013-06-
11T13:44:44.000000Z;HTTPMethod=GET;HTTPURL=/do?action=delete&obj_id=42;HTTPResponseStatus=401;F
ileSize=788;HTTPReferer=https://localhost;HTTPUserAgent='Mozilla/5.0 (X11; Linux x86_64;
rv:17.0) Gecko/17.0 Firefox/17.0';HTTPParams=action=delete&obj_id=42;action=delete;obj_id=42;↵
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.18.1. Configuration
The xm_leef module accepts the following directives in addition to the common module directives.
AddSyslogHeader
This optional boolean directive specifies whether a RFC 3164 (BSD-style) Syslog header should be prepended
to the output. This defaults to TRUE (a Syslog header will be added by the to_leef() procedure).
IncludeHiddenFields
This boolean directive specifies that the to_leef() function or the to_leef() procedure should inlude fields
having a leading dot (.) or underscore (_) in their names. The default is TRUE. If IncludeHiddenFields is set to
TRUE, then generated LEEF text will contain these otherwise excluded fields.
LEEFHeader
This optional directive takes a string type expression and only has an effect on how to_leef() formats the
result. It should evaluate to the following format:
LEEF:1.0|Microsoft|MSExchange|2013 SP1|15345|
When this directive is not specified, the LEEF header is constructed using the $Vendor, $SourceName (or
$SourceModuleName), $Version, and $EventID fields.
130.18.2. Functions
The following functions are exported by xm_leef.
string to_leef()
Convert the internal fields to a single LEEF formatted string.
1064
Chapter 130. Extension Modules NXLog User Guide
Note that directive IncludeHiddenFields has an effect on fields included in the output.
130.18.3. Procedures
The following procedures are exported by xm_leef.
parse_leef();
Parse the $raw_event field as key-value pairs and create the following NXLog fields (if possible): $Category,
$AccountName, $AccountType, $Domain, $EventTime, $Hostname, $MessageSourceAddress, $SeverityValue
(mapped from the sev attribute), $SourceName, $devTimeFormat, $LEEFVersion, $Vendor, $Version,
$EventID, $DelimiterCharacter.
parse_leef(string source);
Parse the the given string as key-value pairs and create the following NXLog fields (if possible): $Category,
$AccountName, $AccountType, $Domain, $EventTime, $Hostname, $MessageSourceAddress, $SeverityValue
(mapped from the sev attribute), $SourceName, $devTimeFormat, $LEEFVersion, $Vendor, $Version,
$EventID, $DelimiterCharacter.
to_leef();
Format the internal fields as LEEF and put this into the $raw_event field. to_leef() will automatically map the
following fields to event attributes, if available:
$AccountName accountName
$AccountType role
$Category cat
$Domain domain
$EventTime devTime
$Hostname identHostName
$MessageSourceAddress src
$SourceName vSrcName
130.18.4. Fields
The following fields are used by xm_leef.
In addition to the fields listed below, the parse_leef() procedure will create a field for every LEEF attribute
contained in the source LEEF message such as $srcPort, $cat, $identHostName, etc.
1065
NXLog User Guide Chapter 130. Extension Modules
≤2 1
3 1
4 2
5 2
6 3
7 3
8 4
9 4
≥10 5
1066
Chapter 130. Extension Modules NXLog User Guide
130.18.5. Examples
Example 646. Sending Windows EventLog as LEEF over UDP
This configuration will collect Windows EventLog and NXLog internal messages, convert them to LEEF, and
forward via UDP.
nxlog.conf
1 <Extension leef>
2 Module xm_leef
3 </Extension>
4
5 <Input internal>
6 Module im_internal
7 </Input>
8
9 <Input eventlog>
10 Module im_msvistalog
11 </Input>
12
13 <Output udp>
14 Module om_udp
15 Host 192.168.168.2:1514
16 Exec to_leef();
17 </Output>
18
19 <Route qradar>
20 Path internal, eventlog => udp
21 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The xm_msdns module does not support the detailed format enabled via the Details option
WARNING in the DNS Server Debug Logging configuration. NXLog could be configured to parse this
format with the xm_multiline module.
1067
NXLog User Guide Chapter 130. Extension Modules
130.19.1. Configuration
The xm_msdns module accepts the following directives in addition to the common module directives.
DateFormat
This optional directive allows you to define the format of the date field when parsing DNS Server logs. The
directive’s argument must be a format string compatiable with the C strptime(3) function. This directive works
similarly to the global DateFormat directive, and if not specified, the default format [D|DD]/[M|MM]/YYYY
[H|HH]:MM:SS [AM|PM] is used.
EventLine
This boolean directive specifies EVENT lines in the input should be parsed. If set to FALSE, EVENT lines will be
discarded. The default is TRUE.
NoteLine
This boolean directive specifies that Note: lines in the input should be parsed. If set to FALSE, Note: lines will
be discarded. The default is TRUE.
PacketLine
This boolean directive specifies that PACKET lines in the input should be parsed. If set to FALSE, PACKET lines
will be discarded. The default is TRUE.
130.19.2. Procedures
The following procedures are exported by xm_msdns.
parse_msdns();
Parse the $raw_event field and populate the DNS log fields.
parse_msdns(string source);
Parse the given string and populate the DNS log fields.
130.19.3. Fields
The following fields are used by xm_msdns.
1068
Chapter 130. Extension Modules NXLog User Guide
1069
NXLog User Guide Chapter 130. Extension Modules
130.19.4. Examples
Example 647. Parsing DNS Logs With InputType
In this configuration, the DNS log file at C:\dns.log is parsed using the InputType provided by the
xm_msdns module. Any Note: lines in the input are discarded (the NoteLine directive is set to FALSE).
nxlog.conf
1 <Extension dns_parser>
2 Module xm_msdns
3 EventLine TRUE
4 PacketLine TRUE
5 NoteLine FALSE
6 </Extension>
7
8 <Input in>
9 Module im_file
10 File 'modules/extension/msdns/xm_msdns1.in'
11 InputType dns_parser
12 </Input>
For cases where parsing via InputType is not possible, individual events can be parsed with the
parse_msdns() procedure.
nxlog.conf
1 <Extension dns_parser>
2 Module xm_msdns
3 </Extension>
4
5 <Input in>
6 Module im_file
7 File 'modules/extension/msdns/xm_msdns1.out'
8 Exec dns_parser->parse_msdns();
9 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The module maintains a separate context for each input source, allowing multiline messages to be processed
correctly even when coming from multiple sources (specifically, multiple files or multiple network connections).
1070
Chapter 130. Extension Modules NXLog User Guide
UDP is treated as a single source and all logs are processed under the same context. It is
WARNING therefore not recommended to use this module with im_udp if messages will be received
by multiple UDP senders (such as Syslog).
130.20.1. Configuration
The xm_multiline module accepts the following directives in addition to the common module directives. One of
FixedLineCount and HeaderLine must be specified.
FixedLineCount
This directive takes a positive integer number defining the number of lines to concatenate. This is useful
when receiving log messages spanning a fixed number of lines. When this number is defined, the module
knows where the event message ends and will not hold a message in the buffers until the next message
arrives.
HeaderLine
This directive takes a string or a regular expression literal. This will be matched against each line. When the
match is successful, the successive lines are appended until the next header line is read. This directive is
mandatory unless FixedLineCount is used.
Until a new message arrives with its associated header, the previous message is stored in the
buffers because the module does not know where the message ends. The im_file module
NOTE will forcibly flush this buffer after the configured PollInterval timeout. If this behavior is
unacceptable, disable AutoFlush, use an end marker with EndLine, or switch to an
encapsulation method (such as JSON).
The /s and /m regular expression modifiers may be used here, but they have no meaning,
NOTE
because HeaderLine is only checked against one input line at a time.
AutoFlush
If set to TRUE, this boolean directive specifies that the corresponding im_file module should forcibly flush the
buffer after its configured PollInterval timeout. The default is TRUE. If EndLine is used, AutoFlush is
automatically set to FALSE to disable this behavior. AutoFlush has no effect if xm_multiline is used with an
input module other than im_file.
EndLine
This is similar to the HeaderLine directive. This optional directive also takes a string or a regular expression
literal to be matched against each line. When the match is successful the message is considered complete.
Exec
This directive is almost identical to the behavior of the Exec directive used by the other modules with the
following differences:
• each line is passed in $raw_event as it is read, and the line terminator in included; and
• other fields cannot be used, and captured strings can not be stored as separate fields.
This is mostly useful for rewriting lines or filtering out certain lines with the drop() procedure.
130.20.2. Examples
1071
NXLog User Guide Chapter 130. Extension Modules
XML is commonly formatted as indented multiline to make it more readable. In the following configuration
file the HeaderLine and EndLine directives are used to parse the events. The events are then converted to
JSON after some timestamp normalization.
nxlog.conf (truncated)
1 <Extension multiline>
2 Module xm_multiline
3 HeaderLine /^<event>/
4 EndLine /^<\/event>/
5 </Extension>
6
7 <Extension xmlparser>
8 Module xm_xml
9 </Extension>
10
11 <Extension json>
12 Module xm_json
13 </Extension>
14
15 <Input filein>
16 Module im_file
17 File "modules/extension/multiline/xm_multiline5.in"
18 InputType multiline
19 <Exec>
20 # Discard everything that doesn't seem to be an xml event
21 if $raw_event !~ /^<event>/ drop();
22
23 # Parse the xml event
24 parse_xml();
25
26 # Rewrite some fields
27 $EventTime = parsedate($timestamp);
28 delete($timestamp);
29 [...]
Input Sample
<?xml version="1.0" encoding="UTF-8">
<event>
<timestamp>2012-11-23 23:00:00</timestamp>
<severity>ERROR</severity>
<message>
Something bad happened.
Please check the system.
</message>
</event>
<event>
<timestamp>2012-11-23 23:00:12</timestamp>
<severity>INFO</severity>
<message>
System state is now back to normal.
</message>
</event>
1072
Chapter 130. Extension Modules NXLog User Guide
Output Sample
{"SourceModuleName":"filein","SourceModuleType":"im_file","severity":"ERROR","message":"\n
Something bad happened.\n Please check the system.\n ","EventTime":"2012-11-23 23:00:00"}
{"SourceModuleName":"filein","SourceModuleType":"im_file","severity":"INFO","message":"\n
System state is now back to normal.\n ","EventTime":"2012-11-23 23:00:12"}
1073
NXLog User Guide Chapter 130. Extension Modules
Each log message has a header (TIMESTAMP INTEGER SEVERITY) which is used as the message boundary. A
regular expression is defined for this with the HeaderLine directive. Each log message is prepended with an
additional line containing dashes and is written to a file.
nxlog.conf
1 <Extension dicom_multi>
2 Module xm_multiline
3 HeaderLine /^\d\d\d\d-\d\d-\d\d\d\d:\d\d:\d\d\.\d+\s+\d+\s+\S+\s+/
4 </Extension>
5
6 <Input filein>
7 Module im_file
8 File "modules/extension/multiline/xm_multiline4.in"
9 InputType dicom_multi
10 </Input>
11
12 <Output fileout>
13 Module om_file
14 File 'tmp/output'
15 Exec $raw_event = "--------------------------------------\n" + $raw_event;
16 </Output>
17
18 <Route parse_dicom>
19 Path filein => fileout
20 </Route>
Input Sample
2011-12-1512:22:51.000000 4296 INFO Association Request Parameters:↵
Our Implementation Class UID: 2.16.124.113543.6021.2↵
Our Implementation Version Name: RZDCX_2_0_1_8↵
Their Implementation Class UID:↵
Their Implementation Version Name:↵
Application Context Name: 1.2.840.10008.3.1.1.1↵
Requested Extended Negotiation: none↵
Accepted Extended Negotiation: none↵
2011-12-1512:22:51.000000 4296 DEBUG Constructing Associate RQ PDU↵
2011-12-1512:22:51.000000 4296 DEBUG WriteToConnection, length: 310, bytes written: 310,
loop no: 1↵
2011-12-1512:22:51.015000 4296 DEBUG PDU Type: Associate Accept, PDU Length: 216 + 6 bytes
PDU header↵
02 00 00 00 00 d8 00 01 00 00 50 41 43 53 20 20↵
20 20 20 20 20 20 20 20 20 20 52 5a 44 43 58 20↵
20 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00↵
2011-12-1512:22:51.031000 4296 DEBUG DIMSE sendDcmDataset: sending 146 bytes↵
1074
Chapter 130. Extension Modules NXLog User Guide
Output Sample
--------------------------------------↵
2011-12-1512:22:51.000000 4296 INFO Association Request Parameters:↵
Our Implementation Class UID: 2.16.124.113543.6021.2↵
Our Implementation Version Name: RZDCX_2_0_1_8↵
Their Implementation Class UID:↵
Their Implementation Version Name:↵
Application Context Name: 1.2.840.10008.3.1.1.1↵
Requested Extended Negotiation: none↵
Accepted Extended Negotiation: none↵
--------------------------------------↵
2011-12-1512:22:51.000000 4296 DEBUG Constructing Associate RQ PDU↵
--------------------------------------↵
2011-12-1512:22:51.000000 4296 DEBUG WriteToConnection, length: 310, bytes written: 310,
loop no: 1↵
--------------------------------------↵
2011-12-1512:22:51.015000 4296 DEBUG PDU Type: Associate Accept, PDU Length: 216 + 6 bytes
PDU header↵
02 00 00 00 00 d8 00 01 00 00 50 41 43 53 20 20↵
20 20 20 20 20 20 20 20 20 20 52 5a 44 43 58 20↵
20 20 20 20 20 20 20 20 20 20 00 00 00 00 00 00↵
--------------------------------------↵
2011-12-1512:22:51.031000 4296 DEBUG DIMSE sendDcmDataset: sending 146 bytes↵
1075
NXLog User Guide Chapter 130. Extension Modules
The following configuration will process messages having a fixed string header containing dashes. Each
event is then prepended with a hash mark (#) and written to a file.
nxlog.conf
1 <Extension multiline>
2 Module xm_multiline
3 HeaderLine "---------------"
4 </Extension>
5
6 <Input filein>
7 Module im_file
8 File "modules/extension/multiline/xm_multiline1.in"
9 InputType multiline
10 Exec $raw_event = "#" + $raw_event;
11 </Input>
12
13 <Output fileout>
14 Module om_file
15 File 'tmp/output'
16 </Output>
17
18 <Route parse_multiline>
19 Path filein => fileout
20 </Route>
Input Sample
---------------↵
1↵
---------------↵
1↵
2↵
---------------↵
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa↵
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb↵
ccccccccccccccccccccccccccccccccccccc↵
dddd↵
---------------↵
Output Sample
#---------------↵
1↵
#---------------↵
1↵
2↵
#---------------↵
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa↵
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb↵
ccccccccccccccccccccccccccccccccccccc↵
dddd↵
#---------------↵
1076
Chapter 130. Extension Modules NXLog User Guide
The following configuration will process messages having a fixed line count of four. Lines containing only
whitespace are ignored and removed. Each event is then prepended with a hash mark (#) and written to a
file.
nxlog.conf
1 <Extension multiline>
2 Module xm_multiline
3 FixedLineCount 4
4 Exec if $raw_event =~ /^\s*$/ drop();
5 </Extension>
6
7 <Input filein>
8 Module im_file
9 File "modules/extension/multiline/xm_multiline2.in"
10 InputType multiline
11 </Input>
12
13 <Output fileout>
14 Module om_file
15 File 'tmp/output'
16 Exec $raw_event = "#" + $raw_event;
17 </Output>
18
19 <Route parse_multiline>
20 Path filein => fileout
21 </Route>
Input Sample
1↵
2↵
3↵
4↵
1asd↵
↵
2asdassad↵
3ewrwerew↵
4xcbccvbc↵
↵
1dsfsdfsd↵
2sfsdfsdrewrwe↵
↵
3sdfsdfsew↵
4werwerwrwe↵
Output Sample
#1↵
2↵
3↵
4↵
#1asd↵
2asdassad↵
3ewrwerew↵
4xcbccvbc↵
#1dsfsdfsd↵
2sfsdfsdrewrwe↵
3sdfsdfsew↵
4werwerwrwe↵
1077
NXLog User Guide Chapter 130. Extension Modules
Often, multiline messages are logged over Syslog and each line is processed as an event, with its own
Syslog header. It is commonly necessary to merge these back into a single event message.
Input Sample
Nov 21 11:40:27 hostname app[26459]: Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-
ERR TX-DRP TX-OVR Flg↵
Nov 21 11:40:27 hostname app[26459]: eth2 1500 0 16936814 0 0 0 30486067
0 8 0 BMRU↵
Nov 21 11:40:27 hostname app[26459]: lo 16436 0 277217234 0 0 0
277217234 0 0 0 LRU↵
Nov 21 11:40:27 hostname app[26459]: tun0 1500 0 316943 0 0 0 368642
0 0 0 MOPRU↵
Nov 21 11:40:28 hostname app[26459]: Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-
ERR TX-DRP TX-OVR Flg↵
Nov 21 11:40:28 hostname app[26459]: eth2 1500 0 16945117 0 0 0 30493583
0 8 0 BMRU↵
Nov 21 11:40:28 hostname app[26459]: lo 16436 0 277217234 0 0 0
277217234 0 0 0 LRU↵
Nov 21 11:40:28 hostname app[26459]: tun0 1500 0 316943 0 0 0 368642
0 0 0 MOPRU↵
Nov 21 11:40:29 hostname app[26459]: Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-
ERR TX-DRP TX-OVR Flg↵
Nov 21 11:40:29 hostname app[26459]: eth2 1500 0 16945270 0 0 0 30493735
0 8 0 BMRU↵
Nov 21 11:40:29 hostname app[26459]: lo 16436 0 277217234 0 0 0
277217234 0 0 0 LRU↵
Nov 21 11:40:29 hostname app[26459]: tun0 1500 0 316943 0 0 0 368642
0 0 0 MOPRU↵
The following configuration strips the Syslog header from the netstat output stored in the traditional Syslog
formatted file, and each message is then printed again with a line of dashes used as a separator.
1078
Chapter 130. Extension Modules NXLog User Guide
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension netstat>
6 Module xm_multiline
7 FixedLineCount 4
8 <Exec>
9 parse_syslog_bsd();
10 $raw_event = $Message + "\n";
11 </Exec>
12 </Extension>
13
14 <Input filein>
15 Module im_file
16 File "modules/extension/multiline/xm_multiline3.in"
17 InputType netstat
18 </Input>
19
20 <Output fileout>
21 Module om_file
22 File 'tmp/output'
23 <Exec>
24 $raw_event = "-------------------------------------------------------" +
25 "-----------------------------\n" + $raw_event;
26 </Exec>
27 </Output>
28
29 <Route parse_multiline>
30 Path filein => fileout
31 </Route>
Output Sample
------------------------------------------------------------------------------------↵
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg↵
eth2 1500 0 16936814 0 0 0 30486067 0 8 0 BMRU↵
lo 16436 0 277217234 0 0 0 277217234 0 0 0 LRU↵
tun0 1500 0 316943 0 0 0 368642 0 0 0 MOPRU↵
------------------------------------------------------------------------------------↵
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg↵
eth2 1500 0 16945117 0 0 0 30493583 0 8 0 BMRU↵
lo 16436 0 277217234 0 0 0 277217234 0 0 0 LRU↵
tun0 1500 0 316943 0 0 0 368642 0 0 0 MOPRU↵
------------------------------------------------------------------------------------↵
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg↵
eth2 1500 0 16945270 0 0 0 30493735 0 8 0 BMRU↵
lo 16436 0 277217234 0 0 0 277217234 0 0 0 LRU↵
tun0 1500 0 316943 0 0 0 368642 0 0 0 MOPRU↵
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1079
NXLog User Guide Chapter 130. Extension Modules
This module only supports parsing NetFlow data received as UDP datagrams and does not
NOTE
support TCP.
xm_netflow uses the IP address of the exporter device to distinguish between different devices
NOTE
so that templates with the same name would not conflict.
The module exports an input parser which can be referenced in the UDP input instance with the InputType
directive:
InputType netflow
This input reader function parses the payload and extracts NetFlow specific fields.
130.21.1. Configuration
The xm_netflow module accepts only the common module directives.
130.21.2. Fields
The fields generated by xm_netflow are provided separately. Please refer to the documentation available online or
in the NXLog package.
130.21.3. Examples
Example 654. Parsing UDP NetFlow Data
The following configuration receives NetFlow data over UDP and converts the parsed data into JSON.
nxlog.conf
1 <Extension netflow>
2 Module xm_netflow
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input udpin>
10 Module im_udp
11 ListenAddr 0.0.0.0:2162
12 InputType netflow
13 </Input>
14
15 <Output out>
16 Module om_file
17 File "netflow.log"
18 Exec to_json();
19 </Output>
20
21 <Route nf>
22 Path udpin => out
23 </Route>
1080
Chapter 130. Extension Modules NXLog User Guide
Microsoft Radius services. Internet Authentication Service (IAS) is the Microsoft implementation of a RADIUS
server and proxy. Internet Authentication Service (IAS) was renamed to Network Policy Server (NPS) starting with
Windows Server 2008. This module is capable of parsing both IAS and NPS formatted data.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
"RasBox","RAS",10/22/2006,09:13:09,1,"DOMAIN\user","DOMAIN\user",,,,,,"192.168.132.45",12,,"192.168.
132.45",,,,0,"CONNECT 24000",1,2,4,,0,"311 1 192.168.132.45 07/31/2006 21:35:14
749",,,,,,,,,,,,,,,,,,,,,,,,,,,,"MSRASV5.00",311,,,,
"RasBox","RAS",10/22/2006,09:13:09,3,,"DOMAIN\user",,,,,,,,,,,,,,,,,4,,36,"311 1 192.168.132.45
07/31/2006 21:35:14 749",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"0x00453D36393120523D3020563D33",,,
"RasBox","RAS",10/22/2006,09:13:13,1,"DOMAIN\user","DOMAIN\user",,,,,,"192.168.132.45",12,,"192.168.
132.45",,,,0,"CONNECT 24000",1,2,4,,0,"311 1 192.168.132.45 07/31/2006 21:35:14
750",,,,,,,,,,,,,,,,,,,,,,,,,,,,"MSRASV5.00",311,,,,
For more information on the NPS format see the Interpret NPS Database Format Log Files article on Microsoft
TechNet.
130.22.1. Configuration
The xm_nps module accepts only the common module directives.
130.22.2. Procedures
The following procedures are exported by xm_nps.
parse_nps();
Parse the $raw_event field as NPS input.
parse_nps(string source);
Parse the given string as NPS format.
130.22.3. Examples
1081
NXLog User Guide Chapter 130. Extension Modules
The following configuration reads NPS formatted files and converts the parsed data into JSON.
nxlog.conf
1 <Extension nps>
2 Module xm_nps
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input filein>
10 Module im_file
11 File 'C:\logs\IAS.log'
12 Exec parse_nps();
13 </Input>
14
15 <Output fileout>
16 Module om_file
17 File 'C:\out.json'
18 Exec to_json();
19 </Output>
20
21 <Route nps_to_json>
22 Path filein => fileout
23 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
There are other techniques such as the radix tree which solve the linearity problem; the drawback is that usually
these require the user to learn a special syntax for specifying patterns. If the log message is already parsed and
is not treated as single line of message, then it is possible to process only a subset of the patterns which partially
solves the linearity problem. With other performance improvements employed within the xm_pattern module, its
speed can compare to the other techniques. Yet the xm_pattern module uses regular expressions which are
familiar to users and can easily be migrated from other tools.
Traditionally, pattern matching on log messages has employed a technique where the log message was one
string and the pattern (regular expression or radix tree based pattern) was executed against it. To match patterns
against logs which contain structured data (such as the Windows EventLog), this structured data (the fields of the
log) must be converted to a single string. This is a simple but inefficient method used by many tools.
The NXLog patterns defined in the XML pattern database file can contain more than one field. This allows multi-
dimensional pattern matching. Thus with NXLog’s xm_pattern module there is no need to convert all fields into a
single string as it can work with multiple fields.
1082
Chapter 130. Extension Modules NXLog User Guide
Patterns can be grouped together under pattern groups. Pattern groups serve an optimization purpose. The
group can have an optional matchfield block which can check a condition. If the condition (such as $SourceName
matches sshd) is satisfied, the xm_pattern module will descend into the group and check each pattern against the
log. If the pattern group’s condition did not match ($SourceName was not sshd), the module can skip all patterns
in the group without having to check each pattern individually.
When the xm_pattern module finds a matching pattern, the $PatternID and $PatternName fields are set on the
log message. These can be used later in conditional processing and correlation rules of the pm_evcorr module,
for example.
The xm_pattern module does not process all patterns. It exits after the first matching pattern is
found. This means that at most one pattern can match a log message. Multiple patterns that
can match the same subset of logs should be avoided. For example, with two regular expression
NOTE patterns ^\d+ and ^\d\d, only one will be matched but not consistently because the internal
order of patterns and pattern groups is changed dynamically by xm_pattern (patterns with the
highest match count are placed and tried first). For a strictly linearly executing pattern matcher,
see the Exec directive.
The XML Schema Definition (XSD) for the pattern database file is available in the nxlog-
NOTE
public/contrib repository.
130.23.1. Configuration
The xm_pattern module accepts the following directives in addition to the common module directives.
PatternFile
This mandatory directive specifies the name of the pattern database file.
130.23.2. Functions
The following functions are exported by xm_pattern.
boolean match_pattern()
Execute the match_pattern() procedure. If the event is successfully matched, return TRUE, otherwise FALSE.
130.23.3. Procedures
The following procedures are exported by xm_pattern.
match_pattern();
Attempt to match the current event according to the PatternFile. Execute statements and add fields as
specified.
130.23.4. Fields
The following fields are used by xm_pattern.
1083
NXLog User Guide Chapter 130. Extension Modules
130.23.5. Examples
1084
Chapter 130. Extension Modules NXLog User Guide
This configuration reads Syslog messages from file and parses them with parse_syslog(). The events are
then further processed with a pattern file and the corresponding match_pattern() procedure to add
additional fields to SSH authentication success or failure events. The matching is done against the
$SourceName and $Message fields, so the Syslog parsing must be performed before the pattern matching
will work.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension pattern>
6 Module xm_pattern
7 PatternFile 'modules/extension/pattern/patterndb2-3.xml'
8 </Extension>
9
10 <Input in>
11 Module im_file
12 File 'test2.log'
13 <Exec>
14 parse_syslog();
15 match_pattern();
16 </Exec>
17 </Input>
The following pattern database contains two patterns to match SSH authentication messages. The patterns
are under a group named ssh which checks whether the $SourceName field is sshd and only tries to match
the patterns if the logs are indeed from sshd. The patterns both extract $AuthMethod, $AccountName, and
$SourceIP4Address fields from the log message when the pattern matches the log. Additionally
$TaxonomyStatus and $TaxonomyAction are set. The second pattern shows an Exec block example, which
is evaluated when the pattern matches.
patterndb2-3.xml
<?xml version='1.0' encoding='UTF-8'?>
<patterndb>
<created>2018-01-01 01:02:03</created>
<version>4</version>
<group>
<name>ssh</name>
<id>1</id>
<matchfield>
<name>SourceName</name>
<type>exact</type>
<value>sshd</value>
</matchfield>
<pattern>
<id>1</id>
<name>ssh auth success</name>
<matchfield>
<name>Message</name>
<type>regexp</type>
<value>^Accepted (\S+) for (\S+) from (\S+) port \d+ ssh2</value>
<capturedfield>
<name>AuthMethod</name>
1085
NXLog User Guide Chapter 130. Extension Modules
<type>string</type>
</capturedfield>
<capturedfield>
<name>AccountName</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>SourceIP4Address</name>
<type>ipaddr</type>
</capturedfield>
</matchfield>
<set>
<field>
<name>TaxonomyStatus</name>
<value>success</value>
<type>string</type>
</field>
<field>
<name>TaxonomyAction</name>
<value>authenticate</value>
<type>string</type>
</field>
</set>
</pattern>
<pattern>
<id>2</id>
<name>ssh auth failure</name>
<matchfield>
<name>Message</name>
<type>regexp</type>
<value>^Failed (\S+) for invalid user (\S+) from (\S+) port \d+ ssh2</value>
<capturedfield>
<name>AuthMethod</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>AccountName</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>SourceIP4Address</name>
<type>ipaddr</type>
</capturedfield>
</matchfield>
<set>
<field>
<name>TaxonomyStatus</name>
<value>failure</value>
<type>string</type>
</field>
<field>
<name>TaxonomyAction</name>
<value>authenticate</value>
<type>string</type>
</field>
1086
Chapter 130. Extension Modules NXLog User Guide
</set>
<exec>
$TestField = 'test';
$TestField = $Testfield + 'value';
</exec>
</pattern>
</group>
</patterndb>
This example is the same as the previous one, and uses the same pattern file, but it uses the
match_pattern() function to discard any event that is not matched by the pattern file.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension pattern>
6 Module xm_pattern
7 PatternFile modules/extension/pattern/patterndb2-3.xml
8 </Extension>
9
10 <Input in>
11 Module im_file
12 File 'test2.log'
13 <Exec>
14 parse_syslog();
15 if not match_pattern() drop();
16 </Exec>
17 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
While the NXLog language is already a powerful framework, it is not intended to be a fully featured programming
language and does not provide lists, arrays, hashes, and other features available in many high-level languages.
With this module, Perl can be used to process event data via a built-in Perl interpreter. See also the im_perl and
om_perl modules.
The Perl interpreter is only loaded if the module is declared in the configuration. The module will parse the file
specified in the PerlCode directive when NXLog starts the module. This file should contain one or more methods
which can be called from the Exec directive of any module that will use Perl for log processing. See the example
below.
1087
NXLog User Guide Chapter 130. Extension Modules
Perl code defined via this module must not be called from the im_perl and om_perl
WARNING
modules as that would involve two Perl interpreters and will likely result in a crash.
To use the xm_perl module on Windows, a separate Perl environment must be installed.
Currently, the only environment supported is a specific version of Strawberry Perl, 5.28.2.1.
NOTE
Newer versions will not work. See the release notes. To download the MSI installer for this
version (100 MB), click here.
To access event data, the Log::Nxlog module must be included, which provides the following methods.
log_debug(msg)
Send the message msg to the internal logger on DEBUG log level. This method does the same as the
log_debug() procedure in NXLog.
log_info(msg)
Send the message msg to the internal logger on INFO log level. This method does the same as the log_info()
procedure in NXLog.
log_warning(msg)
Send the message msg to the internal logger on WARNING log level. This method does the same as the
log_warning() procedure in NXLog.
log_error(msg)
Send the message msg to the internal logger on ERROR log level. This method does the same as the
log_error() procedure in NXLog.
delete_field(event, key)
Delete the value associated with the field named key.
field_names(event)
Return a list of the field names contained in the event data. This method can be used to iterate over all of the
fields.
field_type(event, key)
Return a string representing the type of the value associated with the field named key.
get_field(event, key)
Retrieve the value associated with the field named key. This method returns a scalar value if the key exists
and the value is defined, otherwise it returns undef.
For the full NXLog Perl API, see the POD documentation in Nxlog.pm. The documentation can be read with
perldoc Log::Nxlog.
130.24.1. Configuration
The xm_perl module accepts the following directives in addition to the common module directives.
1088
Chapter 130. Extension Modules NXLog User Guide
PerlCode
This mandatory directive expects a file containing valid Perl code. This file is read and parsed by the Perl
interpreter. Methods defined in this file can be called with the call() procedure.
On Windows, the Perl script invoked by the PerlCode directive must define the Perl library
paths at the beginning of the script to provide access to the Perl modules.
NOTE
nxlog-windows.pl
use lib 'c:\Program Files\nxlog\data';
Config
This optional directive allows you to pass configuration strings to the script file defined by the PerlCode
directive. This is a block directive and any text enclosed within <Config></Config> is submitted as a single
string literal to the Perl code.
If you pass several values using this directive (for example, separated by the \n delimiter) be
NOTE
sure to parse the string correspondingly inside the Perl code.
130.24.2. Procedures
The following procedures are exported by xm_perl.
call(string subroutine);
Call the given Perl subroutine.
130.24.3. Examples
1089
NXLog User Guide Chapter 130. Extension Modules
In this example, logs are parsed as Syslog and then are passed to a Perl method which does a GeoIP lookup
on the source address of the incoming message.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension perl>
6 Module xm_perl
7 PerlCode modules/extension/perl/processlogs.pl
8 </Extension>
9
10 <Output fileout>
11 Module om_file
12 File 'tmp/output'
13
14 # First we parse the input natively from nxlog
15 Exec parse_syslog_bsd();
16
17 # Now call the 'process' subroutine defined in 'processlogs.pl'
18 Exec perl_call("process");
19
20 # You can also invoke this public procedure 'call' in case
21 # of multiple xm_perl instances like this:
22 # Exec perl->call("process");
23 </Output>
processlogs.pl (truncated)
use strict;
use warnings;
# Without Log::Nxlog you cannot access (read or modify) the event data
use Log::Nxlog;
use Geo::IP;
my $geoip;
BEGIN
{
# This will be called once when nxlog starts so you can use this to
# initialize stuff here
#$geoip = Geo::IP->new(GEOIP_MEMORY_CACHE);
$geoip = Geo::IP->open('modules/extension/perl/GeoIP.dat', GEOIP_MEMORY_CACHE);
}
[...]
The file specified by the PythonCode directive should contain one or more methods which can be called from the
Exec directive of any module. See also the im_python and om_python modules.
1090
Chapter 130. Extension Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The Python script should import the nxlog module, and will have access to the following classes and functions.
nxlog.log_debug(msg)
Send the message msg to the internal logger at DEBUG log level. This function does the same as the core
log_debug() procedure.
nxlog.log_info(msg)
Send the message msg to the internal logger at INFO log level. This function does the same as the core
log_info() procedure.
nxlog.log_warning(msg)
Send the message msg to the internal logger at WARNING log level. This function does the same as the core
log_warning() procedure.
nxlog.log_error(msg)
Send the message msg to the internal logger at ERROR log level. This function does the same as the core
log_error() procedure.
class nxlog.Module
This class is instantiated by NXLog and can be accessed via the LogData.module attribute. This can be used to
set or access variables associated with the module (see the example below).
class nxlog.LogData
This class represents an event. It is instantiated by NXLog and passed to the method specified by the
python_call() procedure.
delete_field(name)
This method removes the field name from the event record.
field_names()
This method returns a list with the names of all the fields currently in the event record.
get_field(name)
This method returns the value of the field name in the event.
set_field(name, value)
This method sets the value of field name to value.
module
This attribute is set to the Module object associated with the event.
130.25.1. Configuration
The xm_python module accepts the following directives in addition to the common module directives.
PythonCode
This mandatory directive specifies a file containing Python code. The python_call() procedure can be used to
call a Python function defined in the file. The function must accept an nxlog.LogData object as its argument.
130.25.2. Procedures
The following procedures are exported by xm_python.
1091
NXLog User Guide Chapter 130. Extension Modules
call(string subroutine);
Call the given Python subroutine.
python_call(string function);
Call the specified function, which must accept an nxlog.LogData() object as its only argument.
130.25.3. Examples
1092
Chapter 130. Extension Modules NXLog User Guide
This configuration calls two Python functions to modify each event record. The add_checksum() uses
Python’s hashlib module to add a $ChecksumSHA1 field to the event; the add_counter() function adds a
$Counter field for non-DEBUG events.
The pm_hmac module offers a more complete implementation for checksumming. See
NOTE
Statistical Counters for a native way to add counters.
nxlog.conf (truncated)
1 </Input>
2
3 <Extension _json>
4 Module xm_json
5 DateFormat YYYY-MM-DD hh:mm:ss
6 </Extension>
7
8 <Extension _syslog>
9 Module xm_syslog
10 </Extension>
11
12 <Extension python>
13 Module xm_python
14 PythonCode modules/extension/python/py/processlogs2.py
15 </Extension>
16
17 <Output out>
18 Module om_file
19 File 'tmp/output'
20 <Exec>
21 # The $SeverityValue field is added by this procedure.
22 # Most other parsers also add a normalized severity value.
23 parse_syslog();
24
25 # Add a counter for each event with log level above DEBUG.
26 python_call('add_counter');
27
28 # Calculate a checksum (after the counter field is added).
29 [...]
1093
NXLog User Guide Chapter 130. Extension Modules
processlogs2.py (truncated)
import hashlib
import nxlog
def add_checksum(event):
# Convert field list to dictionary
all = {}
for field in event.field_names():
all.update({field: event.get_field(field)})
def add_counter(event):
# Get module object and initialize counter
module = event.module
[...]
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.26.1. Configuration
The xm_resolver module accepts the following directives in addition to the common module directives.
CacheExpiry
Specifies the time in seconds after entries in the cache are considered invalid and are refreshed by issuing a
DNS lookup. The default expiry is 3600 seconds.
CacheLimit
This directive can be used to specify an upper limit on the number of entries in the cache in order to prevent
the cache from becoming arbitrary large and potentially exhausting memory. When the number of entries in
the cache reaches this value, no more items will be inserted into the cache. The default is 100,000 entries.
130.26.2. Functions
The following functions are exported by xm_resolver.
1094
Chapter 130. Extension Modules NXLog User Guide
130.26.3. Examples
1095
NXLog User Guide Chapter 130. Extension Modules
It is common for devices to send Syslog messages containing the IP address of the device instead of a real
hostname. In this example, Syslog messages are parsed and the hostname field of each Syslog header is
converted to a hostname if it looks like an IP address.
nxlog.conf (truncated)
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _resolver>
6 Module xm_resolver
7 </Extension>
8
9 <Input tcp>
10 Module im_tcp
11 ListenAddr 0.0.0.0:1514
12 <Exec>
13 parse_syslog();
14 if $Hostname =~ /^\d+\.\d+\.\d+\.\d+/
15 {
16 $HostIP = $Hostname;
17 $Hostname = ipaddr_to_name($HostIP);
18 if not defined $Hostname $Hostname = $HostIP;
19
20 if ($Hostname == ipaddr_to_name("127.0.0.1"))
21 {
22 $Hostname = "localhost";
23 }
24 }
25 </Exec>
26 </Input>
27
28 <Output file>
29 [...]
Input Sample
<38>2014-11-11 11:40:27 127.0.0.1 sshd[3436]: Failed none for invalid user asdf from 127.0.0.1
port 51824 ssh2↵
<38>2014-11-12 12:42:37 127.0.0.1 sshd[3436]: Failed password for invalid user fdsa from
127.0.0.1 port 51824 ssh2↵
Output Sample
<38>Nov 11 11:40:27 localhost sshd[3436]: Failed none for invalid user asdf from 127.0.0.1 port
51824 ssh2↵
<38>Nov 12 12:42:37 localhost sshd[3436]: Failed password for invalid user fdsa from 127.0.0.1
port 51824 ssh2↵
• renaming fields,
• deleting specified fields (blacklist),
• keeping only a list of specified fields (whitelist), and
1096
Chapter 130. Extension Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The xm_rewrite module provides Delete, Keep, and Rename directives for modifying event records. With the Exec
directive of this module, it is possible to invoke functions and procedures from other modules. This allows all
data transformation to be configured in a single module instance in order to simplify the configuration. Then the
transformation can be referenced from another module by adding:
Exec rewrite->process();
This same statement can be used by more than one module instance if necessary, rather than duplicating
configuration.
130.27.1. Configuration
The xm_rewrite module accepts the following directives in addition to the common module directives.
The order of the action directives is significant as the module executes them in the order of appearance. It is
possible to configure an xm_rewrite instance with no directives (other than the Module directive). In this case, the
corresponding process() procedure will do nothing.
Delete
This directive takes a field name or a list of fields. The fields specified will be removed from the event record.
This can be used to blacklist specific fields that are not wanted in the event record. This is equivalent to using
delete() in Exec.
Exec
This directive works the same way as the Exec directive in other modules: the statement(s) provided in the
argument/block will be evaluated in the context of the module that called process() (i.e., as though the
statement(s) from this Exec directive/block were inserted into the caller’s Exec directive/block, at the location
of the process() call).
Keep
This directive takes a field name or a list of fields. The fields specified will be kept and all other fields not
appearing in the list will be removed from the event record. This can be used to whitelist specific fields.
To retain only the $raw_event field, use Keep raw_event (it is not possible to delete the $raw_event field).
This can be helpful for discarding extra event fields after $raw_event has been set (with to_json(), for
example) and before an output module that operates on all fields in the event record (such as
om_batchcompress).
Rename
This directive takes two fields. The field in the first argument will be renamed to the name in the second. This
is equivalent to using rename_field() in Exec.
130.27.2. Procedures
The following procedures are exported by xm_rewrite.
process();
This procedure invokes the data processing as specified in the configuration of the xm_rewrite module
instance.
1097
NXLog User Guide Chapter 130. Extension Modules
130.27.3. Examples
Example 661. Using xm_rewrite to Transform Syslog Data Read from File
The following configuration parses Syslog data from a file, invokes the process() procedure of the xm_rewrite
instance to keep and rename whitelisted fields, then writes JSON-formatted output to a file.
nxlog.conf (truncated)
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension rewrite>
6 Module xm_rewrite
7 Keep EventTime, Severity, Hostname, SourceName, Message
8 Rename EventTime, timestamp
9 Rename Hostname, host
10 Rename SourceName, src
11 Rename Message, msg
12 Rename Severity, sev
13 Exec if $msg =~ /error/ $sev = 'ERROR';
14 </Extension>
15
16 <Extension json>
17 Module xm_json
18 </Extension>
19
20 <Input syslogfile>
21 Module im_file
22 File "modules/extension/rewrite/xm_rewrite.in"
23 Exec parse_syslog();
24 Exec rewrite->process();
25 </Input>
26
27 <Output fileout>
28 Module om_file
29 [...]
Input Sample
<0>2010-10-12 12:49:06 mybox app[12345]: kernel message↵
<30>2010-10-12 12:49:06 mybox app[12345]: daemon - info↵
<27>2010-10-12 12:49:06 mybox app[12345]: daemon - error↵
<30>2010-10-12 13:19:11 mybox app[12345]: There was an error↵
Output Sample
{"sev":"CRITICAL","host":"mybox","timestamp":"2010-10-12 12:49:06","src":"app","msg":"kernel
message"}
{"sev":"INFO","host":"mybox","timestamp":"2010-10-12 12:49:06","src":"app","msg":"daemon -
info"}
{"sev":"ERROR","host":"mybox","timestamp":"2010-10-12 12:49:06","src":"app","msg":"daemon -
error"}
{"sev":"ERROR","host":"mybox","timestamp":"2010-10-12 13:19:11","src":"app","msg":"There was an
error"}
1098
Chapter 130. Extension Modules NXLog User Guide
The following configuration does the exact same processing. In this case, however, the Syslog parsing is
moved into the xm_rewrite module instance so the input module only needs to invoke the process()
procedure.
nxlog.conf (truncated)
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension rewrite>
6 Module xm_rewrite
7 Exec parse_syslog();
8 Keep EventTime, Severity, Hostname, SourceName, Message
9 Rename EventTime, timestamp
10 Rename Hostname, host
11 Rename SourceName, src
12 Rename Message, msg
13 Rename Severity, sev
14 Exec if $msg =~ /error/ $sev = 'ERROR';
15 </Extension>
16
17 <Extension json>
18 Module xm_json
19 </Extension>
20
21 <Input syslogfile>
22 Module im_file
23 File "modules/extension/rewrite/xm_rewrite.in"
24 Exec rewrite->process();
25 </Input>
26
27 <Output fileout>
28 Module om_file
29 [...]
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Nxlog.log_info(msg)
Send the message msg to the internal logger at DEBUG log level. This method does the same as the core
log_debug() procedure.
Nxlog.log_debug(msg)
Send the message msg to the internal logger at INFO log level. This method does the same as the core
log_info() procedure.
1099
NXLog User Guide Chapter 130. Extension Modules
Nxlog.log_warning(msg)
Send the message msg to the internal logger at WARNING log level. This method does the same as the core
log_warning() procedure.
Nxlog.log_error(msg)
Send the message msg to the internal logger at ERROR log level. This method does the same as the core
log_error() procedure.
class Nxlog.LogData
This class represents an event.
field_names()
This method returns an array with the names of all the fields currently in the event record.
get_field(name)
This method returns the value of the field name in the event.
set_field(name, value)
This method sets the value of field name to value.
130.28.1. Configuration
The xm_ruby module accepts the following directives in addition to the common module directives.
RubyCode
This mandatory directive expects a file containing valid Ruby code. Methods defined in this file can be called
with the ruby_call() procedure.
130.28.2. Procedures
The following procedures are exported by xm_ruby.
call(string subroutine);
Calls the Ruby method provided in the first argument.
ruby_call(string subroutine);
Calls the Ruby method provided in the first argument.
130.28.3. Examples
1100
Chapter 130. Extension Modules NXLog User Guide
In this example logs are parsed as Syslog, then the data is passed to a Ruby method which adds an
incrementing $AlertCounter field for any event with a normalized $SeverityValue of at least 4.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension ruby>
6 Module xm_ruby
7 RubyCode ./modules/extension/ruby/processlogs2.rb
8 </Extension>
9
10 <Input in>
11 Module im_file
12 File 'test2.log'
13 <Exec>
14 parse_syslog();
15 ruby->call('add_alert_counter');
16 </Exec>
17 </Input>
processlogs2.rb
$counter = 0
def add_alert_counter(event)
if event.get_field('SeverityValue') >= 4
Nxlog.log_debug('Adding AlertCounter field')
$counter += 1
event.set_field('AlertCounter', $counter)
end
end
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Like the xm_syslog module, the xm_snmp module does not provide support for the network transport layer. Since
traps are sent primarily over UDP (typically to port 162), the im_udp module should be used together with this
module. This module registers an input reader function under the name "snmp" which can be used in the
InputType directive to parse UDP message payloads.
The module supports MIB definitions in order to resolve OID numbers to names. In addition to the standard
xm_snmp module fields and the im_udp module fields, each variable in the trap message will be available as an
internal NXLog field. If the OID cannot be resolved to a name, the string OID. will be prepended to the dotted
OID number representation in the field name. For example, if a trap contains a string variable with OID
1.3.6.1.4.1.311.1.13.1.9999.3.0, this field can be accessed as the NXLog field
1101
NXLog User Guide Chapter 130. Extension Modules
To convert the output to Syslog format, consider using one of the to_syslog() procedures
NOTE provided by the xm_syslog module. However, note that the resulting format will not be in
accordance with RFC 5675.
Microsoft Windows can convert and forward EventLog messages as SNMPv1 traps. The evntwin utility can be
used to configure which events are sent as traps. See How to Generate SNMP traps from Windows Events for
more information about setting up this feature.
The Net-SNMP toolkit (available for Unix/Linux and Windows) provides the snmptrap command line utility which
can be used for sending test SNMP traps. Create the following MIB definition file and put it in a directory
specified by the MIBDir directive:
demo-trap TRAP-TYPE
STATUS current
ENTERPRISE demotraps
VARIABLES { sysLocation }
DESCRIPTION "This is just a demo"
::= 17
END
Here is an example for invoking the snmptrap utility (line break added):
The received trap should look like this in the $raw_event field:
If the MIB definition can not be loaded or parsed, the unresolved OID number will be seen in the message:
130.29.1. Configuration
The xm_snmp module accepts the following directives in addition to the common module directives.
1102
Chapter 130. Extension Modules NXLog User Guide
AllowAuthenticatedOnly
This boolean directive specifies whether only authenticated SNMP v3 traps should be accepted. If set to TRUE,
the User block must also be defined, and unauthenticated SNMP traps are not accepted. The default is FALSE:
all SNMP traps are accepted.
MIBDir
This optional directive can be used to define a directory which contains MIB definition files. Multiple MIBDir
directives can be specified.
User
This directive is specified as a block (see Parsing Authenticated and Encrypted SNMP Traps) and provides the
authentication details for an SNMP v3 user. The block must be named with the corresponding user. This
block can be specified more than once to provide authentication details for multiple users.
AuthPasswd
This required directive specifies the authentication password.
AuthProto
This optional directive specifies the authentication protocol to use. Supported values are md5 and sha1. If
this directive is not specified, the default is md5.
EncryptPasswd
This directive specifies the encryption password to use for encrypted traps.
EncryptProto
This optional directive specifies the encryption protocol to use. Supported values are des and aes. The
default, if encryption is in use and this directive is not specified, is des.
130.29.2. Fields
The following fields are used by xm_snmp.
1103
NXLog User Guide Chapter 130. Extension Modules
130.29.3. Examples
Example 664. Using MIB Definitions to Parse SNMP Traps
The InputType snmp directive in the im_udp module block is required to parse the SNMP payload in the
UDP message.
nxlog.conf
1 <Extension snmp>
2 Module xm_snmp
3 MIBDir /usr/share/mibs/iana
4 MIBDir /usr/share/mibs/ietf
5 MIBDir /usr/share/mibs/site
6 </Extension>
7
8 <Input udp>
9 Module im_udp
10 ListenAddr 0.0.0.0:162
11 InputType snmp
12 </Input>
1104
Chapter 130. Extension Modules NXLog User Guide
This configuration parses SNMP v3 traps. Only authenticated traps are parsed; a warning is printed for each
non-authenticated source that sends a trap. The User block provides authentication and encryption
settings for the switch1 user.
nxlog.conf
1 <Extension snmp>
2 Module xm_snmp
3 MIBDir /usr/share/mibs/iana
4 MIBDir /usr/share/mibs/ietf
5 AllowAuthenticatedOnly TRUE
6 <User switch1>
7 AuthPasswd secret
8 AuthProto sha1
9 EncryptPasswd secret
10 EncryptProto aes
11 </User>
12 </Extension>
13
14 <Input udp>
15 Module im_udp
16 Host 0.0.0.0
17 Port 162
18 InputType snmp
19 </Input>
This module will be completely removed in a future release, please update your configuration
NOTE
files.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The older but still widespread BSD Syslog standard defines both the format and the transport protocol in RFC
3164. The transport protocol is UDP, but to provide reliability and security, this line-based format is also
commonly transferred over TCP and SSL. There is a newer standard defined in RFC 5424, also known as the IETF
Syslog format, which obsoletes the BSD Syslog format. This format overcomes most of the limitations of BSD
Syslog and allows multi-line messages and proper timestamps. The transport method is defined in RFC 5426 for
UDP and RFC 5425 for TLS/SSL.
Because the IETF Syslog format supports multi-line messages, RFC 5425 defines a special format to encapsulate
these by prepending the payload size in ASCII to the IETF Syslog message. Messages transferred in UDP packets
1105
NXLog User Guide Chapter 130. Extension Modules
are self-contained and do not need this additional framing. The following input reader and output writer
functions are provided by the xm_syslog module to support this TLS transport defined in RFC 5425. While RFC
5425 explicitly defines that the TLS network transport protocol is to be used, pure TCP may be used if security is
not a requirement. Syslog messages can also be written to file with this framing format using these functions.
InputType Syslog_TLS
This input reader function parses the payload size and then reads the message according to this value. It is
required to support Syslog TLS transport defined in RFC 5425.
OutputType Syslog_TLS
This output writer function prepends the payload size to the message. It is required to support Syslog TLS
transport defined in RFC 5425.
The Syslog_TLS InputType/OutputType can work with any input/output such as im_tcp or im_file
NOTE and does not depend on SSL transport at all. The name Syslog_TLS was chosen to refer to the
octet-framing method described in RFC 5425 used for TLS transport.
The pm_transformer module can also parse and create BSD and IETF Syslog messages, but the
NOTE functions and procedures provided by this module make it possible to solve more complex tasks
which pm_transformer is not capable of on its own.
Structured data in IETF Syslog messages is parsed and put into NXLog fields. The SD-ID will be prepended to the
field name with a dot unless it is NXLOG@XXXX. Consider the following Syslog message:
After this IETF-formatted Syslog message is parsed with parse_syslog_ietf(), there will be two additional fields:
$exampleSDID.eventID and $exampleSDID.eventSource. When SD-ID is NXLOG, the field name will be the
same as the SD-PARAM name. The two additional fields extracted from the structured data part of the following
IETF Syslog message are $eventID and $eventSource:
130.31.1. Configuration
The xm_syslog module accepts the following directives in addition to the common module directives.
IETFTimestampInGMT
This is an alias for the UTCTimestamp directive below.
ReplaceLineBreaks
This optional directive specifies a character with which to replace line breaks in the Syslog message when
generating Syslog events with to_syslog_bsd(), to_syslog_ietf(), and to_syslog_snare(). The default is a space. To
retain line breaks in Syslog messages, set this to \n.
SnareDelimiter
This optional directive takes a single character (see below) as argument. This character is used by the
to_syslog_snare() procedure to separate fields. If this directive is not specified, the default delimiter character
is the tab (\t). In latter versions of Snare 4 this has changed to the hash mark (#); this directive can be used to
specify the alternative delimiter. Note that there is no delimiter after the last field.
1106
Chapter 130. Extension Modules NXLog User Guide
SnareReplacement
This optional directive takes a single character (see below) as argument. This character is used by the
to_syslog_snare() procedure to replace occurrences of the delimiter character inside the $Message field. If this
directive is not specified, the default replacement character is the space.
UTCTimestamp
This optional boolean directive can be used to format the timestamps produced by to_syslog_ietf() in
UTC/GMT instead of local time. The default is FALSE: local time is used with a timezone indicator.
Delimiter ;
Control characters
The following non-printable characters can be specified with escape sequences:
\a
audible alert (bell)
\b
backspace
\t
horizontal tab
\n
newline
\v
vertical tab
\f
formfeed
\r
carriage return
Delimiter \t
Delimiter ';'
1107
NXLog User Guide Chapter 130. Extension Modules
Delimiter '\'
Delimiter "\"
Delimiter 0x20
130.31.2. Functions
The following functions are exported by xm_syslog.
130.31.3. Procedures
The following procedures are exported by xm_syslog.
parse_syslog();
Parse the $raw_event field as either BSD Syslog (RFC 3164) or IETF Syslog (RFC 5424) format.
parse_syslog(string source);
Parse the given string as either BSD Syslog (RFC 3164) or IETF Syslog (RFC 5424) format.
parse_syslog_bsd();
Parse the $raw_event field as BSD Syslog (RFC 3164) format.
parse_syslog_bsd(string source);
Parse the given string as BSD Syslog (RFC 3164) format.
parse_syslog_ietf();
Parse the $raw_event field as IETF Syslog (RFC 5424) format.
1108
Chapter 130. Extension Modules NXLog User Guide
parse_syslog_ietf(string source);
Parse the given string as IETF Syslog (RFC 5424) format.
to_syslog_bsd();
Create a BSD Syslog formatted log message in $raw_event from the fields of the event. The following fields
are used to construct the $raw_event field: $EventTime; $Hostname; $SourceName; $ProcessID or
$ExecutionProcessID; $Message or $raw_event; $SyslogSeverity, $SyslogSeverityValue, $Severity, or
$SeverityValue; and $SyslogFacility or $SyslogFacilityValue. If the fields are not present, a sensible default is
used.
to_syslog_ietf();
Create an IETF Syslog (RFC 5424) formatted log message in $raw_event from the fields of the event. The
following fields are used to construct the $raw_event field: $EventTime; $Hostname; $SourceName;
$ProcessID or $ExecutionProcessID; $Message or $raw_event; $SyslogSeverity, $SyslogSeverityValue,
$Severity, or $SeverityValue; and $SyslogFacility or $SyslogFacilityValue. If the fields are not present, a
sensible default is used.
to_syslog_snare();
Create a SNARE Syslog formatted log message in $raw_event. The following fields are used to construct the
$raw_event field: $EventTime, $Hostname, $SeverityValue, $FileName, $Channel, $SourceName,
$AccountName, $AccountType, $EventType, $Category, $RecordNumber, and $Message.
130.31.4. Fields
The following fields are used by xm_syslog.
In addition to the fields listed below, the parse_syslog() and parse_syslog_ietf() procedures will create fields from
the Structured Data part of an IETF Syslog message. If the SD-ID in this case is not "NXLOG", these fields will be
prefixed by the SD-ID (for example, $mySDID.CustomField).
1109
NXLog User Guide Chapter 130. Extension Modules
Syslog Normalized
Severity Severity
0/emerg 5/critical
1/alert 5/critical
2/crit 5/critical
3/err 4/error
4/warning 3/warning
5/notice 2/info
6/info 2/info
7/debug 1/debug
130.31.5. Examples
1110
Chapter 130. Extension Modules NXLog User Guide
In this example, logs are collected from files, converted to BSD Syslog format with the to_syslog_bsd()
procedure, and sent over UDP with the om_udp module.
nxlog.conf (truncated)
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input file>
6 Module im_file
7
8 # We monitor all files matching the wildcard.
9 # Every line is read into the $raw_event field.
10 File "/var/log/app*.log"
11
12 <Exec>
13 # Set the $EventTime field usually found in the logs by
14 # extracting it with a regexp. If this is not set, the current
15 # system time will be used which might be a little off.
16 if $raw_event =~ /(\d\d\d\d\-\d\d-\d\d \d\d:\d\d:\d\d)/
17 {
18 $EventTime = parsedate($1);
19 }
20
21 # Now set the severity to something custom. This defaults to
22 # 'INFO' if unset.
23 if $raw_event =~ /ERROR/ $Severity = 'ERROR';
24 else $Severity = 'INFO';
25
26 # The facility can be also set, otherwise the default value is
27 # 'USER'.
28 $SyslogFacility = 'AUDIT';
29 [...]
1111
NXLog User Guide Chapter 130. Extension Modules
To collect BSD Syslog messages over UDP, use the parse_syslog_bsd() procedure coupled with the im_udp
module as in the following example.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 ListenAddr 0.0.0.0:514
8 Exec parse_syslog_bsd();
9 </Input>
10
11 <Output file>
12 Module om_file
13 File "/var/log/logmsg.txt"
14 </Output>
15
16 <Route syslog_to_file>
17 Path udp => file
18 </Route>
To collect IETF Syslog messages over UDP as defined by RFC 5424 and RFC 5426, use the parse_syslog_ietf()
procedure coupled with the im_udp module as in the following example. Note that, as for BSD Syslog, the
default port is 514 (as defined by RFC 5426).
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input ietf>
6 Module im_udp
7 ListenAddr 0.0.0.0:514
8 Exec parse_syslog_ietf();
9 </Input>
10
11 <Output file>
12 Module om_file
13 File "/var/log/logmsg.txt"
14 </Output>
15
16 <Route ietf_to_file>
17 Path ietf => file
18 </Route>
1112
Chapter 130. Extension Modules NXLog User Guide
Example 669. Collecting Both IETF and BSD Syslog Messages over the Same UDP Port
To collect both IETF and BSD Syslog messages over UDP, use the parse_syslog() procedure coupled with the
im_udp module as in the following example. This procedure is capable of detecting and parsing both Syslog
formats. Since 514 is the default UDP port number for both BSD and IETF Syslog, this port can be useful to
collect both formats simultaneously. To accept both formats on different ports, the appropriate parsers can
be used as in the previous two examples.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 ListenAddr 0.0.0.0:514
8 Exec parse_syslog();
9 </Input>
10
11 <Output file>
12 Module om_file
13 File "/var/log/logmsg.txt"
14 </Output>
15
16 <Route syslog_to_file>
17 Path udp => file
18 </Route>
1113
NXLog User Guide Chapter 130. Extension Modules
To collect IETF Syslog messages over TLS/SSL as defined by RFC 5424 and RFC 5425, use the
parse_syslog_ietf() procedure coupled with the im_ssl module as in this example. Note that the default port
is 6514 in this case (as defined by RFC 5425). The payload format parser is handled by the Syslog_TLS input
reader.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input ssl>
6 Module im_ssl
7 ListenAddr localhost:6514
8 CAFile %CERTDIR%/ca.pem
9 CertFile %CERTDIR%/client-cert.pem
10 CertKeyFile %CERTDIR%/client-key.pem
11 KeyPass secret
12 InputType Syslog_TLS
13 Exec parse_syslog_ietf();
14 </Input>
15
16 <Output file>
17 Module om_file
18 File "/var/log/logmsg.txt"
19 </Output>
20
21 <Route ssl_to_file>
22 Path ssl => file
23 </Route>
1114
Chapter 130. Extension Modules NXLog User Guide
The following configuration uses the to_syslog_ietf() procedure to convert input to IETF Syslog and forward
it over TCP.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input file>
6 Module im_file
7 File "/var/log/input.txt"
8 Exec $TestField = "test value"; $Message = $raw_event;
9 </Input>
10
11 <Output tcp>
12 Module om_tcp
13 Host 127.0.0.1:1514
14 Exec to_syslog_ietf();
15 OutputType Syslog_TLS
16 </Output>
17
18 <Route file_to_syslog>
19 Path file => tcp
20 </Route>
Because of the Syslog_TLS framing, the raw data sent over TCP will look like the following.
Output Sample
130 <13>1 2012-01-01T16:15:52.873750Z - - - [NXLOG@14506 EventReceivedTime="2012-01-01
17:15:52" TestField="test value"] test message↵
This example shows that all fields—except those which are filled by the Syslog parser—are added to the
structured data part.
1115
NXLog User Guide Chapter 130. Extension Modules
If the message part of the Syslog event matches the regular expression, the $SeverityValue field will be
set to the "error" Syslog severity integer value (which is provided by the syslog_severity_value() function).
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 ListenAddr 0.0.0.0:514
8 Exec parse_syslog_bsd();
9 </Input>
10
11 <Output file>
12 Module om_file
13 File "/var/log/logmsg.txt"
14 Exec if $Message =~ /error/ $SeverityValue = syslog_severity_value("error");
15 Exec to_syslog_bsd();
16 </Output>
17
18 <Route syslog_to_file>
19 Path udp => file
20 </Route>
1116
Chapter 130. Extension Modules NXLog User Guide
The following example does almost the same thing as the previous example, except that the Syslog parsing
and rewrite is moved to a processor module and the rewrite only occurs if the facility was modified. This
can make processing faster on multi-core systems because the processor module runs in a separate
thread. This method can also minimize UDP packet loss because the input module does not need to parse
Syslog messages and therefore can process UDP packets faster.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input udp>
6 Module im_udp
7 ListenAddr 0.0.0.0:514
8 </Input>
9
10 <Processor rewrite>
11 Module pm_null
12 <Exec>
13 parse_syslog_bsd();
14 if $Message =~ /error/
15 {
16 $SeverityValue = syslog_severity_value("error");
17 to_syslog_bsd();
18 }
19 </Exec>
20 </Processor>
21
22 <Output file>
23 Module om_file
24 File "/var/log/logmsg.txt"
25 </Output>
26
27 <Route syslog_to_file>
28 Path udp => rewrite => file
29 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
A common W3C log source is Microsoft IIS, which produces output like the following:
1117
NXLog User Guide Chapter 130. Extension Modules
The format generated by Zeek is similar, as it too defines the field names in the header. The field types and
separator characters are also specified in the header. This allows the parser to automatically process the data.
Below is a sample from Zeek:
#separator \x09↵
#set_separator ,↵
#empty_field (empty)↵
#unset_field -↵
#path dns↵
#open 2013-04-09-21-01-43↵
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p proto
trans_id query qclass qclass_name qtype qtype_name rcode rcode_name AA
TC RD↵
RA Z answers TTLs↵
#types time string addr port addr port enum count string count string
count string count string bool bool bool bool count vector[string]
vector[interval]↵
1210953058.350065 m2EJRWK7sCg 192.168.2.16 1920 192.168.2.1 53 udp
16995 ipv6.google.com 1 C_INTERNET 28 AAAA 0 NOERROR F F T
T 0↵
ipv6.l.google.com,2001:4860:0:2001::68 8655.000000,300.000000↵
1210953058.350065 m2EJRWK7sCg 192.168.2.16 1920 192.168.2.1 53 udp
16995 ipv6.google.com 1 C_INTERNET 28 AAAA 0 NOERROR F F T
T 0↵
ipv6.l.google.com,2001:4860:0:2001::68 8655.000000,300.000000↵
To use the parser in an input module, the InputType directive must reference the instance name of the xm_w3c
module. See the example below.
130.32.1. Configuration
The xm_w3c module accepts the following directives in addition to the common module directives.
Delimiter
This optional directive takes a single character (see below) as argument to specify the delimiter character
used to separate fields. If this directive is not specified, the default delimiter character is either the space or
tab character, as detected. For Microsoft Exchange Message Tracking logs the comma must be set as the
delimiter:
Delimiter ,
Note that there is no delimiter after the last field in W3C, but Microsoft Exchange Message Tracking logs can
contain a trailing comma.
FieldType
This optional directive can be used to specify a field type for a particular field. For example, to parse a
ByteSent field as an integer, use FieldType ByteSent integer. This directive can be used more than once
1118
Chapter 130. Extension Modules NXLog User Guide
Delimiter ;
Control characters
The following non-printable characters can be specified with escape sequences:
\a
audible alert (bell)
\b
backspace
\t
horizontal tab
\n
newline
\v
vertical tab
\f
formfeed
\r
carriage return
Delimiter \t
Delimiter ';'
Delimiter '\'
1119
NXLog User Guide Chapter 130. Extension Modules
Delimiter "\"
Delimiter 0x20
130.32.2. Fields
The following fields are used by xm_w3c.
130.32.3. Examples
Example 674. Parsing Advanced IIS Logs
The following configuration parses logs from the IIS Advanced Logging Module using the pipe delimiter. The
logs are converted to JSON.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension w3cinput>
6 Module xm_w3c
7 Delimiter |
8 </Extension>
9
10 <Input w3c>
11 Module im_file
12 File 'C:\inetpub\logs\LogFiles\W3SVC\ex*.log'
13 InputType w3cinput
14 </Input>
15
16 <Output file>
17 Module om_file
18 File 'C:\test\IIS.json'
19 Exec to_json();
20 </Output>
21
22 <Route w3c_to_json>
23 Path w3c => file
24 </Route>
1120
Chapter 130. Extension Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
130.33.1. Configuration
The xm_wtmp module accepts only the common module directives.
130.33.2. Examples
1121
NXLog User Guide Chapter 130. Extension Modules
nxlog.conf
1 <Extension wtmp>
2 Module xm_wtmp
3 </Extension>
4
5 <Extension json>
6 Module xm_json
7 </Extension>
8
9 <Input in>
10 Module im_file
11 File '/var/log/wtmp'
12 InputType wtmp
13 Exec to_json();
14 </Input>
15
16 <Output out>
17 Module om_file
18 File '/var/log/wtmp.txt'
19 </Output>
20
21 <Route processwtmp>
22 Path in => out
23 </Route>
Output Sample
{
"EventTime":"2013-10-01 09:39:59",
"AccountName":"root",
"Device":"pts/1",
"LoginType":"login",
"EventReceivedTime":"2013-10-10 15:40:20",
"SourceModuleName":"input",
"SourceModuleType":"im_file"
}
{
"EventTime":"2013-10-01 23:23:38",
"AccountName":"shutdown",
"Device":"no device",
"LoginType":"shutdown",
"EventReceivedTime":"2013-10-11 10:58:00",
"SourceModuleName":"input",
"SourceModuleType":"im_file"
}
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1122
Chapter 130. Extension Modules NXLog User Guide
130.34.1. Configuration
The xm_xml module accepts the following directives in addition to the common module directives.
IgnoreRootTag
This optional boolean directive causes parse_xml() to omit the root tag when setting field names. For
example, when this is set to TRUE and the RootTag is set to Event, a field might be named
$Event.timestamp. With this directive set to FALSE, that field name would be $timestamp. The default value
is TRUE.
IncludeHiddenFields
This boolean directive specifies that the to_xml() function or the to_xml() procedure should inlude fields
having a leading underscore (_) in their names. The default is TRUE. If IncludeHiddenFields is set to TRUE,
then generated XML will contain these otherwise excluded fields.
Note that leading dot (.) is not allowed in XML attribute names thus field names having a leading dot (.) will
always be excluded from XML output.
ParseAttributes
When this optional boolean directive is set to TRUE, parse_xml() will also parse XML attributes. The default is
FALSE (attributes are not parsed). For example, if ParseAttributes is set to TRUE, the following would be
parsed into $Msg.time, $Msg.type, and $Msg:
RootTag
This optional directive can be used to specify the name of the root tag that will be used by to_xml() to
generate XML. The default RootTag is Event.
PrefixWinEvent
When this optional boolean directive is set to TRUE, parse_windows_eventlog_xml() will create EventData.
prefiexed fields from <EventData> section of event xml and UserData. prefiexed fields from <UserData>
section. The default PrefixWinEvent is FALSE.
130.34.2. Functions
The following functions are exported by xm_xml.
string to_xml()
Convert the fields to XML and returns this as a string value. The $raw_event field and any field having a
leading dot (.) or underscore (_) will be automatically excluded.
Note that directive IncludeHiddenFields has an effect on fields included in the output.
130.34.3. Procedures
The following procedures are exported by xm_xml.
parse_windows_eventlog_xml();
Parse the $raw_event field as windows eventlog XML input.
Any CR LF and any CR that is not followed by an LF will be translated to a single LF.
1123
NXLog User Guide Chapter 130. Extension Modules
parse_windows_eventlog_xml(string source);
Parse the given string as windows eventlog XML format.
Any CR LF and any CR that is not followed by an LF will be translated to a single LF.
parse_xml();
Parse the $raw_event field as XML input.
parse_xml(string source);
Parse the given string as XML format.
to_xml();
Convert the fields to XML and put this into the $raw_event field. The $raw_event field and any field having a
leading dot (.) or underscore (_) will be automatically excluded.
Note that directive IncludeHiddenFields has an effect on fields included in the output.
130.34.4. Examples
1124
Chapter 130. Extension Modules NXLog User Guide
The following configuration accepts Syslog (both BSD and IETF) and converts it to XML.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension xml>
6 Module xm_xml
7 </Extension>
8
9 <Input tcp>
10 Module im_tcp
11 ListenAddr 0.0.0.0:1514
12 Exec parse_syslog(); to_xml();
13 </Input>
14
15 <Output file>
16 Module om_file
17 File "/var/log/log.xml"
18 </Output>
19
20 <Route tcp_to_file>
21 Path tcp => file
22 </Route>
Input Sample
<30>Sep 30 15:45:43 host44.localdomain.hu acpid: 1 client rule loaded↵
Output Sample
<Event>
<MessageSourceAddress>127.0.0.1</MessageSourceAddress>
<EventReceivedTime>2012-03-08 15:05:39</EventReceivedTime>
<SyslogFacilityValue>3</SyslogFacilityValue>
<SyslogFacility>DAEMON</SyslogFacility>
<SyslogSeverityValue>6</SyslogSeverityValue>
<SyslogSeverity>INFO</SyslogSeverity>
<SeverityValue>2</SeverityValue>
<Severity>INFO</Severity>
<Hostname>host44.localdomain.hu</Hostname>
<EventTime>2012-09-30 15:45:43</EventTime>
<SourceName>acpid</SourceName>
<Message>1 client rule loaded</Message>
</Event>
1125
NXLog User Guide Chapter 130. Extension Modules
The following configuration reads the Windows EventLog and converts it to the BSD Syslog format where
the message part contains the fields in XML.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension xml>
6 Module xm_xml
7 </Extension>
8
9 <Input eventlog>
10 Module im_msvistalog
11 Exec $Message = to_xml(); to_syslog_bsd();
12 </Input>
13
14 <Output tcp>
15 Module om_tcp
16 Host 192.168.1.1:1514
17 </Output>
18
19 <Route eventlog_to_tcp>
20 Path eventlog => tcp
21 </Route>
Output Sample
<14>Mar 8 15:12:12 WIN-OUNNPISDHIG Service_Control_Manager: <Event><EventTime>2012-03-08
15:12:12</EventTime><EventTimeWritten>2012-03-08 15:12:12</EventTimeWritten><Hostname>WIN-
OUNNPISDHIG</Hostname><EventType>INFO</EventType><SeverityValue>2</SeverityValue><Severity>INFO
</Severity><SourceName>Service Control
Manager</SourceName><FileName>System</FileName><EventID>7036</EventID><CategoryNumber>0</Catego
ryNumber><RecordNumber>6791</RecordNumber><Message>The nxlog service entered the running state.
</Message><EventReceivedTime>2012-03-08 15:12:14</EventReceivedTime></Event>↵
130.35.1. Configuration
The xm_zlib module accepts the following directives in addition to the common module directives.
Format
This optional directive specifies the algorithm to be used for compressing and decompressing log data. The
accepted values are gzip and zlib. The default value is gzip.
CompressionLevel
This optional directive specifies the level of compression and ranges between 0 and 9. 0 means compression
with the lowest level but with the highest performance, while 9 means the highest level of compression but
with the lowest performance. If this directive is not specified, the default compression level is set to the
1126
Chapter 130. Extension Modules NXLog User Guide
CompBufSize
This optional directive specifies the amount of bytes to be allocated for the compression memory buffer. The
minimum value is 8192 bytes. The default value is 16384.
DecompBufSize
This optional directive specifies the amount of bytes to be allocated for the decompression memory buffer.
The minimum value is 16384 bytes. The default value is 32768.
DataType
This optional directive specifies the type of data being processed and is used by the compress data converter.
Specifying the data type improves compression results. The accepted values are unknown, text, and binary.
The default value is unknown.
MemoryLevel
This optional directive specifies the amount of available compression memory and accepts values between 1
and 9. The default value is 8.
<InstanceName>.<DataConverterName>
Where <InstanceName> is the given name of the xm_zlib instance and <DataConverterName> is the name of the
converter being invoked.
The following data converters are available to compress and decompress log data.
compress
This data converter is used to compress log data. It should be specified in the OutputType directive after the
output writer function. The compressed result is similar to running the following command:
decompress
This data converter is used to decompress log data. It should be specified in the InputType directive before
the input reader function. The decompressed result is similar to running the following command:
130.35.3. Examples
The examples below describe various ways of processing logs with the xm_zlib module.
1127
NXLog User Guide Chapter 130. Extension Modules
The configuration below utilizes the im_systemd module to read Systemd messages and converts them to
JSON using the xm_json module. The JSON-formatted messages are then written to a file and compressed
using the compress data converter.
nxlog.conf
1 <Extension gzip>
2 Module xm_zlib
3 Format gzip
4 CompressionLevel 9
5 CompBufSize 16384
6 DecompBufsize 16384
7 </Extension>
8
9 <Extension json>
10 Module xm_json
11 </Extension>
12
13 <Input input_systemd>
14 Module im_systemd
15 Exec to_json();
16 </Input>
17
18 <Output output_file>
19 Module om_file
20 OutputType LineBased, gzip.compress
21 File '/tmp/output'
22 </Output>
The following configuration uses the decompress converter to process gzip-compressed log files in the
input instance. The result is saved to a file.
nxlog.conf
1 <Extension gzip>
2 Module xm_zlib
3 Format gzip
4 CompressionLevel 9
5 CompBufSize 16384
6 DecompBufsize 16384
7 </Extension>
8
9 <Input input_file>
10 Module im_file
11 File '/tmp/input'
12 InputType gzip.decompress, LineBased
13 </Input>
14
15 <Output output_file>
16 Module om_file
17 File '/tmp/output'
18 </Output>
The xm_zlib module can process data via a single instance or multiple instances.
1128
Chapter 130. Extension Modules NXLog User Guide
Multiple instances provide flexibility because each instance can be customized for a specific scenario; whereas
using a single instance shortens the configuration.
The configuration below specifies two instances of the xm_zlib module. The gzip instance is used to
decompress gzip-compressed data at the input. Once decompressed, the messages are converted to JSON
using the xm_json module. The zlib instance is then used at the output to compress the JSON data in zlib
format and save it to a file.
nxlog.conf
1 <Extension gzip>
2 Module xm_zlib
3 Format gzip
4 CompressionLevel 9
5 CompBufSize 16384
6 DecompBufSize 16384
7 </Extension>
8
9 <Extension zlib>
10 Module xm_zlib
11 Format zlib
12 CompressionLevel 3
13 CompBufSize 64000
14 DecompBufSize 64000
15 </Extension>
16
17 <Extension json>
18 Module xm_json
19 </Extension>
20
21 <Input input_file>
22 Module im_file
23 File '/tmp/input'
24 InputType gzip.decompress, LineBased
25 Exec to_json();
26 </Input>
27
28 <Output output_file>
29 Module om_file
30 File '/tmp/output'
31 OutputType LineBased, zlib.compress
32 </Output>
1129
NXLog User Guide Chapter 130. Extension Modules
The configuration below specifies a single xm_zlib module instance with default parameters. The input
instance decompresses gzip-compressed log files using the decompress data converter and converts the
log records to IETF Syslog format using the xm_syslog module. The output instance then writes the results
to a file and compresses it using the compress data converter.
nxlog.conf
1 <Extension gzip>
2 Module xm_zlib
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input input_file>
10 Module im_file
11 File '/tmp/input'
12 InputType gzip.decompress, LineBased
13 Exec to_syslog_ietf();
14 </Input>
15
16 <Output output_file>
17 Module om_file
18 File '/tmp/output'
19 OutputType LineBased, gzip.compress
20 </Output>
Data conversion operations can be chained together to create a workflow. For example, the xm_zlib module
functionality can be combined with the xm_crypto module to perform compression and encryption operations
on log files.
Data converters are processed sequentially from left to right, thus the order that they are specified in is
important. When specifying data converters, decryption should always occur before decompression in input
instances, while compression should always precede encryption in output instances, as illustrated in the
following table.
Compression +
Encryption OutputType LineBased compress aes_encrypt
Decompression +
Decryption InputType aes_decrypt decompress LineBased
1130
Chapter 130. Extension Modules NXLog User Guide
The configuration below processes a gzip-compressed and encrypted log file. The input instance decrypts
the file using the aes_decrypt data converter of the xm_crypto module, and then decompresses it using the
decompress converter of the xm_zlib module. Each log record is processed and if it contains the stdout
string it is passed on to the output instance.
The processed log data is written to a file by the output instance. The data is compressed using the
compress converter and finally encrypted using the aes_encrypt converter.
nxlog.conf
1 <Extension gzip>
2 Module xm_zlib
3 Format gzip
4 CompressionLevel 9
5 CompBufSize 16384
6 DecompBufsize 16384
7 </Extension>
8
9 <Extension cryptography>
10 Module xm_crypto
11 UseSalt TRUE
12 PasswordFile /path/to/passwordfile
13 </Extension>
14
15 <Input input_file>
16 Module im_file
17 File '/tmp/input'
18 InputType cryptography.aes_decrypt, gzip.decompress, LineBased
19 Exec if not ($raw_event =~ /stdout/) drop();
20 </Input>
21
22 <Output output_file>
23 Module om_file
24 File '/tmp/output'
25 OutputType LineBased, gzip.compress, cryptography.aes_encrypt
26 </Output>
For more information and examples on combined data conversion operations see the topic on Compression and
Encryption.
1131
NXLog User Guide Chapter 131. Input Modules
Each module provides a set of fields for each log message, these are documented in the corresponding sections
below. The NXLog core creates a set of core fields which are available to each module.
Each NXLog module on Windows can create multiple TCP connections on 127.0.0.1 using
NOTE ephemeral ports. This happens when the module needs to monitor files or sockets and should
be considered part of the normal network resources.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.1.1. Configuration
The im_acct module accepts the following directives in addition to the common module directives.
AcctOff
This boolean directive specifes that accounting should be disabled when im_acct stops. If AcctOff is set to
FALSE, accounting will not be disabled; events will continue to be written to the log file for NXLog to collect
later. The default is FALSE.
AcctOn
This boolean directive specifies that accounting should be enabled when im_acct starts. If AcctOn is set to
FALSE, accounting will not be enabled automatically. The default is TRUE.
File
This optional directive specifies the path where the kernel writes accounting data.
FileSizeLimit
NXLog will automatically truncate the log file when it reaches this size, specified as an integer in bytes (see
Integer). The default is 1 MB.
131.1.2. Fields
The following fields are used by im_acct.
1132
Chapter 131. Input Modules NXLog User Guide
1133
NXLog User Guide Chapter 131. Input Modules
131.1.3. Examples
Example 683. Collecting Process Accounting Logs
With this configuration, the im_acct module will collect process accounting logs. Process accounting will be
automatically enabled and configured to write logs to the file specified. NXLog will allow the file to grow to a
maximum size of 10 MB before truncating it.
nxlog.conf
1 <Input acct>
2 Module im_acct
3 File '/var/log/acct.log'
4 FileSizeLimit 10M
5 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.2.1. Configuration
The im_aixaudit module accepts the following directives in addition to the common module directives.
DeviceFile
This optional directive specifies the device file from which to read audit events. If this is not specified, it
defaults to /dev/audit.
EventsConfigFile
This optional directive contains the path to the file with a list of audit events. This file should contain events in
AuditEvent = FormatCommand format. The AuditEvent is a reference to the audit object which is defined
under the /etc/security/audit/objects path. The FormatCommand defines the auditpr output for the
object. For more information, see the The Audit Subsystem in AIX section on the IBM website.
131.2.2. Fields
See the xm_aixaudit Fields.
131.2.3. Examples
1134
Chapter 131. Input Modules NXLog User Guide
This configuration reads AIX audit events directly from the kernel via the (default) /dev/audit device file.
nxlog.conf
1 <Input in>
2 Module im_aixaudit
3 DeviceFile /dev/audit
4 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1. After logging in to the Portal, click New on the left panel, select the Storage category, and choose the
Storage account - blob, file, table, queue.
2. Create the new storage account. Provide a storage name, location, and replication type.
3. Click [Create Storage Account] and wait for storage setup to complete.
4. Go to Apps, select the application for which to enable logging, and click Configure.
5. Scroll down to the application diagnostic section and configure the table and blob storage options
corresponding with the storage account created above.
6. Confirm the changes by clicking Save, then restart the service. Note that it may take a while for Azure to
create the table and/or blob in the storage.
131.3.2. Configuration
The im_azure module accepts the following directives in addition to the common module directives. The AuthKey
and StorageName directives are required, along with either BlobName or TableName.
AuthKey
This mandatory directive specifies the authentication key to use for connecting to Azure.
BlobName
This directive specifies the storage blob to connect to. One of BlobName and TableName must be defined
(but not both).
SSLCompression
This Boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
1135
NXLog User Guide Chapter 131. Input Modules
StorageName
This mandatory directive specifies the name of the storage account from which to collect logs.
TableName
This directive specifies the storage table to connect to. One of BlobName and TableName must be defined
(but not both).
Address
This directive specifies the URL for connecting to the storage account and corresponding table or blob. If this
directive is not specified, it defaults to http://<table|blob>.<storagename>.core.windows.net. If
defined, the value must start with http:// or https://.
HTTPSAllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE the remote will be able to connect with an unknown or self-signed certificate. The default value
is FALSE: all HTTPS connections must present a trusted certificate.
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote HTTPS client. The certificate filenames in this directory must be in the
OpenSSL hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by
including a copy of the certificate in this directory.
HTTPSCAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote HTTPS client. To trust a self-signed certificate presented by the remote (which is not signed by a
CA), provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote HTTPS client. The certificate filenames in this directory must be in
the OpenSSL hashed format.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote HTTPS client.
1136
Chapter 131. Input Modules NXLog User Guide
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
directive is not needed for passwordless private keys.
HTTPSRequireCert
This boolean directive specifies that the remote HTTPS client must present a certificate. If set to TRUE and
there is no certificate presented during the connection handshake, the connection will be refused. The
default value is TRUE: each connection must use a certificate.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
PollInterval
This directive specifies how frequently the module will check for new events, in seconds. If this directive is not
specified, it defaults to 1 second. Fractional seconds may be specified (PollInterval 0.5 will check twice
every second).
131.3.3. Fields
The following fields are used by im_azure.
Azure Normalized
Severity Severity
Critical 5/CRITICAL
Warning 3/WARNING
Information 2/INFO
Verbose 1/DEBUG
1137
NXLog User Guide Chapter 131. Input Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.4.1. Configuration
The im_batchcompress module accepts the following directives in addition to the common module directives.
ListenAddr
The module accepts connections on the IP address or hostname and port defined here. The default address
is localhost and the default port is 2514. The port number can be defined by appending it at the end of the
hostname or IP address using a colon as a separator (host:port). The port section of this directive and the
Port directive are mutually exclusive. In case both is defined, the port number defined here takes precedence
over a port defined in the Port directive. In case none of them is defined, the default port is used.
When a hostname is used as the ListenAddr, the corresponding IP address is only resolved
NOTE when the module starts up. The listening socket will be bound to that IP addresses until the
module is restarted, regardless of any DNS changes to the hostname.
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
Port
The module listens for incoming connections on the port defined in this directive. The default is port 2514.
1138
Chapter 131. Input Modules NXLog User Guide
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the ListenAddr directive.
AllowUntrusted
This boolean directive specifies whether the remote connection should be allowed without certificate
verification. If set to TRUE the remote will be able to connect with an unknown or self-signed certificate. The
default value is FALSE: by default, all connections must present a trusted certificate.
CADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote socket. The certificate filenames in this directory must be in the OpenSSL
hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including
a copy of the certificate in this directory.
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote socket. To trust a self-signed certificate presented by the remote (which is not signed by a CA),
provide that certificate instead.
CAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the CADir and CAFile directives are mutually
exclusive.
CertFile
This specifies the path of the certificate file to be used for the SSL handshake.
CertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake.
CertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the CertFile and
CertKeyFile directives are mutually exclusive.
CRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote socket. The filenames in this directory must be in the OpenSSL
hashed format.
CRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote socket.
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is not needed for passwordless private keys.
RequireCert
This boolean directive specifies that the remote must present a certificate. If set to TRUE and there is no
certificate presented during the connection handshake, the connection will be refused. The default value is
TRUE: by default, each connections must use a certificate.
1139
NXLog User Guide Chapter 131. Input Modules
SSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
SSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the SSLProtocol directive is
set to TLSv1.3. Use the same format as in the SSLCipher directive.
SSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols are allowed. Note that the OpenSSL library shipped by Linux distributions
may not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
131.4.2. Fields
The following fields are used by im_batchcompress.
131.4.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration listens on port 2514 for incoming log batches and writes them to file.
nxlog.conf
1 <Input batchcompress>
2 Module im_batchcompress
3 ListenAddr 0.0.0.0:2514
4 </Input>
5
6 # Using the syntax prior to NXLog EE 5,
7 # where the port is defined in a separate directive.
8 #<Input batchcompress>
9 # Module im_batchcompress
10 # ListenAddr 0.0.0.0
11 # Port 2514
12 #</Input>
13
14 <Output file>
15 Module om_file
16 File "tmp/output"
17 </Output>
18
19 <Route batchcompress_to_file>
20 Path batchcompress => file
21 </Route>
1140
Chapter 131. Input Modules NXLog User Guide
This module reads directly from the kernel. See also xm_bsm.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The BSM /dev/auditpipe device file is available on FreeBSD and macOS. On Solaris, the device file is not
available and the log files must be read and parsed with im_file and xm_bsm as shown in the example.
131.5.1. Setup
For information about setting up BSM Auditing, see the xm_bsm Setup section.
131.5.2. Configuration
The im_bsm module accepts the following directives in addition to the common module directives.
DeviceFile
This optional directive specifies the device file from which to read BSM events. If this is not specified, it
defaults to /dev/auditpipe.
EventFile
This optional directive can be used to specify the path to the audit event database containing a mapping
between event names and numeric identifiers. The default location is /etc/security/audit_event which is
used when the directive is not specified.
131.5.3. Fields
See the xm_bsm Fields.
131.5.4. Examples
Example 686. Reading BSM Audit Events From the Kernel
This configuration reads BSM audit events directly from the kernel via the (default) /dev/auditpipe device
file (which is not available on Solaris, see the xm_bsm example instead).
nxlog.conf
1 <Input in>
2 Module im_bsm
3 DeviceFile /dev/auditpipe
4 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1141
NXLog User Guide Chapter 131. Input Modules
The OPSEC SDK provides libraries only in 32-bit versions and this makes it impossible to compile
a 64-bit application. For this reason the im_checkpoint module uses a helper program called nx-
NOTE
im-checkpoint. This helper is responsible for collecting the logs and transmitting these over a
pipe to the im_checkpoint module.
CheckPoint uses a certificate export method with an activation password so that certificate keys can be securely
transferred over the network in order to establish trust relationships between the entities involved when using
SSL-based authenticated connections. The following entities (hosts) are involved in the log generation and
collection process:
SmartDashboard
The firewall administrator can use the SmartDashboard management interface to connect to and manage the
firewall.
NXLog
The log collector running NXLog which connects to SPLAT over the OPSEC LEA protocol utilizing the
im_checkpoint module.
The following steps are required to configure the LEA connection between SPLAT and NXLog.
1. Enable the LEA service on SPLAT. Log in to SPLAT, enter expert mode, and run vi
$FWDIR/conf/fwopsec.conf. Make sure the file contains the following lines. Then restart the firewall with
the cprestart command (or cpstop and cpstart).
fwopsec.conf
lea_server auth_port 18184
lea_server auth_type sslca
2. Make sure SPLAT will accept ICA pull requests, the LEA Connection (port 18184), and can generate logs. For
testing purposes, it is easiest to create a single rule to accept all connections and log these. For this the
SmartDashboard host must be added as a GUI Client on SPLAT and a user needs to be configured to be able
to log onto SPLAT remotely from SmartDashboard.
3. Create the certificates for NXLog in SmartDashboard. Select Manage › Servers › OPSEC Applications, then
click [New] and select OPSEC Application. A dialog window should appear. Fill in the following properties
and then click [OK].
Name
Set to nxlog.
Description
Set to NXLog log collector or something similar.
Host
Click on [New] to create a new host and name it accordingly (nxloghost, for example).
Client Entities
Check LEA. All other options should be unchecked.
1142
Chapter 131. Input Modules NXLog User Guide
generated string looks like this: CN=nxlog,O=splat..ebo9pf. This value will be used in our lea.conf file
as the opsec_sic_name parameter.
4. Retrieve the OPSEC application certificate. From the NXLog host, run the following command:
/opt/nxlog/bin/opsec_pull_cert -h SPLAT_IP_ADDR -n nxlog -p ACTIVATION_KEY. Make sure to
substitute the correct values in place of SPLAT_IP_ADDR and ACTIVATION_KEY. If the command is successful,
the certificate file opsec.p12 should appear in the current directory. Copy this file to /opt/nxlog/etc.
5. Get the DN of SPLAT. In SmartDashboard, double-click on Network Objects › Check Point › SPLAT. The
properties window will contain a similar DN under Secure Internal Communication such as
CN=cp_mgmt,o=splat..ebo9pf.
6. Retrieve the sic_policy.conf file from SPLAT. Initiate a secure copy from the firewall in expert mode. Then
move the file to the correct location.
7. Edit /opt/nxlog/etc/sic_policy.conf, and add the necessary policy to the [Outbound rules] section.
sic_policy.conf
1 [Outbound rules]
2 # apply_to peer(s) port(s) service(s) auth-method(s)
3 # --------------------------------------------------------
4
5 # OPSEC configurations - place here (and in [Inbound rules] too)
6 ANY ; ANY ; 18184 ; fwn1_opsec, ssl_opsec, ssl_clear_opsec, lea ; any_method
8. Edit /opt/nxlog/etc/lea.conf. The file should contain the following. Make sure to substitute the correct
value in place of SPLAT_IP_ADDR and use the correct DN values for opsec_sic_name and lea_server
opsec_entity_sic_name.
lea.conf
lea_server ip SPLAT_IP_ADDR
lea_server auth_port 18184
lea_server auth_type sslca
opsec_sic_name "CN=nxlog,O=splat..ebo9pf"
opsec_sslca_file /opt/nxlog/etc/opsec.p12
lea_server opsec_entity_sic_name "CN=cp_mgmt,o=splat..ebo9pf"
opsec_sic_policy_file /opt/nxlog/etc/sic_policy.conf
Refer to the Check Point documentation for more information regarding the LEA log service configuration.
To test whether the log collection works, execute the following command: /opt/nxlog/bin/nx-im-checkpoint
--readfromlast FALSE > output.bin. The process should not exit. Type Ctrl+c to interrupt it. The created
file output.bin should contain logs in NXLog’s Binary format.
The two files sslauthkeys.C and sslsess.C are used during the key-based authentication.
NOTE These files are stored in the same directory where lea.conf resides. To override this, set the
OPSECDIR environment variable.
1143
NXLog User Guide Chapter 131. Input Modules
If the log collection is successful, you can now try running NXLog with the im_checkpoint module.
131.6.1. Configuration
The im_checkpoint module accepts the following directives in addition to the common module directives.
Command
The optional directive specifies the path of the nx-im-checkpoint binary. If not specified, the default is
/opt/nxlog/bin/nx-im-checkpoint on Linux.
LEAConfigFile
This optional directive specifies the path of the LEA configuration file. If not specified, the default is
/opt/nxlog/etc/lea.conf. This file must be edited in order for the OPSEC LEA connection to work.
LogFile
This can be used to specify the log file to be read. If not specified, it defaults to fw.log. To collect the audit
log, use LogFile fw.adtlog which would then be passed to the nx-im-checkpoint binary as --logfile
fw.adtlog.
ReadFromLast
This optional boolean directive instructs the module to only read logs which arrived after NXLog was started if
the saved position could not be read (for example on first start). When SavePos is TRUE and a previously
saved record number could be read, the module will resume reading from this saved record number. If
ReadFromLast is FALSE, the module will read all logs from the LEA source. This can result in quite a lot of
messages, and is usually not the expected behavior. If this directive is not specified, it defaults to TRUE.
Restart
Restart the nx-im-checkpoint process if it exits. There is a one second delay before it is restarted to avoid a
denial-of-service if the process is not behaving. This boolean directive defaults to FALSE.
SavePos
This boolean directive specifies that the last record number should be saved when NXLog exits. The record
number will be read from the cache file upon startup. The default is TRUE: the record number is saved if this
directive is not specified. Even if SavePos is enabled, it can be explicitly turned off with the global NoCache
directive.
131.6.2. Fields
The following fields are used by im_checkpoint.
The LEA protocol provides Check Point device logs in a structured format. For the list of LEA fields, see LEA Fields
Update on CheckPoint.com. Some of the field names are mapped to normalized names which NXLog uses in
other modules (such as $EventTime). The list of these fields is provided below. The other LEA fields are
reformatted such that non-alphanumeric characters are replaced with an underscore (_) in field names. The
$raw_event field contains the list of all fields and their respective values without any modification to the original
LEA field naming.
1144
Chapter 131. Input Modules NXLog User Guide
131.6.3. Examples
1145
NXLog User Guide Chapter 131. Input Modules
This configuration instructs NXLog to collect logs from Check Point devices over the LEA protocol and store
the logs in a file in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input checkpoint>
6 Module im_checkpoint
7 Command /opt/nxlog/bin/nx-im-checkpoint
8 LEAConfigFile /opt/nxlog/etc/lea.conf
9 </Input>
10
11 <Output file>
12 Module om_file
13 File 'tmp/output'
14 Exec $raw_event = to_json();
15 </Output>
16
17 <Route checkpoint_to_file>
18 Path checkpoint => file
19 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The im_dbi and om_dbi modules support GNU/Linux only because of the libdbi library. The
NOTE
im_odbc and om_odbc modules provide native database access on Windows.
libdbi needs drivers to access the database engines. These are in the libdbd-* packages on
Debian and Ubuntu. CentOS 5.6 has a libdbi-drivers RPM package, but this package does not
NOTE contain any driver binaries under /usr/lib64/dbd. The drivers for both MySQL and PostgreSQL
are in libdbi-dbd-mysql. If these are not installed, NXLog will return a libdbi driver initialization
error.
131.7.1. Configuration
The im_dbi module accepts the following directives in addition to the common module directives.
Driver
This mandatory directive specifies the name of the libdbi driver which will be used to connect to the
database. A DRIVER name must be provided here for which a loadable driver module exists under the name
libdbdDRIVER.so (usually under /usr/lib/dbd/). The MySQL driver is in the libdbdmysql.so file.
1146
Chapter 131. Input Modules NXLog User Guide
SQL
This directive should specify the SELECT statement to be executed every PollInterval seconds. The module
automatically appends a WHERE id > ? LIMIT 10 clause to the statement. The result set returned by the
SELECT statement must contain an id column which is then stored and used for the next query.
Option
This directive can be used to specify additional driver options such as connection parameters. The manual of
the libdbi driver should contain the options available for use here.
PollInterval
This directive specifies how frequently the module will check for new records, in seconds. If this directive is
not specified, the default is 1 second. Fractional seconds may be specified (PollInterval 0.5 will check
twice every second).
SavePos
If this boolean directive is set to TRUE, the position will be saved when NXLog exits. The position will be read
from the cache file upon startup. The default is TRUE: the position will be saved if this directive is not
specified. Even if SavePos is enabled, it can be explicitly turned off with the global NoCache directive.
131.7.2. Fields
The following fields are used by im_dbi.
131.7.3. Examples
Example 688. Reading From a MySQL Database
This example uses libdbi and the MySQL driver to connect to the logdb database on the local host and
execute the provided statement.
nxlog.conf
1 <Input dbi>
2 Module im_dbi
3 Driver mysql
4 Option host 127.0.0.1
5 Option username mysql
6 Option password mysql
7 Option dbname logdb
8 SQL SELECT id, facility, severity, hostname, \
9 timestamp, application, message \
10 FROM log
11 </Input>
12
13 <Output file>
14 Module om_file
15 File "tmp/output"
16 </Output>
17
18 <Route dbi_to_file>
19 Path dbi => file
20 </Route>
1147
NXLog User Guide Chapter 131. Input Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
ETW is a mechanism in Windows designed for efficient logging of both kernel and user-mode applications. Debug
and Analytical channels are based on ETW and cannot be collected as regular Windows Event Log channels via
the im_msvistalog module. Various Windows services such as the Windows Firewall and DNS Server can be
configured to log events through Windows Event Tracing.
The im_etw module reads event tracing data directly for maximum efficiency. Unlike other solutions, im_etw does
not save ETW event data into intermediary trace files that need to be parsed again.
131.8.1. Configuration
The im_etw module accepts the following directives in addition to the common module directives. It is required to
specify either the KernelFlags or the Provider directive.
KernelFlags
This directive specifies that kernel trace logs should be collected, and accepts a comma-separated list of flags
to use for filtering the logs. The following values are allowed: ALPC, CSWITCH, DBGPRINT, DISK_FILE_IO,
DISK_IO, DISK_IO_INIT, DISPATCHER, DPC, DRIVER, FILE_IO, FILE_IO_INIT, IMAGE_LOAD, INTERRUPT,
MEMORY_HARD_FAULTS, MEMORY_PAGE_FAULTS, NETWORK_TCPIP, NO_SYSCONFIG, PROCESS, PROCESS_COUNTERS,
PROFILE, REGISTRY, SPLIT_IO, SYSTEMCALL, THREAD, VAMAP, and VIRTUAL_ALLOC. The KernelFlags and
Provider directives are mutually exclusive and specifying one or the other is required.
Only users with administrative privileges and services running as LocalSystem can subscribe
to kernel logger sessions. When the NXLog service is configured to run under a custom or
virtual service account, the account must be a member of the Administrators group for
NXLog to be able to collect kernel trace logs. If not, the following error will be logged in the
NXLog log file:
NOTE
Note that services running with such privileges may expose the system to higher security
risks.
Provider
This directive specifies the name (not GUID) of the ETW provider from which to collect trace logs. Providers
available for tracing can be listed by running the command logman query providers in a command
prompt. The Windows Kernel Trace provider is not supported; instead, the KernelFlags directive should be
used to open a kernel logger session. The Provider and KernelFlags directives are mutually exclusive and
specifying one or the other is required.
When the NXLog service is configured to run under a custom or virtual service account, the
account must be a member of the Performance Log Users group for NXLog to be able to
NOTE collect ETW provider logs. If not, the following error will be logged in the NXLog log file:
1148
Chapter 131. Input Modules NXLog User Guide
Level
This optional directive specifies the log level for collecting trace events. Because kernel log sessions do not
provide log levels, this directive is only available in combination with the Provider directive. Valid values
include Critical, Error, Warning, Information, and Verbose. If this directive is not specified, the verbose
log level is used.
MatchAllKeyword
This optional directive is used for filtering ETW events based on keywords. Defaults to 0x00000000. For more
information, see System ETW Provider Event Keyword-Level Settings in the Microsoft documentation.
MatchAnyKeyword
This optional directive is used for filtering Wndows ETW events based on keywords. Defaults to 0x00000000.
For more information, see System ETW Provider Event Keyword-Level Settings in the Microsoft
documentation.
131.8.2. Fields
The following fields are used by im_etw.
Depending on the ETW provider from which NXLog collects trace logs, the set of fields generated by the im_etw
module may slightly vary. In addition to the fields listed below, the module can generate special provider-specific
fields. If the module is configured to collect trace logs from a custom provider (for example, from a custom user-
mode application), the module will also generate fields derived from the custom provider trace logs.
1149
NXLog User Guide Chapter 131. Input Modules
1/Critical 5/CRITICAL
2/Error 4/ERROR
3/Warning 3/WARNING
4/Information 2/INFO
5/Verbose 1/DEBUG
131.8.3. Examples
1150
Chapter 131. Input Modules NXLog User Guide
With this configuration, NXLog will collect trace events from the Windows kernel. Only events matching the
PROCESS and THREAD flags will be collected.
nxlog.conf
1 <Input etw>
2 Module im_etw
3 KernelFlags PROCESS, THREAD
4 </Input>
With this configuration, NXLog will collect events from the Microsoft-Windows-Firewall trace provider.
nxlog.conf
1 <Input etw>
2 Module im_etw
3 Provider Microsoft-Windows-Firewall
4 </Input>
With this configuration, NXLog will assign event log level for a specified provider.
nxlog.conf
1 <Input etw>
2 Module im_etw
3 Provider Microsoft-Windows-DNS-Client
4 Level verbose
5 MatchAnyKeyword 0xFFFFFFFF
6 MatchAllKeyword 0x0
7 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
If you are using a Perl script, consider using im_perl instead or turning on Autoflush with $|
WARNING = 1;, otherwise im_exec might not receive data immediately due to Perl’s internal buffering.
See the Perl language reference for more information about $|.
131.9.1. Configuration
The im_exec module accepts the following directives in addition to the common module directives. The Command
directive is required.
1151
NXLog User Guide Chapter 131. Input Modules
Command
This mandatory directive specifies the name of the program or script to be executed.
Arg
This is an optional parameter. Arg can be specified multiple times, once for each argument that needs to be
passed to the Command. Note that specifying multiple arguments with one Arg directive, with arguments
separated by spaces, will not work (the Command would receive it as one argument).
InputType
See the InputType description in the global module configuration section.
Restart
Restart the process if it exits. There is a one second delay before it is restarted to avoid a denial-of-service
when a process is not behaving. Looping should be implemented in the script itself, this directive is only to
provide some safety against malfunctioning scripts and programs. This boolean directive defaults to FALSE:
the Command will not be restarted if it exits.
131.9.2. Examples
Example 692. Emulating im_file
The im_file module should be used to read log messages from files. This example only
NOTE
demonstrates the use of the im_exec module.
nxlog.conf
1 <Input messages>
2 Module im_exec
3 Command /usr/bin/tail
4 Arg -f
5 Arg /var/log/messages
6 </Input>
7
8 <Output file>
9 Module om_file
10 File "tmp/output"
11 </Output>
12
13 <Route messages_to_file>
14 Path messages => file
15 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1152
Chapter 131. Input Modules NXLog User Guide
im_file uses a one second interval to monitor files for new messages. This method was implemented because
polling a regular file is not supported on all platforms. If there is no more data to read, the module will sleep for
1 second.
By using wildcards, the module can read multiple files simultaneously and will open new files as they appear. It
will also enter newly created directories if recursion is enabled.
The module needs to scan the directory content for wildcarded file monitoring. This can present
a significant load if there are many files (hundreds or thousands) in the monitored directory. For
NOTE
this reason it is highly recommended to rotate files out of the monitored directory either using
the built-in log rotation capabilities of NXLog or with external tools.
131.10.1. Configuration
The im_file module accepts the following directives in addition to the common module directives. The File
directive is required.
File
This mandatory directive specifies the name of the input file to open. It may be given more than once in a
single im_file module instance. The value must be a string type expression. For relative filenames you should
be aware that NXLog changes its working directory to "/" unless the global SpoolDir is set to something else.
On Windows systems the directory separator is the backslash (\). For compatibility reasons the forward slash
(/) character can be also used as the directory separator, but this only works for filenames not containing
wildcards. If the filename is specified using wildcards, the backslash (\) should be used for the directory
separator. Filenames on Windows systems are treated case-insensitively, but case-sensitively on Unix/Linux.
Wildcards are supported in filenames and directories. Wildcards are not regular expressions, but are patterns
commonly used by Unix shells to expand filenames (also known as "globbing").
?
Matches a single character only.
*
Matches zero or more characters.
\*
Matches the asterisk (*) character.
\?
Matches the question mark (?) character.
[…]
Used to specify a single character. The class description is a list containing single characters and ranges of
characters separated by the hyphen (-). If the first character of the class description is ^ or !, the sense of
the description is reversed (any character not in the list is accepted). Any character can have a backslash (
\) preceding it, which is ignored, allowing the characters ] and - to be used in the character class, as well
as ^ and ! at the beginning.
1153
NXLog User Guide Chapter 131. Input Modules
By default, the backslash character (\) is used as an escape sequence. This character is also
the directory separator on Windows. Because of this, escaping of wildcard characters is not
supported on Windows, see the EscapeGlobPatterns directive. However, string literals are
evaluated differently depending on the quotation type. Single quoted strings are interpreted
as-is without escaping, e.g. 'C:\t???*.log' stays C:\t???\*.log. Escape sequences in
NOTE
double quoted strings are processed, for example "C:\\t???\*.log" becomes
C:\t???\*.log after evaluation. In both cases, the evaluated string is the same and gets
separated into parts with different glob patterns at different levels. In the previous example
the parts are c:, t???, and *.log. NXLog matches these at the proper directory levels to find
all matching files.
ActiveFiles
This directive specifies the maximum number of files NXLog will actively monitor. If there are modifications to
more files in parallel than the value of this directive, then modifications to files above this limit will only get
noticed after the DirCheckInterval (all data should be collected eventually). Typically there are only a few log
sources actively appending data to log files, and the rest of the files are dormant after being rotated, so the
default value of 10 files should be sufficient in most cases. This directive is also only relevant in case of a
wildcarded File path.
CloseWhenIdle
If set to TRUE, this boolean directive specifies that open input files should be closed as soon as possible after
there is no more data to read. Some applications request an exclusive lock on the log file when written or
rotated, and this directive can possibly help if the application tries again to acquire the lock. The default is
FALSE.
DirCheckInterval
This directive specifies how frequently, in seconds, the module will check the monitored directory for
modifications to files and new files in case of a wildcarded File path. The default is twice the value of the
PollInterval directive (if PollInterval is not set, the default is 2 seconds). Fractional seconds may be specified. It
is recommended to increase the default if there are many files which cannot be rotated out and the NXLog
process is causing high CPU load.
Exclude
This directive can specify a file or a set of files (using wildcards) to be excluded. More than one occurrence of
the Exclude directive can be specified.
InputType
See the InputType directive in the list of common module directives. If this directive is not specified the
default is LineBased (the module will use CRLF as the record terminator on Windows, or LF on Unix).
This directive also supports data converters, see the description in the InputType section.
NoEscape
This boolean directive specifies whether the backslash (\) in file paths should be disabled as an escape
sequence. This is especially useful for file paths on Windows. By default, NoEscape is FALSE (backslash
escaping is enabled and the path separator on Windows must be escaped).
OnEOF
This optional block directive can be used to specify a group of statements to execute when a file has been
fully read (on end-of-file). Only one OnEOF block can be specified per im_file module instance. The following
directives are used inside this block.
Exec
This mandatory directive specifies the actions to execute after EOF has been detected and the grace
period has passed. Like the normal Exec directive, the OnEOF Exec can be specified as a normal directive
1154
Chapter 131. Input Modules NXLog User Guide
or a block directive.
GraceTimeout
This optional directive specifies the time in seconds to wait before executing the actions configured in the
Exec block or directive. The default is 1 second.
PollInterval
This directive specifies how frequently the module will check for new files and new log entries, in seconds. If
this directive is not specified, it defaults to 1 second. Fractional seconds may be specified (PollInterval 0.5
will check twice every second).
ReadFromLast
This optional boolean directive instructs the module to only read logs which arrived after NXLog was started if
the saved position could not be read (for example on first start). When SavePos is TRUE and a previously
saved position value could be read, the module will resume reading from this saved position. If
ReadFromLast is FALSE, the module will read all logs from the file. This can result in quite a lot of messages,
and is usually not the expected behavior. If this directive is not specified, it defaults to TRUE.
Recursive
If set to TRUE, this boolean directive specifies that input files set with the File directive should be searched
recursively under sub-directories. For example, /var/log/error.log will match
/var/log/apache2/error.log. Wildcards can be used in combination with Recursive: /var/log/*.log will
match /var/log/apache2/access.log. This directive only causes scanning under the given path and does
not affect the processing of wildcarded directories: /var/*/qemu/debian.log will not match
/var/log/libvirt/qemu/debian.log. The default is FALSE.
RenameCheck
If set to TRUE, this boolean directive specifies that input files should be monitored for possible file rotation via
renaming in order to avoid re-reading the file contents. A file is considered to be rotated when NXLog detects
a new file whose inode and size matches that of another watched file which has just been deleted. Note that
this does not always work correctly and can yield false positives when a log file is deleted and another is
added with the same size. The file system is likely to reuse to inode number of the deleted file and thus the
module will falsely detect this as a rename/rotation. For this reason the default value of RenameCheck is
FALSE: renamed files are considered to be new and the file contents will be re-read.
It is recommended to use a naming scheme for rotated files so names of rotated files do not
NOTE match the wildcard and are not monitored anymore after rotation, instead of trying to solve
the renaming issue with this directive.
SavePos
If this boolean directive is set to TRUE, the file position will be saved when NXLog exits. The file position will
be read from the cache file upon startup. The default is TRUE: the file position will be saved if this directive is
not specified. Even if SavePos is enabled, it can be explicitly turned off with the global NoCache directive.
131.10.2. Functions
The following functions are exported by im_file.
string file_name()
Return the name of the currently open file which the log was read from.
integer record_number()
Returns the number of processed records (including the current record) of the currently open file since it was
opened or truncated.
1155
NXLog User Guide Chapter 131. Input Modules
131.10.3. Examples
Example 693. Forwarding Logs From a File to a Remote Host
This configuration will read from a file and forward messages via TCP. No additional processing is done.
nxlog.conf
1 <Input messages>
2 Module im_file
3 File "/var/log/messages"
4 </Input>
5
6 <Output tcp>
7 Module om_tcp
8 Host 192.168.1.1:514
9 </Output>
10
11 <Route messages_to_tcp>
12 Path messages => tcp
13 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Files are checked periodically, not in real-time. If there are multiple changes between two scans, only the
cumulative effect is logged. For example, if one user modifies a file and another user reverts the changes before
the next scan occurs, only the change in modification time is detected.
For real-time monitoring, auditing must be enabled on the host operating system. See the File Integrity
Monitoring chapter in the User Guide for more information.
131.11.1. Configuration
The im_fim module accepts the following directives in addition to the common module directives. The File
directive is required.
File
This mandatory directive specifies the name of the input file to scan. It must be a string type expression. See
the im_file File directive for more details on how files can be specified. Wildcards are supported. More than
one occurrence of the File directive can be used.
Digest
This specifies the digest method (hash function) to be used to calculate the checksum. The default is sha1.
The following message digest methods can be used: md2, md5, mdc2, rmd160, sha, sha1, sha224, sha256,
sha384, and sha512.
1156
Chapter 131. Input Modules NXLog User Guide
Exclude
This directive can specify a file or a set of files (using wildcards) to be excluded from the scan. More than one
occurrence of the Exclude directive can be specified.
NoEscape
This boolean directive specifies whether the backslash (\) in file paths should be disabled as an escape
sequence. By default, NoEscape is FALSE (the path separator on Windows needs to be escaped).
Recursive
If set to TRUE, this boolean directive specifies that files set with the File directive should be searched
recursively under sub-directories. For example, /var/log/error.log will match
/var/log/apache2/error.log. Wildcards can be used in combination with Recursive: /var/log/*.log will
match /var/log/apache2/access.log. This directive only causes scanning under the given path and does
not affect the processing of wildcarded directories: /var/*/qemu/debian.log will not match
/var/log/libvirt/qemu/debian.log. The default is FALSE.
ScanInterval
This directive specifies how long the module will wait between scans for modifications, in seconds. The
default is 86400 seconds (1 day). The value of ScanInterval can be set to 0 to disable periodic scanning and
instead invoke scans via the start_scan() procedure.
131.11.2. Functions
The following functions are exported by im_fim.
boolean is_scanning()
Returns TRUE if scanning is in progress.
131.11.3. Procedures
The following procedures are exported by im_fim.
start_scan();
Start the file integrity scan. This could be invoked from the Schedule block, for example.
131.11.4. Fields
The following fields are used by im_fim.
1157
NXLog User Guide Chapter 131. Input Modules
131.11.5. Examples
Example 694. Periodic File Integrity Monitoring
With this configuration, NXLog will monitor the specified directories recursively. Scans will occur hourly.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/etc/*"
4 Exclude "/etc/mtab"
5 File "/bin/*"
6 File "/sbin/*"
7 File "/usr/bin/*"
8 File "/usr/sbin/*"
9 Recursive TRUE
10 ScanInterval 3600
11 </Input>
1158
Chapter 131. Input Modules NXLog User Guide
The im_fim module provides a start_scan() procedure that can be called to invoke the scan. The following
configuration sets ScanInterval to zero to disable periodic scanning and uses a Schedule block instead to
trigger the scan every day at midnight.
nxlog.conf
1 <Input fim>
2 Module im_fim
3 File "/bin/*"
4 File "/sbin/*"
5 File "/usr/bin/*"
6 File "/usr/sbin/*"
7 Recursive TRUE
8 ScanInterval 0
9 <Schedule>
10 When @daily
11 Exec start_scan();
12 </Schedule>
13 </Input>
131.12. Go (im_go)
This module provides support for collecting log data with methods written in the Go language. The file specified
by the ImportLib directive should contain one or more methods which can be called from the Exec directive of
any module. See also the xm_go and om_go modules.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
For the system requirements, installation details and environmental configuration requirements
NOTE of Go, see the Getting Started section in the Go documentation. The Go environment is only
needed for compiling the Go file. NXLog does not need the Go environment for its operation.
The Go script imports the NXLog module, and will have access to the following classes and functions.
class nxModule
This class is instantiated by NXLog and can be accessed via the nxLogdata.module attribute. This can be used
to set or access variables associated with the module (see the example below).
nxmodule.NxLogdataNew(*nxLogdata)
This function creates a new log data record.
nxmodule.Post(ld *nxLogdata)
This function puts log data struct for further processing.
nxmodule.AddEvent()
This function adds a READ event to NXLog. This allows to call the READ event later.
nxmodule.AddEventDelayed(mSec C.int)
This function adds a delayed READ event to NXLog. This allows to call the delayed READ event later.
class nxLogdata
This class represents an event. It is instantiated by NXLog and passed to the function specified by the
ImportFunc directive.
1159
NXLog User Guide Chapter 131. Input Modules
nxlogdata.Delete(field string)
This function removes the field from logdata.
nxlogdata.Fields() []string
This function returns an array of fields names in the logdata record.
module
This attribute is set to the module object associated with the event.
131.12.3. Configuration
The im_go module accepts the following directives in addition to the common module directives.
ImportLib
This mandatory directive specifies the file containing the Go code compiled into a shared library .so file.
ImportFunc
This mandatory directive calls the specified function, which must accept an unsafe.Pointer object as its only
argument. This function is called when the module tries to read data. It is a mandatory function.
1160
Chapter 131. Input Modules NXLog User Guide
In this Go file template, the read function is called via the ImportFunc directive.
im_go Template
//export read
func read(ctx unsafe.Pointer) {
// get reference to caller module
if module, ok := gonxlog.GetModule(ctx); ok {
// generate new logdata for NXLog
ld := module.NxLogdataNew()
// set 'raw_event' value
ld.Set("raw_event", "some string data")
// send logdata to NXLog input module
module.Post(ld)
}
}
131.12.5. Examples
1161
NXLog User Guide Chapter 131. Input Modules
This configuration reads log files from the /var/log/syslog file directory from a remote server via SSH. The
code defined in the shared object library then gets the reference from the context pointer and gets data
from the channel. After that, it generates new log data by setting the raw_event value then sending it to
the input module by calling the read function. Finally it is saved to a file.
nxlog.conf
1 <Input in1>
2 Module im_go
3 ImportLib "input/input.so"
4 ImportFunc read
5 </Input>
6
7 <Output out>
8 Module om_file
9 File "output/file"
10 Exec log_info($raw_event);
11 </Output>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1162
Chapter 131. Input Modules NXLog User Guide
131.13.1. Configuration
The im_http module accepts the following directives in addition to the common module directives.
ListenAddr
The module accepts connections on the IP address or hostname and port defined here. The default address
is localhost and the default port is 2514. The port number can be defined by appending it at the end of the
hostname or IP address using a colon as a separator (host:port). The port section of this directive and the
Port directive are mutually exclusive. In case both is defined, the port number defined here takes precedence
over a port defined in the Port directive.
When a hostname is used as the ListenAddr, the corresponding IP address is only resolved
NOTE when the module starts up. The listening socket will be bound to that IP addresses until the
module is restarted, regardless of any DNS changes to the hostname.
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
Port
The module listens for incoming connections on the port defined in The default is port 80.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the ListenAddr directive.
HTTPSAllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE the remote will be able to connect with an unknown or self-signed certificate. The default value
is FALSE: all HTTPS connections must present a trusted certificate.
1163
NXLog User Guide Chapter 131. Input Modules
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote HTTPS client. The certificate filenames in this directory must be in the
OpenSSL hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by
including a copy of the certificate in this directory.
HTTPSCAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote HTTPS client. To trust a self-signed certificate presented by the remote (which is not signed by a
CA), provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote HTTPS client. The certificate filenames in this directory must be in
the OpenSSL hashed format.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote HTTPS client.
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
directive is not needed for passwordless private keys.
HTTPSRequireCert
This boolean directive specifies that the remote HTTPS client must present a certificate. If set to TRUE and
there is no certificate presented during the connection handshake, the connection will be refused. The
default value is TRUE: each connection must use a certificate.
HTTPSSSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
1164
Chapter 131. Input Modules NXLog User Guide
HTTPSSSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
131.13.2. Fields
The following fields are used by im_http.
131.13.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration listens for HTTPS connections from localhost. Received log messages are written to file.
nxlog.conf
1 <Input http>
2 Module im_http
3 ListenAddr 0.0.0.0:8888
4 HTTPSCertFile %CERTDIR%/server-cert.pem
5 HTTPSCertKeyFile %CERTDIR%/server-key.pem
6 HTTPSCAFile %CERTDIR%/ca.pem
7 HTTPSRequireCert TRUE
8 HTTPSAllowUntrusted FALSE
9 </Input>
10
11 # Using the syntax prior to NXLog EE 5,
12 # where the port is defined in a separate directive.
13 #<Input http>
14 # Module im_http
15 # ListenAddr 0.0.0.0
16 # Port 8888
17 # HTTPSCertFile %CERTDIR%/server-cert.pem
18 # HTTPSCertKeyFile %CERTDIR%/server-key.pem
19 # HTTPSCAFile %CERTDIR%/ca.pem
20 #</Input>
1165
NXLog User Guide Chapter 131. Input Modules
This configuration uses the HTTPSCAThumbprint and HTTPSCertThumbprint directives for the verification
of the Certificate Authority and the SSL handshake respectively.
nxlog.conf
1 <Input in_https>
2 Module im_http
3 ListenAddr 0.0.0.0:443
4 HTTPSCAThumbprint c2c902f736d39d37fd65c458afe0180ea799e443
5 HTTPSCertThumbprint 7c2cc5a5fb59d4f46082a510e74df17da95e2152
6 HTTPSSSLProtocol TLSv1.2
7 </Input>
8
9 # Using the syntax prior to NXLog EE 5,
10 # where the port is defined in a separate directive.
11 #<Input in_https>
12 # Module im_http
13 # ListenAddr 0.0.0.0
14 # Port 443
15 # HTTPSCAThumbprint c2c902f736d39d37fd65c458afe0180ea799e443
16 # HTTPSCertThumbprint 7c2cc5a5fb59d4f46082a510e74df17da95e2152
17 # HTTPSSSLProtocol TLSv1.2
18 #</Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Only messages with log level INFO and above are supported. Debug messages are ignored due
NOTE to technical reasons. For debugging purposes the direct logging facility should be used: see the
global LogFile and LogLevel directives.
One must be careful about the use of the im_internal module because it is easy to cause
message loops. For example, consider the situation when internal log messages are sent to
a database. If the database is experiencing errors which result in internal error messages,
WARNING then these are again routed to the database and this will trigger further error messages,
resulting in a loop. In order to avoid a resource exhaustion, the im_internal module will drop
its messages when the queue of the next module in the route is full. It is recommended to
always put the im_internal module instance in a separate route.
If internal messages are required in Syslog format, they must be explicitly converted with
NOTE pm_transformer or the to_syslog_bsd() procedure of the xm_syslog module, because the
$raw_event field is not generated in Syslog format.
131.14.1. Configuration
The im_internal module accepts the following directive in addition to the common module directives.
1166
Chapter 131. Input Modules NXLog User Guide
LogqueueSize
This optional directive specifies the maximum number of internal log messages that can be queued by this
module. When the queue becomes full (which can happen for example, when FlowControl is in effect), a
warning will be logged, and older queued messages will be dropped in favor of new ones. The default value
for this directive is inherited from the value of the global level LogqueueSize directive.
131.14.2. Fields
The following fields are used by im_internal.
131.14.3. Examples
1167
NXLog User Guide Chapter 131. Input Modules
This configuration collects NXLog internal messages, adds BSD Syslog headers, and forwards via UDP.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input internal>
6 Module im_internal
7 </Input>
8
9 <Output udp>
10 Module om_udp
11 Host 192.168.1.1:514
12 Exec to_syslog_bsd();
13 </Output>
14
15 <Route internal_to_udp>
16 Path internal => udp
17 </Route>
For the system requirements, installation details and environmental configuration requirements
NOTE
of Java, see the Installing Java section in the Java documentation.
The NXLog Java class provides access to the NXLog functionality in the Java code. This class contains nested
classes Logdata and Module with log processing methods, as well as methods for sending messages to the
internal logger.
To have access to log processing methods, the public static method should accept an NXLog.Logdata or
NXLog.Module object as a parameter.
class NXLog.Logdata
This Java class provides the methods to interact with an NXLog event record object:
getField(name)
This method returns the value of the field name in the event.
setField(name, value)
This method sets the value of field name to value.
deleteField(name)
This method removes the field name from the event record.
getFieldnames()
This method returns an array with the names of all the fields currently in the event record.
1168
Chapter 131. Input Modules NXLog User Guide
getFieldtype(name)
This method retrieves the field type using the value from the name field.
post(module)
This method will submit the LogData event to NXLog for processing by the next module in the route.
class NXLog.Module
The methods below allow setting and accessing variables associated with the module instance.
logdataNew()
This method returns a new NXLog.Logdata object.
setReadTimer(delay)
This method sets a trigger for another read after a specified delay in milliseconds.
saveCtx(key,value)
This method saves user data in the module data storage using values from the key and value fields.
loadCtx(key)
This method retrieves data from the module data storage using the value from the key field.
Below is the list of methods for sending messages to the internal logger.
NXLog.logInfo(msg)
This method sends the message msg to to the internal logger at INFO log level. It does the same as the core
log_info() procedure.
NXLog.logDebug(msg)
This method sends the message msg to to the internal logger at DEBUG log level. It does the same as the core
log_debug() procedure.
NXLog.logWarning(msg)
This method sends the message msg to to the internal logger at WARNING log level. It does the same as the
core log_warning() procedure.
NXLog.logError(msg)
This method sends the message msg to to the internal logger at ERROR log level. It does the same as the core
log_error() procedure.
131.15.1. Configuration
The NXLog process maintains only one JVM instance for all im_java, om_java, or xm_java running instances. This
means all Java classes loaded by the ClassPath directive will be available for all running instances.
The im_java module accepts the following directives in addition to the common module directives.
ClassPath
This mandatory directive defines the path to the .class files or a .jar file. This directive should be defined at
least once within a module block.
VMOption
This optional directive defines a single Java Virtual Machine (JVM) option.
VMOptions
This optional block directive serves the same purpose as the VMOption directive, but also allows specifying
multiple Java Virtual Machine (JVM) instances, one per line.
1169
NXLog User Guide Chapter 131. Input Modules
JavaHome
This optional directive defines the path to the Java Runtime Environment (JRE). The path is used to search for
the libjvm shared library. If this directive is not defined, the Java home directory will be set to the build-time
value. Only one JRE can be defined for one or multiple NXLog Java instances. Defining multiple JRE instances
causes an error.
Run
This mandatory directive specifies the static method inside the Classpath file which should be called.
1170
Chapter 131. Input Modules NXLog User Guide
This example parses the input, keeps only the entries which belong to the PATH type, and generates log
records line-by-line. Using NXLog facilities, these entries are divided into key-value pairs and converted to
JSON format.
The doInput method of the Input Java class is used to run the processing.
nxlog.conf
1 <Input javain>
2 Module im_java
3 # Path to the compiled class
4 Classpath Input.jar
5 # Static method which will be called by the im_java module
6 Run Input.doInput
7 # Path to Java Runtime
8 #JavaHome /usr/lib/jvm/java-11-openjdk-amd64
9 </Input>
10
11 <Output javaout>
12 Module om_file
13 File "/tmp/output.txt"
14 <Exec>
15 kvp->parse_kvp();
16 delete($EventReceivedTime);
17 delete($SourceModuleName);
18 delete($SourceModuleType);
19 to_json();
20 </Exec>
21 </Output>
1171
NXLog User Guide Chapter 131. Input Modules
Input.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
if (lines == null)
{
lines = new ArrayList<>();
1172
Chapter 131. Input Modules NXLog User Guide
Input Sample
type=CWD msg=audit(1489999368.711:35724): cwd="/root/nxlog"↵
↵
type=PATH msg=audit(1489999368.711:35724): item=0 name="/root/test" inode=528869 dev=08:01
mode=040755 ouid=0 ogid=0 rdev=00:00↵
↵
type=SYSCALL msg=audit(1489999368.711:35725): arch=c000003e syscall=2 success=yes exit=3
a0=12dcc40 a1=90800 a2=0 a3=0 items=1 ppid=15391 pid=12309 auid=0 uid=0 gid=0 euid=0 suid=0
fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=583 comm="ls" exe="/bin/ls" key=(null)↵
Output Sample
{
"type":"PATH",
"msg":"audit(1489999368.711:35724):",
"item":0,"name":"/root/test",
"inode":528869,"dev":"08:01",
"mode":040755,"ouid":0,
"ogid":0,
"rdev":"00:00"
}
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.16.1. Configuration
The im_kafka module accepts the following directives in addition to the common module directives. The
BrokerList and Topic directives are required.
BrokerList
This mandatory directive specifies the list of Kafka brokers to connect to for collecting logs. The list should
include ports and be comma-delimited (for example, localhost:9092,192.168.88.35:19092).
Topic
This mandatory directive specifies the Kafka topic to collect records from.
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote brokers. CAFile is required if Protocol is set to ssl or sasl_ssl. To trust a self-signed certificate
presented by the remote (which is not signed by a CA), provide that certificate instead.
CertFile
This specifies the path of the certificate file to be used for the SSL handshake.
CertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake.
1173
NXLog User Guide Chapter 131. Input Modules
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is not needed for passwordless private keys.
Option
This directive can be used to pass a custom configuration property to the Kafka library (librdkafka). For
example, the group ID string can be set with Option group.id mygroup. This directive may be used more
than once to specify multiple options. For a list of configuration properties, see the librdkafka
CONFIGURATION.md file.
Passing librdkafka configuration properties via the Option directive should be done with
WARNING care since these properties are used for the fine-tuning of the librdkafka performance
and may result in various side effects.
Partition
This optional integer directive specifies the topic partition to read from. If this directive is not given, messages
are collected from partition 0.
Protocol
This optional directive specifies the protocol to use for connecting to the Kafka brokers. Accepted values
include plaintext (the default) and ssl, sasl_plaintext and sasl_ssl. If Protocol is set to ssl or
sasl_ssl, then the CAFile directive must also be provided.
SASLKerberosServiceName
This directive specifies the Kerberos service name to be used for SASL authentication. The service name is
required for the sasl_plaintext and sasl_ssl protocols.
SASLKerberosPrincipal
This specifies the client’s Kerberos principal name for the sasl_plaintext and sasl_ssl protocols. This
directive is only available and mandatory on Linux/UNIX. See note below.
SASLKerberosKeytab
Specifies the path to the kerberos keytab file which contains the client’s allocated principal name. This
directive is only available and mandatory on Linux/UNIX.
NOTE For details about configuring Apache Kafka brokers to accept SASL/Kerberos authentication
from clients, please follow the instructions provided by the librdkafka project:
• For kafka brokers running on Linux and UNIX-likes: Using SASL with librdkafka
• For kafka brokers running on Windows: Using SASL with librdkafka on Windows
131.16.2. Fields
The following fields are used by im_kafka.
1174
Chapter 131. Input Modules NXLog User Guide
131.16.3. Examples
Example 701. Using the im_kafka Module
This configuration collects events from a Kafka cluster using the brokers specified. Events are read from the
first partition of the nxlog topic.
nxlog.conf
1 <Input in>
2 Module im_kafka
3 BrokerList localhost:9092,192.168.88.35:19092
4 Topic nxlog
5 Partition 0
6 Protocol ssl
7 CAFile /root/ssl/ca-cert
8 CertFile /root/ssl/client_debian-8.pem
9 CertKeyFile /root/ssl/client_debian-8.key
10 KeyPass thisisasecret
11 </Input>
The librdkafka library can produce its performance statistics and format it in JSON. All fields from the JSON
structure are explained on the Statistics page of the librdkafka project on the GitHub website. NXLog can be
configured to poll this data at a specified fixed interval. The result can be saved to the internal logger.
To read statistical data of the librdkafka library, the millisecond polling interval needs to be specified
against the Option directive using the statistics.interval.ms option.
The Schedule block sets the interval to run the code of the nested Exec block. Inside the Exec block, the
log_info() procedure is called with the kafka_in->get_stats() parameter passed.
To get the librdkafka statistics produced and delivered synchronously, the statistics.interval.ms
option and the Schedule block should specify the same interval amount.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1175
NXLog User Guide Chapter 131. Input Modules
In order for NXLog to read logs from the kernel buffer, it may be necessary to disable the
WARNING
system logger (systemd, klogd, or logd) or configure it to not read events from the kernel.
Special privileges are required for reading kernel logs. For this, NXLog needs to be started as root. With the User
and Group global directives, NXLog can then drop its root privileges while keeping the CAP_SYS_ADMIN capability
for reading the kernel log buffer.
Unfortunately it is not possible to read from the /proc/kmsg pseudo file for an unprivileged
process even if the CAP_SYS_ADMIN capability is kept. For this reason the /proc/kmsg interface
NOTE is not supported by the im_kernel module. The im_file module should work fine with the
/proc/kmsg pseudo file if one wishes to collect kernel logs this way, though this will require
NXLog to be running as root.
Log Sample
<6>Some message from the kernel.↵
Kernel messages are valid BSD Syslog messages, with a priority from 0 (emerg) to 7 (debug), but do not contain
timestamp and hostname fields. These can be parsed with the xm_syslog parse_syslog_bsd() procedure, and the
timestamp and hostname fields will be added by NXLog.
131.17.1. Configuration
The im_kernel module accepts the following directives in addition to the common module directives.
DeviceFile
This directive sets the device file from which to read events, for non-Linux platforms. If this directive is not
specified, the default is /dev/klog.
PollInterval
This directive specifies how frequently the module will check for new events, in seconds, on Linux. If this
directive is not specified, the default is 1 second. Fractional seconds may be specified (PollInterval 0.5 will
check twice every second).
131.17.2. Examples
Example 703. Reading Messages From the Kernel
This configuration collects log messages from the kernel and writes them to file. This should work on Linux,
the BSDs, and macOS (but the system logger may need to be disabled or reconfigured).
nxlog.conf
1 # Drop privileges after being started as root
2 User nxlog
3 Group nxlog
4
5 <Input kernel>
6 Module im_kernel
7 </Input>
8
9 <Output file>
10 Module om_file
11 File "tmp/output"
12 </Output>
1176
Chapter 131. Input Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Rules must be provided using at least one of the LoadRule and Rules directives. Rules should be specified using
the format documented in the Defining Persistent Audit Rules section of the Red Hat Enterprise Linux Security
Guide.
The -e control rule should be included in the ruleset to enable the Audit system (as -e 1 or -e 2). Rules are not
automatically removed, either before applying a ruleset or when NXLog exits. To clear the current ruleset before
setting rules, begin the ruleset with the -D rule. If the Audit configuration is locked when im_linuxaudit starts,
NXLog will print a warning and collect events generated by the active ruleset.
131.18.1. Configuration
The im_linuxaudit module accepts the following directives in addition to the common module directives. At least
one of LoadRule and Rules must be specified.
LoadRule
Use this directive to load a ruleset from an external rules file. This directive can be used more than once.
Wildcards can be used to read rules from multiple files.
ResolveValues
This boolean directive, when set to TRUE, enables name resolution for the following fields: $arch, $auid,
$cmd, $egid, $euid, $fsgid, $fsuid, $gid, $mode, $new_gid, $oauid, $obj_gid, $obj_uid, $ogid, $ouid,
$sauid, $sgid, $suid, $syscall and $uid. These fields will be converted to human-readable strings,
symilarly to how the ausearch tool resolves them. The xm_resolver module must be loaded in order for this
to work. The default value for this directive is FALSE, meaning that fields will not be resolved.
Rules
This directive, specified as a block, can be used to provide Audit rules directly from the NXLog configuration
file. The following control rules are supported: -b, -D, -e, -f, -r, --loginuid-immutable,
--backlog_wait_time, and --reset-lost; see auditctl(8) for more information.
Include
This directive can be used inside a Rules block to read rules from a separate file. Like the LoadRule
directive, wildcards are supported.
LockConfig
If this boolean directive is set to TRUE, NXLog will lock the Audit system configuration after the rules have
been set. It will not be possible to modify the Audit configuration until after a reboot. The default is FALSE: the
Audit configuration will not be locked.
1177
NXLog User Guide Chapter 131. Input Modules
131.18.2. Fields
The following fields are used by im_linuxaudit.
1178
Chapter 131. Input Modules NXLog User Guide
1179
NXLog User Guide Chapter 131. Input Modules
1180
Chapter 131. Input Modules NXLog User Guide
1181
NXLog User Guide Chapter 131. Input Modules
1182
Chapter 131. Input Modules NXLog User Guide
131.18.3. Examples
1183
NXLog User Guide Chapter 131. Input Modules
This configuration uses a set of external rule files to configure the Audit system.
nxlog.conf
1 <Input audit>
2 Module im_linuxaudit
3 FlowControl FALSE
4 LoadRule 'im_linuxaudit_*.rules'
5 </Input>
This configuration lists the rules inside the NXLog configuration file instead of using a separate Audit rules
file.
nxlog.conf
1 <Input audit>
2 Module im_linuxaudit
3 FlowControl FALSE
4 <Rules>
5 # Watch /etc/passwd for modifications and tag with 'passwd'
6 -w /etc/passwd -p wa -k passwd
7 </Rules>
8 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
By default, if no module-specific directives are set, a log message will be generated every 30 minutes containing
-- MARK --.
The $raw_event field is not generated in Syslog format. If mark messages are required in Syslog
NOTE
format, they must be explicitly converted with the to_syslog_bsd() procedure.
The functionality of the im_mark module can be also achieved using the Schedule block with a
NOTE log_info("--MARK--") Exec statement, which would insert the messages via the im_internal
module into a route. Using a single module for this task can simplify configuration.
131.19.1. Configuration
The im_mark module accepts the following directives in addition to the common module directives.
Mark
This optional directive sets the string for the mark message. The default is -- MARK --.
MarkInterval
This optional directive sets the interval for mark messages, in minutes. The default is 30 minutes.
1184
Chapter 131. Input Modules NXLog User Guide
131.19.2. Fields
The following fields are used by im_mark.
131.19.3. Examples
Example 706. Using the im_mark Module
Here, NXLog will write the specified string to file every minute.
nxlog.conf
1 <Input mark>
2 Module im_mark
3 MarkInterval 1
4 Mark -=| MARK |=-
5 </Input>
6
7 <Output file>
8 Module om_file
9 File "tmp/output"
10 </Output>
11
12 <Route mark_to_file>
13 Path mark => file
14 </Route>
1185
NXLog User Guide Chapter 131. Input Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Windows Vista, Windows 2008, and later use a new EventLog API which is not backward
compatible. Messages in some events produced by sources in this new format cannot be
resolved with the old API which is used by this module. If such an event is encountered, a
$Message similar to the following will be set: The description for EventID XXXX from
source SOURCE cannot be read by im_mseventlog because this does not support
NOTE
the newer WIN2008/Vista EventLog API. Consider using the im_msvistalog module
instead.
Though the majority of event messages can be read with this module even on Windows
2008/Vista and later, it is recommended to use the im_msvistalog module instead.
Strings are stored in DLL and executable files and need to be read by the module when reading
EventLog messages. If a program (DLL/EXE) is already uninstalled and is not available for looking
NOTE up a string, the following message will appear instead:
The description for EventID XXXX from source SOURCE cannot be found.
131.20.1. Configuration
The im_mseventlog module accepts the following directives in addition to the common module directives.
ReadFromLast
This optional boolean directive instructs the module to only read logs which arrived after NXLog was started if
the saved position could not be read (for example on first start). When SavePos is TRUE and a previously
saved position value could be read, the module will resume reading from this saved position. If
ReadFromLast is FALSE, the module will read all logs from the EventLog. This can result in quite a lot of
messages, and is usually not the expected behavior. If this directive is not specified, it defaults to TRUE.
SavePos
This boolean directive specifies that the file position should be saved when NXLog exits. The file position will
be read from the cache file upon startup. The default is TRUE: the file position will be saved if this directive is
not specified. Even if SavePos is enabled, it can be explicitly turned off with the global NoCache directive.
Sources
This optional directive takes a comma-separated list of EventLog filenames, such as Security,
Application, to select specific EventLog sources for reading. If this directive is not specified, then all
available EventLog sources are read (as listed in the registry). This directive should not be confused with the
$SourceName field contained within the EventLog and it is not a list of such names. The value of this is stored
in the FileName field.
UTF8
If this optional boolean directive is set to TRUE, all strings will be converted to UTF-8 encoding. Internally this
calls the convert_fields procedure. The xm_charconv module must be loaded for the character set conversion
to work. The default is TRUE, but conversion will only occur if the xm_charconv module is loaded, otherwise
strings will be in the local codepage.
131.20.2. Fields
The following fields are used by im_mseventlog.
1186
Chapter 131. Input Modules NXLog User Guide
1187
NXLog User Guide Chapter 131. Input Modules
1/Critical 5/CRITICAL
2/Error 4/ERROR
3/Warning 3/WARNING
4/Information 2/INFO
5/Verbose 1/DEBUG
131.20.3. Examples
Example 707. Forwarding EventLogs from a Windows Machine to a Remote Host
This configuration collects Windows EventLog and forwards the messages to a remote host via TCP.
nxlog.conf
1 <Input eventlog>
2 Module im_mseventlog
3 </Input>
4
5 <Output tcp>
6 Module om_tcp
7 Host 192.168.1.1:514
8 </Output>
9
10 <Route eventlog_to_tcp>
11 Path eventlog => tcp
12 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
For Windows 2003 and earlier, use the im_mseventlog module because the new Windows Event
NOTE
Log API is only available in Windows Vista, Windows 2008, and later.
1188
Chapter 131. Input Modules NXLog User Guide
Use the im_etw module to collect Analytic and Debug logs as the Windows Event Log subsystem,
NOTE
which im_msvistalog uses, does not support subscriptions to Debug or Analytic channels.
Unlike nxlog4 NXLog can alter fields content regarding CR and LF characters according to W3C
NOTE recommendations. Any CR LF and any CR that is not followed by an LF will be translated to a
single LF.
In addition to the standard set of fields which are listed under the System section, event providers can define
their own additional schema which enables logging additional data under the EventData section. The Security log
makes use of this new feature and such additional fields can be seen as in the following XML snippet:
<EventData>
<Data Name="SubjectUserSid">S-1-5-18</Data>
<Data Name="SubjectUserName">WIN-OUNNPISDHIG$</Data>
<Data Name="SubjectDomainName">WORKGROUP</Data>
<Data Name="SubjectLogonId">0x3e7</Data>
<Data Name="TargetUserSid">S-1-5-18</Data>
<Data Name="TargetUserName">SYSTEM</Data>
<Data Name="TargetDomainName">NT AUTHORITY</Data>
<Data Name="TargetLogonId">0x3e7</Data>
<Data Name="LogonType">5</Data>
<Data Name="LogonProcessName">Advapi</Data>
<Data Name="AuthenticationPackageName">Negotiate</Data>
<Data Name="WorkstationName" />
<Data Name="LogonGuid">{00000000-0000-0000-0000-000000000000}</Data>
<Data Name="TransmittedServices">-</Data>
<Data Name="LmPackageName">-</Data>
<Data Name="KeyLength">0</Data>
<Data Name="ProcessId">0x1dc</Data>
<Data Name="ProcessName">C:\Windows\System32\services.exe</Data>
<Data Name="IpAddress">-</Data>
<Data Name="IpPort">-</Data>
</EventData>
NXLog can extract this data when fields are logged using this schema. The values will be available in the fields of
the internal NXLog log structure. This is especially useful because there is no need to write pattern matching
rules to extract this data from the message. These fields can be used in filtering rules, be written into SQL tables,
or be used to trigger actions. The Exec directive can be used for filtering:
1 <Input in>
2 Module im_msvistalog
3 Exec if ($TargetUserName == 'SYSTEM') OR \
4 ($EventType == 'VERBOSE') drop();
5 </Input>
131.21.1. Configuration
The im_msvistalog module accepts the following directives in addition to the common module directives.
AddPrefix
If this boolean directive is set to TRUE, names of fields parsed from the <EventData> portion of the event
XML will be prefixed with EventData.. For example, $EventData.SubjectUserName will be added to the
event record instead of $SubjectUserName. The same applies to <UserData>. This directive defaults to
FALSE: field names will not be prefixed.
ReadBatchSize
This optional directive can be used to specify the number of event records the EventLog API will pass to the
module for processing. Larger sizes may increase throughput. Note that there is a known issue in the
1189
NXLog User Guide Chapter 131. Input Modules
Windows EventLog subsystem: when this value is higher than 31 it may fail to retrieve some events on busy
systems, returning the error "EvtNext failed with error 1734: The array bounds are invalid." For this reason,
increasing this value is not recommended. The default is 31.
CaptureEventXML
This boolean directive defines whether the module should store raw XML-formatted event data. If set to
TRUE, the module stores raw XML data in the $EventXML field. By default, the value is set to FALSE, and the
$EventXML field is not added to the record.
Channel
The name of the Channel to query. If not specified, the module will read from all sources defined in the
registry. See the MSDN documentation about Event Selection.
File
This optional directive can be used to specify a full path to a log file. Log file types that can be used have the
.evt and .evtx extensions. The path of the file must not be quoted (as opposed to im_file and om_file). If the
File directive is specified, the SavePos directive will be overridden to TRUE.
The File directive can also be used for reading .etl files with the limitation that the
NOTE _im_msvistalog module can not seek in .etl files. It can only read these files from start to
end.
The File directive can be specified multiple times to read from multiple files. This module finds files only
when the module instance is started; any files added later will not be read until it is restarted. If the log file
specified by this directive is updated with new event records while NXLog is running (the file size or
modification date attribute changes), the module detects the newly appended records on the fly without
requiring the module instance to be restarted. Reading an EventLog file directly is mostly useful for forensics
purposes. The System log would be read directly with the following:
File C:\Windows\System32\winevt\Logs\System.evtx
You can use wildcards to specify file names and directories. Wildcards are not regular expressions, but are
patterns commonly used by Unix shells to expand filenames (also known as "globbing").
?
Matches any single character.
*
Matches any string, including the empty string.
\*
Matches the asterisk (*) character.
\?
Matches the question mark (?) character.
[…]
Matches one character specified within the brackets. The brackets should contain a single character (for
example, [a]) or a range of characters ([a-z]). If the first character in the brackets is ^ or !, it reverses the
wildcard matching logic (the wildcard matches any character not in the brackets). The backslash (\)
characters are ignored and should be used to escape ] and - characters as well as ^ and ! at the
beginning of the pathname.
Language
This optional directive specifies a language to use for rendering the events. The language should be given as a
hyphen-separated language/region code (for example, fr-FR for French). Note that the required language
1190
Chapter 131. Input Modules NXLog User Guide
support must be installed on the system. If this directive is not given, the system’s default locale is used.
PollInterval
This directive specifies how frequently the module will check for new events, in seconds. If this directive is not
specified, the default is 1 second. Fractional seconds may be specified (PollInterval 0.5 will check twice
every second).
Query
This directive specifies the query for pulling only specific EventLog sources. See the MSDN documentation
about Event Selection. Note that this directive requires a single-line parameter, so multi-line query XML
should be specified using line continuation:
1 Query <QueryList> \
2 <Query Id='1'> \
3 <Select Path='Security'>*[System/Level=4]</Select> \
4 </Query> \
5 </QueryList>
When the Query contains an XPath style expression, the Channel must also be specified. Otherwise if an XML
Query is specified, the Channel should not be used.
QueryXML
This directive is the same as the Query directive above, except it can be used as a block. Multi-line XML
queries can be used without line continuation, and the XML Query can be copied directly from Event Viewer.
1 <QueryXML>
2 <QueryList>
3 <!-- XML-style comments can
4 span multiple lines in
5 QueryXML blocks like this.
6 -->
7 <Query Id='1'>
8 <Select Path='Security'>*[System/Level=4]</Select>
9 </Query>
10 </QueryList>
11 </QueryXML>
Commenting with the # mark does not work within multi-line Query directives or QueryXML
blocks. In this case, use XML-style comments <!-- --> as shown in the example above.
CAUTION Failure to follow this syntax for comments within queries will render the module instance
useless. Since NXLog does not parse the content of QueryXML blocks, this behavior is
expected.
ReadFromLast
This optional boolean directive instructs the module to only read logs which arrived after NXLog was started if
the saved position could not be read (for example on first start). When SavePos is TRUE and a previously
saved position value could be read, the module will resume reading from this saved position. If
ReadFromLast is FALSE, the module will read all logs from the EventLog. This can result in quite a lot of
messages, and is usually not the expected behavior. If this directive is not specified, it defaults to TRUE.
RemoteAuthMethod
This optional directive specifies the authentication method to use. Available values are Default, Negotiate,
Kerberos, and NTLM. When the directive is not specified, Default is used, which is actually Negotiate.
RemoteDomain
Domain of the user used for authentication when logging on the remote server to collect event logs.
1191
NXLog User Guide Chapter 131. Input Modules
RemotePassword
Password of the user used for authentication when logging on the remote server to collect event logs.
RemoteServer
This optional directive specifies the name of the remote server to collect event logs from. If not specified, the
module will collect locally.
RemoteUser
Name of the user used for authentication when logging on the remote server to collect event logs.
ResolveGUID
This optional boolean directive specifies that GUID values should be resolved to their object names in the
$Message field. If ResolveGUID is set to TRUE, it produces two output fields. One that retains the non-
resolved form of the GUID, and another which resolves to the above mentioned object name. To differentiate
the two output fields, the resolved field name will have the DN suffix added to it. If the field already exists with
the same name the resolved field will not be added and the original is preserved. The default setting is FALSE;
the module will not resolve GUID values. Windows Event Viewer shows the Message with the GUID values
resolved, and this must be enabled to get the same output with NXLog.
ResolveSID
This optional boolean directive specifies that SID values should be resolved to user names in the $Message
field. If ResolveSID is set to TRUE, it produces two output fields. One that retains the non-resolved form of
the SID, and another which resolves to the above mentioned user name. To differentiate the two output
fields, the resolved field name will have the Name suffix added to it. If the field already exists with the same
name the resolved field will not be added and the original is preserved. The default setting is FALSE; the
module will not resolve SID values. Windows Event Viewer shows the Message with the SID values resolved,
and this must be enabled to get the same output with NXLog.
SavePos
This boolean directive specifies that the file position should be saved when NXLog exits. The file position will
be read from the cache file upon startup. The default is TRUE: the file position is saved if this directive is not
specified. Even if SavePos is enabled, it can be explicitly turned off with the global NoCache directive.
TolerateQueryErrors
This boolean directive specifies that im_msvistalog should ignore any invalid sources in the query. The default
is FALSE: im_msvistalog will fail to start if any source is invalid.
131.21.2. Fields
The following fields are used by im_msvistalog.
1192
Chapter 131. Input Modules NXLog User Guide
1193
NXLog User Guide Chapter 131. Input Modules
1/Critical 5/CRITICAL
2/Error 4/ERROR
3/Warning 3/WARNING
4/Information 2/INFO
5/Verbose 1/DEBUG
131.21.3. Examples
Due to a bug or limitation of the Windows Event Log API, 23 or more clauses in a query will
result in a failure with the following error message: ERROR failed to subscribe to
NOTE
msvistalog events, the Query is invalid: This operator is unsupported by this
implementation of the filter.; [error code: 15001]
1194
Chapter 131. Input Modules NXLog User Guide
Example 708. Forwarding Windows EventLog from Windows to a Remote Host in Syslog Format
This configuration collects Windows EventLog with the specified query. BSD Syslog headers are added and
the messages are forwarded to a remote host via TCP.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input eventlog>
6 Module im_msvistalog
7 <QueryXML>
8 <QueryList>
9 <Query Id='0'>
10 <Select Path='Application'>*</Select>
11 <Select Path='Security'>*[System/Level<4]</Select>
12 <Select Path='System'>*</Select>
13 </Query>
14 </QueryList>
15 </QueryXML>
16 </Input>
17
18 <Output tcp>
19 Module om_tcp
20 Host 192.168.1.1:514
21 Exec to_syslog_bsd();
22 </Output>
23
24 <Route eventlog_to_tcp>
25 Path eventlog => tcp
26 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Setting up the ODBC data source is not in the scope of this document. Please consult the relevant ODBC guide:
the unixODBC documentation or the Microsoft ODBC Data Source Administrator guide. The data source must be
accessible by the user NXLog is running under.
In order to continue reading only new log entries after a restart, the table must contain an auto increment, serial,
1195
NXLog User Guide Chapter 131. Input Modules
or timestamp column named id in the returned result set. The value of this column is substituted into the ?
contained in the SELECT (see the SQL directive).
Some data types are not supported by im_odbc. If a column of an unsupported type is included in the result set,
im_odbc will log an unsupported odbc type error to the internal log. To read values from data types that are not
directly supported, use the CAST() function to convert to a supported type. See the Reading Unsupported Types
example below. Additionally, due to a change in the internal representation of datetime values in SQL Server,
some timestamp values cannot be compared correctly (when used as the id) without an explicit casting in the
WHERE clause. See the SQL Server Reading logs by SQL datetime ID example in the User Guide.
131.23.1. Configuration
The im_odbc module accepts the following directives in addition to the common module directives. The
ConnectionString and SQL directives are required.
ConnectionString
This specifies the connection string containing the ODBC data source name.
SQL
This mandatory parameter sets the SQL statement the module will execute in order to query data from the
data source. The select statement must contain a WHERE clause using the column aliased as id.
Note that WHERE RecordNumber > ? is crucial: without this clause the module will read logs in an endless
loop. The result set returned by the select must contain this id column which is then stored and used for the
next query.
IdIsTimestamp
When this directive is set to TRUE, it instructs the module to treat the id field as TIMESTAMP type. If this
directive is not specified, it defaults to FALSE: the id field is treated as an INTEGER/NUMERIC type.
WARNING This configuration directive has been obsoleted in favor of IdType timestamp.
IdType
This directive specifies the type of the id field and accepts the following values: integer, timestamp, and
uniqueidentifier. If this directive is not specified, it defaults to integer and the id field is treated as an
INTEGER/NUMERIC type.
The timestamp type in Microsoft SQL Server is not a real timestamp; see rowversion
NOTE (Transact-SQL) on Microsoft Docs. To use an SQL Server timestamp type field as the id, set
IdType to integer.
The Microsoft SQL Server uniqueidentifier type is only sequential when initialized with
NOTE the NEWSEQUENTIALID function. Even then, the IDs are not guaranteed to be sequential in all
cases. For more information, see uniqueidentifier and NEWSEQUENTIALID on Microsoft
Docs.
The im_odbc module parses timestamps as local time, converted to UTC, and then saves
NOTE them in the event record. This module does not apply any time offset for fields that include
time zone information.
1196
Chapter 131. Input Modules NXLog User Guide
MaxIdSQL
This directive can be used to specify an SQL select statement for fetching the last record. MaxIdSQL is
required if ReadFromLast is set to TRUE. The statement must alias the ID column as maxid and return at least
one row with at least that column.
PollInterval
This directive specifies how frequently, in seconds, the module will check for new records in the database by
executing the SQL SELECT statement. If this directive is not specified, the default is 1 second. Fractional
seconds may be specified (PollInterval 0.5 will check twice every second).
ReadFromLast
This boolean directive instructs the module to only read logs that arrived after NXLog was started if the saved
position could not be read (for example on first start). When SavePos is TRUE and a previously saved position
value could be read, the module will resume reading from this saved position. If ReadFromLast is TRUE, the
MaxIDSQL directive must be set. If this directive is not specified, it defaults to FALSE.
SavePos
This boolean directive specifies that the last row id should be saved when NXLog exits. The row id will be read
from the cache file upon startup. The default is TRUE: the row id is saved if this directive is not specified. Even
if SavePos is enabled, it can be explicitly turned off with the global NoCache directive.
131.23.2. Fields
The following fields are used by im_odbc.
In addition to the field below, each column name returned in the result set is mapped directly to an NXLog field
name.
• the EventTime column or the current time if EventTime was not returned in the result set;
• the Hostname column or the hostname of the local system if Hostname was not returned in the result set;
• the Severity column or INFO if Severity was not returned in the result set; and
131.23.3. Examples
1197
NXLog User Guide Chapter 131. Input Modules
This example uses ODBC to connect to the mydb database and retrieve log messages. The messages are
then forwarded to another agent in the NXLog binary format.
nxlog.conf
1 <Input odbc>
2 Module im_odbc
3 ConnectionString DSN=mssql;database=mydb;
4 SQL SELECT RecordNumber AS id, \
5 DateOccured AS EventTime, \
6 data AS Message \
7 FROM logtable WHERE RecordNumber > ?
8 </Input>
9
10 <Output tcp>
11 Module om_tcp
12 Host 192.168.1.1:514
13 OutputType Binary
14 </Output>
This example reads from an SQL Server database. The LogTime field uses the datetimeoffset type, which is
not directly supported by im_odbc. The following configuration uses a SELECT statement that returns two
columns for this field: EventTime for the timestamp and TZOffset for the time-zone offset value.
nxlog.conf
1 <Input mssql_datetimeoffset>
2 Module im_odbc
3 ConnectionString Driver={ODBC Driver 17 for SQL Server}; Server=MSSQL-HOST; \
4 Trusted_Connection=yes; Database=TESTDB
5 IdType integer
6 SQL SELECT RecordID AS id, \
7 CAST(LogTime AS datetime2) AS EventTime, \
8 DATEPART(tz, LogTime) AS TZOffset, \
9 Message \
10 FROM dbo.test1 WHERE RecordID > ?
11 Exec rename_field($id, $RecordID);
12 </Input>
131.24.1. Configuration
The im_pcap module accepts the following directives in addition to the common module directives.
Dev
This optional directive can only occur once. It specifies the name of a network device/interface on which
im_pcap will capture packets. This directive is mutually exclusive with the File directive.
1198
Chapter 131. Input Modules NXLog User Guide
Fields
The names of protocol fields to be included in the output. If no field names are present in the protocol
configuration then all fields for the protocol will be present in the output. If any field names are present in the
configuration for a protocol, then only those named fields will be present in the output. Refer to NXLog Pcap
Protocols for details of the fields supported for each protocol.
File
This optional directive can only occur once. It specifies the path to the file which contains capture packet data.
The file path do not need to be enclosed in quotation marks, although both single quoted and double quoted
paths are accepted. This directive is mutually exclusive with the Dev directive.
Protocol
This is an optional group directive. It specifies the protocol, port number and protocol-specific fields which
should be captured. May be used multiple times in the module definition, to specify multiple protocols. If no
Protocol directive is specified, then all protocols will be captured. It has the following sub-directives:
Type
Defines the name of a protocol to capture. Allowed types are; ethernet, ipv4, ipv6, ip, tcp, udp, http,
arp, vlan, icmp, pppoe, dns, mpls, gre, ppp_pptp, ssl, sll, dhcp, null_loopback, igmp, vxlan, sip, sdp,
radius, modbus, profinet, dnp3, bacnet, iec104.
Port
A list of custom port numbers to capture for the protocol specified in the Type directive. If omitted,
standard port number(s) corresponding to the protocol will be used. Refer to NXLog Pcap Protocols for
details of the default ports for each protocol.
The list of port numbers must be separated by a comma. Spaces and tabs between the
NOTE
values are accepted.
Filter
An optional directive that defines a filter, which can be used to further limit the packets that should be
captured and handled by the module. Filters do not need to be enclosed in quotation marks, although both
single quoted and double quoted filters are accepted. If this directive is not used, then no filtering will be
done.
Filtering is done by the libpcap library. See the Manpage of PCAP-FILTER in the libpcap
NOTE
documentation for the syntax. Not all protocols are supported for libpcap filtering.
131.24.2. Examples
1199
NXLog User Guide Chapter 131. Input Modules
Example 711. Reading from a PCAP File While Applying a Packet Filter
In this example, the File directive defines the path and filename of a .pcap file containing packets saved by
Wireshark. The Filter directive defines a filter that selects only TCP packets targeted for port 443. The output
is formatted as JSON while written to file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input pcap>
6 Module im_pcap
7 File "/tmp/example.pcap"
8 Filter tcp dst port 443
9 </Input>
10
11 <Output file>
12 Module om_file
13 File "/tmp/output.json"
14 Exec to_json();
15 </Output>
1200
Chapter 131. Input Modules NXLog User Guide
Example 712. Capturing TCP, Ethernet, and HTTP Traffic to a Single File
In this example, the configuration illustrates how the Protocol group directive can be defined multiple times
within the same module instance. Three types of network packets are to be captured: HTTP requests; TCP
for the source and destination ports of all visible TCP traffic; and Ethernet to log the MAC addresses of
packet sources and their destinations. The events are formatted to JSON while writing to a file.
This approach has two distinct advantages. It produces events that include all fields of all three protocols,
which enables correlation between protocols that yield source and destination information with those
protocols that do not provide such fields. Additionally, it achieves this goal using a single module instance
instead of multiple instances, which reduces system resource consumption.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input pcap>
6 Module im_pcap
7 Dev any
8 <Protocol>
9 Type http
10 Field http.request.uri
11 Field http.request.method
12 Field http.response.code
13 Field http.response.phrase
14 </Protocol>
15 <Protocol>
16 Type tcp
17 Field tcp.src_port
18 Field tcp.dst_port
19 Field tcp.flag
20 </Protocol>
21 <Protocol>
22 Type ethernet
23 Field eth.src_mac
24 Field eth.dest.mac
25 </Protocol>
26 </Input>
27
28 <Output file>
29 Module om_file
30 File "tmp/output"
31 Exec to_json();
32 </Output>
1201
NXLog User Guide Chapter 131. Input Modules
Example 713. Capturing TCP, Ethernet, and HTTP Traffic to Separate Files
In this example, each of the three protocols are managed by a separate module instance. The events are
formatted to JSON while being written to each of their respective files. This approach can be used when
there is a need to analyze each protocol in isolation from each other. Because three input instances are
used, more system resources will be consumed when compared to the multi-protocol, single-instance
approach.
nxlog.conf (truncated)
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input pcap_tcp>
6 Module im_pcap
7 Dev any
8 <Protocol>
9 Type tcp
10 Field tcp.src_port
11 Field tcp.dst_port
12 Field tcp.flag
13 </Protocol>
14 </Input>
15
16 <Input pcap_http>
17 Module im_pcap
18 Dev any
19 <Protocol>
20 Type http
21 Field http.request.uri
22 Field http.request.method
23 Field http.response.code
24 Field http.response.phrase
25 </Protocol>
26 </Input>
27
28 <Input pcap_eth>
29 [...]
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module makes it possible to execute Perl code in an input module to capture and inject event data directly
into NXLog. See also the om_perl and xm_perl modules.
The module will parse the file specified in the PerlCode directive when NXLog starts the module. The Perl code
must implement the read_data subroutine which will be called by the module. To generate event data, the
Log::Nxlog Perl module must be included, which provides the following methods.
1202
Chapter 131. Input Modules NXLog User Guide
To use the im_perl module on Windows, a separate Perl environment must be installed, such as
NOTE
Strawberry Perl. Currently, the im_perl module on Windows requires Strawberry Perl 5.28.2.1.
log_debug(msg)
Send the message msg to the internal logger on DEBUG log level. This method does the same as the
log_debug() procedure in NXLog.
log_info(msg)
Send the message msg to the internal logger on INFO log level. This method does the same as the log_info()
procedure in NXLog.
log_warning(msg)
Send the message msg to the internal logger on WARNING log level. This method does the same as the
log_warning() procedure in NXLog.
log_error(msg)
Send the message msg to the internal logger on ERROR log level. This method does the same as the
log_error() procedure in NXLog.
add_input_data(event)
Pass the event record to the next module instance in the route. Failure to call this method will result in a
memory leak.
logdata_new()
Create a new event record. The return value can be used with the set_field_*() methods to insert data.
set_read_timer(delay)
Set the timer in seconds to invoke the read_data method again.
The set_read_timer() method should be called in order to invoke read_data again. This is typically
NOTE
used for polling data. The read_data method must not block.
For the full NXLog Perl API, see the POD documentation in Nxlog.pm. The documentation can be read with
perldoc Log::Nxlog.
131.25.1. Configuration
The im_perl module accepts the following directives in addition to the common module directives.
PerlCode
This mandatory directive expects a file containing valid Perl code that implements the read_data subroutine.
This file is read and parsed by the Perl interpreter.
1203
NXLog User Guide Chapter 131. Input Modules
On Windows, the Perl script invoked by the PerlCode directive must define the Perl library
paths at the beginning of the script to provide access to the Perl modules.
NOTE
nxlog-windows.pl
use lib 'c:\Program Files\nxlog\data';
Config
This optional directive allows you to pass configuration strings to the script file defined by the PerlCode
directive. This is a block directive and any text enclosed within <Config></Config> is submitted as a single
string literal to the Perl code.
If you pass several values using this directive (for example, separated by the \n delimiter) be
NOTE
sure to parse the string correspondingly inside the Perl code.
Call
This optional directive specifies the Perl subroutine to invoke. With this directive, you can call only specific
subroutines from your Perl code. If the directive is not specified, the default subroutine read_data is invoked.
131.25.2. Examples
1204
Chapter 131. Input Modules NXLog User Guide
In this example, logs are generated by a Perl function that increments a counter and inserts it into the
generated line.
nxlog.conf
1 <Output file2>
2 Module om_file
3 File 'tmp/output2'
4 </Output>
5
6
7 <Input perl>
8 Module im_perl
9 PerlCode modules/input/perl/perl-input.pl
10 Call read_data1
11 </Input>
12
13 <Input perl2>
14 Module im_perl
15 PerlCode modules/input/perl/perl-input2.pl
16 </Input>
17
18 <Route r1>
19 Path perl => file
20 </Route>
21
22 <Route r2>
23 Path perl2 => file2
24 </Route>
perl-input.pl
use strict;
use warnings;
use Log::Nxlog;
my $counter;
sub read_data1
{
my $event = Log::Nxlog::logdata_new();
$counter //= 1;
my $line = "Input1: this is a test line ($counter) that should appear in the output";
$counter++;
Log::Nxlog::set_field_string($event, 'raw_event', $line);
Log::Nxlog::add_input_data($event);
if ( $counter <= 100 )
{
Log::Nxlog::set_read_timer(0);
}
}
1205
NXLog User Guide Chapter 131. Input Modules
131.26.1. Configuration
The im_pipe module accepts the following directives in addition to the common module directives.
CreateDir
If set to TRUE, this optional boolean directive instructs the module to create the directory where the Pipe pipe
file is located, if it does not already exist. The default is FALSE.
Pipe
This mandatory directive specifies the name of the input pipe file. The module checks if the specified pipe file
exists and creates it in case it does not. If the specified pipe file is not a named pipe, the module does not
start.
InputType
This directive specifies the input data format. The default value is LineBased. See the InputType directive in
the list of common module directives.
Group
Use this directive to set the group ownership for the created socket or pipe or file. By default, this is the group
NXLog is running as, (which may be specified by the global Group directive). This directive is not currently
supported on Windows.
Perms
This directive specifies the permissions to use for the created socket or pipe or file. This must be a four-digit
octal value beginning with a zero. By default, OS default permissions will be set. This directive is not currently
supported on Windows.
User
Use this directive to set the user ownership for the created socket or pipe or file. By default, this is the user
NXLog is running as (which may be specified by the global User directive). This directive is not currently
supported on Windows.
131.26.2. Examples
This example provides the NXLog configuration for processing messages from a named pipe on a UNIX-like
operating system.
With this configuration, NXLog reads messages from a named pipe and forwards them via TCP. No
additional processing is done.
nxlog.conf
<Input in>↵
Module im_pipe↵
Pipe "tmp/pipe"↵
</Input>↵
↵
<Output out>↵
Module om_tcp↵
Host 192.168.1.2↵
Port 514↵
</Output>↵
1206
Chapter 131. Input Modules NXLog User Guide
The file specified by the PythonCode directive should contain a read_data() method which is called by the
im_python module instance. See also the xm_python and om_python modules.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The Python script should import the nxlog module, and will have access to the following classes and functions.
nxlog.log_debug(msg)
Send the message msg to the internal logger at DEBUG log level. This function does the same as the core
log_debug() procedure.
nxlog.log_info(msg)
Send the message msg to the internal logger at INFO log level. This function does the same as the core
log_info() procedure.
nxlog.log_warning(msg)
Send the message msg to the internal logger at WARNING log level. This function does the same as the core
log_warning() procedure.
nxlog.log_error(msg)
Send the message msg to the internal logger at ERROR log level. This function does the same as the core
log_error() procedure.
class nxlog.Module
This class will be instantiated by NXLog and passed to the read_data() method in the script.
logdata_new()
This method returns a new LogData event object.
set_read_timer(delay)
This method sets a trigger for another read after a specified delay in seconds (float).
class nxlog.LogData
This class represents a Logdata event object.
delete_field(name)
This method removes the field name from the event record.
field_names()
This method returns a list with the names of all the fields currently in the event record.
get_field(name)
This method returns the value of the field name in the event.
post()
This method will submit the LogData event to NXLog for processing by the next module in the route.
set_field(name, value)
This method sets the value of field name to value.
1207
NXLog User Guide Chapter 131. Input Modules
module
This attribute is set to the Module object associated with the event.
131.27.1. Configuration
The im_python module accepts the following directives in addition to the common module directives.
PythonCode
This mandatory directive specifies a file containing Python code. The im_python instance will call a
read_data() function which must accept an nxlog.Module object as its only argument.
Call
This optional directive specifies the Python method to invoke. With this directive, you can call only specific
methods from your Python code. If the directive is not specified, the default method read_data is invoked.
131.27.2. Examples
Example 716. Using im_python to Generate Event Data
In this example, a Python script is used to read Syslog events from multiple log files bundled in tar archives,
which may be compressed. The parse_syslog() procedure is also used to parse the events.
To avoid re-reading archives, each one should be removed after reading (see the
NOTE
comments in the script) or other similar functionality implemented.
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input in>
6 Module im_python
7 PythonCode modules/input/python/2_python.py
8 Exec parse_syslog();
9 </Input>
2_python.py (truncated)
import os
import tarfile
import nxlog
LOG_DIR = 'modules/input/python/2_logdir'
POLL_INTERVAL = 30
def read_data(module):
nxlog.log_debug('Checking for new archives')
for file in os.listdir(LOG_DIR):
path = os.path.join(LOG_DIR, file)
nxlog.log_debug("Attempting to read from '{}'".format(path))
try:
for line in read_tar(path):
event = module.logdata_new()
event.set_field('ImportFile', path)
event.set_field('raw_event', line.decode('utf-8'))
[...]
1208
Chapter 131. Input Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The output counterpart, om_redis, can be used to populate the Redis server with data.
131.28.1. Configuration
The im_redis module accepts the following directives in addition to the common module directives. The Host
directive is required.
Host
This mandatory directive specifies the IP address or DNS hostname of the Redis server to connect to.
Channel
This optional directive defines the Redis channel this module will subscribe to. This directive can be specified
multiple times within the module definition. When the Command directive is set to PSUBSCRIBE, each
Channel directive specifies a glob that will be matched by the Redis server against its available channels. For
the SUBSCRIBE command, Channel specifies the channel names which will be matched as is (no globbing).
The usage of this directive is mutually exclusive with the usage of the LPOP and RPOP commands in the
Command directive.
Command
This optional directive can be used to choose between the LPOP, RPOP, SUBSCRIBE and PSUBSCRIBE
commands. The default Command is set to LPOP, if this directive is not specified.
InputType
See the InputType directive in the list of common module directives. The default is the Dgram reader function,
which expects a plain string. To preserve structured data Binary can be used, but it must also be set on the
other end.
Key
This specifies the Key used by the LPOP command. The default is nxlog. The usage of this directive is
mutually exclusive with the usage of the SUBSCRIBE and PSUBSCRIBE commands in the Command directive.
PollInterval
This directive specifies how frequently the module will check for new data, in seconds. If this directive is not
specified, the default is 1 second. Fractional seconds may be specified (PollInterval 0.5 will check twice
every second). The usage of this directive is mutually exclusive with the usage of the SUBSCRIBE and
PSUBSCRIBE commands in the Command directive.
Port
This specifies the port number of the Redis server. The default is port 6379.
131.28.2. Fields
The following fields are used by im_redis.
1209
NXLog User Guide Chapter 131. Input Modules
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.29.1. Configuration
The im_regmon module accepts the following directives in addition to the common module directives. The
RegValue directive is required.
RegValue
This mandatory directive specifies the name of the registry entry. It must be a string type expression.
Wildcards are also supported. See the File directive of im_file for more details on how wildcarded entries can
be specified. More than one occurrence of the RegValue directive can be specified. The path of the registry
entry specified with this directive must start with one of the following: HKCC, HKU, HKCU, HKCR, or HKLM.
The user running NXLog must have at least read permission on the specified keys. If NXLog
is running as a service, then the user the service is running as must have the appropriate
permissions applied to it. Refer to the Microsoft documentation on how to change registry
WARNING
values or permissions from a command line or a script. Permissions can also be applied
from the Windows Registry user interface, see the How to apply permissions to a Windows
registry key article in the Sophos documentation.
The Microsoft PsExec tool can be used to run the Windows Registry interactively as the System
TIP
account in order to change the necessary permissions.
64BitView
If set to TRUE, this boolean directive indicates that the 64 bit registry view should be monitored. The default is
TRUE.
Digest
This specifies the digest method (hash function) to be used to calculate the checksum. The default is sha1.
The following message digest methods can be used: md2, md5, mdc2, rmd160, sha, sha1, sha224, sha256,
sha384, and sha512.
Exclude
This directive specifies a single registry path or a set of registry values (using wildcards) to be excluded from
the scan. More than one occurrence of the Exclude directive can be used.
1210
Chapter 131. Input Modules NXLog User Guide
Recursive
If set to TRUE, this boolean directive specifies that registry entries set with the RegValue directive should be
scanned recursively under subkeys. For example, HKCU\test\value will match HKCU\test\subkey\value.
Wildcards can be used in combination with Recursive: HKCU\test\value* will match
HKCU\test\subkey\value2. This directive only causes scanning under the given path: HKCU\*\value will not
match HKCU\test\subkey\value. The default is FALSE.
ScanInterval
This directive specifies how frequently, in seconds, the module will check the registry entry or entries for
modifications. The default is 86400 (1 day). The value of ScanInterval can be set to 0 to disable periodic
scanning and instead invoke scans via the start_scan() procedure.
131.29.2. Procedures
The following procedures are exported by im_regmon.
start_scan();
Trigger the Windows registry integrity scan. This procedure returns before the scan is finished.
131.29.3. Fields
The following fields are used by im_regmon.
1211
NXLog User Guide Chapter 131. Input Modules
131.29.4. Examples
Example 717. Periodic Registry Monitoring
This example monitors the registry entry recursively, and scans every 10 seconds. Messages generated by
any detected changes will be written to file in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input regmon>
6 Module im_regmon
7 RegValue 'HKLM\Software\Policies\*'
8 ScanInterval 10
9 </Input>
10
11 <Output file>
12 Module om_file
13 File 'C:\test\regmon.log'
14 Exec to_json();
15 </Output>
16
17 <Route regmon_to_file>
18 Path regmon => file
19 </Route>
1212
Chapter 131. Input Modules NXLog User Guide
The im_regmon module provides a start_scan() procedure that can be called to invoke the scan. The
following configuration will trigger the scan every day at midnight.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input regmon>
6 Module im_regmon
7 RegValue 'HKLM\Software\*'
8 Exclude 'HKLM\Software\Program Groups\*'
9 ScanInterval 0
10 <Schedule>
11 When @daily
12 Exec start_scan();
13 </Schedule>
14 </Input>
15
16 <Output file>
17 Module om_file
18 File 'C:\test\regmon.log'
19 Exec to_json();
20 </Output>
21
22 <Route dailycheck>
23 Path regmon => file
24 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Nxlog.log_info(msg)
Send the message msg to the internal logger at DEBUG log level. This method does the same as the core
log_debug() procedure.
Nxlog.log_debug(msg)
Send the message msg to the internal logger at INFO log level. This method does the same as the core
log_info() procedure.
Nxlog.log_warning(msg)
Send the message msg to the internal logger at WARNING log level. This method does the same as the core
log_warning() procedure.
Nxlog.log_error(msg)
Send the message msg to the internal logger at ERROR log level. This method does the same as the core
log_error() procedure.
1213
NXLog User Guide Chapter 131. Input Modules
class Nxlog.Module
This class will be instantiated by NXLog and passed to the method specified by the Call directive.
logdata_new()
This method returns a new LogData object.
set_read_timer(delay)
This method sets a trigger for another read after a specified delay in seconds (float).
class Nxlog.LogData
This class represents an event.
field_names()
This method returns an array with the names of all the fields currently in the event record.
get_field(name)
This method returns the value of the field name in the event.
post()
This method will submit the event to NXLog for processing by the next module in the route.
set_field(name, value)
This method sets the value of field name to value.
131.30.1. Configuration
The im_ruby module accepts the following directives in addition to the common module directives. The RubyCode
directive is required.
RubyCode
This mandatory directive specifies a file containing Ruby code. The im_ruby instance will call the method
specified by the Call directive. The method must accept an Nxlog.Module object as its only argument.
Call
This optional directive specifies the Ruby method to call. The default is read_data.
131.30.2. Examples
1214
Chapter 131. Input Modules NXLog User Guide
In this example, events are generated by a simple Ruby method that increments a counter. Because this
Ruby method does not set the $raw_event field, it would be reasonable to use to_json() or some other way
to preserve the fields for further processing.
nxlog.conf
1 <Input in>
2 Module im_ruby
3 RubyCode ./modules/input/ruby/input2.rb
4 Call read_data
5 </Input>
input2.rb
$index = 0
def read_data(mod)
Nxlog.log_debug('Creating new event via input.rb')
$index += 1
event = mod.logdata_new
event.set_field('Counter', $index)
event.set_field('Message', "This is message #{$index}")
event.post
mod.set_read_timer 0.3
end
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.31.1. Configuration
The im_ssl module accepts the following directives in addition to the common module directives.
ListenAddr
The module accepts connections on the IP address or hostname and port defined here. The default address
is localhost and the default port is 514. The port number can be defined by appending it at the end of the
hostname or IP address using a colon as a separator (host:port). The port section of this directive and the
Port directive are mutually exclusive. In case both is defined, the port number defined here takes precedence
over a port defined in the Port directive. In case none of them is defined, the default port is used.
Formerly called Host, this directive is now ListenAddr. Host will become deprecated
IMPORTANT
from NXLog EE 6.0 for incoming traffic.
When a hostname is used as the ListenAddr, the corresponding IP address is only resolved
NOTE when the module starts up. The listening socket will be bound to that IP addresses until the
module is restarted, regardless of any DNS changes to the hostname.
1215
NXLog User Guide Chapter 131. Input Modules
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
Port
The module listens for incoming connections on the port defined in this directive. The default is port 514.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the ListenAddr directive.
AllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE the remote will be able to connect with an unknown or self-signed certificate. The default value
is FALSE: all connections must present a trusted certificate.
CADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote socket. The certificate filenames in this directory must be in the OpenSSL
hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including
a copy of the certificate in this directory.
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote socket. To trust a self-signed certificate presented by the remote (which is not signed by a CA),
provide that certificate instead.
CAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
1216
Chapter 131. Input Modules NXLog User Guide
This directive is only supported on Windows. This directive and the CADir and CAFile directives are mutually
exclusive.
CertFile
This specifies the path of the certificate file to be used for the SSL handshake.
CertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake.
CertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the CertFile and
CertKeyFile directives are mutually exclusive.
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is not needed for passwordless private keys.
CRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote socket. The certificate filenames in this directory must be in the
OpenSSL hashed format.
CRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote socket.
RequireCert
This boolean value specifies that the remote must present a certificate. If set to TRUE and there is no
certificate presented during the connection handshake, the connection will be refused. The default value is
TRUE: each connection must use a certificate.
SSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
SSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the SSLProtocol directive is
set to TLSv1.3. Use the same format as in the SSLCipher directive.
SSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
SSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols are allowed. Note that the OpenSSL library shipped by Linux distributions
may not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
1217
NXLog User Guide Chapter 131. Input Modules
131.31.2. Fields
The following fields are used by im_ssl.
131.31.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration accepts secured log messages in the NXLog binary format and writes them to file.
nxlog.conf
1 <Input ssl>
2 Module im_ssl
3 ListenAddr localhost:23456
4 CAFile %CERTDIR%/ca.pem
5 CertFile %CERTDIR%/client-cert.pem
6 CertKeyFile %CERTDIR%/client-key.pem
7 KeyPass secret
8 InputType Binary
9 </Input>
10
11 # Using the syntax prior to NXLog EE 5,
12 # where the port is defined in a separate directive.
13 #<Input ssl>
14 # Module im_ssl
15 # ListenAddr localhost
16 # Port 23456
17 # CAFile %CERTDIR%/ca.pem
18 # CertFile %CERTDIR%/client-cert.pem
19 # CertKeyFile %CERTDIR%/client-key.pem
20 # KeyPass secret
21 # InputType Binary
22 #</Input>
23
24 <Output file>
25 Module om_file
26 File "tmp/output"
27 </Output>
28
29 <Route ssl_to_file>
30 Path ssl => file
31 </Route>
1218
Chapter 131. Input Modules NXLog User Guide
To enable running the im_systemd module under the nxlog user, the latter must be added to the
NOTE systemd-journal group. For example, this could be the following command:
$ sudo gpasswd -a nxlog -g systemd-journal
131.32.1. Configuration
The im_systemd module accepts the following directive in addition to the common module directives.
ReadFromLast
If set to TRUE, this optional boolean directive will read only new entries from the journal.
131.32.2. Fields
The following fields are used by im_systemd.
1219
NXLog User Guide Chapter 131. Input Modules
1220
Chapter 131. Input Modules NXLog User Guide
1221
NXLog User Guide Chapter 131. Input Modules
131.32.3. Examples
1222
Chapter 131. Input Modules NXLog User Guide
Example 721. Using the im_systemd Module to Read the Systemd Journal
nxlog.conf
1 <Input systemd>
2 Module im_systemd
3 ReadFromLast TRUE
4 </Input>
Below is the sample of a systemd journal message after it has been accepted by the im_systemd module
and converted into JSON format using the xm_json module.
Event Sample
{"Severity":"info","SeverityValue":6,"Facility":"auth","FacilityValue":3,↵
"Message":"Reached target User and Group Name Lookups.","SourceName":"systemd",↵
"ProcessID":"1","BootID":"179e1f0a40c64b6cb126ed97278aef89",↵
"MachineID":"0823d4a95f464afeb0021a7e75a1b693","Hostname":"user",↵
"Transport":"kernel","EventReceivedTime":"2020-02-05T14:46:09.809554+00:00",↵
"SourceModuleName":"systemd","SourceModuleType":"im_systemd"}↵
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module provides no access control. Firewall rules can be used to deny connections from
NOTE
certain hosts.
131.33.1. Configuration
The im_tcp module accepts the following directives in addition to the common module directives.
ListenAddr
The module will accept connections on this IP address or DNS hostname. For security, the default listen
address is localhost (the localhost loopback address is not accessible from the outside). To receive logs from
remote hosts, the address specified here must be accessible. The any address 0.0.0.0 is commonly used
here. The port number can be defined by appending it at the end of the hostname or IP address using a colon
as a separator (host:port). The port section of this directive and the Port directive are mutually exclusive. In
case both is defined, the port number defined here takes precedence over a port defined in the Port directive.
In case none of them is defined, the default port 514 is used.
Formerly called Host, this directive is now ListenAddr. Host for incoming traffic will
IMPORTANT
become deprecated from NXLog EE 6.0.
When a hostname is used as the ListenAddr, the corresponding IP address is only resolved
NOTE when the module starts up. The listening socket will be bound to that IP addresses until the
module is restarted, regardless of any DNS changes to the hostname.
1223
NXLog User Guide Chapter 131. Input Modules
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
Port
The module will listen for incoming connections on this port number. The default port is 514 if this directive is
not specified.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the ListenAddr directive.
ReusePort
This optional boolean directive enables synchronous listening on the same port by multiple module
instances. Each module instance runs in its own thread, allowing NXLog to process incoming data
simultaneously to take better advantage of multiprocessor systems. The default value is FALSE.
To enable synchronous listening, the configuration file should contain multiple im_tcp module instances
listening on the same port and the ReusePort directive set to TRUE, see the Examples section.
131.33.2. Fields
The following fields are used by im_tcp.
1224
Chapter 131. Input Modules NXLog User Guide
131.33.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
With this configuration, NXLog listens for TCP connections on port 1514 and writes the received log
messages to a file.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 ListenAddr 0.0.0.0:1514
4 </Input>
5
6 # Using the syntax prior to NXLog EE 5,
7 # where the port is defined in a separate directive.
8 #<Input tcp>
9 # Module im_tcp
10 # Host 0.0.0.0
11 # Port 1514
12 #</Input>
13
14 <Output file>
15 Module om_file
16 File "tmp/output"
17 </Output>
18
19 <Route tcp_to_file>
20 Path tcp => file
21 </Route>
1225
NXLog User Guide Chapter 131. Input Modules
The configuration below provides two im_tcp module instances to reuse port 1514 via the ReusePort
directive. Received messages are written to the /tmp/output file.
nxlog.conf
1 <Input tcp_one>
2 Module im_tcp
3 ListenAddr 192.168.31.11:1514
4 ReusePort TRUE
5 </Input>
6
7 <Input tcp_two>
8 Module im_tcp
9 ListenAddr 192.168.31.11:1514
10 ReusePort TRUE
11 </Input>
12
13 # Using the syntax prior to NXLog EE 5,
14 # where the port is defined in a separate directive.
15 #<Input tcp_one>
16 # Module im_tcp
17 # Host 192.168.31.11
18 # Port 1514
19 # ReusePort TRUE
20 #/Input>
21 #
22 #<Input tcp_two>
23 # Module im_tcp
24 # Host 192.168.31.11
25 # Port 1514
26 # ReusePort TRUE
27 #</Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.34.1. Configuration
The im_testgen module accepts the following directives in addition to the common module directives.
MaxCount
The module will generate this many events, and then stop generating events. If this directive is not specified,
im_testgen will continue generating events until the module is stopped or NXLog exits.
1226
Chapter 131. Input Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
UDP is an unreliable transport protocol, and does not guarantee delivery. Messages may
WARNING not be received or may be truncated. It is recommended to use the TCP or SSL transport
modules instead, if possible.
This module provides no access control. Firewall rules can be used to drop log events from
NOTE
certain hosts.
For parsing Syslog messages, see the pm_transformer module or the parse_syslog_bsd() procedure of xm_syslog.
131.35.1. Configuration
The im_udp module accepts the following directives in addition to the common module directives.
ListenAddr
The module accepts connections on the IP address or hostname and port defined here. The default address
is localhost and the default port is 514. The port number can be defined by appending it at the end of the
hostname or IP address using a colon as a separator (host:port). The port section of this directive and the
Port directive are mutually exclusive. In case both is defined, the port number defined here takes precedence
over a port defined in the Port directive. In case none of them is defined, the default port 514 is used.
Formerly called Host, this directive is now ListenAddr. Host will become deprecated
IMPORTANT
from NXLog EE 6.0.
When a hostname is used as the ListenAddr, the corresponding IP address is only resolved
NOTE when the module starts up. The listening socket will be bound to that IP addresses until the
module is restarted, regardless of any DNS changes to the hostname.
1227
NXLog User Guide Chapter 131. Input Modules
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
Port
The module will listen for incoming connections on this port number. The default is port 514.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the ListenAddr directive.
ReusePort
This optional boolean directive enables synchronous listening on the same port by multiple module
instances. Each module instance runs in its own thread, allowing NXLog to process incoming data
simultaneously to take better advantage of multiprocessor systems. The default value is FALSE.
To enable synchronous listening, the configuration file should contain multiple im_udp module instances
listening on the same port and the ReusePort directive set to TRUE, see the Examples section.
SockBufSize
This optional directive sets the socket buffer size (SO_RCVBUF) to the value specified. If not set, the operating
system defaults are used. If UDP packet loss is occurring at the kernel level, setting this to a high value (such
as 150000000) may help. On Windows systems the default socket buffer size is extremely low, and using this
option is highly recommended.
UseRecvmmsg
This boolean directive specifies that the recvmmsg() system call should be used, if available, to receive
multiple messages per call to improve performance. The default is TRUE.
1228
Chapter 131. Input Modules NXLog User Guide
131.35.2. Fields
The following fields are used by im_udp.
131.35.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration accepts log messages via UDP and writes them to a file.
nxlog.conf
1 <Input udp>
2 Module im_udp
3 ListenAddr 192.168.1.1:514
4 </Input>
5
6 # Using the syntax prior to NXLog EE 5,
7 # where the port is defined in a separate directive.
8 #<Input udp>
9 # Module im_udp
10 # Host 192.168.1.1
11 # Port 514
12 #</Input>
13
14 <Output file>
15 Module om_file
16 File "tmp/output"
17 </Output>
18
19 <Route udp_to_file>
20 Path udp => file
21 </Route>
1229
NXLog User Guide Chapter 131. Input Modules
The configuration below provides two im_udp module instances to reuse port 514 via the ReusePort
directive. Received messages are written to the /tmp/output file.
nxlog.conf (truncated)
1 <Input udp_one>
2 Module im_udp
3 ListenAddr 192.168.1.1:514
4 ReusePort TRUE
5 </Input>
6
7 <Input udp_two>
8 Module im_udp
9 ListenAddr 192.168.1.1:514
10 ReusePort TRUE
11 </Input>
12
13 # Using the syntax prior to NXLog EE 5,
14 # where the port is defined in a separate directive.
15 #<Input udp_one>
16 # Module im_udp
17 # Host 192.168.1.1
18 # Port 514
19 # ReusePort TRUE
20 #</Input>
21 #
22 #<Input udp_two>
23 # Module im_udp
24 # Host 192.168.1.1
25 # Port 514
26 # ReusePort TRUE
27 #</Input>
28 [...]
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
It is recommended to disable FlowControl when this module is used to collect local Syslog
messages from the /dev/log Unix domain socket. Otherwise, if the corresponding Output queue
NOTE
becomes full, the syslog() system call will block in any programs trying to write to the system log
and an unresponsive system may result.
For parsing Syslog messages, see the pm_transformer module or the parse_syslog_bsd() procedure of xm_syslog.
131.36.1. Configuration
The im_uds module accepts the following directives in addition to the common module directives.
1230
Chapter 131. Input Modules NXLog User Guide
UDS
This specifies the path of the Unix domain socket. The default is /dev/log.
CreateDir
If set to TRUE, this optional boolean directive instructs the module to create the directory where the UDS
socket file is located, if it does not already exist. The default is FALSE.
Group
Use this directive to set the group ownership for the created socket or pipe or file. By default, this is the group
NXLog is running as, (which may be specified by the global Group directive). This directive is not currently
supported on Windows.
InputType
See the InputType directive in the list of common module directives. This defaults to dgram if UDSType is set
to dgram or to linebased if UDSType is set to stream.
Perms
This directive specifies the permissions to use for the created socket or pipe or file. This must be a four-digit
octal value beginning with a zero. By default, OS default permissions will be set. This directive is not currently
supported on Windows.
UDSType
This directive specifies the domain socket type. Supported values are dgram and stream. The default is dgram.
User
Use this directive to set the user ownership for the created socket or pipe or file. By default, this is the user
NXLog is running as (which may be specified by the global User directive). This directive is not currently
supported on Windows.
131.36.2. Examples
Example 726. Using the im_uds Module
This configuration will accept logs via the specified socket and write them to file.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 FlowControl False
5 </Input>
1231
NXLog User Guide Chapter 131. Input Modules
This configuration accepts logs via the specified socket, and also specifies ownership and permissions to
use for the socket.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /opt/nxlog/var/spool/nxlog/socket
4 UDSOwner root
5 UDSGroup adm
6 UDSPerms 0660
7 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
If performance counters are not working or some counters are missing, it may be necessary to
rebuild the performance counter registry settings by running C:\windows\system32\lodctr.exe
TIP
/R. See How to rebuild performance counters on Windows Vista/Server2008/7/Server2008R2 on
TechNet for more details, including how to save a backup before rebuilding.
131.37.1. Configuration
The im_winperfcount module accepts the following directives in addition to the common module directives. The
Counter directive is required.
Counter
This mandatory directive specifies the name of the performance counter that should be polled, such as
\Memory\Available Bytes. More than one Counter directive can be specified to poll multiple counters at
once. Available counter names can be listed with typeperf -q (see the typeperf command reference on
Microsoft Docs).
PollInterval
This directive specifies how frequently, in seconds, the module will poll the performance counters. If this
directive is not specified, the default is 1 second. Fractional seconds may be specified (PollInterval 0.5 will
check twice every second).
UseEnglishCounters
This optional boolean directive specifies whether to use English counter names. This makes it possible to use
the same NXLog configuration across all deployments even if the localization differs. If this directive is not
specified it defaults to FALSE (native names will be used).
1232
Chapter 131. Input Modules NXLog User Guide
AllowInvalidCounters
If set to TRUE, invalid counter names will be ignored and a warning will be logged instead of stopping with an
error. If this directive is not specified it defaults to FALSE.
131.37.2. Fields
The following fields are used by im_winperfcount.
131.37.3. Examples
1233
NXLog User Guide Chapter 131. Input Modules
With this configuration, NXLog will retrieve the specified counters every 60 seconds. The resulting messages
will be written to file in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input counters>
6 Module im_winperfcount
7 Counter \Memory\Available Bytes
8 Counter \Process(_Total)\Working Set
9 PollInterval 60
10 </Input>
11
12 <Output file>
13 Module om_file
14 File 'C:\test\counter.log'
15 Exec to_json();
16 </Output>
17
18 <Route perfcount>
19 Path counters => file
20 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The im_mseventlog module requires NXLog to be installed as an agent on the source host. The im_msvistalog
module can be configured to pull Windows EventLog remotely from Windows hosts with a NXLog agent running
on Windows. The im_wseventing module, can be used on all supported platforms including GNU/Linux systems to
remotely collect Windows EventLog without requiring any software to be installed on the source host. Windows
clients can be configured through Group Policy to forward EventLog to the system running the im_wseventing
module, without the need to list each client machine individually in the configuration.
The WS-Eventing protocol and im_wseventing support HTTPS using X509 certificates and Kerberos to authenticate
and securely transfer EventLog.
While there are other products implementing the WS-Eventing protocol (such as IBM
WebSphere DataPower), this module was implemented with the primary purpose of collecting
NOTE
and parsing forwarded events from Microsoft Windows. Compatibility with other products has
not been assessed.
1234
Chapter 131. Input Modules NXLog User Guide
b. Set the nameserver and static IP address (substitute the correct interface name).
# nano /etc/sysconfig/network-scripts/ifcfg-enp0s3
Set to:
BOOTPROTO=static
IPADDR=192.168.0.3
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=192.168.0.2
# ntpdate ad.domain.com
3. Go to the domain controller ad.domain.com and create a new user linux (the name of the user should
match the hostname of the Linux node).
a. Go to Administrative Tools → Active Directory Users and Computers → ad.domain.com → Users.
b. Right click and choose New → User.
i. First name: linux
5. Open a Command Prompt on ad.domain.com and execute these commands. Use the same <password> as
in step 3b.
1235
NXLog User Guide Chapter 131. Input Modules
a. Confirm that the Kerberos krb5 client and utility software are installed on the system. The required
package can be installed with (for example) yum install krb5-workstation or apt install krb5-
user.
.domain.com = DOMAIN.COM
domain.com = DOMAIN.COM
DOMAIN.COM = {
kdc = domain.com
admin_server = domain.com
}
# ktutil
ktutil: rkt /root/hosts-nxlog.keytab
ktutil: rkt /root/nxlog.keytab
ktutil: wkt /root/nxlog-result.keytab
ktutil: q
# klist -e -k -t /root/nxlog-result.keytab
Keytab name: FILE:/root/nxlog-result.keytab
KVNO Timestamp Principal
---- ------------------- ------------------------------------------------------
5 17.02.2016 04:16:37 hosts/linux.domain.com@DOMAIN.COM (aes256-cts-hmac-sha1-96)
4 17.02.2016 04:16:37 http/linux.domain.com@DOMAIN.COM (aes256-cts-hmac-sha1-96)
e. Either copy the keytab into place, or merge if there are already keys in /etc/krb5.keytab.
cp /root/nxlog-result.keytab /etc/krb5.keytab
1236
Chapter 131. Input Modules NXLog User Guide
# ktutil
ktutil: rkt /etc/krb5.keytab
ktutil: rkt /root/nxlog-result.keytab
ktutil: wkt /etc/krb5.keytab
ktutil: q
# klist -e -k -t /etc/krb5.keytab
Keytab name: FILE:/etc/krb5.keytab
KVNO Timestamp Principal
---- ------------------- ------------------------------------------------------
5 31.12.1969 15:00:00 HTTP/linux.domain.com@PEROKSID.COM (aes256-cts-hmac-sha1-96)
5 17.02.2016 04:20:08 HTTP/linux.domain.com@PEROKSID.COM (aes256-cts-hmac-sha1-96)
5 17.02.2016 04:20:08 hosts/linux.domain.com@DOMAIN.COM (aes256-cts-hmac-sha1-96)
4 17.02.2016 04:20:08 http/linux.domain.com@DOMAIN.COM (aes256-cts-hmac-sha1-96)
9. Make sure the port defined in the im_wseventing configuration is accessible from the Windows clients. The
local firewall rules on the Linux node may need to be updated.
10. Configure and run NXLog. See the configuration example below.
• X509 certificate generation using either OpenSSL or the Windows certificate manager,
• configuration of the NXLog im_wseventing module.
• configuration of Windows Remote Management (WinRM) on each Windows source host,
We will refer to the host running NXLog with the im_wseventing module as server. Under
NOTE Windows the Subscription Manager refers to the same entity since im_wsevening is what
manages the subscription. We will use the name client when referring to the Windows hosts
sending the logs using WEF.
The client certificate must have the X509 v3 Extended Key Usage: TLS Web Client Authentication
extension and the server certificate needs the X509 v3 Extended Key Usage: TLS Web Server
Authentication extension. You will likely encounter an error when trying to configure WEF and the connection
to the server will fail without these extended key usage attributes. Also make sure that the intended purpose of
the certificates are set to Server Authentication and Client Authentication respectively.
When generating the certificates please ensure that the CN in the server certificate subject matches the reverse
DNS name, otherwise you may get errors in the Microsoft Windows/Event-ForwardingPlugin/Operational
eventlog saying The SSL certificate contains a common name (CN) that does not match the
hostname.
For OpenSSL based certificate generation see the scripts in our public git repository.
SUBJ="/CN=NXLog-WEF-CA/O=nxlog.org/C=HU/ST=state/L=location"
openssl req -x509 -nodes -newkey rsa:2048 -keyout ca-key.pem -out ca-cert.pem -batch -subj "$SUBJ"
-config gencert.cnf
openssl x509 -outform der -in ca-cert.pem -out ca-cert.crt
1237
NXLog User Guide Chapter 131. Input Modules
Generate the client certificate and export it together with the CA in PFX format to be imported into the Windows
certificate store:
CLIENTSUBJ="/CN=winclient.domain.corp/O=nxlog.org/C=HU/ST=state/L=location"
openssl req -new -newkey rsa:2048 -nodes -keyout client-key.pem -out req.pem -batch -subj
"$CLIENTSUBJ" -config gencert.cnf
openssl x509 -req -days 1024 -in req.pem -CA ca-cert.pem -CAkey ca-key.pem -out client-cert.pem
-set_serial 01 -extensions client_cert -extfile gencert.cnf
openssl pkcs12 -export -out client.pfx -inkey client-key.pem -in client-cert.pem -certfile ca-
cert.pem
SERVERSUBJ="/CN=nxlogserver.domain.corp/O=nxlog.org/C=HU/ST=state/L=location"
openssl req -new -newkey rsa:2048 -nodes -keyout server-key.pem -out req.pem -batch -subj
"$SERVERSUBJ" -config gencert.cnf
openssl x509 -req -days 1024 -in req.pem -CA ca-cert.pem -CAkey ca-key.pem -out server-cert.pem
-set_serial 01 -extensions server_cert -extfile gencert.cnf
openssl x509 -outform der -in server-cert.pem -out server-cert.crt
In order to generate the certificates with the correct extensions the following is needed in gencert.cnf:
[ server_cert ]
basicConstraints=CA:FALSE
nsCertType = server
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
#crlDistributionPoints=URI:http://127.0.0.1/crl.pem
[ client_cert ]
basicConstraints=CA:FALSE
nsCertType = client
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth
If you are using an intermediary CA please make sure that the ca-cert.pem file contains—in
NOTE correct order—the public part of every issuer’s certificate. The easiest way to achieve this is to
'cat' the pem certificates together.
If you have more complex requirements follow this guide on how to set up a CA and generate certificates with
OpenSSl.
For more information on creating certificates under windows see this document: Request Certificates by Using
the Certificate Request Wizard.
Make sure to create the certificates with the required extensions as noted above. Once you have issued the
certificates you will need to export the server certificate in PFX format. The PFX must contain the private key also,
the password may be omitted. The PFX file can then be converted to the PEM format required by im_wseventing
using openssl:
1238
Chapter 131. Input Modules NXLog User Guide
You will also need to export the CA certificate (without the private key) the same way and convert it into ca-
cert.pem.
You will need to use server-key.pem, server-cert.pem and ca-cert.pem for the HTTPSCertKeyFile,
HTTPSCertFile and HTTPSCAFile respectively.
Optionally you can use the QueryXML option to filter on specific channels or events.
See the configuration example below for how your nxlog.conf should look.
Once the configuration is complete you may start the nxlog service.
1. Install, configure, and enable Windows Remote Management (WinRM) on each source host.
a. Make sure the Windows Remote Management (WS-Management) service is installed, running, and set to
Automatic startup type.
b. If WinRM is not already installed, see these instructions on MSDN: Installation and Configuration for
Windows Remote Management.
c. Check that the proper client authentication method (Certificate) is enabled for WinRM. Issue the
following command:
Auth
Basic = false
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = true [Source="GPO"]
Windows Remoting does not support event forwarding over unsecured transport (such
as HTTP). Therefore it is recommended to disable the Basic authentication:
NOTE
winrm set winrm/config/client/auth @{Basic="false"}
d. Import the client authentication certificate if you used OpenSSL to generate these. In the Certificate
MMC snap-in for the Local Computer click More actions - All Tasks - Import…. Import the
client.pfx file. Enter the private key password (if set) and make sure the Include all extended
properties check-box is selected.
After importing is completed, open the Certificates MMC snap-in, select Computer
account and double-click on the client certificate to check if the full certificate chain is
NOTE
available and trusted. You may want to move the CA certificate under the Trusted
Root Certification Authorities in order to make the client certificate trusted.
e. Grant the NetworkService account the proper permissions to access the client certificate using the
1239
NXLog User Guide Chapter 131. Input Modules
Windows HTTP Services Certificate Configuration Tool (WinHttpCertCfg.exe) and check that the
NetworkService account has access to the private key file of the client authentication certificate by
running the following command:
If NetworkService is not listed in the output, grant it permissions by running the following command:
f. In order to access the Security EventLog, the NetworkService account needs to be added to the Event Log
Readers group.
g. Configure the source host security policy to enable event forwarding:
i. Run the Group Policy MMC snap-in (gpedit.msc) and go to Computer Configuration ›
Administrative Templates › Windows Components › Event Forwarding.
ii. Right-click the SubscriptionManager setting and select Properties › ]. Enable the
SubscriptionManager setting › and click [Show to add a server address.
iii. Add at least one setting that specifies the NXLog collector system. The SubscriptionManager
Properties window contains an Explain tab that describes the syntax for the setting. If you have
used the gencert-server.sh script it should print the subscription manager string that has the
following format:
Server=HTTPS://nxlogserver.domain.corp:5985/wsman/,Refresh=14400,IssuerCA=57F5048548A6A98
3C3A14DA80E0626E4A462FC04
iv. To find the IssuerCA fingerprint, open MMC, add the Certificates snap-in, select the Local Computer
account find the Issuing CA certificate. Copy the Thumbprint from the Details tab. Please make
sure to eliminate spaces and the invisible non-breaking space that is before the first character of the
thumbprint on Windows 2008.
v. After the SubscriptionManager setting has been added, ensure the policy is applied by running:
gpupdate /force
vi. At this point the WinRM service on the Windows client should connect to NXLog and there should be
a connection attempt logged in nxlog.log and you should soon start seeing events arriving.
O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x5;;;BA)(A;;0x1;;;S-1-5-32-573)(A;;0x1;;;NS)
1240
Chapter 131. Input Modules NXLog User Guide
131.38.4. Troubleshooting
WEF if not easy to configure and there may be many things that can go wrong. To troubleshoot WEF you should
check the Windows Eventlog under the following channels:
The CN in the server certificate subject must match the reverse dns, otherwise you may get errors in the
Microsoft Windows/Event-ForwardingPlugin/Operational eventlog saying The SSL certificate
contains a common name (CN) that does not match the hostname. Also in that case the WinRM service
may want to use a CRL url to download the revocation list. If it cannot check the CRL there will be error messages
under Applications and Services Logs/Microsoft Windows/CAPI2 such as this:
In our experience if the FQDN and the reverse DNS of the server is properly set up it shouldn’t fail with the CRL
check.
Unfortunately the diagnostic messages in the Windows Eventlog are in some cases rather sloppy. You may see
messages such as The forwarder is having a problem communicating with the subscription manager
at address https://nxlog:5985/wsman/. Error code is 42424242 and the Error Message is . Note
the empty error message. Other than guessing you may try looking up the error code on the internet…
If the IssuerCA thumbprint is incorrect or it can’t locate the certificate in the certificate store then the above error
will be logged in the Windows EventLog with Error code 2150858882.
The Refresh interval should be set to a higher value (e.g. Refresh=1200), in the GPO Subscription Manager
settings otherwise the windows client will reconnect too frequently resulting in a lot of connection/disconnection
messages in nxlog.log.
By default the module does not log connection attempts which would be otherwise useful for troubleshooting
purposes. This can be turned on with the LogConnections configuration directive. The windows Event Forwarding
service may disconnect during the TLS handshake with the following message logged in nxlog.log when
LogConnections is enabled. This is normal as long as there is another connection attempt right after the
disconnection.
See the article on Technet titled Windows Event Forwarding to a workgroup Collector Server for further
instructions and troubleshooting tips.
131.38.5. Configuration
The im_wseventing module accepts the following directives in addition to the common module directives. The
Address and ListenAddr directives are required.
Address
This mandatory directive accepts a URL address. This address is sent to the client to notify it where the events
should be sent. For example, Address https://nxlogserver.domain.corp:5985/wsman.
1241
NXLog User Guide Chapter 131. Input Modules
ListenAddr
This mandatory directive specifies the address of the interface where the module should listen for client
connections. Normally the any address 0.0.0.0 is used.
When a hostname is used as the ListenAddr, the corresponding IP address is only resolved
NOTE when the module starts up. The listening socket will be bound to that IP addresses until the
module is restarted, regardless of any DNS changes to the hostname.
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
AddPrefix
If this boolean directive is set to TRUE, names of fields parsed from the <EventData> portion of the event
XML will be prefixed with EventData.. For example, $EventData.SubjectUserName will be added to the
event record instead of $SubjectUserName. The same applies to <UserData>. This directive defaults to
FALSE: field names will not be prefixed.
CaptureEventXML
This boolean directive defines whether the module should store raw XML-formatted event data. If set to
TRUE, the module stores raw XML data in the $EventXML field. By default, the value is set to FALSE, and the
$EventXML field is not added to the event record.
ConnectionRetry
This optional directive specifies the reconnection interval. The default value is PT60.0S (60 seconds).
ConnectionRetryTotal
This optional directive specifies the maximum number of reconnection attempts. The default is 5 attempts. If
the client exceeds the retry count it will consider the subscription to be stale and will not attempt to
1242
Chapter 131. Input Modules NXLog User Guide
reconnect.
Expires
This optional directive can be used to specify a duration after which the subscription will expire, or an
absolute time when the subscription will expire. By default, the subscription will never expire.
HeartBeats
Heartbeats are dummy events that do not appear in the output. These are used by the client to signal that
logging is still functional if no events are generated during the specified time period. The default heartbeat
value of PT3600.000S may be overridden with this optional directive.
HTTPSAllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE the remote will be able to connect with an unknown or self-signed certificate. The default value
is FALSE: all HTTPS connections must present a trusted certificate.
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote HTTPS client. The certificate filenames in this directory must be in the
OpenSSL hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by
including a copy of the certificate in this directory.
HTTPSCAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote HTTPS client. To trust a self-signed certificate presented by the remote (which is not signed by a
CA), provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote HTTPS client. The certificate filenames in this directory must be in
the OpenSSL hashed format.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote HTTPS client.
1243
NXLog User Guide Chapter 131. Input Modules
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
directive is not needed for passwordless private keys.
HTTPSSSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
HTTPSSSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
LogConnections
This boolean directive can be used to turn on logging of connections. Since WEF connections can be quite
frequent and excessive it could generate a lot of noise. On the other hand it can be useful to troubleshoot
clients. This is disabled by default.
MaxElements
This optional directive specifies the maximum number of event records to be batched by the client. If this is
not specified the default value is decided by the client.
MaxEnvelopeSize
This optional directive can be used to set a limit on the size of the allowed responses, in bytes. The default
size is 153600 bytes. Event records exceeding this size will be dropped by the client and replaced by a drop
notification.
MaxTime
This optional directive specifies the maximum amount of time allowed to elapse for the client to batch events.
The default value is PT30.000S (30 seconds).
Port
This specifies the port on which the module will listen for incoming connections. The default is port 5985.
Query
This directive specifies the query for pulling only specific EventLog sources. See the MSDN documentation
about Event Selection. Note that this directive requires a single-line parameter, so multi-line query XML
should be specified using line continuation:
1244
Chapter 131. Input Modules NXLog User Guide
1 Query <QueryList> \
2 <Query Id='1'> \
3 <Select Path='Security'>*[System/Level=4]</Select> \
4 </Query> \
5 </QueryList>
QueryXML
This directive is the same as the Query directive above, except it can be used as a block. Multi-line XML
queries can be used without line continuation, and the XML Query can be directly copied from Event Viewer.
1 <QueryXML>
2 <QueryList>
3 <!-- XML-style comments can
4 span multiple lines in
5 QueryXML blocks like this.
6 -->
7 <Query Id='1'>
8 <Select Path='Security'>*[System/Level=4]</Select>
9 </Query>
10 </QueryList>
11 </QueryXML>
Commenting with the # mark does not work within multi-line Query directives or QueryXML
blocks. In this case, use XML-style comments <!-- --> as shown in the example above.
CAUTION Failure to follow this syntax for comments within queries will render the module instance
useless. Since NXLog does not parse the content of QueryXML blocks, this behavior is
expected.
SubscriptionName
The default value of NXLog Subscription may be overridden by with this optional directive. This name will
appear in the client logs.
131.38.6. Fields
The following fields are used by im_wseventing.
The actual fields generated will vary depending on the particular event’s source data.
1245
NXLog User Guide Chapter 131. Input Modules
1246
Chapter 131. Input Modules NXLog User Guide
1/Critical 5/CRITICAL
2/Error 4/ERROR
3/Warning 3/WARNING
4/Information 2/INFO
5/Verbose 1/DEBUG
131.38.7. Examples
1247
NXLog User Guide Chapter 131. Input Modules
nxlog.conf
1 SuppressRepeatingLogs FALSE
2
3 <Extension json>
4 Module xm_json
5 </Extension>
6
7 <Input wseventin>
8 Module im_wseventing
9 Address http://LINUX.DOMAIN.COM:80/wsman
10 ListenAddr 0.0.0.0
11 Port 80
12 SubscriptionName test
13 Exec log_info(to_json());
14 <QueryXML>
15 <QueryList>
16 <Query Id="0" Path="Application">
17 <Select Path="Application">*</Select>
18 <Select Path="Security">*</Select>
19 <Select Path="Setup">*</Select>
20 <Select Path="System">*</Select>
21 <Select Path="ForwardedEvents">*</Select>
22 <Select Path="Windows PowerShell">*</Select>
23 </Query>
24 </QueryList>
25 </QueryXML>
26 </Input>
1248
Chapter 131. Input Modules NXLog User Guide
This example Input module instance collects Windows EventLog remotely. Two EventLog queries are
specified, the first for hostnames matching foo* and the second for other hostnames.
nxlog.conf
1 <Input wseventing>
2 Module im_wseventing
3 ListenAddr 0.0.0.0
4 Port 5985
5 Address https://linux.corp.domain.com:5985/wsman
6 HTTPSCertFile %CERTDIR%/server-cert.pem
7 HTTPSCertKeyFile %CERTDIR%/server-key.pem
8 HTTPSCAFile %CERTDIR%/ca.pem
9 <QueryXML>
10 <QueryList>
11 <Computer>foo*</Computer>
12 <Query Id="0" Path="Application">
13 <Select Path="Application">*</Select>
14 </Query>
15 </QueryList>
16 </QueryXML>
17 <QueryXML>
18 <QueryList>
19 <Query Id="0" Path="Application">
20 <Select Path="Application">*</Select>
21 <Select Path="Microsoft-Windows-Winsock-AFD/Operational">*</Select>
22 <Select Path="Microsoft-Windows-Wired-AutoConfig/Operational">*</Select>
23 <Select Path="Microsoft-Windows-Wordpad/Admin">*</Select>
24 <Select Path="Windows PowerShell">*</Select>
25 </Query>
26 </QueryList>
27 </QueryXML>
28 </Input>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
131.39.1. Configuration
The im_zmq module accepts the following directives in addition to the common module directives. The Address,
ConnectionType, Port, and SocketType directives are required.
Address
This directive specifies the ZeroMQ socket address.
ConnectionType
This mandatory directive specifies the underlying transport protocol. It may be one of the following: TCP, PGM,
or EPGM.
1249
NXLog User Guide Chapter 131. Input Modules
Port
This directive specifies the ZeroMQ socket port.
SocketType
This mandatory directive defines the type of the socket to be used. It may be one of the following: REQ,
DEALER, SUB, XSUB, or PULL. This must be set to SUB if ConnectionType is set to PGM or EPGM.
Connect
If this boolean directive is set to TRUE, im_zmq will connect to the Address specified. If FALSE, im_zmq will bind
to the Address and listen for connections. The default is FALSE.
InputType
See the InputType directive in the list of common module directives. The default is Dgram.
Interface
This directive specifies the ZeroMQ socket interface.
SockOpt
This directive can be used to set ZeroMQ socket options. For example, SockOpt ZMQ_SUBSCRIBE
ANIMALS.CATS. This directive may be used more than once to set multiple options.
131.39.2. Examples
Example 731. Using the im_zmq Module
This example configuration accepts ZeroMQ messages over TCP and writes them to file.
nxlog.conf
1 <Input zmq>
2 Module im_zmq
3 SocketType PULL
4 ConnectionType TCP
5 Address 10.0.0.1
6 Port 1415
7 </Input>
8
9 <Output file>
10 Module om_file
11 File "/var/log/zmq-messages.log"
12 </Output>
13
14 <Route zmq_to_file>
15 Path zmq => file
16 </Route>
1250
Chapter 132. Processor Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
132.1.1. Configuration
The pm_blocker module accepts only the common module directives.
132.1.2. Functions
The following functions are exported by pm_blocker.
boolean is_blocking()
Return TRUE if the module is currently blocking the data flow, FALSE otherwise.
132.1.3. Procedures
The following procedures are exported by pm_blocker.
block(boolean mode);
When mode is TRUE, the module will block. A block(FALSE) should be called from a Schedule block or
another module, it might not get invoked if the queue is already full.
132.1.4. Examples
1251
NXLog User Guide Chapter 132. Processor Modules
In this example messages are received over UDP and forwarded to another host via TCP. The log data is
forwarded during non-working hours (between 7pm and 8am). During working hours, the data is buffered
on the disk.
nxlog.conf
1 <Input udp>
2 Module im_udp
3 ListenAddr 0.0.0.0:1514
4 </Input>
5
6 <Processor buffer>
7 Module pm_buffer
8 # 100 MB disk buffer
9 MaxSize 102400
10 Type disk
11 </Processor>
12
13 <Processor blocker>
14 Module pm_blocker
15 <Schedule>
16 When 0 8 * * *
17 Exec blocker->block(TRUE);
18 </Schedule>
19 <Schedule>
20 When 0 19 * * *
21 Exec blocker->block(FALSE);
22 </Schedule>
23 </Processor>
24
25 <Output tcp>
26 Module om_tcp
27 Host 192.168.1.1:1514
28 </Output>
29
30 <Route udp_to_tcp>
31 Path udp => buffer => blocker => tcp
32 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The pm_buffer module supports disk- and memory-based log message buffering. If both are required, multiple
pm_buffer instances can be used with different settings. Because a memory buffer can be faster, though its size is
limited, combining memory and disk based buffering can be a good idea if buffering is frequently used.
The disk-based buffering mode stores the log message data in chunks. When all the data is successfully
forwarded from a chunk, it is then deleted in order to save disk space.
1252
Chapter 132. Processor Modules NXLog User Guide
Using pm_buffer is only recommended when there is a chance of message loss. The built-in flow
control in NXLog ensures that messages will not be read by the input module until the output
side can send, store, or forward. When reading from files (with im_file) or the Windows EventLog
NOTE
(with im_mseventlog or im_msvistalog) it is rarely necessary to use the pm_buffer module unless
log rotation is used. During a rotation, there is a possibility of dropping some data while the
output module (im_tcp, for example) is being blocked.
132.2.1. Configuration
The pm_buffer module accepts the following directives in addition to the common module directives. The
MaxSize and Type directives are required.
CreateDir
If set to TRUE, this optional boolean directive instructs the module to create the output directory before
opening the file for writing if it does not exist. The default is FALSE.
MaxSize
This mandatory directive specifies the size of the buffer in kilobytes.
Type
This directive can be set to either Mem or Disk to select memory- or disk-based buffering.
Directory
This directory will be used to store the disk buffer file chunks. This is only valid if Type is set to Disk.
WarnLimit
This directive specifies an optional limit, smaller than MaxSize, which will trigger a warning message when
reached. The log message will not be generated again until the buffer size drops to half of WarnLimit and
reaches it again in order to protect against a warning message flood.
132.2.2. Functions
The following functions are exported by pm_buffer.
integer buffer_count()
Return the number of log messages held in the memory buffer.
integer buffer_size()
Return the size of the memory buffer in bytes.
132.2.3. Examples
1253
NXLog User Guide Chapter 132. Processor Modules
Example 733. Using a Memory Buffer to Protect Against UDP Message Loss
This configuration accepts log messages via UDP and forwards them via TCP. An intermediate memory-
based buffer allows the im_udp module instance to continue accepting messages even if the om_tcp output
stops working (caused by downtime of the remote host or network issues, for example).
nxlog.conf
1 <Input udp>
2 Module im_udp
3 ListenAddr 0.0.0.0:514
4 </Input>
5
6 <Processor buffer>
7 Module pm_buffer
8 # 1 MB buffer
9 MaxSize 1024
10 Type Mem
11 # warn at 512k
12 WarnLimit 512
13 </Processor>
14
15 <Output tcp>
16 Module om_tcp
17 Host 192.168.1.1:1514
18 </Output>
19
20 <Route udp_to_tcp>
21 Path udp => buffer => tcp
22 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module was greatly inspired by the Perl based correlation tool SEC. Some of the rules of the pm_evcorr
module were designed to mimic those available in SEC. This module aims to be a better alternative to SEC with
the following advantages:
• The correlation rules in SEC work with the current time. With pm_evcorr it is possible to specify a time field
which is used for elapsed time calculation making offline event correlation possible.
• SEC uses regular expressions extensively, which can become quite slow if there are many correlation rules. In
contrast, this module can correlate pre-processed messages using fields from, for example, the pattern
matcher and Syslog parsers without requiring the use of regular expressions (though these are also available
for use by correlation rules). Thus testing conditions can be significantly faster when simple comparison is
used instead of regular expression based pattern matching.
• This module was designed to operate on fields, making it possible to correlate structured logs in addition to
simple free-form log messages.
• Most importantly, this module is written in C, providing performance benefits (where SEC is written in pure
Perl).
The rulesets of this module can use a context. A context is an expression which is evaluated during runtime to a
1254
Chapter 132. Processor Modules NXLog User Guide
value and the correlation rule is checked in the context of this value. For example, to count the number of failed
logins per user and alert if the failed logins exceed 3 for the user, the $AccountName would be used as the
context. There is a separate context storage for each correlation rule instance. For global contexts accessible
from all rule instances, see module variables and statistical counters.
132.3.1. Configuration
The pm_evcorr module accepts the following directives in addition to the common module directives.
The pm_evcorr configuration contains correlation rules which are evaluated for each log message processed by
the module. Currently there are seven rule types supported by pm_evcorr: Absence, Group, Pair, Simple, Stop,
Suppressed, and Thresholded. These rules are defined in configuration blocks. The rules are evaluated in the
order they are defined. For example, a correlation rule can change a state, variable, or field which can be then
used by a later rule. File inclusion can be useful to store correlation rules in a separate file.
Absence
This rule type does the opposite of Pair. When TriggerCondition evaluates to TRUE, this rule type will wait
Interval seconds for RequiredCondition to become TRUE. If it does not become TRUE, it executes the
statement(s) in the Exec directive(s).
Context
This optional directive specifies an expression to be used as the context. It must evaluate to a value.
Usually a field is specified here.
Exec
One or more Exec directives must be specified, each taking a statement as argument.
The evaluation of this Exec is not triggered by a log event; thus it does not make sense to
NOTE
use log data related operations such as accessing fields.
Interval
This mandatory directive takes an integer argument specifying the number of seconds to wait for
RequiredCondition to become TRUE. Its value must be greater than 0. The TimeField directive is used to
calculate time.
RequiredCondition
This mandatory directive takes an expression as argument which must evaluate to a boolean value. When
this evaluates to TRUE after TriggerCondition evaluated to TRUE within Interval seconds, the statement(s)
in the Exec directive(s) are NOT executed.
TriggerCondition
This mandatory directive takes an expression as argument which must evaluate to a boolean value.
Group
This rule type groups messages together based on the specified correlation context. The Exec block is
executed at each event. The last log data of each context group is available through get_prev_event_data().
This way, fields and information can be propagated from the previous group event to the following one.
Context
This mandatory directive specifies an expression to be used as the context. It must evaluate to a value.
Usually a field is specified here.
Exec
One or more Exec directives must be specified, each taking a statement as an argument.
1255
NXLog User Guide Chapter 132. Processor Modules
Pair
When TriggerCondition evaluates to TRUE, this rule type will wait Interval seconds for RequiredCondition to
become TRUE. It then executes the statement(s) in the Exec directive(s).
Context
This optional directive specifies an expression to be used as the context. It must evaluate to a value.
Usually a field is specified here.
Exec
One or more Exec directives must be specified, each taking a statement as argument.
Interval
This directive takes an integer argument specifying the number of seconds to wait for RequiredCondition
to become TRUE. If this directive is 0 or not specified, the rule will wait indefinitely for RequiredCondition
to become TRUE. The TimeField directive is used to calculate time.
RequiredCondition
This mandatory directive takes an expression as argument which must evaluate to a boolean value. When
this evaluates to TRUE after TriggerCondition evaluated to TRUE within Interval seconds, the statement(s)
in the Exec directive(s) are executed.
TriggerCondition
This mandatory directive takes an expression as argument which must evaluate to a boolean value.
Simple
This rule type is essentially the same as the Exec directive supported by all modules. Because Execs are
evaluated before the correlation rules, the Simple rule was also needed to be able to evaluate a statement as
the other rules do, following the rule order. The Simple block has one directive also with the same name.
Exec
One or more Exec directives must be specified, with a statement as argument.
Stop
This rule type will stop evaluating successive rules if the Condition evaluates to TRUE. The optional Exec
directive will be evaluated in this case.
Condition
This mandatory directive takes an expression as argument which must evaluate to a boolean value. When
it evaluates to TRUE, the correlation rule engine will stop checking any further rules.
Exec
One or more Exec directives may be specified, each taking a statement as argument. This will be
evaluated when the specified Condition is satisfied. This directive is optional.
Suppressed
This rule type matches the given condition. If the condition evaluates to TRUE, the statement specified with
the Exec directive is evaluated. The rule will then ignore any log messages for the time specified with Interval
directive. This rule is useful for avoiding creating multiple alerts in a short period when a condition is
satisfied.
Condition
This mandatory directive takes an expression as argument which must evaluate to a boolean value.
Context
This optional directive specifies an expression to be used as the context. It must evaluate to a value.
Usually a field is specified here.
1256
Chapter 132. Processor Modules NXLog User Guide
Exec
One or more Exec directives must be specified, each taking a statement as argument.
Interval
This mandatory directive takes an integer argument specifying the number of seconds to ignore the
condition. The TimeField directive is used to calculate time.
Thresholded
This rule type will execute the statement(s) in the Exec directive(s) if the Condition evaluates to TRUE
Threshold or more times during the Interval specified. The advantage of this rule over the use of statistical
counters is that the time window is dynamic and shifts as log messages are processed.
Condition
This mandatory directive takes an expression as argument which must evaluate to a boolean value.
Context
This optional directive specifies an expression to be used as the context. It must evaluate to a value.
Usually a field is specified here.
Exec
One or more Exec directives must be specified, each taking a statement as argument.
Interval
This mandatory directive takes an integer argument specifying a time window for Condition to become
TRUE. Its value must be greater than 0. The TimeField directive is used to calculate time. This time window
is dynamic, meaning that it will shift.
Threshold
This mandatory directive takes an integer argument specifying the number of times Condition must
evaluate to TRUE within the given time Interval. When the threshold is reached, the module executes the
statement(s) in the Exec directive(s).
ContextCleanTime
When a Context is used in the correlation rules, these must be purged from memory after they are expired,
otherwise using too many context values could result in a high memory usage. This optional directive
specifies the interval between context cleanups, in seconds. By default a 60 second cleanup interval is used if
any rules use a Context and this directive is not specified.
TimeField
This specifies the name of the field to use for calculating elapsed time, such as EventTime. The name of the
field must be specified without the leading dollar sign ($). If this parameter is not specified, the current time is
assumed. This directive makes it possible to accurately correlate events based on the event time recorded in
the logs and to do non-real-time event correlation.
132.3.2. Functions
The following functions are exported by pm_evcorr.
1257
NXLog User Guide Chapter 132. Processor Modules
132.3.3. Examples
Example 734. The Absence Directive
The following configuration shows the Absence directive. In this case, if TriggerCondition evaluates to
TRUE, it waits the seconds defined in Interval for the RequiredCondition to become TRUE. If the
RequiredCondition does not become TRUE within the specified interval, then it executes what is defined in
Exec.
nxlog.conf
1 <Input internal>
2 Module im_internal
3 <Exec>
4 $raw_event = $Message;
5 $EventTime = 2010-01-01 00:01:00;
6 </Exec>
7 </Input>
8
9 <Processor evcorr>
10 Module pm_evcorr
11 TimeField EventTime
12 <Absence>
13 TriggerCondition $Message =~ /^absence-trigger/
14 RequiredCondition $Message =~ /^absence-required/
15 Interval 10
16 <Exec>
17 log_info("'absence-required' not received within 10 secs");
18 </Exec>
19 </Absence>
20 </Processor>
Input Sample
2010-01-01 00:00:26 absence-trigger↵
2010-01-01 00:00:29 absence-required - will not log 'got absence'↵
2010-01-01 00:00:46 absence-trigger↵
2010-01-01 00:00:57 absence-required - will log an additional 'absence-required not received
within 10 secs'↵
Output Sample
absence-trigger↵
absence-required - will not log 'got absence'↵
absence-trigger↵
absence-required - will log an additional 'absence-required not received within 10 secs'↵
'absence-required' not received within 10 secs↵
1258
Chapter 132. Processor Modules NXLog User Guide
The following configuration shows rules for the Group directive. It rewrites the events to exclude the date
and time, then rewrites the $raw_event with the context and message. After that, for every matched event,
it adds the $Message field of the newly matched event to it.
nxlog.conf
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4 ContextCleanTime 10
5 <Group>
6 Context $Context
7 <Exec>
8 if defined get_prev_event_data("raw_event")
9 {
10 $raw_event = get_prev_event_data("raw_event") + ", " + $Message;
11 }
12 else
13 {
14 $raw_event = "Context: " + $Context + " Messages: " + $Message;
15 }
16 </Exec>
17 </Group>
18 </Processor>
Input Sample
2010-01-01 00:00:01 [a] suppressed1↵
2010-01-01 00:00:02 [b] suppressed2↵
2010-01-01 00:00:03 [a] suppressed3↵
2010-01-01 00:00:04 [b] suppressed4↵
2010-01-01 00:00:04 [b] suppressed5↵
2010-01-01 00:00:05 [c] suppressed6↵
2010-01-01 00:00:06 [c] suppressed7↵
2010-01-01 00:00:34 [b] suppressed8↵
2010-01-01 00:01:00 [a] pair-first1↵
Output Sample
Context: a Messages: suppressed1↵
Context: b Messages: suppressed2↵
Context: a Messages: suppressed1, suppressed3↵
Context: b Messages: suppressed2, suppressed4↵
Context: b Messages: suppressed2, suppressed4, suppressed5↵
Context: c Messages: suppressed6↵
Context: c Messages: suppressed6, suppressed7↵
Context: b Messages: suppressed2, suppressed4, suppressed5, suppressed8↵
Context: a Messages: suppressed1, suppressed3, pair-first1↵
1259
NXLog User Guide Chapter 132. Processor Modules
The following configuration shows rules for the Pair directive. In this case, if TriggerCondition evaluates to
TRUE, it waits the seconds defined in Interval for the RequiredCondition to become TRUE, then executes
what is defined in Exec. If the Interval is 0, there is no window for matching.
nxlog.conf
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4 <Pair>
5 TriggerCondition $Message =~ /^pair-first/
6 RequiredCondition $Message =~ /^pair-second/
7 Interval 30
8 Exec $raw_event = "got pair";
9 </Pair>
10 </Processor>
Input Sample
2010-01-01 00:00:12 pair-first - now look for pair-second↵
2010-01-01 00:00:22 pair-second - will log 'got pair'↵
2010-01-01 00:00:25 pair-first↵
2010-01-01 00:00:56 pair-second - will not log 'got pair' because it is over the interval↵
Output Sample
pair-first - now look for pair-second↵
got pair↵
pair-first↵
The following configuration shows rules for the Simple directive. In this case, if the $Message field starts
with simple it is rewritten to got simple.
nxlog.conf
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4 <Simple>
5 Exec if $Message =~ /^simple/ $raw_event = "got simple";
6 </Simple>
7 </Processor>
Input Sample
2010-01-01 00:00:00 Not simple↵
2010-01-01 00:00:05 Not simple again↵
2010-01-01 00:00:10 simple1↵
2010-01-01 00:00:15 simple2↵
Output Sample
Not simple↵
Not simple again↵
got simple↵
got simple↵
1260
Chapter 132. Processor Modules NXLog User Guide
The following configuration shows a rule for the Stop directive in conjunction with the Simple directive. In
this case, if the Stop condition evaluates to FALSE, the Simple directive returns the output as rewritten.
nxlog.conf
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4 <Stop>
5 Condition $EventTime < 2010-01-01 00:00:00
6 Exec log_debug("got stop");
7 </Stop>
8 <Simple>
9 Exec $raw_event = "rewritten";
10 </Simple>
11 </Processor>
Input Sample
2010-01-02 00:00:00 this will be rewritten↵
2010-01-02 00:00:10 this too↵
2010-01-02 00:00:15 as well as this↵
Output Sample
rewritten↵
rewritten↵
rewritten↵
The following configuration shows a rule for the Suppressed directive. In this case, the directive matches
the input event and executes the corresponding action, but only for the time defined in the Interval
condition in seconds. After that, it logs the input as is.
nxlog.conf
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4 <Suppressed>
5 Condition $Message =~ /^to be suppressed/
6 Interval 30
7 Exec $raw_event = "suppressed..";
8 </Suppressed>
9 </Processor>
Input Sample
2010-01-01 00:00:01 to be suppressed1 - Suppress kicks in, will log 'suppressed..'↵
2010-01-01 00:00:21 to be suppressed2 - suppressed and logged as is↵
2010-01-01 00:00:23 to be suppressed3 - suppressed and logged as is↵
Output Sample
suppressed..↵
to be suppressed2 - suppressed and logged as is↵
to be suppressed3 - suppressed and logged as is↵
1261
NXLog User Guide Chapter 132. Processor Modules
The following configuration shows rules for the Thresholded directive. In this case, if the number of events
exceeds the given threshold within the interval period, the action defined in Exec is carried out.
nxlog.conf
1 <Processor evcorr>
2 Module pm_evcorr
3 TimeField EventTime
4 <Thresholded>
5 Condition $Message =~ /^thresholded/
6 Threshold 3
7 Interval 60
8 Exec $raw_event = "got thresholded";
9 </Thresholded>
10 </Processor>
Input Sample
2010-01-01 00:00:13 thresholded1 - not tresholded will log as is↵
2010-01-01 00:00:15 thresholded2 - not tresholded will log as is↵
2010-01-01 00:00:20 thresholded3 - will log 'got thresholded'↵
2010-01-01 00:00:25 thresholded4 - will log 'got thresholded' again↵
Output Sample
thresholded1 - not tresholded will log as is↵
thresholded2 - not tresholded will log as is↵
got thresholded↵
got thresholded↵
This module has been deprecated and will be removed in a future release. Filtering is now
NOTE
possible in any module with a conditional drop() procedure in an Exec block or directive.
This statement drops the current event if the $raw_event field matches the specified regular expression.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
132.4.1. Configuration
The pm_filter module accepts the following directives in addition to the common module directives.
Condition
This mandatory directive takes an expression as argument which must evaluate to a boolean value. If the
expression does not evaluate to TRUE, the log message is discarded.
1262
Chapter 132. Processor Modules NXLog User Guide
132.4.2. Examples
Example 742. Filtering Messages
This configuration retains only log messages that match one of the regular expressions, all others are
discarded.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Processor filter>
7 Module pm_filter
8 Condition $raw_event =~ /failed/ or $raw_event =~ /error/
9 </Processor>
10
11 <Output file>
12 Module om_file
13 File "/var/log/error"
14 </Output>
15
16 <Route uds_to_file>
17 Path uds => filter => file
18 </Route>
NOTE This module has been deprecated and will be removed in a future release.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
When the module starts, it creates an initial random hash value which is signed with the private key and stored in
$nxlog.hmac_initial field. As messages pass through the module, it calculates a hash value using the previous
hash value, the initial hash value, and the fields of the log message. This calculated value is added to the log
message as a new field called $nxlog.hmac, and can be used to later verify the integrity of the message.
If the attacker can insert messages at the source, this module will add a HMAC value and
WARNING the activity will go unnoticed. This method only secures messages that are already
protected with a HMAC value.
For this method to work more securely, the private key should be protected by a password and
NOTE the password should not be stored with the key (the configuration file should not contain the
password). This will force the agent to prompt for the password when it is started.
1263
NXLog User Guide Chapter 132. Processor Modules
132.5.1. Configuration
The pm_hmac module accepts the following directives in addition to the common module directives. The
CertKeyFile directive is required.
CertKeyFile
This mandatory directive specifies the path of the private key file to be used to sign the initial hash value.
Fields
This directive accepts a comma-separated list of fields. These fields will be used for calculating the HMAC
value. This directive is optional, and the $raw_event field will be used if it is not specified.
HashMethod
This directive sets the hash function. The following message digest methods can be used: md2, md5, mdc2,
rmd160, sha, sha1, sha224, sha256, sha384, and sha512. The default is md5.
KeyPass
This specifies the password of the CertKeyFile.
132.5.2. Fields
The following fields are used by pm_hmac.
132.5.3. Examples
1264
Chapter 132. Processor Modules NXLog User Guide
This configuration uses the im_uds module to read log messages from a socket. It then adds a hash value
to each message. Finally it forwards them via TCP to another NXLog agent in the binary format.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Processor hmac>
7 Module pm_hmac
8 CertKeyFile %CERTDIR%/client-key.pem
9 KeyPass secret
10 HashMethod SHA1
11 </Processor>
12
13 <Output tcp>
14 Module om_tcp
15 Host 192.168.1.1:1514
16 OutputType Binary
17 </Output>
18
19 <Route uds_to_tcp>
20 Path uds => hmac => tcp
21 </Route>
NOTE This module has been deprecated and will be removed in a future release.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
132.6.1. Configuration
The pm_hmac_check module accepts the following directives in addition to the common module directives. The
CertFile directive is required.
CertFile
This mandatory directive specifies the path of the certificate file to be used to verify the signature of the initial
hash value.
HashMethod
This directive sets the hash function. The following message digest methods can be used: md2, md5, mdc2,
rmd160, sha, sha1, sha224, sha256, sha384, and sha512. The default is md5. This must be the same as the
hash method used for creating the HMAC values.
1265
NXLog User Guide Chapter 132. Processor Modules
CADir
This optional directive specifies the path to a directory containing certificate authority (CA) certificates, which
will be used to verify the certificate. The certificate filenames in this directory must be in the OpenSSL hashed
format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including a copy
of the certificate in this directory.
CAFile
This optional directive specifies the path of the certificate authority (CA) certificate, which will be used to
verify the certificate. To trust a self-signed certificate presented by the remote (which is not signed by a CA),
provide that certificate instead.
CRLDir
This optional directive specifies the path to a directory containing certificate revocation lists (CRLs), which will
be consulted when checking the certificate. The certificate filenames in this directory must be in the OpenSSL
hashed format.
CRLFile
This optional directive specifies the path of the certificate revocation list (CRL), which will be consulted when
checking the certificate.
Fields
This directive accepts a comma-separated list of fields. These fields will be used for calculating the HMAC
value. This directive is optional, and the $raw_event field will be used if it is not specified.
132.6.2. Fields
The following fields are used by pm_hmac_check.
132.6.3. Examples
1266
Chapter 132. Processor Modules NXLog User Guide
This configuration accepts log messages in the NXLog binary format. The HMAC values are checked, then
the messages are written to file.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 ListenAddr 192.168.1.1:1514
4 InputType Binary
5 </Input>
6
7 <Processor hmac_check>
8 Module pm_hmac_check
9 CertFile %CERTDIR%/client-cert.pem
10 CAFile %CERTDIR%/ca.pem
11 # CRLFile %CERTDIR%/crl.pem
12 HashMethod SHA1
13 </Processor>
14
15 <Output file>
16 Module om_file
17 File "/var/log/msg"
18 </Output>
19
20 <Route tcp_to_file>
21 Path tcp => hmac_check => file
22 </Route>
This module has been deprecated and will be removed in a future release. The functionality of
NOTE
this module can be implemented with Variables.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
132.7.1. Configuration
The pm_norepeat module accepts the following directives in addition to the common module directives.
CheckFields
This optional directive takes a comma-separated list of field names which are used to compare log messages.
Only the fields listed here are compared, the others are ignored. For example, the $EventTime field will be
different in repeating messages, so this field should not be used in the comparison. If this directive is not
specified, the default field to be checked is $Message.
132.7.2. Fields
The following fields are used by pm_norepeat.
1267
NXLog User Guide Chapter 132. Processor Modules
132.7.3. Examples
Example 745. Filtering Out Duplicated Messages
This configuration reads log messages from the socket. The $Hostname, $SourceName, and $Message fields
are used to detect duplicates. Then the messages are written to file.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Processor norepeat>
7 Module pm_norepeat
8 CheckFields Hostname, SourceName, Message
9 </Processor>
10
11 <Output file>
12 Module om_file
13 File "/var/log/messages"
14 </Output>
15
16
17 <Route uds_to_file>
18 Path uds => norepeat => file
19 </Route>
1268
Chapter 132. Processor Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The XML Schema Definition (XSD) for the pattern database file is available in the nxlog-
NOTE
public/contrib repository.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
132.9.1. Configuration
The pm_pattern module accepts the following directives in addition to the common module directives.
PatternFile
This mandatory directive specifies the name of the pattern database file.
132.9.2. Fields
The following fields are used by pm_pattern.
132.9.3. Examples
1269
NXLog User Guide Chapter 132. Processor Modules
This configuration reads BSD Syslog messages from the socket, processes the messages with a pattern file,
and then writes them to file in JSON format.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input uds>
10 Module im_uds
11 UDS /dev/log
12 Exec parse_syslog_bsd();
13 </Input>
14
15 <Processor pattern>
16 Module pm_pattern
17 PatternFile /var/lib/nxlog/patterndb.xml
18 </Processor>
19
20 <Output file>
21 Module om_file
22 File "/var/log/out"
23 Exec to_json();
24 </Output>
25
26 <Route uds_to_file>
27 Path uds => pattern => file
28 </Route>
The following pattern database contains two patterns to match SSH authentication messages. The patterns
are under a group named ssh which checks whether the $SourceName field is sshd and only tries to match
the patterns if the logs are indeed from sshd. The patterns both extract AuthMethod, AccountName, and
SourceIP4Address from the log message when the pattern matches the log. Additionally TaxonomyStatus and
TaxonomyAction are set. The second pattern utilizes the Exec block, which is evaluated when the pattern
matches.
For this pattern to work, the logs must be parsed with parse_syslog() prior to processing by
NOTE the pm_pattern module (as in the above example), because it uses the $SourceName and
$Message fields.
patterndb.xml
<?xml version='1.0' encoding='UTF-8'?>
<patterndb>
<created>2010-01-01 01:02:03</created>
<version>42</version>
<group>
<name>ssh</name>
<id>42</id>
<matchfield>
<name>SourceName</name>
<type>exact</type>
1270
Chapter 132. Processor Modules NXLog User Guide
<value>sshd</value>
</matchfield>
<pattern>
<id>1</id>
<name>ssh auth success</name>
<matchfield>
<name>Message</name>
<type>regexp</type>
<!-- Accepted publickey for nxlogfan from 192.168.1.1 port 4242 ssh2 -->
<value>^Accepted (\S+) for (\S+) from (\S+) port \d+ ssh2</value>
<capturedfield>
<name>AuthMethod</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>AccountName</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>SourceIP4Address</name>
<type>string</type>
</capturedfield>
</matchfield>
<set>
<field>
<name>TaxonomyStatus</name>
<value>success</value>
<type>string</type>
</field>
<field>
<name>TaxonomyAction</name>
<value>authenticate</value>
<type>string</type>
</field>
</set>
</pattern>
<pattern>
<id>2</id>
<name>ssh auth failure</name>
<matchfield>
<name>Message</name>
<type>regexp</type>
<value>^Failed (\S+) for invalid user (\S+) from (\S+) port \d+ ssh2</value>
<capturedfield>
<name>AuthMethod</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>AccountName</name>
<type>string</type>
</capturedfield>
<capturedfield>
<name>SourceIP4Address</name>
<type>string</type>
1271
NXLog User Guide Chapter 132. Processor Modules
</capturedfield>
</matchfield>
<set>
<field>
<name>TaxonomyStatus</name>
<value>failure</value>
<type>string</type>
</field>
<field>
<name>TaxonomyAction</name>
<value>authenticate</value>
<type>string</type>
</field>
</set>
<exec>
$TestField = 'test';
</exec>
<exec>
$TestField = $Testfield + 'value';
</exec>
</pattern>
</group>
</patterndb>
This module has been deprecated and will be removed in a future release. Format conversion is
NOTE now possible in any module by using functions and procedures provided by the following
modules: xm_syslog, xm_csv, xm_json, and xm_xml.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
132.10.1. Configuration
The pm_transformer module accepts the following directives in addition to the common module directives. For
conversion to occur, the InputFormat and OutputFormat directives must be specified.
InputFormat
This directive specifies the input format of the $raw_event field so that it is further parsed into fields. If this
directive is not specified, no parsing will be performed.
CSV
Input is parsed as a comma-separated list of values. See xm_csv for similar functionality. The input fields
must be defined by CSVInputFields.
JSON
Input is parsed as JSON. This does the same as the parse_json() procedure.
1272
Chapter 132. Processor Modules NXLog User Guide
syslog_bsd
Same as syslog_rfc3164.
syslog_ietf
Same as syslog_rfc5424.
syslog_rfc3164
Input is parsed in the BSD Syslog format as defined by RFC 3164. This does the same as the
parse_syslog_bsd() procedure.
syslog_rfc5424
Input is parsed in the IETF Syslog format as defined by RFC 5424. This does the same as the
parse_syslog_ietf() procedure.
XML
Input is parsed as XML. This does the same as the parse_xml() procedure.
OutputFormat
This directive specifies the output transformation. If this directive is not specified, fields are not converted
and $raw_event is left unmodified.
CSV
Output in $raw_event is formatted as a comma-separated list of values. See xm_csv for similar
functionality.
JSON
Output in $raw_event is formatted as JSON. This does the same as the to_json() procedure.
syslog_bsd
Same as syslog_rfc3164.
syslog_ietf
Same as syslog_rfc5424.
syslog_rfc3164
Output in $raw_event is formatted in the BSD Syslog format as defined by RFC 3164. This does the same
as the to_syslog_bsd() procedure.
syslog_rfc5424
Output in $raw_event is formatted in the IETF Syslog format as defined by RFC 5424. This does the same
as the to_syslog_ietf() procedure.
syslog_snare
Output in $raw_event is formatted in the SNARE Syslog format. This does the same as the
to_syslog_snare() procedure. This should be used in conjunction with the im_mseventlog or im_msvistalog
module to produce an output compatible with Snare Agent for Windows.
XML
Output in $raw_event is formatted in XML. This does the same as the to_xml() procedure.
CSVInputFields
This is a comma-separated list of fields which will be set from the input parsed. The field names must have
the dollar sign ($) prepended.
1273
NXLog User Guide Chapter 132. Processor Modules
CSVInputFieldTypes
This optional directive specifies the list of types corresponding to the field names defined in CSVInputFields. If
specified, the number of types must match the number of field names specified with CSVInputFields. If this
directive is omitted, all fields will be stored as strings. This directive has no effect on the fields-to-CSV
conversion.
CSVOutputFields
This is a comma-separated list of message fields which are placed in the CSV lines. The field names must have
the dollar sign ($) prepended.
132.10.2. Examples
Example 747. Using the pm_transformer Module
This configuration reads BSD Syslog messages from file and writes them to another file in CSV format.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input filein>
6 Module im_file
7 File "tmp/input"
8 </Input>
9
10 <Processor transformer>
11 Module pm_transformer
12 InputFormat syslog_rfc3164
13 OutputFormat csv
14 CSVOutputFields $facility, $severity, $timestamp, $hostname, \
15 $application, $pid, $message
16 </Processor>
17
18 <Output fileout>
19 Module om_file
20 File "tmp/output"
21 </Output>
22
23 <Route filein_to_fileout>
24 Path filein => transformer => fileout
25 </Route>
NOTE This module has been deprecated and will be removed in a future release.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1274
Chapter 132. Processor Modules NXLog User Guide
A timestamp request is created for each log message received by this module, and the response is appended to
the tsa_response field. The module does not request the certificate to be included in the response as this would
greatly increase the size of the responses. The certificate used by the server for creating timestamps should be
saved manually for later verification. The module establishes one HTTP connection to the server for the time-
stamping by using HTTP Keep-Alive requests and will reconnect if the remote closes the connection.
Since each log message generates a HTTP(S) request to the Time-Stamp server, the message
throughput can be greatly affected. It is recommended that only messages of relevant
importance are time-stamped through the use of proper filtering rules applied to messages
NOTE before they reach the pm_ts module instance.
Creating timestamps in batch mode (requesting one timestamp on multiple messages) is not
supported at this time.
132.11.1. Configuration
The pm_ts module accepts the following directives in addition to the common module directives. The URL
directive is required.
URL
This mandatory directive specifies the URL of the Time-Stamp Authority server. The URL must begin with
either http:// for plain HTTP over TCP or https:// for HTTP over SSL.
Digest
This specifies the digest method (hash function) to be used. The SHA1 hash function is used by default. The
following message digest methods can be used: md2, md5, mdc2, rmd160, sha, sha1, sha224, sha256, sha384,
and sha512. Note that the Time-Stamp server must support the digest method specified.
Fields
This directive accepts a comma-separated list of fields. These fields will be used for calculating the hash value
sent to the TSA server. This directive is optional, and the $raw_event field is used if it is not specified.
HTTPSAllowUntrusted
This boolean directive specifies that the connection to the Time-Stamp Authority server should be allowed
without certificate verification. If set to TRUE, the connection will be allowed even if the server provides an
unknown or self-signed certificate. The default value is FALSE: all Time-Stamp Authority servers must present
a trusted certificate.
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote Time-Stamp Authority server. The certificate filenames in this directory
must be in the OpenSSL hashed format. This directive can only be specified if the URL begins with https. A
remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including a copy of the
certificate in this directory.
HTTPSCAFile
This specifies the path of the certificate of the certificate authority (CA) certificate, which will be used to check
the certificate of the remote Time-Stamp Authority server. This directive can only be specified if the URL
begins with https. To trust a self-signed certificate presented by the remote (which is not signed by a CA),
provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
1275
NXLog User Guide Chapter 132. Processor Modules
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the SSL handshake. This directive can only be
specified if the URL begins with https. If this directive is not specified but the URL begins with https, then an
anonymous SSL connection is attempted without presenting a client-side certificate.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake. This directive can only be
specified if the URL begins with https. If this directive is not specified but the URL begins with https, then an
anonymous SSL connection is attempted without presenting a client-side certificate.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote Time-Stamp Authority server. The certificate filenames in this
directory must be in the OpenSSL hashed format. This directive can only be specified if the URL begins with
https.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote Time-Stamp Authority server. This directive can only be specified if the URL begins
with https.
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
directive is not needed for passwordless private keys.
HTTPSSSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
HTTPSSSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
1276
Chapter 132. Processor Modules NXLog User Guide
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
132.11.2. Fields
The following fields are used by pm_ts.
132.11.3. Examples
Example 748. Storing Requested Timestamps in a CSV File
With this configuration, NXLog will read BSD Syslog messages from the socket, add timestamps, and then
save the messages to file in CSV format.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input uds>
6 Module im_uds
7 UDS /dev/log
8 Exec parse_syslog_bsd();
9 </Input>
10
11 <Processor ts>
12 Module pm_ts
13 URL https://tsa-server.com:8080/tsa
14 Digest md5
15 </Processor>
16
17 <Processor csv>
18 Module pm_transformer
19 OutputFormat csv
20 CSVOutputFields $facility, $severity, $timestamp, $hostname, \
21 $application, $pid, $message, $tsa_response
22 </Processor>
23
24 <Output file>
25 Module om_file
26 File "/dev/stdout"
27 </Output>
28
29 <Route uds_to_file>
30 Path uds => ts => csv => file
31 </Route>
1277
NXLog User Guide Chapter 133. Output Modules
When running NXLog on Windows, each module can create multiple TCP connections on
NOTE 127.0.0.1 using ephemeral ports. These should be considered part of the normal network
resources needed by NXLog on Windows.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.1.1. Configuration
The om_batchcompress module accepts the following directives in addition to the common module directives. The
Host directive is required.
Host
The module connects to the IP address or hostname defined in this directive. If additional hosts are specified
on new lines, the module works in a failover configuration. If a destination becomes unavailable, the module
automatically fails over to the next one. If the last destination becomes unavailable, the module will fail over
to the first destination.
The port number can be defined by appending it at the end of the hostname or IP address using a colon as a
separator (host:port). For each destination with no port number defined here, the port number specified in
the Port directive is used. Port numbers defined here take precedence over any port number defined in the
Port directive.
Port
The module connects to the port number on the destination host defined in this directive. This configuration
is only used for any destination that does not have a port number specified in the Host directive. If no port is
configured for a destination in either directive, the default port is used, which is port 2514.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the Host directive.
AllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE the remote will be able to connect with unknown and self-signed certificates. The default value
is FALSE: all connections must present a trusted certificate.
CADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote socket. The certificate filenames in this directory must be in the OpenSSL
hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including
1278
Chapter 133. Output Modules NXLog User Guide
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote socket. To trust a self-signed certificate presented by the remote (which is not signed by a CA),
provide that certificate instead.
CAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the CADir and CAFile directives are mutually
exclusive.
CertFile
This specifies the path of the certificate file to be used for the SSL handshake.
CertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake.
CertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the CertFile and
CertKeyFile directives are mutually exclusive.
CRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote socket. The certificate filenames in this directory must be in the
OpenSSL hashed format.
CRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote socket.
FlushInterval
This directive has been deprecated. Please use the BatchFlushInterval directive instead.
FlushLimit
This directive has been deprecated. Please use the BatchSize directive instead.
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is not needed for passwordless private keys.
LocalPort
This optional directive specifies the local port number of the connection. If this is not specified a random high
port number will be used, which is not always ideal in firewalled network environments.
SSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
SSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the SSLProtocol directive is
set to TLSv1.3. Use the same format as in the SSLCipher directive.
1279
NXLog User Guide Chapter 133. Output Modules
SSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols are allowed. Note that the OpenSSL library shipped by Linux distributions
may not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
UseSSL
This boolean directive specifies that SSL transfer mode should be enabled. The default is FALSE.
133.1.2. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration forwards logs in compressed batches to a remote NXLog agent over the default port.
Batches are sent at least once every two seconds, or more frequently if the buffer reaches 100 events.
nxlog.conf
1 <Input null>
2 Module im_null
3 BatchSize 200
4 BatchFlushInterval 2
5 </Input>
6 <Output batchcompress>
7 Module om_batchcompress
8 Host example.com:2514
9 </Output>
10
11 # Using the syntax used before NXLog EE 5,
12 # where the port is defined in a separate directive.
13 # Module om_batchcompress
14 # Host example.com
15 # Port 2514
16 # FlushLimit 100
17 # FlushInterval 2
18 #</Output>
19 <Route null_to_batchcompress>
20 Path null => batchcompress
21 </Route>
This configuration sends logs in compressed batches to a remote NXLog agent in a failover configuration
(multiple Hosts defined).
nxlog.conf
1 <Output batchcompress>
2 Module om_batchcompress
3 # destination host / IP and destination port
4 Host example1:2514
5 # first fail-over
6 Host example2:2514
7 # originating port
8 LocalPort 15000
9 </Output>
1280
Chapter 133. Output Modules NXLog User Guide
The sleep() procedure can also be used for testing by simulating log message delays.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.2.1. Configuration
The om_blocker module accepts only the common module directives.
133.2.2. Examples
Example 751. Testing Buffering With the om_blocker Module
Because the route in this configuration is blocked, this will test the behavior of the configured memory-
based buffer.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Processor buffer>
7 Module pm_buffer
8 WarnLimit 512
9 MaxSize 1024
10 Type Mem
11 </Processor>
12
13 <Output blocker>
14 Module om_blocker
15 </Output>
16
17 <Route uds_to_blocker>
18 Path uds => buffer => blocker
19 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The im_dbi and om_dbi modules support GNU/Linux only because of the libdbi library. The
NOTE
im_odbc and om_odbc modules provide native database access on Windows.
1281
NXLog User Guide Chapter 133. Output Modules
libdbi needs drivers to access the database engines. These are in the libdbd-* packages on
Debian and Ubuntu. CentOS 5.6 has a libdbi-drivers RPM package, but this package does not
NOTE contain any driver binaries under /usr/lib64/dbd. The drivers for both MySQL and PostgreSQL
are in libdbi-dbd-mysql. If these are not installed, NXLog will return a libdbi driver initialization
error.
133.3.1. Configuration
The om_dbi module accepts the following directives in addition to the common module directives.
Driver
This mandatory directive specifies the name of the libdbi driver which will be used to connect to the
database. A DRIVER name must be provided here for which a loadable driver module exists under the name
libdbdDRIVER.so (usually under /usr/lib/dbd/). The MySQL driver is in the libdbdmysql.so file.
SQL
This directive should specify the INSERT statement to be executed for each log message. The field names
(names beginning with $) will be replaced with the value they contain. String types will be quoted.
Option
This directive can be used to specify additional driver options such as connection parameters. The manual of
the libdbi driver should contain the options available for use here.
133.3.2. Examples
These two examples are for the plain Syslog fields. Other fields generated by parsers, regular expression rules,
the pm_pattern pattern matcher module, or input modules, can also be used. Notably, the im_msvistalog and
im_mseventlog modules generate different fields than those shown in these examples.
1282
Chapter 133. Output Modules NXLog User Guide
The following configuration accepts log messages via TCP and uses libdbi to insert log messages into the
database.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input tcp>
6 Module im_tcp
7 ListenAddr 0.0.0.0:1234
8 Exec parse_syslog_bsd();
9 </Input>
10
11 <Output dbi>
12 Module om_dbi
13 SQL INSERT INTO log (facility, severity, hostname, timestamp, \
14 application, message) \
15 VALUES ($SyslogFacility, $SyslogSeverity, $Hostname, '$EventTime', \
16 $SourceName, $Message)
17 Driver pgsql
18 Option host 127.0.0.1
19 Option username dbuser
20 Option password secret
21 Option dbname logdb
22 </Output>
23
24 <Route tcp_to_dbi>
25 Path tcp => dbi
26 </Route>
1283
NXLog User Guide Chapter 133. Output Modules
This configuration reads log messages from the socket and inserts them into a MySQL database.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input uds>
6 Module im_uds
7 UDS /dev/log
8 Exec parse_syslog_bsd();
9 </Input>
10
11 <Output dbi>
12 Module om_dbi
13 SQL INSERT INTO log (facility, severity, hostname, timestamp, \
14 application, message) \
15 VALUES ($SyslogFacility, $SyslogSeverity, $Hostname, '$EventTime', \
16 $SourceName, $Message)
17 Driver mysql
18 Option host 127.0.0.1
19 Option username mysql
20 Option password mysql
21 Option dbname logdb
22 </Output>
23
24 <Route uds_to_dbi>
25 Path uds => dbi
26 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module requires the xm_json extension module to be loaded in order to convert the
NOTE payload to JSON. If the $raw_event field does not start with a left curly bracket ({), the module
will automatically convert the data to JSON.
• By default, Elasticsearch will not automatically detect the date format used by NXLog Enterprise Edition 3.x.
As a result, NXLog datetime values, such as $EventTime, will be mapped as strings rather than dates. To fix
this, add an Elasticsearch template for indices matching the specified pattern (nxlog*). Extend the
dynamic_date_formats setting to include additional date formats. For compatibility with indices created
with Elasticsearch 5.x or older, use _default_ instead of _doc (but _default_ will not be supported by
1284
Chapter 133. Output Modules NXLog User Guide
Elasticsearch 7.0.0).
• The IndexType directive should be set to _doc (the default in NXLog Enterprise Edition 3.x is logs). However,
for compatibility with indices created with Elasticsearch 5.x or older, set IndexType as required for the
configured mapping types. See the IndexType directive below for more information.
133.4.2. Configuration
The om_elasticsearch module accepts the following directives in addition to the common module directives. The
URL directive is required.
URL
This mandatory directive specifies the URL for the module to POST the event data. If multiple URL directives
are specified, the module works in a failover configuration. If a destination becomes unavailable, the module
automatically fails over to the next one. If the last destination becomes unavailable, the module will fail over
to the first destination. The module operates in plain HTTP or HTTPS mode depending on the URL provided. If
the port number is not explicitly indicated in the URL, it defaults to port 80 for HTTP and port 443 for HTTPS.
The URL should point to the _bulk endpoint, or Elasticsearch will return 400 Bad Request.
AddHeader
This optional directive specifies an additional header to be added to each HTTP request.
FlushInterval
This directive has been deprecated. Please use the BatchFlushInterval directive instead.
FlushLimit
This directive has been deprecated. Please use the BatchSize directive instead.
Index
This directive specifies the index to insert the event data into. It must be a string type expression. If the
expression in the Index directive is not a constant string (it contains functions, field names, or operators), it
will be evaluated for each event to be inserted. The default is nxlog. Typically, an expression with strftime() is
used to generate an index name based on the event’s time or the current time (for example,
strftime(now(), "nxlog-%Y%m%d").
IndexType
This directive specifies the index type to use in the bulk index command. It must be a string type expression.
If the expression in the IndexType directive is not a constant string (it contains functions, field names, or
operators), it will be evaluated for each event to be inserted. The default is _doc. Note that index mapping
types have been deprecated and will be removed in Elasticsearch 7.0.0 (see Removal of mapping types in the
Elasticsearch Reference). IndexType should only be used if required for indices created with Elasticsearch 5.x
1285
NXLog User Guide Chapter 133. Output Modules
or older.
ID
This directive allows to specify a custom _id field for Elasticsearch documents. If the directive is not defined,
Elasticsearch uses a GUID for the _id field. Setting custom _id fields can be useful for correlating
Elasticsearch documents in the future and can help to prevent storing duplicate events in the Elasticsearch
storage. The directive’s argument must be a string type expression. If the expression in the ID directive is not
a constant string (it contains functions, field names, or operators), it will be evaluated for each event to be
submitted. You can use a concatenation of event fields and the event timestamp to uniquely and
informatively identify events in the Elasticsearch storage.
HTTPSAllowUntrusted
This boolean directive specifies that the remote connection should be allowed without certificate verification.
If set to TRUE, the connection will be allowed even if the remote HTTPS server presents an unknown or self-
signed certificate. The default value is FALSE: the remote HTTPS server must present a trusted certificate.
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote HTTPS server. The certificate filenames in this directory must be in the
OpenSSL hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by
including a copy of the certificate in this directory.
HTTPSCAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote HTTPS server. To trust a self-signed certificate presented by the remote (which is not signed by a
CA), provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote HTTPS server. The certificate filenames in this directory must be
in the OpenSSL hashed format.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote HTTPS server.
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
1286
Chapter 133. Output Modules NXLog User Guide
HTTPSSSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
HTTPSSSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
Proxy
This optional directive is used to specify the IP address (or hostname) and port number of the HTTP proxy
server to be used. The format is hostname:port. If the port number is ommited, it defaults to 80.
The om_elasticsearch module supports HTTP proxying only. SOCKS4/SOCKS5 proxying is not
NOTE
supported.
ProxyAddress
This directive has been deprecated. Please use the Proxy directive instead.
ProxyPort
This directive has been deprecated. Please use the Proxy directive instead.
SNI
This optional directive specifies the host name used for Server Name Indication (SNI) in HTTPS mode.
133.4.3. Procedures
The following procedures are exported by om_elasticsearch.
133.4.4. Examples
1287
NXLog User Guide Chapter 133. Output Modules
This configuration reads log messages from file and forwards them to the Elasticsearch server on localhost.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Input file>
6 Module im_file
7 File '/var/log/myapp*.log'
8 # Parse log here if needed
9 # $EventTime should be set here
10 </Input>
11
12 <Output elasticsearch>
13 Module om_elasticsearch
14 URL http://localhost:9200/_bulk
15 FlushInterval 2
16 FlushLimit 100
17 # Create an index daily
18 Index strftime($EventTime, "nxlog-%Y%m%d")
19 # Or use the following if $EventTime is not set
20 # Index strftime(now(), "nxlog-%Y%m%d")
21 </Output>
This configuration sends log messages to an Elasticsearch server in a failover configuration (multiple URLs
defined). The actual destinations used in this case are http://localhost:9200/_bulk,
http://192.168.1.1:9200/_bulk, and http://example.com:9200/_bulk.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Output elasticsearch>
6 Module om_elasticsearch
7 URL http://localhost:9200/_bulk
8 URL http://192.168.1.1:9200/_bulk
9 URL http://example.com:9200/_bulk
10 </Output>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
1288
Chapter 133. Output Modules NXLog User Guide
133.5.1. Configuration
The om_eventdb module accepts the following directives in addition to the common module directives. The
DBname, Password, and UserName directives are required along with one of Host and UDS.
DBname
Name of the database to read the logs from.
Host
This specifies the IP address or a DNS hostname the module should connect to (the hostname of the MySQL
server). This directive cannot be used with UDS.
Password
Password for authenticating to the database server.
UDS
For Unix domain socket connections, this directive can be used to specify the path of the socket such as
/var/run/mysqld.sock. This directive cannot be used with the Host and Port directive.
UserName
Username for authenticating to the database server.
BulkLoad
If set to TRUE, this optional boolean directive instructs the module to use a bulk-loading technique to load
data into the database; otherwise traditional INSERT statements are issued to the server. The default is TRUE.
LoadInterval
This directive specifies how frequently bulk loading should occur, in seconds. It can be only used when
BulkLoad is set to TRUE. The default bulk load interval is 20 seconds.
Port
This specifies the port the module should connect to, on which the database is accepting connections. This
directive cannot be used with UDS. The default is port 3306.
TempDir
This directive sets a directory where temporary files are written. It can be only used when BulkLoad is set to
TRUE. If this directive is not specified, the default directory is /tmp. If the chosen directory does not exist, the
module will try to create it.
133.5.2. Examples
1289
NXLog User Guide Chapter 133. Output Modules
This configuration accepts log messages via TCP in the NXLog binary format and inserts them into a
database using libdrizzle.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 ListenAddr localhost:2345
4 InputType Binary
5 </Input>
6
7 <Output eventdb>
8 Module om_eventdb
9 Host localhost
10 Port 3306
11 Username joe
12 Password secret
13 Dbname eventdb_test2
14 </Output>
15
16 <Route tcp_to_eventdb>
17 Path tcp => eventdb
18 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The program or script is started when NXLog starts and must not exit until the module is
NOTE
stopped. To invoke a program or script for each log message, use xm_exec instead.
133.6.1. Configuration
The om_exec module accepts the following directives in addition to the common module directives. The
Command directive is required.
Command
This mandatory directive specifies the name of the program or script to be executed.
Arg
This is an optional parameter. Arg can be specified multiple times, once for each argument that needs to be
passed to the Command. Note that specifying multiple arguments with one Arg directive, with arguments
separated by spaces, will not work (the Command will receive it as one argument).
Restart
Restart the process if it exits. There is a one second delay before it is restarted to avoid a denial-of-service
when a process is not behaving. Looping should be implemented in the script itself. This directive is only to
1290
Chapter 133. Output Modules NXLog User Guide
provide some safety against malfunctioning scripts and programs. This boolean directive defaults to FALSE:
the Command will not be restarted if it exits.
133.6.2. Examples
Example 757. Piping Logs to an External Program
With this configuration, NXLog will start the specified command, read logs from socket, and write those logs
to the standard input of the command.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Output someprog>
7 Module om_exec
8 Command /usr/bin/someprog
9 Arg -
10 </Output>
11
12 <Route uds_to_someprog>
13 Path uds => someprog
14 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.7.1. Configuration
The om_file module accepts the following directives in addition to the common module directives. The File
directive is required.
File
This mandatory directive specifies the name of the output file to open. It must be a string type expression. If
the expression in the File directive is not a constant string (it contains functions, field names, or operators), it
will be evaluated before each event is written to the file (and after the Exec is evaluated). Note that the
filename must be quoted to be a valid string literal, unlike in other directives which take a filename argument.
For relative filenames, note that NXLog changes its working directory to "/" unless the global SpoolDir is set to
something else.
Below are three variations for specifying the same output file on a Windows system:
File 'C:\logs\logmsg.txt'
File "C:\\logs\\logmsg.txt"
File 'C:/logs/logmsg.txt'
1291
NXLog User Guide Chapter 133. Output Modules
CacheSize
In case of dynamic filenames, a cache can be utilized to keep files open. This increases performance by
reducing the overhead caused by many open/close operations. It is recommended to set this to the number
of expected files to be written. Note that this should not be set to more than the number of open files
allowed by the system. This caching provides performance benefits on Windows only. Caching is disabled by
default.
CreateDir
If set to TRUE, this optional boolean directive instructs the module to create the output directory before
opening the file for writing if it does not exist. The default is FALSE.
Group
Use this directive to set the group ownership for the created socket or pipe or file. By default, this is the group
NXLog is running as, (which may be specified by the global Group directive). This directive is not currently
supported on Windows.
OutputType
See the OutputType directive in the list of common module directives. If this directive is not specified the
default is LineBased (the module will use CRLF as the record terminator on Windows, or LF on Unix).
This directive also supports data converters, see the description in the OutputType section.
Perms
This directive specifies the permissions to use for the created socket or pipe or file. This must be a four-digit
octal value beginning with a zero. By default, OS default permissions will be set. This directive is not currently
supported on Windows.
Sync
This optional boolean directive instructs the module to sync the file after each log message is written,
ensuring that it is really written to disk from the buffers. Because this can hurt performance, the default is
FALSE.
Truncate
This optional boolean directive instructs the module to truncate the file before each write, causing only the
most recent log message to be saved. The default is FALSE: messages are appended to the output file.
User
Use this directive to set the user ownership for the created socket or pipe or file. By default, this is the user
NXLog is running as (which may be specified by the global User directive). This directive is not currently
supported on Windows.
133.7.2. Functions
The following functions are exported by om_file.
string file_name()
Return the name of the currently open file which was specified using the File directive. Note that this will be
the old name if the filename changes dynamically; for the new name, use the expression specified for the File
directive instead of using this function.
integer file_size()
Return the size of the currently open output file in bytes. Returns undef if the file is not open. This can
happen if File is not a string literal expression and there was no log message.
133.7.3. Procedures
The following procedures are exported by om_file.
1292
Chapter 133. Output Modules NXLog User Guide
reopen();
Reopen the current file. This procedure should be called if the file has been removed or renamed, for
example with the file_cycle(), file_remove(), or file_rename() procedures of the xm_fileop module. This does
not need to be called after rotate_to() because that procedure reopens the file automatically.
rotate_to(string filename);
Rotate the current file to the filename specified. The module will then open the original file specified with the
File directive. Note that the rename(2) system call is used internally which does not support moving files
across different devices on some platforms. If this is a problem, first rotate the file on the same device. Then
use the xm_exec exec_async() procedure to copy it to another device or file system, or use the xm_fileop
file_copy() procedure.
133.7.4. Examples
Example 758. Storing Raw Syslog Messages into a File
This configuration reads log messages from socket and writes the messages to file. No additional
processing is done.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Output file>
7 Module om_file
8 File "/var/log/messages"
9 </Output>
10
11 <Route uds_to_file>
12 Path uds => file
13 </Route>
1293
NXLog User Guide Chapter 133. Output Modules
With this configuration, NXLog accepts log messages via TCP and parses them as BSD Syslog. A separate
output file is used for log messages from each host. When the output file size exceeds 15 MB, it will be
automatically rotated and compressed.
nxlog.conf
1 <Extension exec>
2 Module xm_exec
3 </Extension>
4
5 <Extension syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input tcp>
10 Module im_tcp
11 ListenAddr 0.0.0.0:1514
12 Exec parse_syslog_bsd();
13 </Input>
14
15 <Output file>
16 Module om_file
17 File "tmp/output_" + $Hostname + "_" + month(now())
18 <Exec>
19 if file->file_size() > 15M
20 {
21 $newfile = "tmp/output_" + $Hostname + "_" +
22 strftime(now(), "%Y%m%d%H%M%S");
23 file->rotate_to($newfile);
24 exec_async("/bin/bzip2", $newfile);
25 }
26 </Exec>
27 </Output>
28
29 <Route tcp_to_file>
30 Path tcp => file
31 </Route>
133.8. Go (om_go)
This module provides support for forwarding log data with methods written in the Go language. The file specified
by the ImportLib directive should contain one or more methods which can be called from the Exec directive of
any module. See also the xm_go and im_go modules.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
For the system requirements, installation details and environmental configuration requirements
NOTE of Go, see the Getting Started section in the Go documentation. The Go environment is only
needed for compiling the Go file. NXLog does not need the Go environment for its operation.
The Go script imports the NXLog module, and will have access to the following classes and functions.
class nxModule
This class is instantiated by NXLog and can be accessed via the nxLogdata.module attribute. This can be used
1294
Chapter 133. Output Modules NXLog User Guide
to set or access variables associated with the module (see the example below).
nxmodule.NxLogdataNew(*nxLogdata)
This function creates a new log data record.
nxmodule.Post(ld *nxLogdata)
This function puts log data struct for further processing.
nxmodule.AddEvent()
This function adds a READ event to NXLog. This allows to call the READ event later.
nxmodule.AddEventDelayed(mSec C.int)
This function adds a delayed READ event to NXLog. This allows to call the delayed READ event later.
class nxLogdata
This class represents an event. It is instantiated by NXLog and passed to the function specified by the
ImportFunc directive.
nxlogdata.Delete(field string)
This function removes the field from logdata.
nxlogdata.Fields() []string
This function returns an array of fields names in the logdata record.
module
This attribute is set to the module object associated with the event.
For the Go environment to work with NXLog, the gonxlog.go file has to be installed.
1295
NXLog User Guide Chapter 133. Output Modules
133.8.3. Configuration
The om_go module accepts the following directives in addition to the common module directives.
ImportLib
This mandatory directive specifies the file containing the Go code compiled into a shared library .so file.
ImportFunc
This mandatory directive calls the specified function, which must accept an unsafe.Pointer object as its only
argument. This function is called when the module tries to read data. It is a mandatory function.
In this Go file template, the write function is called via the ImportFunc directive.
om_go Template
//export write
func write(ctx unsafe.Pointer) {
// get logdata from the context
if ld, ok := gonxlog.GetLogdata(ctx); ok {
// place your code here
}
}
133.8.5. Examples
1296
Chapter 133. Output Modules NXLog User Guide
nxlog.conf
1 <Input in>
2 Module im_testgen
3 MaxCount 10
4 </Input>
5
6 <Output out>
7 Module om_go
8 ImportLib "file/output.so"
9 ImportFunc write
10 </Output>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.9.1. Configuration
The om_http module accepts the following directives in addition to the common module directives. The URL
directive is required.
1297
NXLog User Guide Chapter 133. Output Modules
URL
This mandatory directive specifies the URL for the module to POST the event data. If multiple URL directives
are specified on new lines, the module works in a failover configuration. If a destination becomes unavailable,
the module automatically fails over to the next one. If the last destination becomes unavailable, the module
fails over to the first destination.
The module operates in plain HTTP or HTTPS mode depending on the URL provided. If the port number is not
explicitly defined in the URL, it defaults to port 80 for HTTP and port 443 for HTTPS.
AddHeader
This optional directive specifies an additional header to be added to each HTTP request or body part (in
Multipart batching mode).
BatchMode
This optional directive sets, whether the event data should be sent as a single record per POST request or as
a batch of multiple records per POST request. The default setting is none, meaning that event data will be
sent as a single record per POST request. For multipart, the generated POST request will use the
multipart/mixed content type, where each record will be sent as a separate body part. For the multiline
batching mode, batched records will be sent as a single HTTP request, one record per line (separated by CRLF
(\r\n) characters).
The add_http_header() and set_http_request_path() procedures may cause the current batch to
be flushed immediately. For the multiline batching mode, this happens whenever the value of
the URL path or the value of an HTTP header changes, because this requires a new HTTP
request to be built. In multipart batching mode, only set_http_request_path() will cause a
NOTE
batch flush when the path value changes, because add_http_header() only modifies the HTTP
header for the HTTP body part corresponding to the event record that is currently being
processed. Pipelining can somewhat alleviate the performance penalty of using these
procedures.
ContentType
This directive sets the Content-Type HTTP header to the string specified. The Content-Type is set to text/plain
by default. Note: If the BatchMode directive is set to multipart, then the value specified here will be used as
the Content-Type header for each part of the multipart/mixed HTTP request.
FlushInterval
This directive has been deprecated. Please use the BatchFlushInterval directive instead.
FlushLimit
This directive has been deprecated. Please use the BatchSize directive instead.
HTTPSAllowUntrusted
This boolean directive specifies that the connection should be allowed without certificate verification. If set to
TRUE, the connection will be allowed even if the remote HTTPS server presents an unknown or self-signed
certificate. The default value is FALSE: the remote HTTPS server must present a trusted certificate.
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote HTTPS server. The certificate filenames in this directory must be in the
OpenSSL hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by
including a copy of the certificate in this directory.
1298
Chapter 133. Output Modules NXLog User Guide
HTTPSCAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote HTTPS server. To trust a self-signed certificate presented by the remote (which is not signed by a
CA), provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote HTTPS server. The certificate filenames in this directory must be
in the OpenSSL hashed format.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL) which will be consulted when checking the
certificate of the remote HTTPS server.
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
directive is not needed for passwordless private keys.
HTTPSSSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
HTTPSSSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
1299
NXLog User Guide Chapter 133. Output Modules
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
Pipeline
This boolean directive can be set to TRUE to enable pipelining of multiple HTTP requests from the same batch,
meaning that all requests will be sent first, and then all responses from the server will be handled. HTTP
pipelining can improve performance by avoiding head-of-line blocking, but not all HTTP servers support it.
The default value is FALSE.
Proxy
This optional directive is used to specify the IP address (or hostname) and port number of the HTTP proxy
server to be used. The format is hostname:port. If the port number is ommited, it defaults to 80.
The om_http module supports HTTP proxying only. SOCKS4/SOCKS5 proxying is not
NOTE
supported.
ProxyAddress
This directive has been deprecated. Please use the Proxy directive instead.
ProxyPort
This directive has been deprecated. Please use the Proxy directive instead.
SNI
This optional directive specifies the host name used for Server Name Indication (SNI) in HTTPS mode.
133.9.2. Procedures
The following procedures are exported by om_http.
This function impacts the way batching works. See the BatchMode directive for more
NOTE
information.
set_http_request_path(string path);
Set the path in the HTTP request to the string specified. This is useful if the URL is dynamic and parameters
such as event ID need to be included in the URL. Note that the string must be URL encoded if it contains
reserved characters.
This function impacts the way batching works. See the BatchMode directive for more
NOTE
information.
133.9.3. Examples
1300
Chapter 133. Output Modules NXLog User Guide
This configuration reads log messages from file and forwards them via HTTPS.
nxlog.conf
1 <Output http>
2 Module om_http
3 URL https://server:8080/
4 AddHeader Auth-Token: 4ddf1d3c9
5 HTTPSCertFile %CERTDIR%/client-cert.pem
6 HTTPSCertKeyFile %CERTDIR%/client-key.pem
7 HTTPSCAFile %CERTDIR%/ca.pem
8 HTTPSAllowUntrusted FALSE
9 BatchMode multipart
10 </Output>
This configuration sends logs via HTTPS in a failover configuration with multiple instances of the URL
directive defined on new lines.
nxlog.conf
1 <Output http>
2 Module om_http
3 URL https://server:8080/
4 URL https://192.168.1.1:8080/
5 URL https://example.com:8080/
6 HTTPSCertFile %CERTDIR%/client-cert.pem
7 HTTPSCertKeyFile %CERTDIR%/client-key.pem
8 HTTPSCAFile %CERTDIR%/ca.pem
9 HTTPSAllowUntrusted FALSE
10 </Output>
For the system requirements, installation details and environmental configuration requirements
NOTE
of Java, see the Installing Java section in the Java documentation.
The NXLog Java class provides access to the NXLog functionality in the Java code. This class contains nested
classes Logdata and Module with log processing methods, as well as methods for sending messages to the
internal logger.
class NXLog.Logdata
This Java class provides the methods to interact with an NXLog event record object:
getField(name)
This method returns the value of the field name in the event.
setField(name, value)
This method sets the value of field name to value.
1301
NXLog User Guide Chapter 133. Output Modules
deleteField(name)
This method removes the field name from the event record.
getFieldnames()
This method returns an array with the names of all the fields currently in the event record.
getFieldtype(name)
This method retrieves the field type using the value from the name field.
class NXLog.Module
The methods below allow setting and accessing variables associated with the module instance.
saveCtx(key,value)
This method saves user data in the module data storage using values from the key and value fields.
loadCtx(key)
This method retrieves data from the module data storage using the value from the key field.
Below is the list of methods for sending messages to the internal logger.
NXLog.logInfo(msg)
This method sends the message msg to to the internal logger at INFO log level. It does the same as the core
log_info() procedure.
NXLog.logDebug(msg)
This method sends the message msg to to the internal logger at DEBUG log level. It does the same as the core
log_debug() procedure.
NXLog.logWarning(msg)
This method sends the message msg to to the internal logger at WARNING log level. It does the same as the
core log_warning() procedure.
NXLog.logError(msg)
This method sends the message msg to to the internal logger at ERROR log level. It does the same as the core
log_error() procedure.
133.10.1. Configuration
The NXLog process maintains only one JVM instance for all om_java, im_java or xm_java running instances. This
means all classes loaded by the ClassPath directive will be available for all running Java instances.
The om_java module accepts the following directives in addition to the common module directives.
ClassPath
This mandatory directive defines the path to the .class files or a .jar file. This directive should be defined at
least once within a module block.
VMOption
This optional directive defines a single Java Virtual Machine (JVM) option.
VMOptions
This optional block directive serves the same purpose as the VMOption directive, but also allows specifying
multiple Java Virtual Machine (JVM) instances, one per line.
JavaHome
This optional directive defines the path to the Java Runtime Environment (JRE). The path is used to search for
1302
Chapter 133. Output Modules NXLog User Guide
the libjvm shared library. If this directive is not defined, the Java home directory will be set to the build-time
value. Only one JRE can be defined for one or multiple NXLog Java instances. Defining multiple JRE instances
causes an error.
Run
This mandatory directive specifies the static method inside the Classpath file which should be called.
1303
NXLog User Guide Chapter 133. Output Modules
This is an example of a configuration for adding a timestamp field and writing log processing results to a
file. The run method of the Writer Java class is being used to handle the processing.
nxlog.conf
1 <Output javaout>
2 Module om_java
3 # The Run directive includes the full method name with
4 # the nested and outer classes
5 # The mandatory parameter will be passed automatically
6 Run Output$Writer.run
7 ClassPath Output.jar
8 </Output>
Output.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.*;
try {
// 1. Retrieves the $raw_event field from the NXLog data record
// 2. Adds the timestamp field with the current time
// 3. Writes the results into the file
if (((String)ld.getField("raw_event")).contains("type=")) {
Files.write(Paths.get(fileName), ("timestamp=" + df.format(currentDate) + "
" + (String) ld.getField("raw_event") + "\n").getBytes(), StandardOpenOption.CREATE,
StandardOpenOption.APPEND);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
1304
Chapter 133. Output Modules NXLog User Guide
Input sample
type=CWD msg=audit(1489999368.711:35724): cwd="/root/nxlog"↵
↵
type=PATH msg=audit(1489999368.711:35724): item=0 name="/root/test" inode=528869 dev=08:01
mode=040755 ouid=0 ogid=0 rdev=00:00↵
↵
type=SYSCALL msg=audit(1489999368.711:35725): arch=c000003e syscall=2 success=yes exit=3
a0=12dcc40 a1=90800 a2=0 a3=0 items=1 ppid=15391 pid=12309 auid=0 uid=0 gid=0 euid=0 suid=0
fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=583 comm="ls" exe="/bin/ls" key=(null)↵
Output Sample
timestamp=02.20.2020.09:19:58 type=CWD msg=audit(1489999368.711:35724): cwd="/root/nxlog"
timestamp=02.20.2020.09:19:58 type=PATH msg=audit(1489999368.711:35724): item=0
name="/root/test" inode=528869 dev=08:01 mode=040755 ouid=0 ogid=0 rdev=00:00
timestamp=02.20.2020.09:19:58 type=SYSCALL msg=audit(1489999368.711:35725): arch=c000003e
syscall=2 success=yes exit=3 a0=12dcc40 a1=90800 a2=0 a3=0 items=1 ppid=15391 pid=12309 auid=0
uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=583 comm="ls"
exe="/bin/ls" key=(null)
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The om_kafka module is not supported as the underlying librdkafka library is unstable on
WARNING
AIX. Use it on IBM AIX at your own risk.
The module uses an internal persistent queue to back up event records that should be pushed to a Kafka broker.
Once the module receives an acknowledgement from the Kafka server that the message has been delivered
successfully, the module removes the corresponding message from the internal queue. If the module is unable
to deliver a message to a Kafka broker (for example, due to connectivity issues or the Kafka server being down),
this message is retained in the internal queue (including cases when NXLog restarts) and the module will attempt
to re-deliver the message again.
The number of re-delivery attempts can be specified by passing the message.send.max.retries property via
the Option directive (for example, Option message.send.max.retries 5). By default, the number of retries is
set to 2 and the time interval between two subsequent retries is 5 minutes. Thus, by altering the number of
retries, it is possible to control the total time for a message to remain in the internal queue. If a message cannot
be delivered within the allowed retry attempts, the message is dropped. The maximum size of the internal queue
is controlled by the LogqueueSize directive, which defaults to 100 messages. To increase the size of the internal
queue, follow these steps:
1. Specify the required queue size value using the LogqueueSize directive.
2. Set the directive Option queue.buffering.max.messages N. When this option is not set, the default value
used by librdkafka is 10000000.
For optimum performance, the LogqueueSize directive should be set to a value that is slightly larger than the
value used for the queue.buffering.max.messages option.
1305
NXLog User Guide Chapter 133. Output Modules
133.11.1. Configuration
The om_kafka module accepts the following directives in addition to the common module directives. The
BrokerList and Topic directives are required.
BrokerList
This mandatory directive specifies the list of Kafka brokers to connect to for publishing logs. The list should
include ports and be comma-delimited (for example, localhost:9092,192.168.88.35:19092).
Topic
This mandatory directive specifies the Kafka topic to publish records to.
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote brokers. CAFile is required if Protocol is set to ssl or sasl_ssl. To trust a self-signed certificate
presented by the remote (which is not signed by a CA), provide that certificate instead.
CertFile
This specifies the path of the certificate file to be used for the SSL handshake.
CertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake.
Compression
This directive specifies the compression types to use during transfer. Available types depend on the Kafka
library, and should include none (the default), gzip, snappy, and lz4.
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is not needed for passwordless private keys.
Option
This directive can be used to pass a custom configuration property to the Kafka library (librdkafka). For
example, the group ID string can be set with Option group.id mygroup. This directive may be used more
than once to specify multiple options. For a list of configuration properties, see the librdkafka
CONFIGURATION.md file.
Passing librdkafka configuration properties via the Option directive should be done with
WARNING care since these properties are used for the fine-tuning of the librdkafka performance
and may result in various side effects.
Partition
This optional integer directive specifies the topic partition to write to. If this directive is not given, messages
are sent without a partition specified.
Protocol
This optional directive specifies the protocol to use for connecting to the Kafka brokers. Accepted values
include plaintext (the default), ssl, sasl_plaintext and sasl_ssl. If Protocol is set to ssl or sasl_ssl,
then the CAFile directive must also be provided.
SASLKerberosServiceName
This directive specifies the Kerberos service name to be used for SASL authentication. The service name is
required for the sasl_plaintext and sasl_ssl protocols.
1306
Chapter 133. Output Modules NXLog User Guide
SASLKerberosPrincipal
This specifies the client’s Kerberos principal name for the sasl_plaintext and sasl_ssl protocols. This
directive is only available and mandatory on Linux/UNIX. See note below.
SASLKerberosKeytab
Specifies the path to the kerberos keytab file which contains the client’s allocated principal name. This
directive is only available and mandatory on Linux/UNIX.
NOTE For details about configuring Apache Kafka brokers to accept SASL/Kerberos authentication
from clients, please follow the instructions provided by the librdkafka project:
• For kafka brokers running on Linux and UNIX-likes: Using SASL with librdkafka
• For kafka brokers running on Windows: Using SASL with librdkafka on Windows
133.11.2. Examples
Example 763. Using the om_kafka Module
This configuration sends events to a Kafka cluster using the brokers specified. Events are published to the
first partition of the nxlog topic.
nxlog.conf
1 <Output out>
2 Module om_kafka
3 BrokerList localhost:9092,192.168.88.35:19092
4 Topic nxlog
5 Partition 0
6 Protocol ssl
7 CAFile /root/ssl/ca-cert
8 CertFile /root/ssl/client_debian-8.pem
9 CertKeyFile /root/ssl/client_debian-8.key
10 KeyPass thisisasecret
11 </Output>
The librdkafka library can produce its performance statistics and format it in JSON. All fields from the JSON
structure are explained on the Statistics page of the librdkafka project on the GitHub website. NXLog can be
configured to poll this data at a specified fixed interval. The result can be saved to the internal logger.
1307
NXLog User Guide Chapter 133. Output Modules
To read statistical data of the librdkafka library, the millisecond polling interval needs to be specified
against the Option directive using the statistics.interval.ms option.
The Schedule block sets the interval to run the code of the nested Exec block. Inside the Exec block, the
log_info() procedure is called with the kafka_in->get_stats() parameter passed.
To get the librdkafka statistics produced and delivered synchronously, the statistics.interval.ms
option and the Schedule block should specify the same interval amount.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Setting up the ODBC data source is not in the scope of this document. Please consult the relevant ODBC guide:
the unixODBC documentation or the Microsoft ODBC Data Source Administrator guide. The data source must be
accessible by the user NXLog is running under.
The "SQL Server" ODBC driver is unsupported and does not work. Instead, use the "SQL Server
NOTE Native Client" or the "ODBC Driver for SQL Server" to insert records into a Microsoft SQL Server
database.
In addition to the SQL directive, this module provides two functions, sql_exec() and sql_fetch(), which can be
executed using the Exec directive. This allows more complex processing rules to be used and also makes it
possible to insert records into more than one table.
1308
Chapter 133. Output Modules NXLog User Guide
Both sql_exec() and sql_fetch() can take bind parameters as function arguments. It is
recommended to use bind parameters instead of concatenating the SQL statement with the
value. For example, these two are equivalent but the first is dangerous due to the lack of
escaping:
NOTE
133.13.1. Configuration
The om_odbc module accepts the following directives in addition to the common module directives.
ConnectionString
This mandatory directive specifies the ODBC data source connection string.
SQL
This optional directive can be used to specify the INSERT statement to be executed for each log message. If
the statement fails for an event, it will be attempted again. If the SQL directive is not given, then an Exec
directive should be used to execute the sql_exec() function.
133.13.2. Functions
The following functions are exported by om_odbc.
string sql_error()
Return the error message from the last failed ODBC operation.
133.13.3. Examples
Example 765. Write Events to SQL Server
This configuration uses a DSN-less connection and SQL Authentication to connect to an SQL Server
database. Records are inserted into the dbo.test1 table’s timestamp and message columns, using the
$EventTime and $Message fields from the current event.
nxlog.conf
1 <Output mssql>
2 Module om_odbc
3 ConnectionString Driver={ODBC Driver 13 for SQL Server}; Server=MSSQL-HOST; \
4 UID=test; PWD=testpass; Database=TESTDB
5 SQL "INSERT INTO dbo.test1 (timestamp, message) VALUES (?,?)", \
6 $EventTime, $Message
7 </Output>
1309
NXLog User Guide Chapter 133. Output Modules
In this example, the events read from the TCP input are inserted into the message column. The table has an
auto_increment id column, which is used to fetch and print the newly inserted line.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 ListenAddr 0.0.0.0:1234
4 </Input>
5
6 <Output odbc>
7 Module om_odbc
8 ConnectionString DSN=mysql_ds;username=mysql;password=mysql;database=logdb;
9 <Exec>
10 if ( sql_exec("INSERT INTO log (facility, severity, hostname, timestamp, " +
11 "application, message) VALUES (?, ?, ?, ?, ?, ?)",
12 1, 2, "host", now(), "app", $raw_event) == TRUE )
13 {
14 if ( sql_fetch("SELECT max(id) as id from log") == TRUE )
15 {
16 log_info("ID: " + $id);
17 if ( sql_fetch("SELECT message from log WHERE id=?", $id) == TRUE )
18 {
19 log_info($message);
20 }
21 }
22 }
23 </Exec>
24 </Output>
25
26 <Route tcp_to_odbc>
27 Path tcp => odbc
28 </Route>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module makes it possible to execute Perl code in an output module that can handle the data directly in Perl.
See also the im_perl and xm_perl modules.
The module will parse the file specified in the PerlCode directive when NXLog starts the module. The Perl code
must implement the write_data subroutine which will be called by the module when there is data to process. This
subroutine is called for each event record and the event record is passed as an argument. To access event data,
the Log::Nxlog Perl module must be included, which provides the following methods.
To use the om_perl module on Windows, a separate Perl environment must be installed, such as
NOTE
Strawberry Perl. Currently, the om_perl module on Windows requires Strawberry Perl 5.28.2.1.
1310
Chapter 133. Output Modules NXLog User Guide
log_debug(msg)
Send the message msg to the internal logger on DEBUG log level. This method does the same as the
log_debug() procedure in NXLog.
log_info(msg)
Send the message msg to the internal logger on INFO log level. This method does the same as the log_info()
procedure in NXLog.
log_warning(msg)
Send the message msg to the internal logger on WARNING log level. This method does the same as the
log_warning() procedure in NXLog.
log_error(msg)
Send the message msg to the internal logger on ERROR log level. This method does the same as the
log_error() procedure in NXLog.
get_field(event, key)
Retrieve the value associated with the field named key. The method returns a scalar value if the key exists and
the value is defined, otherwise it returns undef.
For the full NXLog Perl API, see the POD documentation in Nxlog.pm. The documentation can be read with
perldoc Log::Nxlog.
133.14.1. Configuration
The om_perl module accepts the following directives in addition to the common module directives.
PerlCode
This mandatory directive expects a file containing valid Perl code. This file is read and parsed by the Perl
interpreter.
On Windows, the Perl script invoked by the PerlCode directive must define the Perl library
paths at the beginning of the script to provide access to the Perl modules.
NOTE
nxlog-windows.pl
use lib 'c:\Program Files\nxlog\data';
Config
This optional directive allows you to pass configuration strings to the script file defined by the PerlCode
directive. This is a block directive and any text enclosed within <Config></Config> is submitted as a single
string literal to the Perl code.
If you pass several values using this directive (for example, separated by the \n delimiter) be
NOTE
sure to parse the string correspondingly inside the Perl code.
Call
This optional directive specifies the Perl subroutine to invoke. With this directive, you can call only specific
subroutines from your Perl code. If the directive is not specified, the default subroutine write_data is
invoked.
133.14.2. Examples
1311
NXLog User Guide Chapter 133. Output Modules
This output module sends events to the Perl script, which simply writes the data from the $raw_event field
into a file.
nxlog.conf
1 <Output out>
2 Module om_perl
3 PerlCode modules/output/perl/perl-output.pl
4 Call write_data1
5 </Output>
perl-output.pl
use strict;
use warnings;
use Log::Nxlog;
sub write_data1
{
my ($event) = @_;
my $rawevt = Log::Nxlog::get_field($event, 'raw_event');
open(OUT, '>', 'tmp/output') || die("cannot open tmp/output: $!");
print OUT $rawevt, "(from perl)", "\n";
close(OUT);
}
133.15.1. Configuration
The om_pipe module accepts the following directives in addition to the common module directives.
Pipe
This mandatory directive specifies the name of the output pipe file. The module checks if the specified pipe
file exists and creates it in case it does not. If the specified pipe file is not a named pipe, the module does not
start.
Group
Use this directive to set the group ownership for the created socket or pipe or file. By default, this is the group
NXLog is running as, (which may be specified by the global Group directive). This directive is not currently
supported on Windows.
Perms
This directive specifies the permissions to use for the created socket or pipe or file. This must be a four-digit
octal value beginning with a zero. By default, OS default permissions will be set. This directive is not currently
supported on Windows.
User
Use this directive to set the user ownership for the created socket or pipe or file. By default, this is the user
NXLog is running as (which may be specified by the global User directive). This directive is not currently
supported on Windows.
1312
Chapter 133. Output Modules NXLog User Guide
OutputType
This directive specifies the input data format. The default value is LineBased. See the OutputType directive in
the list of common module directives.
133.15.2. Examples
This example provides the NXLog configuration for forwarding messages to a named pipe on a UNIX-like
operating system.
With this configuration, NXLog reads messages from a file and forwards them to a pipe. No additional
processing is done.
nxlog.conf
<Input in>↵
Module im_file↵
File "/tmp/input"↵
</Input>↵
↵
<Output out>↵
Module om_pipe↵
Pipe "/tmp/output"↵
</Output>↵
The file specified by the PythonCode directive should contain a write_data() method which is called by the
om_python module instance. See also the xm_python and im_python modules.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
The Python script should import the nxlog module, and will have access to the following classes and functions.
nxlog.log_debug(msg)
Send the message msg to the internal logger at DEBUG log level. This function does the same as the core
log_debug() procedure.
nxlog.log_info(msg)
Send the message msg to the internal logger at INFO log level. This function does the same as the core
log_info() procedure.
nxlog.log_warning(msg)
Send the message msg to the internal logger at WARNING log level. This function does the same as the core
log_warning() procedure.
nxlog.log_error(msg)
Send the message msg to the internal logger at ERROR log level. This function does the same as the core
log_error() procedure.
1313
NXLog User Guide Chapter 133. Output Modules
class nxlog.Module
This class is instantiated by NXLog and can be accessed via the LogData.module attribute. This can be used to
set or access variables associated with the module (see the example below).
class nxlog.LogData
This class represents an event. It is instantiated by NXLog and passed to the write_data() method.
delete_field(name)
This method removes the field name from the event record.
field_names()
This method returns a list with the names of all the fields currently in the event record.
get_field(name)
This method returns the value of the field name in the event.
set_field(name, value)
This method sets the value of field name to value.
module
This attribute is set to the Module object associated with the LogData event.
133.16.1. Configuration
The om_python module accepts the following directives in addition to the common module directives.
PythonCode
This mandatory directive specifies a file containing Python code. The om_python instance will call a
write_data() function which must accept an nxlog.LogData object as its only argument.
Call
This optional directive specifies the Python method to invoke. With this directive, you can call only specific
methods from your Python code. If the directive is not specified, the default method write_data is invoked.
133.16.2. Examples
1314
Chapter 133. Output Modules NXLog User Guide
This example shows an alerter implemented as an output module instance in Python. First, any event with
a normalized severity less than of 4/ERROR is dropped; see the Exec directive (xm_syslog and most other
modules set a normalized $SeverityValue field). Then the Python function generates a custom email and
sends it via SMTP.
nxlog.conf
1 <Output out>
2 Module om_python
3 PythonCode /opt/nxlog/etc/output.py
4 Exec if $SeverityValue < 4 drop();
5 </Output>
output.py (truncated)
from email.mime.text import MIMEText
import pprint
import smtplib
import socket
import nxlog
HOSTNAME = socket.gethostname()
FROM_ADDR = 'nxlog@{}'.format(HOSTNAME)
TO_ADDR = 'you@example.com'
def write_data(event):
nxlog.log_debug('Python alerter received event')
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module requires the xm_json extension module to be loaded in order to convert the
payload to JSON. If the $raw_event field is empty the fields will be automatically converted to
NOTE
JSON. If $raw_event contains a valid JSON string it will be sent as-is, otherwise a JSON record will
be generated in the following structure: {"raw_event":"escaped raw_event content"}
1315
NXLog User Guide Chapter 133. Output Modules
133.17.1. Configuration
The om_raijin module accepts the following directives in addition to the common module directives.
DBName
This mandatory directive specifies the name of the Raijin database containing the table where logs will be
stored.
DBTable
This mandatory directive specifies the name of the database table where log events will be inserted as JSON
records.
URL
This mandatory directive is comprised of the REST API URI that Raijin Server uses for receiving bulk, JSON-
formatted events via POST requests:
http://<RaijinServerHostname>:<port>/_bulk
If an om_raijin module instance contains multiple URL directives, the hosts will function as a cluster in NXLog
failover mode. This directive also supports HTTPS URLs. If the optional port number part of the URL (:<port>)
is not explicitly included in the URL, it will default to port 80 for HTTP (or port 443 for HTTPS). The /_bulk
endpoint part of the URL is required and will return a 400 Bad Request error if missing.
The Raijin Database REST API listens by default on port 2500. If you plan to use this directive
NOTE without explicitly specifying a port number, make sure the Raijin Database server is configured
to listen on the correct default port corresponding to this directive (either 80 or 443).
FlushInterval
This directive has been deprecated. Please use the BatchFlushInterval directive instead.
FlushLimit
This directive has been deprecated. Please use the BatchSize directive instead.
HTTPSAllowUntrusted
Accepts a boolean value to determine whether the remote connection should be allowed without certificate
verification. If set to TRUE, the connection will be allowed even if the remote HTTPS server presents an
unknown or self-signed certificate. The default value is FALSE; the remote HTTPS server must present a
trusted certificate.
HTTPSCADir
Specifies the path to a directory containing certificate authority (CA) certificates which will be used to check
the certificate of the remote HTTPS server. The certificate filenames in this directory must be in the OpenSSL
hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including
a copy of the certificate in this directory.
HTTPSCAFile
Specifies the path to the certificate authority (CA) certificate which will be used to validate the certificate of
the remote HTTPS server. To trust a self-signed certificate presented by the remote host (which is not signed
by a CA), provide that certificate instead.
1316
Chapter 133. Output Modules NXLog User Guide
HTTPSCertFile
Specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
Specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCRLDir
Specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted when
checking the certificate of the remote HTTPS server. The certificate filenames in this directory must be in the
OpenSSL hashed format.
HTTPSCRLFile
Specifies the path of the certificate revocation list (CRL) which will be consulted when checking the certificate
of the remote HTTPS server.
HTTPSKeyPass
Specifies a password for the certificate key file defined in HTTPSCertKeyFile. This directive is not needed for
passwordless private keys.
HTTPSSSLCipher
Sets the permitted SSL cipher list, overriding the default. Use the format described in the ciphers man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
HTTPSSSLCompression
Accepts a boolean value to determine whether data compression should be enabled. The compression
algorithm is based on the zlib compression library. If not specified, it defaults to FALSE (compression will be
disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on startup if
NOTE
compression support is missing. The generic deb/rpm packages are bundled with a zlib-enabled
libssl library.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
ProxyAddress
Specifies the IP address of the proxy server in case the module needs to connect to a Raijin Database server
through a proxy.
The om_raijin module supports only HTTP proxies, i.e. SOCKS4/SOCKS5 proxies are not
NOTE
supported.
ProxyPort
Specifies the port number required to connect to the proxy server.
SNI
Specifies the hostname used for Server Name Indication (SNI) in HTTPS mode.
1317
NXLog User Guide Chapter 133. Output Modules
133.17.2. Examples
Example 770. Sending logs to a Raijin Database server on localhost
This configuration reads log messages from a file and forwards them to a Raijin Database server deployed
on localhost.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Output raijin_local>
6 Module om_raijin
7 URL http://localhost:2500/_bulk
8 DBName logdb
9 DBTable logs
10 </Output>
Example 771. Sending logs to a Raijin Database cluster of servers in NXLog failover mode
This configuration sends logs to a cluster of Raijin Database servers configured for NXLog failover mode.
The cluster is comprised of three hosts: http://raijin-1.example.com:2500/_bulk,
http://localhost:2500/_bulk, and http://192.168.1.123:2500/_bulk.
nxlog.conf
1 <Extension json>
2 Module xm_json
3 </Extension>
4
5 <Output raijin_cluster>
6 Module om_raijin
7 URL http://raijin-1.example.com:2500/_bulk
8 URL http://localhost:2500/_bulk
9 URL http://192.168.1.123:2500/_bulk
10 DBName logdb
11 DBTable logs
12 </Output>
The input counterpart, im_redis, can be used to retrieve data from a Redis server.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.18.1. Configuration
The om_redis module accepts the following directives in addition to the common module directives. The Host
directive is required.
1318
Chapter 133. Output Modules NXLog User Guide
Host
This mandatory directive specifies the IP address or DNS hostname of the Redis server to connect to.
Channel
This directive is interpreted the same way as the Key directive (can be an expression which evaluates to a
string), except that its evaluated value will be used as the name of the Redis channel to which this module will
publish records. The usage of this directive is mutually exclusive with the usage of the LPUSH, RPUSH LPUSHX
and RPUSHX commands in the Command directive.
Command
This optional directive specifies the command to be used. The possible commands are LPUSH, RPUSH (the
default), LPUSHX, RPUSHX and PUBLISH.
Key
This specifies the Key used by the RPUSH command. It must be a string type expression. If the expression in
the Key directive is not a constant string (it contains functions, field names, or operators), it will be evaluated
for each event to be inserted. The default is nxlog. The usage of this directive is mutually exclusive with the
usage of the PUBLISH command in the Command directive.
OutputType
See the OutputType directive in the list of common module directives. If this directive is unset, the default
Dgram formatter function is used, which writes the value of $raw_event without a line terminator. To
preserve structured data Binary can be used, but it must also be set on the other end.
Port
This specifies the port number of the Redis server. The default is port 6379.
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
Nxlog.log_info(msg)
Send the message msg to the internal logger at DEBUG log level. This method does the same as the core
log_debug() procedure.
Nxlog.log_debug(msg)
Send the message msg to the internal logger at INFO log level. This method does the same as the core
log_info() procedure.
Nxlog.log_warning(msg)
Send the message msg to the internal logger at WARNING log level. This method does the same as the core
log_warning() procedure.
Nxlog.log_error(msg)
Send the message msg to the internal logger at ERROR log level. This method does the same as the core
log_error() procedure.
1319
NXLog User Guide Chapter 133. Output Modules
class Nxlog.LogData
This class represents an event. It is instantiated by NXLog and passed to the method specified by the Call
directive.
field_names()
This method returns an array with the names of all the fields currently in the event record.
get_field(name)
This method returns the value of the field name in the event.
set_field(name, value)
This method sets the value of field name to value.
133.19.1. Configuration
The om_ruby module accepts the following directives in addition to the common module directives. The
RubyCode directive is required.
RubyCode
This mandatory directive specifies a file containing Ruby code. The om_ruby instance will call the method
specified by the Call directive. The method must accept an Nxlog.LogData object as its only argument.
Call
This optional directive specifies the Ruby method to call. The default is write_data.
133.19.2. Examples
1320
Chapter 133. Output Modules NXLog User Guide
This example uses a Ruby script to choose an output file according to the severity of the event. Normalized
severity fields are added by most modules; see, for example, the xm_syslog $SeverityValue field.
TIP See Using Dynamic Filenames for a way to implement this functionality natively.
nxlog.conf
1 <Output out>
2 Module om_ruby
3 RubyCode ./modules/output/ruby/proc2.rb
4 Call write_data
5 </Output>
proc2.rb
def write_data event
if event.get_field('SeverityValue') >= 4
Nxlog.log_debug('Writing out high severity event')
File.open('tmp/high_severity', 'a') do |file|
file.write("#{event.get_field('raw_event')}\n")
file.flush
end
else
Nxlog.log_debug('Writing out low severity event')
File.open('tmp/low_severity', 'a') do |file|
file.write("#{event.get_field('raw_event')}\n")
file.flush
end
end
end
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.20.1. Configuration
The om_ssl module accepts the following directives in addition to the common module directives. The Host
directive is required.
Host
The module connects to the IP address or hostname defined in this directive. If additional hosts are specified
on new lines, the module works in a failover configuration. If a destination becomes unavailable, the module
automatically fails over to the next one. If the last destination becomes unavailable, the module fails over to
the first destination.
The port number can be defined by appending it at the end of the hostname or IP address using a colon as a
separator (host:port). For each destination with no port number defined here, the port number specified in
the Port directive is used. Port numbers defined here take precedence over any port number defined in the
Port directive.
1321
NXLog User Guide Chapter 133. Output Modules
Port
The module connects to the port number on the destination host defined in this directive. This configuration
is only used for any destination that does not have a port number specified in the Host directive. If no port is
configured for a destination in either directive, the default port is used, which is port 514.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the Host directive.
AllowUntrusted
This boolean directive specifies that the connection should be allowed without certificate verification. If set to
TRUE the connection will be allowed even if the remote server presents an unknown or self-signed certificate.
The default value is FALSE: the remote socket must present a trusted certificate.
CADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote socket. The certificate filenames in this directory must be in the OpenSSL
hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by including
a copy of the certificate in this directory.
CAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote socket. To trust a self-signed certificate presented by the remote (which is not signed by a CA),
provide that certificate instead.
CAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
This directive is only supported on Windows. This directive and the CADir and CAFile directives are mutually
exclusive.
CertFile
This specifies the path of the certificate file to be used for the SSL handshake.
CertKeyFile
This specifies the path of the certificate key file to be used for the SSL handshake.
CertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the CertFile and
CertKeyFile directives are mutually exclusive.
CRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote socket. The certificate filenames in this directory must be in the
OpenSSL hashed format.
CRLFile
This specifies the path of the certificate revocation list (CRL) which will be used to check the certificate of the
remote socket against.
KeyPass
With this directive, a password can be supplied for the certificate key file defined in CertKeyFile. This directive
is not needed for passwordless private keys.
1322
Chapter 133. Output Modules NXLog User Guide
LocalPort
This optional directive specifies the local port number of the connection. If this is not specified a random high
port number will be used, which is not always ideal in firewalled network environments.
OutputType
See the OutputType directive in the list of common module directives. The default is LineBased_LF.
Reconnect
This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in
every defined second. If it is not set, the reconnect interval will start at 1 second and doubles on every
attempt. If the duration of the successful connection is greater than the current reconnect interval, then the
reconnect interval will be reset to 1 sec.
SNI
This optional directive specifies the host name used for Server Name Indication (SNI).
SSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
SSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the SSLProtocol directive is
set to TLSv1.3. Use the same format as in the SSLCipher directive.
SSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
SSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols are allowed. Note that the OpenSSL library shipped by Linux distributions
may not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
TCPNoDelay
This boolean directive is used to turn off the network optimization performed by Nagle’s algorithm. Nagle’s
algorithm is a network optimization tweak that tries to reduce the number of small packets sent out to the
network, by merging them into bigger frames, and by not sending them to the other side of the session
before receiving the ACK. If this directive is unset, the TCP_NODELAY socket option will not be set.
133.20.2. Procedures
The following procedures are exported by om_ssl.
reconnect();
Force a reconnection. This can be used from a Schedule block to periodically reconnect to the server.
1323
NXLog User Guide Chapter 133. Output Modules
133.20.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration reads log messages from socket and sends them in the NXLog binary format to another
NXLog agent.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS tmp/socket
4 </Input>
5
6 <Output ssl>
7 Module om_ssl
8 Host example.com:23456
9 LocalPort 15014
10 CAFile %CERTDIR%/ca.pem
11 CertFile %CERTDIR%/client-cert.pem
12 CertKeyFile %CERTDIR%/client-key.pem
13 KeyPass secret
14 AllowUntrusted TRUE
15 OutputType Binary
16 </Output>
17
18 # Using the syntax prior to NXLog EE 5,
19 # where the port is defined in a separate directive.
20 #<Output ssl>
21 # Module om_ssl
22 # Host example.com
23 # Port 23456
24 # CAFile %CERTDIR%/ca.pem
25 # CertFile %CERTDIR%/client-cert.pem
26 # CertKeyFile %CERTDIR%/client-key.pem
27 # KeyPass secret
28 # AllowUntrusted TRUE
29 # OutputType Binary
30 #</Output>
This configuration sends logs to another NXLog agent in a failover configuration (multiple Hosts defined).
nxlog.conf
1 <Output ssl>
2 Module om_ssl
3 Host 192.168.1.2:23456
4 Host 192.168.1.3:23456
5 Host example.com:1514
6 CAFile %CERTDIR%/ca.pem
7 </Output>
1324
Chapter 133. Output Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.21.1. Configuration
The om_tcp module accepts the following directives in addition to the common module directives. The Host or
ListenAddr directive is required.
IMPORTANT Use either Host for the connect or ListenAddr for the listen mode.
Host
The module connects to the IP address or hostname defined in this directive. If additional hosts are specified
on new lines, the module works in a failover configuration. If a destination becomes unavailable, the module
automatically fails over to the next one. If the last destination becomes unavailable, the module fails over to
the first destination.
The port number can be defined by appending it at the end of the hostname or IP address using a colon as a
separator (host:port). For each destination with no port number defined here, the port number specified in
the Port directive is used. Port numbers defined here take precedence over any port number defined in the
Port directive. The default port is 514.
ListenAddr
The module listens for connections on this IP address or DNS hostname. The default is localhost. Add the
port number to listen on to the end of a host using a colon as a separator (host:port).
When the Host directive is used with a hostname instead of an IP address, the the hostname
will be resolved to an IP address for each new connection. If a resolver, e.g. DNS, returns
multiple IP addresses, only the first IP address will be used. If a single output instance is
configured with multiple Host directives, these hosts are accessed in failover mode. If a Host
NOTE
directive is configured with a hostname, it will send to that host as long a usable connection can
be established with the IP address it resolves to. Should that connection fail, it will then resolve
the IP address of the next hostname in the list and attempt to establish a connection with it.
Each time a failure occurs, the next Host directive in the list is tried.
1325
NXLog User Guide Chapter 133. Output Modules
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will be
an IPv6 address, meaning that any applications that act as clients to a listening module (and the
systems they run on) will also have to have IPv6 support enabled, and they must be able to
connect to the same IPv6 address. Output client modules achieve this requirement through
failover. For third-party client applications, the configuration details are application-specific, but
they should have a similar ability to detect which IP address the server is listening on, when they
use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a system
that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may be set to
an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive approach.
On most Linux-based systems, this can be achieved through the /etc/gai.conf configuration
file. On BSD-based systems, the ip6addrctl command can be used. Windows is more limited
and can only be configured to prioritize IPv4 over IPv6 addresses for ALL hostnames resolved on
the system, by setting the the following registry value to 0x20 (see this link for other possible
values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disable
dComponents
This limitation will be addressed with a future release, by making listening modules bind to all
available IPv4/IPv6 addresses that a hostname resolves to.
Port
The module connects to the port number on the destination host defined in this directive. This configuration
is only used for any destination that does not have a port number specified in the Host directive. If no port is
configured for a destination in either directive, the default port is used, which is port 514. Alternatively, if
Listen is set to TRUE, the module listens for connections on this port.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the Host directive.
Listen
If TRUE, this boolean directive specifies that om_tcp should listen for connections at the local address
specified by the Host and Port directives rather than opening a connection to the address. The default is
FALSE: om_tcp connects to the specified address.
The Listen directive will become deprecated from NXLog EE 6.0. Use either Host for
IMPORTANT
connect mode or ListenAddr for listen mode.
LocalPort
This optional directive specifies the local port number of the connection. This directive only applies if Listen is
set to FALSE. If this is not specified a random high port number will be used, which is not always ideal in
firewalled network environments.
OutputType
See the OutputType directive in the list of common module directives. The default is LineBased_LF.
1326
Chapter 133. Output Modules NXLog User Guide
QueueInListenMode
If set to TRUE, this boolean directive specifies that events should be queued if no client is connected. If this
module’s buffer becomes full, the preceding module in the route will be paused or events will be dropped,
depending on whether FlowControl is enabled. This directive only applies if Listen is set to TRUE. The default
is FALSE: om_tcp will discard events if no client is connected.
Reconnect
This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in
every defined second. If it is not set, the reconnect interval will start at 1 second and doubles on every
attempt. If the duration of the successful connection is greater than the current reconnect interval, then the
reconnect interval will be reset to 1 sec.
TCPNoDelay
This boolean directive is used to turn off the network optimization performed by Nagle’s algorithm. Nagle’s
algorithm is a network optimization tweak that tries to reduce the number of small packets sent out to the
network, by merging them into bigger frames, and by not sending them to the other side of the session
before receiving the ACK. If this directive is unset, the TCP_NODELAY socket option will not be set.
133.21.2. Procedures
The following procedures are exported by om_tcp.
reconnect();
Force a reconnection. This can be used from a Schedule block to periodically reconnect to the server.
133.21.3. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
With this configuration, NXLog will read log messages from socket and forward them via TCP.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Output tcp>
7 Module om_tcp
8 Host 192.168.1.1:1514
9 </Output>
10
11 # Using the syntax prior to NXLog EE 5,
12 # where the port is defined in a separate directive.
13 #<Output tcp>
14 # Module om_tcp
15 # Host 192.168.1.1
16 # Port 1514
17 #</Output>
18
19 <Route uds_to_tcp>
20 Path uds => tcp
21 </Route>
1327
NXLog User Guide Chapter 133. Output Modules
This configuration sends logs via TCP in a failover configuration (multiple Hosts defined).
nxlog.conf
1 <Output tcp>
2 Module om_tcp
3 Host 192.168.1.2:1514
4 Host 192.168.1.3:1234
5 Host example.com:1234
6 </Output>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.22.1. Configuration
The om_udp module accepts the following directives in addition to the common module directives. The Host
directive is required.
Host
The module connects to the IP address or hostname defined in this directive. If additional hosts are specified
on new lines, the module works in a failover configuration. If a destination becomes unavailable, the module
automatically fails over to the next one. If the last destination becomes unavailable, the module fails over to
the first destination.
When the Host directive is used with a hostname instead of an IP address, the the hostname
will be resolved to an IP address for each new connection. If a resolver, e.g. DNS, returns
multiple IP addresses, only the first IP address will be used. If a single output instance is
configured with multiple Host directives, these hosts are accessed in failover mode. If a Host
NOTE
directive is configured with a hostname, it will send to that host as long a usable connection
can be established with the IP address it resolves to. Should that connection fail, it will then
resolve the IP address of the next hostname in the list and attempt to establish a connection
with it. Each time a failure occurs, the next Host directive in the list is tried.
1328
Chapter 133. Output Modules NXLog User Guide
When a module is listening for and accepting incoming connections (i.e. acting as a server), it
will bind to the first IP address that is exposed by the system for the hostname given in the
ListenAddr (or similar) directive. On most systems that have IPv6 support, this address will
be an IPv6 address, meaning that any applications that act as clients to a listening module
(and the systems they run on) will also have to have IPv6 support enabled, and they must be
able to connect to the same IPv6 address. Output client modules achieve this requirement
through failover. For third-party client applications, the configuration details are application-
specific, but they should have a similar ability to detect which IP address the server is
listening on, when they use a hostname to connect to the server.
For client applications that don’t support IPv6, when the listening module is running on a
system that prioritizes IPv6 addresses, the ListenAddr directive of the listening module may
be set to an IPv4 address (like 0.0.0.0), to avoid the behavior and requirements described
above.
NOTE
Alternatively, the server-side system may be configured to prioritize IPv4 addresses for the
ListenAddr hostname, although this is a more complicated and potentially intrusive
approach. On most Linux-based systems, this can be achieved through the /etc/gai.conf
configuration file. On BSD-based systems, the ip6addrctl command can be used. Windows
is more limited and can only be configured to prioritize IPv4 over IPv6 addresses for ALL
hostnames resolved on the system, by setting the the following registry value to 0x20 (see
this link for other possible values):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Disa
bledComponents
This limitation will be addressed with a future release, by making listening modules bind to
all available IPv4/IPv6 addresses that a hostname resolves to.
The port number can be defined by appending it at the end of the hostname or IP address using a colon as a
separator (host:port). For each destination with no port number defined here, the port number specified in
the Port directive is used. Port numbers defined here take precedence over any port number defined in the
Port directive. The default port is 514.
Because of the nature of the UDP protocol and how ICMP messages are handled by various
network devices, the failover functionality in this module is considered as "best effort".
WARNING
Detecting hosts going offline is not supported. Detecting the receiving service being
stopped - while the host stays up is supported.
Port
The module connects to the port number on the destination host defined in this directive. This configuration
is only used for any destination in the Host directive which does not have a port specified. If no port is
configured for a destination in either directive, the default port is used, which is port 514.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the Host directive.
LocalPort
This optional directive specifies the local port number of the connection. If this is not specified a random high
port number will be used, which is not always ideal in firewalled network environments.
OutputType
See the OutputType directive in the list of common module directives. If this directive is not specified, the
default is Dgram.
1329
NXLog User Guide Chapter 133. Output Modules
Reconnect
This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in
every defined second. If it is not set, the reconnect interval will start at 1 second and doubles on every
attempt. If the duration of the successful connection is greater than the current reconnect interval, then the
reconnect interval will be reset to 1 sec.
SockBufSize
This optional directive sets the socket buffer size (SO_SNDBUF) to the value specified. If this is not set, the
operating system default is used.
133.22.2. Examples
Pre-v5 syntax examples are included, they will become invalid with NXLog EE 6.0.
This configuration reads log messages from socket and forwards them via UDP.
nxlog.conf
1 <Input uds>
2 Module im_uds
3 UDS /dev/log
4 </Input>
5
6 <Output udp>
7 Module om_udp
8 Host 192.168.1.1:1514
9 LocalPort 1555
10 </Output>
11 # Using the syntax prior to NXLog EE 5,
12 # where the port is defined in a separate directive.
13 #<Output udp>
14 # Module om_udp
15 # Host 192.168.1.1
16 # Port 1514
17 # LocalPort 1555
18 #</Output>
19
20 <Route uds_to_udp>
21 Path uds => udp
22 </Route>
This configuration sends logs via UDP in a failover configuration (multiple Hosts defined).
nxlog.conf
1 <Output udp>
2 Module om_udp
3 Host 192.168.1.2:1514
4 Host 192.168.1.3:1514
5 Host example.com:1234
6 </Output>
1330
Chapter 133. Output Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module is very similar to the om_udp module and can be used as a drop-in replacement. The SpoofAddress
configuration directive can be used to set the address if necessary. The UDP datagram will be sent with the local
IP address if the IP address to be spoofed is invalid. The source port in the UDP datagram will be set to the port
number of the local connection (the port number is not spoofed).
The network input modules (im_udp, im_tcp, and im_ssl) all set the $MessageSourceAddress field, and this value
will be used when sending the UDP datagrams (unless SpoofAddress is explicitly set to something else). This
allows logs to be collected over reliable and secure transports (like SSL), while the om_udpspoof module is only
used for forwarding to the destination server that requires spoofed UDP input.
133.23.1. Configuration
The om_udpspoof module accepts the following directives in addition to the common module directives. The Host
directive is required.
Host
The module sends UDP datagrams to the IP address or hostname defined in this directive. If additional hosts
are specified on new lines, the module works in a failover configuration. If a destination becomes unavailable,
the module automatically fails over to the next one. If the last destination becomes unavailable, the module
fails over to the first destination.
The port number can be defined by appending it at the end of the hostname or IP address using a colon as a
separator (host:port). For each destination with no port number defined here, the port number specified in
the Port directive is used. Port numbers defined here take precedence over any port number defined in the
Port directive. The default port is 514.
Port
The module sends UDP packets to this port. The default port is 514 if this directive is not specified.
The Port directive will become deprecated from NXLog EE 6.0. After that, the port can
IMPORTANT
only be defined in the Host directive.
LocalPort
This optional directive specifies the local port number of the connection. If this is not specified a random high
port number will be used which is not always ideal in firewalled network environments.
MTU
This directive can be used to specify the maximum transfer size of the IP data fragments. If this value exceeds
the MTU size of the sending interface, an error may occur and the packet be dropped. The default MTU value
is 1500.
OutputType
See the OutputType directive in the list of common module directives. If this directive is not specified, the
default is Dgram.
1331
NXLog User Guide Chapter 133. Output Modules
SockBufSize
This optional directive sets the socket buffer size (SO_SNDBUF) to the value specified. If this is not set, the
operating system default is used.
SpoofAddress
This directive is optional. The IP address rewrite takes place depending on how this directive is specified.
Expression
The expression specified here will be evaluated for each message to be sent. Normally this can be a field
name, but anything is accepted which evaluates to a string or an ipaddr type. For example, SpoofAddress
$MessageSourceAddress has the same effect as when SpoofAddress is not set.
133.23.2. Examples
Old syntax examples are included, they will become invalid with NXLog EE 6.0.
The im_tcp module will accept log messages via TCP and will set the $MessageSourceAddress field for each
event. This value will be used by om_udpspoof to set the UDP source address when sending the data to
logserver via UDP.
nxlog.conf
1 <Input tcp>
2 Module im_tcp
3 ListenAddr 0.0.0.0:1514
4 </Input>
5
6 <Output udpspoof>
7 Module om_udpspoof
8 Host logserver.example.com:1514
9 </Output>
10
11 # Using the syntax used before NXLog EE 5,
12 # where the port is defined in a separate directive.
13 #<Output udpspoof>
14 # Module om_udpspoof
15 # Host logserver.example.com
16 # Port 1514
17 #</Output>
18
19 <Route tcp_to_udpspoof>
20 Path tcp => udpspoof
21 </Route>
1332
Chapter 133. Output Modules NXLog User Guide
Example 780. Forwarding Log Messages with Spoofed IP Address from Multiple Sources
This configuration accepts log messages via TCP and UDP, and also reads messages from a file. Both im_tcp
and im_udp set the $MessageSourceAddress field for incoming messages, and in both cases this is used to
set $sourceaddr. The im_file module instance is configured to set the $sourceaddr field to 10.1.2.3 for
all log messages. Finally, the om_udpspoof output module instance is configured to read the value of the
$sourceaddr field for spoofing the UDP source address.
nxlog.conf (truncated)
1 <Input tcp>
2 Module im_tcp
3 ListenAddr 0.0.0.0:1514
4 Exec $sourceaddr = $MessageSourceAddress;
5 </Input>
6
7 <Input udp>
8 Module im_udp
9 ListenAddr 0.0.0.0:1514
10 Exec $sourceaddr = $MessageSourceAddress;
11 </Input>
12
13 <Input file>
14 Module im_file
15 File '/var/log/myapp.log'
16 Exec $sourceaddr = 10.1.2.3;
17 </Input>
18
19 <Output udpspoof>
20 Module om_udpspoof
21 Host 10.0.0.1:1514
22 SpoofAddress $sourceaddr
23 </Output>
24
25 # Using the syntax prior to NXLog EE 5,
26 # where the port is defined in a separate directive.
27 #<Input tcp>
28 # Module im_tcp
29 [...]
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
This module supports SOCK_DGRAM type sockets only. SOCK_STREAM type sockets may be
NOTE
supported in the future.
133.24.1. Configuration
The om_uds module accepts the following directives in addition to the common module directives.
1333
NXLog User Guide Chapter 133. Output Modules
UDS
This specifies the path of the Unix domain socket. The default is /dev/log.
Group
Use this directive to set the group ownership for the created socket or pipe or file. By default, this is the group
NXLog is running as, (which may be specified by the global Group directive). This directive is not currently
supported on Windows.
Perms
This directive specifies the permissions to use for the created socket or pipe or file. This must be a four-digit
octal value beginning with a zero. By default, OS default permissions will be set. This directive is not currently
supported on Windows.
UDSType
This directive specifies the domain socket type. Supported values are dgram, stream, and auto. The default is
auto.
User
Use this directive to set the user ownership for the created socket or pipe or file. By default, this is the user
NXLog is running as (which may be specified by the global User directive). This directive is not currently
supported on Windows.
OutputType
See the OutputType directive in the list of common module directives. If UDSType is set to Dgram or is set to
auto and a SOCK_DGRAM type socket is detected, this defaults to Dgram. If UDSType is set to stream or is set
to auto and a SOCK_STREAM type socket is detected, this defaults to LineBased.
133.24.2. Examples
Example 781. Using the om_uds Module
This configuration reads log messages from a file, adds BSD Syslog headers with default fields, and writes
the messages to socket.
nxlog.conf
1 <Extension syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Input file>
6 Module im_file
7 File "/var/log/custom_app.log"
8 </Input>
9
10 <Output uds>
11 Module om_uds
12 # Defaulting Syslog fields and creating Syslog output
13 Exec parse_syslog_bsd(); to_syslog_bsd();
14 UDS /dev/log
15 </Output>
16
17 <Route file_to_uds>
18 Path file => uds
19 </Route>
1334
Chapter 133. Output Modules NXLog User Guide
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.25.1. Configuration
The om_webhdfs module accepts the following directives in addition to the common module directives. The File
and URL directives are required.
File
This mandatory directive specifies the name of the destination file. It must be a string type expression. If the
expression in the File directive is not a constant string (it contains functions, field names, or operators), it will
be evaluated before each request is dispatched to the WebHDFS REST endpoint (and after the Exec is
evaluated). Note that the filename must be quoted to be a valid string literal, unlike in other directives which
take a filename argument.
URL
This mandatory directive specifies the URL of the WebHDFS REST endpoint where the module should POST
the event data. The module operates in plain HTTP or HTTPS mode depending on the URL provided, and
connects to the hostname specified in the URL. If the port number is not explicitly indicated in the URL, it
defaults to port 80 for HTTP and port 443 for HTTPS.
FlushInterval
The module will send the data to the endpoint defined in URL after this amount of time in seconds, unless
FlushLimit is reached first. This defaults to 5 seconds.
FlushLimit
When the number of events in the output buffer reaches the value specified by this directive, the module will
send the data to the endpoint defined in URL. This defaults to 500 events. The FlushInterval may trigger
sending the write request before this limit is reached if the log volume is low to ensure that data is sent
promptly.
HTTPSAllowUntrusted
This boolean directive specifies that the connection should be allowed without certificate verification. If set to
TRUE, the connection will be allowed even if the remote HTTPS server presents an unknown or self-signed
certificate. The default value is FALSE: the remote must present a trusted certificate.
HTTPSCADir
This specifies the path to a directory containing certificate authority (CA) certificates, which will be used to
check the certificate of the remote HTTPS server. The certificate filenames in this directory must be in the
OpenSSL hashed format. A remote’s self-signed certificate (which is not signed by a CA) can also be trusted by
including a copy of the certificate in this directory.
HTTPSCAFile
This specifies the path of the certificate authority (CA) certificate, which will be used to check the certificate of
the remote HTTPS server. To trust a self-signed certificate presented by the remote (which is not signed by a
CA), provide that certificate instead.
HTTPSCAThumbprint
This optional directive specifies the certificate thumbprint of the certificate authority (CA), which is used to
look up the CA certificate from the Windows certificate store. The hexadecimal fingerprint string can be
copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are automatically removed.
1335
NXLog User Guide Chapter 133. Output Modules
This directive is only supported on Windows. This directive and the HTTPSCADir and HTTPSCAFile directives
are mutually exclusive.
HTTPSCertFile
This specifies the path of the certificate file to be used for the HTTPS handshake.
HTTPSCertKeyFile
This specifies the path of the certificate key file to be used for the HTTPS handshake.
HTTPSCertThumbprint
This optional directive specifies the certificate thumbprint to be used for the SSL handshake. The hexadecimal
fingerprint string can be copied straight from Windows Certificate Manager (certmgr.msc), whitespaces are
automatically removed. This directive is only supported on Windows. This directive and the HTTPSCertFile and
HTTPSCertKeyFile directives are mutually exclusive.
HTTPSCRLDir
This specifies the path to a directory containing certificate revocation lists (CRLs), which will be consulted
when checking the certificate of the remote HTTPS server. The certificate filenames in this directory must be
in the OpenSSL hashed format.
HTTPSCRLFile
This specifies the path of the certificate revocation list (CRL), which will be consulted when checking the
certificate of the remote HTTPS server.
HTTPSKeyPass
With this directive, a password can be supplied for the certificate key file defined in HTTPSCertKeyFile. This
directive is not needed for passwordless private keys.
HTTPSSSLCipher
This optional directive can be used to set the permitted SSL cipher list, overriding the default. Use the format
described in the ciphers(1ssl) man page.
HTTPSSSLCiphersuites
This optional directive can be used to define the permitted SSL cipher list in case the HTTPSSSLProtocol
directive is set to TLSv1.3. Use the same format as in the HTTPSSSLCipher directive.
HTTPSSSLCompression
This boolean directive allows you to enable data compression when sending data over the network. The
compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults
to FALSE (the compression is disabled).
Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and
may not support the zlib compression mechanism. The module will emit a warning on
NOTE
startup if the compression support is missing. The generic deb/rpm packages are bundled
with a zlib-enabled libssl library.
HTTPSSSLProtocol
This directive can be used to set the allowed SSL/TLS protocol(s). It takes a comma-separated list of values
which can be any of the following: SSLv2, SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. By default, the
TLSv1.2 and TLSv1.3 protocols is allowed. Note that the OpenSSL library shipped by Linux distributions may
not support SSLv2 and SSLv3, and these will not work even if enabled with this directive.
QueryParam
This configuration option can be used to specify additional HTTP Query Parameters such as BlockSize. This
option may be used to define more than one parameter:
1336
Chapter 133. Output Modules NXLog User Guide
QueryParam blocksize 42
QueryParam destination /foo
133.25.2. Examples
Example 782. Sending Logs to a WebHDFS Server
This example output module instance forwards messages to the specified URL and file using the WebHDFS
protocol.
nxlog.conf
1 <Output hdfs>
2 Module om_webhdfs
3 URL http://hdfsserver.domain.com/
4 File "myfile"
5 QueryParam blocksize 42
6 QueryParam destination /foo
7 </Output>
To examine the supported platforms, see the list of installer packages in the Available Modules
NOTE
chapter.
133.26.1. Configuration
The om_zmq module accepts the following directives in addition to the common module directives. The Address,
ConnectionType, Port, and SocketType directives are required.
Address
This directive specifies the ZeroMQ socket address.
ConnectionType
This mandatory directive specifies the underlying transport protocol. It may be one of the following: TCP, PGM,
or EPGM.
Port
This directive specifies the ZeroMQ socket port.
SocketType
This mandatory directive defines the type of the socket to be used. It may be one of the following: REP,
ROUTER, PUB, XPUB, or PUSH. This must be set to PUB if ConnectionType is set to PGM or EPGM.
Interface
This directive specifies the ZeroMQ socket interface.
Listen
If this boolean directive is set to TRUE, om_zmq will bind to the Address specified and listen for connections. If
FALSE, om_zmq will connect to the Address. The default is FALSE.
1337
NXLog User Guide Chapter 133. Output Modules
OutputType
See the OutputType directive in the list of common module directives. The default value is Dgram.
SockOpt
This directive can be used to set ZeroMQ socket options. For example, SockOpt ZMQ_BACKLOG 2000. This
directive may be used more than once to set multiple options.
133.26.2. Examples
Example 783. Using the om_zmq Module
This example configuration reads log messages from file and forwards them via ZeroMQ PUSH socket over
TCP.
nxlog.conf
1 <Input file>
2 Module im_file
3 File "/var/log/messages"
4 </Input>
5
6 <Output zmq>
7 Module om_zmq
8 SocketType PUSH
9 ConnectionType TCP
10 Address 10.0.0.1
11 Port 1514
12 </Output>
13
14 <Route file_to_zmq>
15 Path file => zmq
16 </Route>
1338
NXLog User Guide
NXLog Manager
1339
NXLog User Guide Chapter 134. Introduction
The NXLog Manager is a log management solution which provides a web based administration interface to
configure all parameters the log collection and enables the log management administrator to efficiently monitor
and manage the NXLog agents securely from a central console. The NXLog Manager is able to operate in
clustered mode if the network topology requires multiple manager nodes.
134.1. Requirements
To use and administer NXLog Manager, the user is expected to be familiar with the following:
There are known problems with Microsoft Internet Explorer and it is not supported.
134.2. Architecture
NXLog Manager web application
NXLog Manager is a java based web application which can communicate with the NXLog agents.
NXLog
NXLog is the log collector with no frontend. NXLog can be used in both server and client mode. When running
as a client (agent), NXLog will collect local log sources and will forward the data over the network. NXLog can
also operate as a server to store messages locally or as a relay to forward messages to another instance.
The architecture of NXLog Manager allows log collection to function even if NXLog Manager is not running or the
control channel is not functional, thus an NXLog Manager upgrade will not cause any interruption to the log
collection process.
1340
Chapter 135. System Requirements NXLog User Guide
Minimum Recommended
Processor cores 2 2
The NXLog Manager memory/RAM requirement increases by 2 MB for each managed agent. For
example, if an NXLog Manager instance monitors 100 agents, the recommended memory/RAM
requirement is 4296 MB. These requirements are in addition to the operating system’s
NOTE
requirements, and the requirements should be combined cumulatively with the NXLog
Enterprise Edition’s System Requirements for systems running both NXLog Enterprise Edition
and NXLog Manager.
1341
NXLog User Guide Chapter 136. Supported Platforms
CentOS 6 java-1.8.0-openjdk-headless
CentOS 7 java-1.8.0-openjdk-headless
Debian 8 openjdk-7-jre
Debian 9 openjdk-8-jre
NOTE
NXLog Manager is only supported on the 64-bit version of Java.
1342
Chapter 137. Installation NXLog User Guide
or
If Java is not installed or the correct version of Java is not selected, NXLog Manager will
NOTE
refuse to start.
3. Download the appropriate NXLog Manager installation file from the NXLog website.
4. Transfer the file to the target server.
5. Install the downloaded package with the following command:
# dpkg -i nxlog-manager_X.X.XXX_.deb
6. If dpkg returned errors about uninstalled dependencies, use apt-get to install them and complete the NXLog
Manager installation.
# apt-get -f install
Make sure that your hostname and DNS settings are setup correctly, to avoid problems with
NOTE
NXLog Manager. Refer to host setup common issues for more information.
To select the default version of Java on your system, use the command:
To access the web interface from another host, the firewall rules should allow access to port 9090 from the
external network:
1343
NXLog User Guide Chapter 137. Installation
# iptables -F
Make sure that your hostname and DNS settings are setup correctly, to avoid problems
WARNING
with NXLog Manager. Refer to host setup common issues for more information.
To build, (re)create and start the container execute the following command.
$ docker-compose up -d
By default the Dockerized NXLog Manager listens on port 9090. The port configuration is defined as
HOST:CONTAINER. To change this setting, edit the docker-compose.yml file by modifying the HOST port number
preceding the colon (9080 in the below example). The port number for the CONTAINER, following the colon
should be left at 9090.
docker-compose.yml
ports:
- "4041:4041"
- "9080:9090"
restart: always
To change the default memory allocation for NXLog Manager, the Java invocation (CMD) in the included
Dockerfile needs to be updated. Options other than -Xms and -Xmx should not be changed.
Dockerfile
CMD java -Xms1g -Xmx2g ...
For more information managing the allocated memory size for NXLog Manager, see the
NOTE
Increasing the Heap Size for NXLog Manager section.
For the configuration change to take effect, the Docker container needs to be stopped and started with the
following commands.
$ sudo docker-compose up
The NXLog Manager Docker container includes MySQL. Therefore there is no need to install and
NOTE configure MySQL separately. After installing, you may proceed with the NXLog Manager
configuration.
1344
Chapter 137. Installation NXLog User Guide
2. Install NXLog Manager from the DEB or RPM package, depending on the operating system. At least the EC2
"t2.small" instance type is recommended.
3. Edit /opt/nxlog-manager/db_init/db.conf. Add the RDS hostname and the database master
username/password to the MYSQLOPTS variable.
4. Execute the database initialization script. This should only be done once for the cluster!
# cd /opt/nxlog-manager/db_init
# ./dbinit.sh
5. Configure NXLog Manager to run in a distributed manner by editing the INSTANCE_MODE in /opt/nxlog-
manager/conf/nxlog-manager.conf.
INSTANCE_MODE=distributed-manager
Set JMSBrokerAddress to the instance private IP, used for communications inside the VPC.
<Set name="jmsBrokerAddress">172.31.9.100</Set>
1345
NXLog User Guide Chapter 137. Installation
<Set name="jdbcUrl">jdbc:mysql://RDS_INSTANCE.rds.amazonaws.com:3306/nxlog-
manager5?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
&autoReconnect=true</Set>
<New class="com.nxsec.log4ensics.data.bean.common.Log4ensicsDatabaseAccess">
<Set name="databaseName">nxlog-manager5</Set>
<Set name="username">nxlog-manager5</Set>
<Set name="password">nxlog-manager5</Set>
<Set name="location">RDS_INSTANCE.rds.amazonaws.com:3306</Set>
</New>
7. From the EC2 service dashboard, go to Security Groups. Allow TCP traffic on ports 20000 and 34200-34300
to allow JMS communications inside the security group created for NXLog Manager EC2 instances. Please
note that the security group ID should be used in the Source field.
1. From the EC2 service dashboard go to Load Balancing. Click [Create Load Balancer]. Select
Application Load Balancer and click [Create].
2. Configure the load balancer. Set the listener to use port 9090 (the same as the backend application).
1346
Chapter 137. Installation NXLog User Guide
3. Choose availability zones and configure a security group in order to limit access to the load balancer.
Configure routing to forward requests to port 9090.
4. Configure the health check path to /nxlog-manager. In Advanced health check settings, set the Success
codes to 302, as it is the default reply from the nxlog-manager service.
1347
NXLog User Guide Chapter 137. Installation
5. Select instances for the target group and finish creation of the load balancer. From the EC2 dashboard go to
Target Groups (in the LOAD BALANCING section). Select the target group and click [Edit attributes].
Enable Stickiness to prevent breaking user sessions. This will create a cookie named AWSALB with encrypted
contents.
6. Edit security groups to allow traffic between the load balancer and its target group. After this step, the
solution is ready.
1348
Chapter 137. Installation NXLog User Guide
NOTE MariaDB has replaced MySQL in more recent versions such as Debian (Stretch).
NOTE systemctl has replaced service in more recent versions such as Debian (Stretch).
nxlog-manager.conf
INSTANCE_MODE=distributed-manager
The NXLog Manager instances communicate over JMS (Java Message Service) API. Please set the public IP
address of the interface in /opt/nxlog-manager/conf/jetty-env.xml and make sure to replace the value
127.0.0.1 set for JMSBrokerAddress with the public IP:
1349
NXLog User Guide Chapter 137. Installation
jetty-env.xml
<Set name="jmsBrokerAddress">10.0.0.42</Set>
To operate in clustered mode, NXLog Manager requires MariaDB Galera Cluster v5.5.
# apt-get update
galera.cnf
[mysqld]
#mysql settings
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
query_cache_size=0
query_cache_type=0
bind-address=0.0.0.0
#galera settings
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="my_wsrep_cluster"
wsrep_cluster_address="gcomm://<IP1>,<IP2>,...,<IPN>"
wsrep_sst_method=rsync
Here IP1,…,IPN are the addresses of all nodes in the Galera cluster. Distribute this file to all nodes.
On node1:
On node2:
1350
Chapter 137. Installation NXLog User Guide
On nodeN:
On node1:
On node2:
On nodeN:
To add the MariaDB repository create the file /etc/yum.repos.d/mariadb.repo with the following content:
mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
You can download and install 'socat' here in case of the following error:
To create an initial MariaDB configuration, execute these commands and follow the instructions:
1351
NXLog User Guide Chapter 137. Installation
On each cluster node, edit /etc/my.cnf.d/server.cnf and make sure to add the following content:
server.cnf
[mysqld]
pid-file = /var/lib/mysql/mysqld.pid
port = 3306
[mariadb]
query_cache_size=0
binlog_format=ROW
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://IP2,...,IPN
wsrep_cluster_name='cluster1'
wsrep_node_address='IP1'
wsrep_node_name='db1'
wsrep_sst_method=rsync
wsrep_sst_auth=root:password
# /etc/init.d/mysql bootstrap
Bootstrapping the cluster.. Starting MySQL.... SUCCESS!
SELinux may block MariaDB from binding on the cluster port and it will print the following error in the MariaDB
error log in /etc/selinux/config:
This can be solved by running setenforce 0 and setting SELINUX=permissive. Then repeat the above
installation steps on each node.
1352
Chapter 137. Installation NXLog User Guide
If you are installing NXLog Manager in clustered mode, this only needs to be executed once for
NOTE
the DB cluster - i.e. only on the first node.
If a root password is set for the MySQL/MariaDB database, edit /opt/nxlog-manager/db_init/my.cnf and
provide the password:
my.cnf
[client]
password=
Execute the database initialization script (only once for the Galera cluster):
$ cd /opt/nxlog-manager/db_init
# ./dbinit.sh
To ensure that the MySQL/MariaDB database is started on boot on CentOS/RHEL distributions, execute the
following command:
# chkconfig mysqld on
or
# chkconfig mariadb on
The size of the maximum packet allowed by MySQL/MariaDB can be raised by adding the following to the global
configuration options, typically /etc/my.cnf or /etc/mysql/my.cnf. Raising the size of the maximum allowed
packet will eliminate any max_allowed_packet exceeded error messages from the log files.
my.cnf
[mysqld]
max_allowed_packet = 256M
2. Connect to the web interface. Launch a web browser and navigate to http://x.x.x.x:9090/nxlog-manager in
order to make sure the start was successful.
Check the logs under /opt/nxlog-manager/logs if you are having trouble accessing the web
NOTE
interface.
Running NXLog Manager directly can provide additional information if the NXLog Manager
NOTE
service fails to start. Run cd /opt/nxlog-manager/bin/, then ./jetty.sh.
1353
NXLog User Guide Chapter 137. Installation
# yum install dialog apr perl perl-DBI perl-JSON openssl pcre zlib expat libcap libdbi
Simply click Next, accept the license agreement, then finish the installation.
1354
Chapter 137. Installation NXLog User Guide
During the first login of the admin user, NXLog Manager generates the encryption key. The key is shared among
all administrative accounts with ROLE_ADMINISTRATOR and/or ROLE_CERTIFICATE roles within the same
application session.
The application session is an instance of the started service which is always new at each start of NXLog Manager.
The encryption key encrypts private keys of user accounts. The application session cannot function without the
key. This is the reason why it should always be available either in the system database and/or in the application
session.
After each administrator login, this key is decrypted and stored in the application session.
For each new administrative user as well as the admin user, during the first login the key is copied, encrypted
with the user’s password, and stored in the NXAuthSettings table. After a user changes its password, the key is
encrypted with the new password. Additional details about encryption of certificates are provided in the
Certificates Encryption section.
If for any reason it is required, the encryption of private keys can be disabled. See the
content about the Don’t encrypt agent manager’s private key checkbox in the Agent
WARNING Manager Configuration section. If this checkbox is unchecked, encryption is applied and the
suggestions from the Best Practices for Managing Encryption Keys section below are
recommended to be followed.
• The NXLog Manager instance should always have at least one account with the assigned
ROLE_ADMINISTRATOR and/or ROLE_CERTIFICATE roles. Otherwise it does not function.
• It is recommended to keep the default admin account in the system. Instead of deleting, it can be kept in a
disabled state and used only in specific situations. This account can provide the application session with the
encryption key after NXLog Manager is restarted.
If keeping the admin account is not possible, another account with the ROLE_ADMINISTRATOR and/or
ROLE_CERTIFICATE roles should be created and logged into the same application session with the admin.
This action will share the encryption key from the admin to the new account and makes it available for all
future accounts. After this action is taken, the admin account can be deleted because the new administrative
account can now log in and share the encryption key within the application session.
• It is strongly recommended to have a backup for the NXLog Manager database while taking any actions with
administrative accounts.
• After each restart of NXLog Manager, at least one administrative account with the ROLE_ADMINISTRATOR
and/or ROLE_CERTIFICATE roles should always be available for login, decryption of the encryption key, and
sharing it within the application session. If the only administrative account is deleted or unassigned from its
roles, the decryption key is also deleted from the application session and the database.
1355
NXLog User Guide Chapter 137. Installation
WARNING This situation immediately leads to an unrecoverable loss of system and data control.
• Accounts with the ROLE_ADMINISTRATOR and/or ROLE_CERTIFICATE roles should be assigned only to trusted
system administrators. Other users should employ other roles which are available in NXLog Manager.
• Each new account with the ROLE_ADMINISTRATOR and/or ROLE_CERTIFICATE roles should share the same
application session with the other administrative accounts. There is no point in logging into another session
if it has no encryption key from a logged user.
• The same encryption key should be available for all administrative accounts on the running instance of
NXLog Manager.
In case all administrative accounts are deleted, the decryption key is also destroyed and
WARNING
NXLog Manager terminates. This immediately leads to a complete data and system loss.
To set how long the NXLog Manager UI waits before requiring user re-authentication, find the
screenLockIdleTimeB block in conf/jetty-env.xml and then set screenLockIdleTime to the desired value.
To control the active session length, find the applicationSettingsB block and then set sessionTimeout to the
desired value. Note that sessionTimeout must be larger than screenLockIdleTime for screen lock to work.
Values are in minutes.
The following example shows the directives in context. Note that other directives have been omitted from the
example to aid readability.
jetty-env.xml
<New id="applicationSettingsB" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg/>
<Arg>bean/applicationSettingsBean</Arg>
<Arg>
<New class="com.nxsec.log4ensics.data.bean.common.ApplicationSettingsBean">
<!--Session Timeout set to 15 minutes-->
<Set name="sessionTimeout">10</Set>
</New>
</Arg>
</New>
<New id="screenLockIdleTimeB" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg/>
<Arg>bean/screenLockIdleTimeBean</Arg>
<Arg>
<New class="com.nxsec.log4ensics.data.bean.common.ScreenLockIdleTimeBean">
<!--Screen Lock Idle Time set to 10 minutes-->
<Set name="screenLockIdleTime">10</Set>
</New>
</Arg>
</New>
1356
Chapter 137. Installation NXLog User Guide
The next dialog window will ask to create a certificate for the Agent manager.
1357
NXLog User Guide Chapter 137. Installation
The default values should be sufficient for most users; click Finish.
The initial settings can be changed any time later under the menu items Admin > Settings > Agent Manager
and Admin > Settings > Certificates.
If you have already configured the Agent manager with the Wizard as described in the previous
NOTE
section then you will not need to modify anything here. Just make sure your settings are correct.
Select whether you would like the agents or the agent manager to initiate the connection. This can be useful
when special firewall and zone rules apply. Make sure that the agent manager certificate is properly set. Click
Save & Restart to apply settings.
The Don’t encrypt agent manager’s private key checkbox disables using of the encryption key if activated.
For more information, see the NXLog Manager Configuration section.
1358
Chapter 137. Installation NXLog User Guide
The installation steps for automated agent deployment consist of the following:
To export the CA certificate, navigate to Admin > Certificates and select the CA with the checkbox as shown in
the screenshot below.
1359
NXLog User Guide Chapter 137. Installation
Click Export. The CA certificate should be exported using the 'Certificate in PEM format' option. Save the file as
agent-ca.pem.
The default installation of NXLog will create a file that is to be updated by NXLog Manager. On Windows systems
this is C:\Program Files\nxlog\conf\nxlog.d\managed.conf, on GNU/Linux systems this configuration file is
/opt/nxlog/etc/nxlog.d/managed.conf. When doing an automated deployment, this file should be replaced
with the following default configuration.
managed.conf
1 # Please set the following values to suit your environment and make
2 # sure agent-ca.pem is copied to %CERTDIR% with the proper ownership
3
4 define NXLOG_MANAGER_ADDRESS X.X.X.X
5 define NXLOG_MANAGER_PORT 4041
6
7 LogLevel INFO
8 LogFile %MYLOGFILE%
9
10 <Extension agent_managment>
11 Module xm_soapadmin
12 Connect %NXLOG_MANAGER_ADDRESS%
13 Port %NXLOG_MANAGER_PORT%
14 SocketType SSL
15 CAFile %CERTDIR%/agent-ca.pem
16 # CertFile %CERTDIR%/agent-cert.pem
17 # CertKeyFile %CERTDIR%/agent-key.pem
18 AllowUntrusted TRUE
19 RequireCert FALSE
20 <ACL conf>
21 Directory %CONFDIR%
22 AllowRead TRUE
23 AllowWrite TRUE
24 </ACL>
25 <ACL cert>
26 Directory %CERTDIR%
27 AllowRead TRUE
28 AllowWrite TRUE
29 </ACL>
30 </Extension>
Please make sure to replace X.X.X.X with the proper IP address of the NXLog Manager instance that the NXLog
agent needs to be connected to.
The CA certificate file agent-ca.pem must be also copied to the proper location as referenced in the above
configuration which is normally under C:\Program Files (x86)\nxlog\cert\ on Windows systems and under
/opt/nxlog/var/lib/nxlog/cert/ on GNU/Linux systems.
1360
Chapter 137. Installation NXLog User Guide
When the configuration and certificate files are updated remotely, NXLog must have
NOTE permissions to overwrite these files when it is running as a regular (i.e. nxlog) user. Please make
sure that the ownership is correct:
Now start the NXLog service. The nxlog.log file should contain the following if the NXLog agent has successfully
connected.
nxlog.log
2014-10-24 17:24:46 WARNING no functional input modules!↵
2014-10-24 17:24:46 WARNING no routes defined!↵
2014-10-24 17:24:46 INFO nxlog-2.8.1281 started↵
2014-10-24 17:24:46 INFO connecting to agent manager at X.X.X.X:4041↵
2014-10-24 17:24:46 INFO successfully connected to agent manager at X.X.X.X:4041 in SSL mode↵
Click the AGENTS menu to see the list of agents. You should see the newly connected agent with an UNTRUSTED
(yellow) status. If you don’t see the agent there, check the logs for error diagnostics.
The name of the untrusted agent should be the reverse DNS of its IP address.
In order to establish a mutually trusted connection between the NXLog agent and NXLog Manager, a certificate
and private key pair needs to be issued and transferred to the agent. Select the untrusted agent in the list and
click Issue certificate. When Update connected agents is enabled, the newly issued certificate and the
configuration will be pushed to the agent. The agent will need to reload the configuration in order to reconnect
with the certificate, select the agent and click Reload.
After the agent has successfully reconnected and the agent list is refreshed the agent status should be 'online'
showing a green sphere.
At this stage the NXLog agent should be operational and can now be managed and configured from the NXLog
Manager interface.
1361
NXLog User Guide Chapter 137. Installation
On GNU/Linux systems, extract the agents-config.zip and put the files under /opt/nxlog/var/lib/nxlog.
Make sure the files have the proper ownership:
On Windows systems, place the certificates in C:\Program Files (x86)\nxlog\cert. After restarting the
NXLog service you should now see your agent as Online under AGENTS.
1. To configure the log collection, click on your agent in the agent list and then select the Configure tab.
2. Click 'Routes' and add a route. Add a TCP input module for testing purposes:
Name: tcptest
Module: TCP Input (im_tcp)
Listen On: 0.0.0.0
Port: 1514
Input Format: line based
3. Add an output module. For test purposes we will use a null output that discards the data.
Name: out
Module: Null Output (om_null)
1362
Chapter 137. Installation NXLog User Guide
4. Now click Update config on the Info tab, then click Reload.
After the agent is restarted the newly configured modules are visible on the Modules tab.
6. On the Modules tab check all modules and click Refresh status. The count under the Received column is 1
(or more).
Configuration files are available in the /opt/nxlog-manager/conf directory on Linux installations and the
<NXLogManagerDirectory>/conf directory on the Docker installation of NXLog Manager. Log priorities, levels
and log rotation can be configured in the log4j.xml file of this directory.
Log rotation is set by default to rotate both files at the beginning of each month. The frequency of log rotation
can be controlled by the DatePattern parameter, as shown below.
log4j.xml
<appender name="internalAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="${logs.root}.log"/>
<param name="Threshold" value="INFO"/>
<param name="DatePattern" value="'.'yyyy-MM"/>
<layout class="co.nxlog.manager.common.logging.ContextPatternLayout">
<param name="ConversionPattern" value="%d %p $host $user $component [%c] - %m %n"/>
</layout>
</appender>
'.'yyyy-ww Rollover at the first day of each week. The first day of
the week depends on the locale.
1363
NXLog User Guide Chapter 137. Installation
log4j.xml
<root>
<priority value="DEBUG"/>
<appender-ref ref="internalAppender"/>
<appender-ref ref="errorAppender"/>
<appender-ref ref="debugAppender"/>
</root>
To gain more insight on what happens during the SSL communication and the reasons which cause the
connection to fail, additionally edit the nxlog-manager.conf file by adding the
-Djavax.net.debug=ssl,handshake options to the JVM_OPTS parameter. The ssl option turns on SSL debugging
and the handshake option prints each handshake message. To learn more about options, see the Debugging
Utilities section on the Oracle website.
After the changes, restart the nxlog-manager service and connect the agent first in untrusted mode and then
restart it with the newly issued certificates.
Once this has been done, please send us the debug log from the /opt/nxlog-manager/log/nxlog-
manager.debug file.
After the installation, the key and certificate are stored under the following paths:
In case the private key is password-protected, the following properties are available to set the password:
• for versions 5.x, it can be set under the ServerKeyPassword property of the
<NXLogManager_HOME>/conf/jetty-config.xml file.
• for versions 6.x, the password can be specified under the jetty.sslContext.keyStorePassword property
1364
Chapter 137. Installation NXLog User Guide
Since Jetty9 supports hashed passwords, they can be generated by using Jetty’s password utility. For example,
enter the following command to generate a secured version of the password newpass for user myuser:
where -xxx signifies the version of Jetty installed in NXLog Manager. The following output will be generated:
newpass
OBF:1xmi1vu91vv91xfj1vu11vv11xms
MD5:e6053eb8d35e02ae40beeeacef203c1a
CRYPT:myBmXhAi5GjtE
The first line is a plain text password. Copy the secured version of your choice with the prefix and paste it in the
<NXLogManager_HOME>/etc/start.ini file under the jetty.sslContext.keyStorePassword property.
For versions 5.x, the port can be customized in the <NXLogManager_HOME>/conf/jetty-config.xml file.
For versions 6.x, the port can be customized in the <NXLogManager_HOME>/etc/start.ini file by editing the
jetty.ssl.port parameter.
To enable SSL in versions 5.x prior to 5.5, uncomment three sections in <NXLogManager_HOME>/conf/jetty-
config.xml which look as follows:
1365
NXLog User Guide Chapter 137. Installation
jetty-config.xml
<New id="sslContextFactory"
class="com.nxsec.log4ensics.web.common.server.util.ssl.SslContextFactory">
<Set name="ServerCertificate"><Property name="jetty.home" default=".." />/conf/jetty9-
cert.pem</Set>
<Set name="ServerKey"><Property name="jetty.home" default=".." />/conf/jetty9-key.pem</Set>
<Set name="ServerKeyPassword"></Set>
<Set name="EndpointIdentificationAlgorithm"></Set>
<Set name="NeedClientAuth"><Property name="jetty.ssl.needClientAuth" default="false"/></Set>
<Set name="WantClientAuth"><Property name="jetty.ssl.wantClientAuth" default="false"/></Set>
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA256</Item>
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA256</Item>
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA256</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA256</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA</Item>
</Array>
</Set>
</New>
jetty-config.xml
<New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Arg><Ref refid="httpConfig"/></Arg>
<Call name="addCustomizer">
<Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
</Call>
</New>
1366
Chapter 137. Installation NXLog User Guide
jetty-config.xml
<Call name="addConnector">
<Arg>
<New id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.SslConnectionFactory">
<Arg name="next">http/1.1</Arg>
<Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
</New>
</Item>
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref refid="sslHttpConfig" /></Arg>
</New>
</Item>
</Array>
</Arg>
Procedure
1. Create the directory that will hold the changes for the nxlog-manager service.
1367
NXLog User Guide Chapter 137. Installation
[Service]
LimitNOFILE=10000
In this configuration, 10000 represents to the number of files that NXLog Manager is allowed to open.
Change this number to suit the requirements of your environment.
4. To tell NXLog Manager about the changes, the nxlog-manager service needs to be restarted.
JVM_OPTS="-Xms1g -Xmx2g
Only the initial part of the line is relevant for setting the heap size.
For a well-loaded manager instance with 1800 agents (around 90% load), use the following settings:
JVM_OPTS="-Xms5648m -Xmx7696m
The above is for a machine running NXLog Manager only, no NXLog instance is included. Calculate the
recommended and minimum settings using the system requirements for NXLog Manager table.
Use whole numbers to allocate memory: Xmx1.5G results in an error, 1536M is the valid
IMPORTANT
syntax in this case.
1368
Chapter 137. Installation NXLog User Guide
It is always advisable and good practice to create a backup before upgrading. This enables the
NOTE process to be rolled back if something goes wrong. Use mysqldump or phpMyAdmin to backup
MySQL/MariaDB. It is also recommended to make a backup of the configuration files.
After stopping the NXLog Manager service, upgrade NXLog Manager but do not start the service. Navigate to
/opt/nxlog-manager/db_init/upgrade/ and execute the command:
After stopping the NXLog Manager service, upgrade NXLog Manager but do not start the service. The upgraded
NXLog Manager requires first a database initialization. Do not start the NXLog Manager service as part of the
initialization. After initializing the database, navigate to /opt/nxlog-manager/db_init/upgrade/ and execute
the command:
The command will copy all the relevant information from the earlier version of NXLog Manager database to the
new database without altering the old database. The upgraded version of NXLog Manager service can now be
started.
After stopping the NXLog Manager service, upgrade the NXLog Manager packages through dpkg/apt or rpm/yum
and then start the service.
Upgrading NXLog Manager migrates existing settings to the new version. Nonetheless, it is highly recommended
to create a database backup before upgrading.
1369
NXLog User Guide Chapter 137. Installation
The following steps should be performed to upgrade NXLog Manager as a Docker application.
1. Docker containers should be stopped with the following command in the NXLog Manager directory:
$ docker-compose down
2. The archive with the new version of NXLog Manager should be unpacked with the following command:
3. The .deb package from the unpacked archive should be put to the NXLog Manager directory and the existing
package file should be deleted.
4. Docker images and containers should be built and started with the following command in the NXLog
Manager directory:
$ docker-compose up --build -d
nxlog-manager.err
2016-11-21 16:14:31,015 ERROR manager-host unknown nxlog-manager [net.sf.ehcache.Cache] - Unable to
set manager-host. This prevents creation of a GUID. Cause was:↵
java.net.UnknownHostException: nxlogmgr.domain.local↵
To set the hostname to myname, the line containing the host IP address along with the FQDN and the name
aliases should be added to the /etc/hosts file.
/etc/hosts
172.16.183.1 myname.example.com myname
Any of the locally bound IP address may be used as the Manager hostname.
Configuring the /etc/hosts file works for both Debian and RHEL versions of Linux.
By default, a Docker container inherits DNS settings from the Docker daemon, including the contents of the
/etc/resolv.conf and /etc/hosts files.
These settings can be overridden on a per-container basis with the following flags to docker commands:
Flag Description
1370
Chapter 137. Installation NXLog User Guide
Flag Description
--dns-opt A key-value pair representing a DNS option and its value. See the
operating system’s documentation for the resolv.conf file for
valid options.
The most common way is to edit the /etc/resolv.conf file. Usually up to three nameservers can be set up
using the nameserver keyword, followed by the IP address of the nameserver.
To test whether your configuration functions correctly, use the host or dig programs to perform both a DNS
lookup and a reverse DNS lookup (by querying with an IP address). Make sure that participating hosts on your
NXLog collection system are resolved correctly.
For more information, visit the Manually configuring the /etc/resolv.conf file in the RedHat documentation for
RHEL related distributions or visit the Defining the (DNS) Nameservers section in the Debian Wiki for Debian
based distrubutions.
There is also a comprehensive article on the Anatomy of a Linux DNS Lookup on the zwischenzugs website that
discusses the different methods and tools that can be used.
1371
NXLog User Guide Chapter 138. Dashboard and Menu
The default user id and password is admin/nxlog123. This should be changed as soon as possible.
HOME
Clicking on this menu item will load the dashboard.
PATTERNS
CREATE PATTERN
Click this menu item to create a new pattern. See the Patterns chapter for more information about
patterns.
LIST PATTERNS
Click this menu item to list all available patterns. See the Patterns chapter for more information about
patterns.
1372
Chapter 138. Dashboard and Menu NXLog User Guide
SEARCH PATTERN
Click this menu item to search for specific patterns. See the Patterns chapter for more information about
patterns.
CREATE GROUP
Click this menu item to create a new pattern group. See the Patterns chapter for more information about
pattern groups.
LIST GROUPS
Click this menu item to list all available pattern groups. See the Patterns chapter for more information
about pattern groups.
IMPORT PATTERN
Click this menu item to import a pattern database file. See the Patterns chapter for more information
about patterns.
CREATE FIELD
Click this menu item to create a new field. See the Fields chapter for more information about fields.
LIST FIELDS
Click this menu item to list all available fields. See the Fields chapter for more information about fields.
CORRELATION
Click this menu item to manage correlation rules and rulesets. See the Correlation chapter for more
information.
AGENTS
Click this menu item to see the list of nxlog agents and manage them. See the Agents chapter for more
information.
ADMIN
USERS
Clicking this menu item will load the user management interface. See the Users section for more
information.
ROLES
Clicking this menu item will load the role management interface. See the Roles section for more
information.
CERTIFICATES
Click this menu item to see the list of certificates available in the built in PKI. See the Certificates chapter
for more information.
SETTINGS
Clicking this menu item allows to change various system-wide settings and personal preferences. See the
Settings chapter for more information.
LOGOUT
Click this menu item to log out of the Log4ensics web application and terminate your session. You will be
logged out automatically after some idle time if there is no activity.
Depending on your configured roles, some menu items will not be shown which you do not
NOTE have access rights to. See the Roles section for more information about the access control in
NXLog Manager.
The successive chapters are organized to cover each of these components which can be accessed from the
1373
NXLog User Guide Chapter 138. Dashboard and Menu
menu.
138.3. Dashboard
On the first login the following screen should appear.
The dashboard can be customized and will display different content for each logged in user. After clicking the
[Add] button, an empty dashboard item will appear:
The following item types can be selected with the combo box:
Agent list
The number of agents are displayed for each category:
• Online
• Offline
• Error
• Unmanaged
1374
Chapter 138. Dashboard and Menu NXLog User Guide
Jobs summary
Will display a summary about scheduled jobs.
Certificate summary
Will display a summary about certificates grouping them by the following categories:
• Expired
• To be expired in the next 10 days
• Revoked
• Valid
Agent chart
Will display a one of these agent charts for an agent:
After the required parameters are filled in, click [Save] to add the item to the dashboard. Click [Cancel] if you
wish to discard the dashboard item.
The header bar of the dashboard item can be clicked to drag and move the dashboard item around.
The following items are on the header bar from left to right order:
Up arrow
Click to minimize the dashboard item.
Title
The title which was filled in when editing the dashboard item.
Edit
Click to edit the dashboard item.
X
Click the X button to remove the dashboard item.
Down arrow
Click the down arrow in the top right corner to maximize the dashboard item.
1375
NXLog User Guide Chapter 139. Fields
As NX-Log4ensics and NXLOG operate with a set of fields belonging to a log message, it is important to manage
these as well. Fields in NX-Log4ensics are typed, this allows complex operations and efficient storage of event log
data. All of the major components depend on fields and these are used in various places in Log4ensics, including
Patters, Correlation and Agent configuration.
Log4ensics comes with a set of predefiend fields which should be enough for the general cases but can be
extended to suit custom requirements.
To list the available fields, click on the LIST FIELDS menu item under the PATTERN menu. A list similar to the
following should appear:
The field properties will be explained shortly as we look at creating and modifying fields. To do this, click on
[Create] or [Edit] under the field list.
1376
Chapter 139. Fields NXLog User Guide
Name
The name of the field will be used to refer to the field from various places in Log4ensics and nxlog.
Type
The following types can be chosen for a field:
• STRING
• INTEGER
• BINARY
• DATETIME
• IPV4ADDR
• IPV6ADDR
• BOOLEAN
Persist
If this option is not enabled, field values will be only available to the nxlog agent for correlation, pattern
matching. Fields should be persisted if the information is needed in additional functions.
Lookup
This is a special property and only takes effect when the field is persistent and is a string type. The lookup
property should be enabled for fields whose values are highly repetitive such as user names, enumerations,
host names etc. This enables the storage engine to map the value to an integer which yields significant
compression and performance boost.
Description
The description is only used as an information about the field.
1377
NXLog User Guide Chapter 139. Fields
1378
Chapter 140. Patterns NXLog User Guide
Consider the following example generated by the SSH server when an authentication failure occurs:
To be able to create a report about authentication failures, the username (john in the above example) needs to
be extracted. Regular expressions are commonly used for this purpose.
The patterns used by NXLog Manager and NXLog are special in a way that these are not only single regular
expressions.
• Patterns contain match criteria to be executed against one or more fields. A pattern matches only if all fields
with a match criteria match. This technique allows patterns to be used with structured logs as well.
• The matching executed against the field(s) can be an exact match or a regular expression.
• Patterns can extract data from strings using captured substrings and store these in separate fields.
• Patterns can modify the log by setting additional fields. This is useful for message classification.
• Patterns can contain test cases for validation.
• Patterns are grouped under Pattern Groups.
Patterns are used by the NXLog agent. This makes it possible to distribute this task to the agents and recieve
preprocessed and ready-to-store logs instead of parsing all logs at the central server. This approach can yield a
significant reduction in CPU load on the central log server.
For more information about the patterns used by the NXLog agent, please refer to the pm_pattern module
documentation in the NXLog Reference Manual.
Pattern groups also serve an optimization purpose. They can have an optional match criteria. One or more fields
can be specified using either EXACT or REGEXP match. The log message is first checked against this match
criteria. If it matches, only then will be the patterns belonging to the group matched against the log message.
1379
NXLog User Guide Chapter 140. Patterns
1380
Chapter 140. Patterns NXLog User Guide
In the above example the ssh patterns will be only checked against the log if the field SourceName matches the
string sshd. The SourceName field must be extracted from the Syslog message with a syslog parser prior to
running the logs through the pattern matcher.
1381
NXLog User Guide Chapter 140. Patterns
Here you should enter the basic pattern information. Make sure the Pattern Group is set.
The next Match block must be populated with field(s) value(s). For example a message field:
This can be more generic according to our needs so that the pattern can extract the user name and the
destination IP address from the message:
We replace those parts of the message with regular expressions constructs (\S+ in the above example) which are
not static. Captured substrings (the (\S+)) are stored in the fields we select. In the above example AccountName
and DesinationIPVAddress are used to store the extracted values.
If it is necessary, add more than one field to execute the matching operation against. The match type can be
either an EXACT or a REGEXP match. If this is toggled to REGEXP, the NXLog Manager will offer to escape special
characters:
If the regular expression does not start with the caret (^), the regexp engine would try to find an occurrence
anywhere in the subject string. This is a costly operation. Usually the provided regular expression is written to
match the start of the string and it is easy to forget the caret from the start. For this reason the interface will
show a hint:
1382
Chapter 140. Patterns NXLog User Guide
The regular expressions are compiled and executed by the NXLog engine using the PCRE library.
NOTE
The regular expression must be PCRE compatible in order to work.
This built-in testing interface is extremely useful for verifying the functionality of our patterns. Without this we
could only find out that the pattern doesn’t work if we loaded the pattern into the agent and ran it against a set
of logs.
The field value was already filled in using the log message we used to create the pattern from. After clicking the
Calcualte Fields button, the captured field values should appear correctly. If they don’t, you have made a mistake
somewhere and should go fix it.
There are five special fields starting with Taxonomy. NXLog Manager comes with a dictionary for these taxonomy
values and only a value from this dictionary list can be set. Event taxonomy is an important concept which allows
to handle events generically regardless of their source.
If you do not want to classify the event with the Taxonomy fields or one or more is not applicable, click the Delete
to remove it. The Taxonomy fields are optional but are recommended to be set. It is possible to add other
additional fields and specify their value.
1383
NXLog User Guide Chapter 140. Patterns
There is a more powerful search interface which allows searching in any of the patterns' properties (fields, test
cases, etc). Click on the SEARCH PATTERN menu item under the PATTERN menu.
1384
Chapter 140. Patterns NXLog User Guide
To use the patterns in an NXLog agent, add a pm_pattern processor module and select the appropriate pattern
groups:
The patterns will be pushed to the NXLog agent after clicking Update config and they will take effect after a
restart. See the Agents chapter for more information about agent configuration details.
Some patterns work with a set of fields and this requires some preprocessing (e.g. syslog
parsing) in some cases. Instead of writing a regular expression to match a full Syslog line which
includes the header (priority, timestamp, hostname etc), it is a lot more efficient to write the
NOTE
regular expression to match the Message field (instead of the raw_event field) and have a syslog
parser store the header information in separate fields before the pattern matching. These
patterns will be usable when the same message is collected over a different protocol.
1385
NXLog User Guide Chapter 141. Correlation
A trivial example for this is to detect 3 failed login attempts into a system. When this happens, the user will be
likely locked out. If the log analysis system is capable to detect such situation, a lot of things can be automated.
You will not need to wait for the user to come asking for a new password.
Event correlation in NXLog Manager is architected similarly to the Pattern system. It is performed in real-time by
the NXLog agents. This way it is possible to do local event correlation on the client side (at the agent). This will
not only reduce load on the central server but the system can send alerts over another channel (e.g. SMS) even if
the network is down and the log messages would not reach the central log server.
For more information about the correlation capabilities of NXLog Manager, please consult the NXLOG Reference
Manual and see the documentation about the pm_evcorr module.
Clicking the name of a correlation ruleset will show a list of correlation rules within the ruleset:
1386
Chapter 141. Correlation NXLog User Guide
The order of the rules within the rulset matter because they are evaluated by NXLog’s pm_evcorr
NOTE module in the order they appear. To change the order of the rules, use the Up and Down
buttons.
Each correlation rule has a mandatory Name, Type and Action parameter and one ore more type specific
parameters where the conditions can be specified. The following correlation rule types are available:
• Simple
• Suppressed
• Pair
• Absence
• Thresholded
Please consult the NXLog Reference Manual and see the documentation about these rule types provided by the
pm_evcorr module. There are two modes available to specify a condition
Matched pattern is
This will generate a simple test to check whether the specified pattern matched. The generated NXLog config
will contain a similar snippet:
1387
NXLog User Guide Chapter 141. Correlation
if $PatternID == 42 {\
ACTION \
}
For this to work, the pm_pattern module must be configured and must be in front of the
NOTE pm_evcorr module in the route. The pm_pattern module is responsible for setting the
PatternID field.
Expert
The Expert field expects a statement (a boolean condition) which evaluates to TRUE or FALSE. The above
expressed in Expert form would look like the following:
$PatternID == 42
In this example we will create a correlation rule which will detect ssh bruteforce attempts. We define a
bruteforce attempt as 5 login failures within a 20 second interval. In this example only an internal warning
message is generated, but it is possible to trigger any other action, for example execute an external script
to block the IP or send an alert in email.
This correlation rule depends on a pattern which matches an ssh authentication failure event. See the
Creating patterns section on how to do this. Once the pattern is available in our database, the correlation
rule should be configured as shown on the following screenshot:
1388
Chapter 141. Correlation NXLog User Guide
Unlike patterns, correlation rules used by NXLog are not in XML. Correlation rules exported from
NXLog Manager cannot by used by NXLog because the NXLog agent uses apache-style
NOTE
configuration file for the rules and this is part of (or included in) the pm_evcorr module
configuration block in nxlog.conf.
To use the correlation rules in an NXLog agent, add a pm_evcorr processor module and select the appropriate
correlation ruleset:
It is recommended to use only one ruleset per agent. The correlation rules will be pushed to the NXLog agent
after clicking Update config and they will take effect after a restart. See the Agents chapter for more information
about agent configuration details.
In many cases correlation rules depend on patterns (and the PatternID field). For this reason a
NOTE
pm_pattern module should be in the processor chain before the pm_evcorr module.
1389
NXLog User Guide Chapter 142. Agents
NXLog agent instances can be managed, monitored, and configured remotely over a secure channel. The
management component in NXLog Manager is called the agent manager. There are two operation modes:
• The NXLog agent initiates the connection and connects to the agent manager.
• The agent manager initiates the connection and connects to the NXLog agent.
Mutual X.509 certificate-based authentication is used over a trusted, secure TLS/SSL channel in order to
guarantee that only an authorized NXLog agent can connect to the agent manager. The agent manager queries
the status information of each NXLog agent every 60 seconds.
Each agent instance is provided with a special configuration file coming from the agent manager. The file name is
managed.conf and it is located under the path to /opt/nxlog/etc/nxlog.d/ on Linux and C:\Program
Files\nxlog\conf\nxlog.d\ on Windows platforms.
This file contains a BASE64-encoded blob in the header that stores the configuration of the agent. NXLog
Manager can restore the configuration of the agent in case the agent configuration gets lost from the manager’s
database.
It is important that this file should not be modified manually or deleted. In case the manager cannot read the
blob, the below error message is generated:
To list the available NXLog agents, click on the AGENTS menu. A list similar to the following should appear:
Status
There is coloured ball showing agent’s status. It can be any of the following:
Green - Online
If the last status response was successfull and the agent is functioning normally, the status is Online.
Grey - Offline
When there is no connection with the agent manager the status is Offline. Usually this indicates that there
is a network error, the agent is stopped, has not been started or is misconfigured. You should check the
NXLog agent’s LogFile for error diagnostics.
1390
Chapter 142. Agents NXLog User Guide
Red - Error
This status is shown when one or more modules aren’t running. For network output modules this can be
shown when there is no connection and the module is unable to send. This can be fixed by starting the
module or solving the problem which prevents the module to function correctly. You should check the
NXLog agent’s LogFile for error diagnostics.
Yellow - Unmanaged
When the agent is configured to be Unmanaged, it is not possible to administer it remotely.
Yellow - Untrusted
When the agent is connected to the manager without own certificate. The manager accepts it, but with
warning. For those agents must be issued certificates if they are freshly installed without certificate.
Yellow - Forged
When the agent is connected to the manager with certificate which CN doesn’t match the reverse DNS of
this agent. Most probably it’s certificate is copied/configured from another agent, thus for it must be
issued certificate as well.
If the agent configuration has been updated either centrally (by the application), or locally (on the agent
side), there will be small yellow warning sign next to the ball with tooltip of the message. You must issue
Update config command in order to apply the central configuration. If the configuration has been changed
locally, a confirmation will be asked.
Agent name
The agent name is taken from the certificate subject name. For this reason the same name must be used
here as the certificate subject. Clicking on the agent name will load the Agent information page.
Template
The assigned template to this agent. Agents inherit all the template configuration. For more information
about templates, see Templates chapter.
This column is not visible by default. To enable it, select it from the column list by clicking on
NOTE
the round Configuration button on the top left of the table.
Tags
The assigned tags to this agent (usually they are assigned to its template). For more information about
configuring tags for templates, see Tags section.
This column is not visible by default. To enable it, select it from the column list by clicking on
NOTE
the round Configuration button on the top left of the table.
Version
This is the NXLog agent version number.
Host
This is the IP address of the remote socket where the NXLog agent has connected from. Not available when
the agent is Offline or Unmanaged.
Started
Shows the time when the NXLog agent has been started. Not available when the agent is Offline or
Unmanaged. The value is set when the NXLog service is started or restarted. This is not reset when using the
Reload button.
Load
The system load as reported by the operating system where the NXLog agent is running. This is not
implemented on some platforms (notably Microsoft Windows), in this case Unknown will be shown.
1391
NXLog User Guide Chapter 142. Agents
This value represents the system load of the operating system and not that of the NXLog
NOTE agent. Due to other resource intensive processes this can be high even if the NXLog agent is
idle.
NOTE There is small thumbnail graph for the statistics of last 10 average values.
Mem. usage
The amount of memory used by the NXLog agent. On some platforms Unknown is shown where this
information is not available.
NOTE There is small thumbnail graph for the statistics of last 10 average values.
Received
The sum of log messages received by all input modules since the agent has been started.
NOTE There is small thumbnail graph for the statistics of last 10 average values.
Received today
The sum of log messages received by all input modules for the last 24 hours.
NOTE There is small thumbnail graph for the statistics of last 10 average values.
Processing
Each NXLog agent module has a separate queue. This number shows the sum of messages in all modules'
queues.
NOTE There is small thumbnail graph for the statistics of last 10 average values.
Sent
The sum of log messages written or sent by all output modules since the agent has been started.
If you have two output modules writing/sending logs from a single input, the number under
NOTE
Sent will be double of the value under Received for obvious reasons.
NOTE There is small thumbnail graph for the statistics of last 10 average values.
Sent today
The sum of log messages written or sent by all output modules for the last 24 hours.
If you have two output modules writing/sending logs from a single input, the number under
NOTE
Sent will be double of the value under Received for obvious reasons.
1392
Chapter 142. Agents NXLog User Guide
NOTE There is small thumbnail graph for the statistics of last 10 average values.
The information shown in the agent list is refreshed every 60 seconds or when Refresh status is clicked.
On the top of the list there is a [Filter agents] button which can be used for agent filtering on that list. When
clicked, the following dialog appears:
Here agents can be filtered by 3 criteria: Status(es), Agent name (contains the character sequence specified), and
Template(s). Clicking [Apply filter] will refresh the agent list with only agents matching filtering criteria. For
example selecting ONLINE status will show the following:
When a filter is applied, next to Filter agents appears another button [Clear filter] which can be used to
discard the applied filter and show the list with all agents again.
On the Filter Agents dialog there is also another option to save this filter in the configuration database as an
Agents View. Clicking on [Create View] button will popup another dialog to enter the view name:
The view name must be unique and not containing any special characters and blank spaces. All saved views will
appear as tabs next to Agent templates tab and the newly created view will be immediately selected
automatically:
1393
NXLog User Guide Chapter 142. Agents
On the bottom of the list there is a row of buttons which can be used to manage the agent(s).
Refresh status
This will send a query to the agent to retrieve status information. You need to select at least one Online agent
with the checkbox to be able to use this.
Start
Start all stopped modules. You need to select at least one Online agent with the checkbox to be able to use
this.
The xm_soapadmin module responsible for the agent manager connection must be always
NOTE running, so this is module not affected. The NXLog process cannot be stopped and/or
started from the NXLog Manager management interface.
Stop
Stop all modules. You need to select at least one Online agent with the checkbox to be able to use this.
The xm_soapadmin module responsible for the agent manager connection must be always
NOTE running, so this is module not affected. The NXLog process cannot be stopped and/or
started from the NXLog Manager management interface.
Export
Exports agent configuration in XML text format. When activated on the selected agent, export options dialog
will appear:
In this dialog the manager allows separate parts to be exported. When export is finished, the browser downloads
it.
1394
Chapter 142. Agents NXLog User Guide
Import
Presumably, the import button imports the agent configuration exported in the previous section described
action.
There is the option to override and define new global configuration, such as new manager
NOTE
address, and so on.
When triggered, browser redirects to import options (if global config has been overridden, this section is
skipped):
Here choose the XML file to import and the new agent(s) configuration, similarly to "Clone" agent function. When
this is done, the manager also allows separate parts from the configuration to be imported:
1395
NXLog User Guide Chapter 142. Agents
Update config
After the agent settings were changed, use this button to push the new configuration to the agent. All
configuration related files, including pattern database files and certificates will be pushed to the agent. You
will most probably want to Reload the agent after updating the configuration in order for the new settings to
take effect. You need to select at least one Online agent with the checkbox to be able to use this.
Reload
This forces the agent to stop and shutdown all modules, reload the configuration and then reinitalize and
start all. This should be used after a new configuration was pushed to the agent in order for the new setting
to take effect. You need to select at least one Online agent with the checkbox to be able to use this.
This is not a process/service level restart but rather a reload. The xm_soapadmin module
responsible for the agent manager connection must be always running, so this is module not
NOTE
affected. The NXLog process cannot be stopped and/or started from the NXLog Manager
management interface.
Configure
This button will load the Agent configuration page. You need to select exactly one agent with the checkbox to
be able to use this.
Add
Add a new agent.
An agent will appear in the list without a configuration after successfully connecting to the
agent manager even if it does not exist in the agent list. It is possible to add a new agent by
NOTE
creating a certificate, deploying the installer and starting the NXLog service. The new agent
entry should appear automatically.
Delete
Delete the agent.
1396
Chapter 142. Agents NXLog User Guide
The agent will reappear if it has a valid certificate and can successfully authenticate to the
agent manager. Make sure to revoke the certificate and stop the NXLog service before you
NOTE
delete the entry with this button. If the NXLog service is not stopped and removed, it will try
to reconnect (if it was configured so).
Clone
Clone the agent. The cloned agent(s) will have all the modules and routes of the original one. You need to
select exactly one agent with the checkbox to be able to use this.
Download config
Downloads the agent configuration in zip file to ease agents deployment locally. For each agent there will be
folder in the archive with it’s name containing all the necessary configuration files and certificates. You must
select at least one agent with the checkbox to be able to use this.
View log
View the log of an agent. By the default it is limited to 100K of the last log. You need to select exactly one
agent with the checkbox to be able to use this.
Assign template
Assign template to agent(s). The selected agents will lose their configuration and now will have the template
one.
You must select at least one agent with the checkbox to be able to use this.
Issue certificate
Issue certificate for the selected agent(s). If the checkbox Update connected agents remains checked, the
manager will also issue Update config command. You must select at least one agent which doesn’t have
certificate already with the checkbox to be able to use this.
Renew certificate
Renew certificate for the selected agent(s) due to expiry or other reason. If the checkbox Update connected
agents remains checked, the manager will also issue Update config command.
NOTE If a selected agent has already valid certificate, it will be revoked by the system.
You must select at least one agent with the checkbox to be able to use this.
The page will show less information if the agent is not connected to the agent manager. The action buttons on
1397
NXLog User Guide Chapter 142. Agents
this page are not discussed as they are the same as on the agent list described previously.
If the agent is Online and some of its modules has variables or statistical counters, they will appear on this page
in a table.
Clicking on the Modules tab will show detailed information in a table about each module as shown in the
following image.
This information is only available when the agent is Online and contains the following information.
Name
The name of the module instance.
Module
The type of the loadable module which was used to create the module instance.
Type
The type of the module. It can take the following values:
• INPUT
• PROCESSOR
• OUTPUT
Status
• STOPPED
• RUNNING
• PAUSED
• UNINITIALIZED
The module may become PAUSED if it cannot send or forward the output. This is caused
by the built-in flow control and is perfectly normal unless you see the module in this
NOTE
status for a longer period and the number of sent messages does not increase. You do
not need to start the module when it is PAUSED, it will resume operations automatically.
Received
The number log messages received or read.
Processing
The number of log messages in the module’s queue waiting to be processed.
1398
Chapter 142. Agents NXLog User Guide
Sent
The number of log messages written or sent by the module.
Dropped
The module may filter and drop some messages. This number will be shown here. This is calculated using the
value reported in Received and Sent.
Clicking on the Statistics tab will show several fully interactive graphs. There will be a graph for the following
parameters:
The interval of the graph can be selected using the combo box to be one of the following:
• Six hours
• One day
• One week
• One year
1399
NXLog User Guide Chapter 142. Agents
Agent name
Set this to the certificate subject name. It is automatically filled out when the agent has connected and was
automatically added.
Connection type
Unmanaged
Set the connection type to Unmanaged if you do not want to administer the agent remotely over a secure
connection.
Address
The address where the agent should connect to or where the agent is listening on, depending on how the
Connection type is configured.
Port
The port number where the agent should connect to or where the agent is listening on, depending on how
the Connection type is configured.
Certificate
The certificate which will be presented by the NXLog agent during the mutual authentication phase when the
connection is established with the agent manager. The agent manager will check whether the agent
certificate has been signed with the CA configured on the Agent Manager settings tab.
Loglevel
The loglevel to use when sending internal messages to the logfile and the im_internal input module.
Log to file
Enable this if you want to use a local nxlog.log file where the internal events of the NXLog agent are written.
This method is more efficient and error resistant than using im_internal and it also works with DEBUG
loglevel.
1400
Chapter 142. Agents NXLog User Guide
Verbatim config
Verbatim configuration text for this agent. This configuration will be put in the managed.conf file as it is.
The list of modules can be managed independently regardless of the route they belong to. The following
screenshot shows an example list of modules.
Click the [Add] button to add a new module. The module configuration dialog will pop up. To remove a module,
click the checkbox after the module’s name. Modules which are already part of a route cannot be removed. Go to
the Routes tab to remove or add modules to a route. On the other hand modules not part of a route can only be
removed on this list. Configuration will not be generated for modules which are not part of a route. Click on copy
to copy this module configuration to other agents. A popup will appear to select them. Click on the module’s
name to modify its configuration.
To configure the flow of log data in the NXLog agent, click the Routes tab. A freshly created agent does not have
any routes. Click the Add route button to add a route.
Enter the name and select the priority. Data will be processed in priority order among routes. Lower gets
processed first. This is only useful if you have more routes which contain different input sources. Select default if
you do not wish to assign a priority value.
After the route is added, you can now add modules to it. A route requires at least one input and one output
module. The following screenshot shows an example of a route with one module for each type.
1401
NXLog User Guide Chapter 142. Agents
Click the [Add] button inside the input/processor/output block to add a module instance. The module
configuration dialog will pop up. If there is already an existing module instance, you will be able to select that
also. It is possible to add more module instances to each block. To remove a module, uncheck the checkbox after
its name. The module instance is only removed from the route. To fully delete it, click the Modules tab and
remove the module.
As with modules, there is option to copy entire route to other agents. Click on Copy link on top right of a route to
select one or more agents to copy to.
The last tab contains the generated nxlog configuration which will be pushed to the NXLog agent when clicking
on Update config as shown in the following screenshot.
1402
Chapter 142. Agents NXLog User Guide
The module configuration dialog Parameters tab consists of two blocks: Common parameters and Module
specific parameters. The Common parameters are as follows:
Name
The name of the module instance.
Module
The loadable module which is used to create the module instance.
Actions
The Action text area can be used to input statements in NXLog’s configuration language. It is possible to add
multiple Action input widgets. Add each action with the Add action button. Click Verify to verify the
statement(s). The contents of the Action block are copied into the module’s Exec directive. Newline characters
will be replaced with the backslash escape character. The statement entered on the above screenshot is
highlighted below in the generated NXLog configuration.
Verbatim config
1403
NXLog User Guide Chapter 142. Agents
Module specific parameters are not discussed in this user manual. Please consult the NXLog Enterprise Edition
Reference Manual for more information about each module and their capabilites.
1404
Chapter 143. Templates NXLog User Guide
To list the available NXLog templates, click on the Agent templates tab in AGENTS page. A list similar to the
following should appear:
Template name
The template name is the unique name of a NXLog template. Clicking on the template name will load the
Template configuration page.
Description
This is the NXLog template detailed description.
Connection address
This column shows the address of the NXLog agents belonging to this template are configured for connection
with the NXLog Manager. Not available when the template is Unmanaged.
Connection port
This column shows the port of the NXLog agents belonging to this template are configured for connection
with the NXLog Manager. Not available when the template is Unmanaged.
Created
This column shows the date and time when this NXLog template is created.
Last modified
This column shows the date and time when this NXLog template has been last modified.
On the bottom of the list there is a row of buttons which can be used to manage the agent(s).
Add
Add a new template.
Export
Similarly to Export agent configuration, this action exports template configuration.
Import
Similarly to Import agent configuration, this action imports template configuration.
Delete
Delete the template.
1405
NXLog User Guide Chapter 143. Templates
Deleted template must be unassigned from the agents belonging to it. If there are any, a
confirmation dialog will appear:
NOTE
Clone
Clone a template with the same configuration.
Create agents
Create agents and automatically assign this template to them.
143.1.1. Tags
NXLog templates/agents can be managed by tags. Tags have role and user access permissions. To list them for a
template, click on Tags tab under Template configuration page:
Name
The unique name of a tag.
Description
This is the tag detailed description.
1406
Chapter 143. Templates NXLog User Guide
Permissions by Role
This column shows the access permissions of each role which is allowed to manage NXLog agents.
Permissions by User
This column shows the access permissions of each user which is allowed to manage NXLog agents.
On the bottom of the list there is a row of buttons which can be used to manage the tags(s).
Add
Add a new tag.
Edit
Edit a tag.
Assign
Assign (or unassign) existing tags to this template.
To add a new tag to the system (and in parallel assign to this template), click on the Add button. An Add tag
dialog will appear:
Fill in the Name and optionally description of this tag. When click on Save a new tag will be created with default
access permissions, assigned to this template and will appear on the list:
Tag can be then edited by selecting it and click the Edit button. Edit dialog appears, containing two tabs: Tag and
Permissions:
1407
NXLog User Guide Chapter 143. Templates
When some permissions are changed, click Update permissions button. When all done Save, to make sure all the
changes will be accepted.
If tags are needed to be assigned/unassigned to the current template, click on Assign button on tag list page. The
following dialog will appear:
Select the tags needed from the multi select box and Assign them.
1408
Chapter 144. Agent Groups NXLog User Guide
To list the available NXLog agent groups, click on the Agent groups tab in AGENTS page. A list similar to the
following should appear:
Group name
The group name is the unique name of a NXLog agent group. Clicking on the name will load the agents which
are tagged by it.
Description
This is the NXLog agent group detailed description.
On the bottom of the list there is a row of buttons which can be used to manage the groups.
Add
Add a new group.
In agent list under a group page except the standard agent management buttons, there are additional buttons
which can be used to manage this group.
Delete group
Delete this group/tag.
Add agents
Add agents to this group.
To add agents to this group, click on the Add agents button. An Add agents dialog will appear:
1409
NXLog User Guide Chapter 144. Agent Groups
Select the desired agents and click Add. The selected agents will be added to the list in this group.
1410
Chapter 145. Certificates NXLog User Guide
Name
The certificate subject name.
Type
This can be either CA or CERT.
Activation
The time and date after the certificate is valid.
Expiration
The time and date before the certificate is valid.
Status
The status of the certificate can be VALID, REVOKED and EXPIRED.
Private Key
This field indicates whether the private key pair of the certificate is available or not.
The certificate list shows entries in a hierarchical (tree) structure. Certificates (and sub-CAs) will be rooted under
the CA which was used to sign it.
If the PKI system does not have any certificates, you will need to create a CA first.
145.2. Creating a CA
The certificate authority is used to issue and sign certificates and can be used to later verify the trust
relationship. To be able to create certificates, a CA is required. To create a CA cert, click on the Add new CA on the
certificate list page. The following screenshot shows the certificate creator form.
1411
NXLog User Guide Chapter 145. Certificates
Some values will be already filled in if the Certificate settings are configured. After clicking Create, the new CA
should appear.
Some values will be already filled in if the Certificate settings are configured. Fill in the name (certificate subject),
expiry and select the certificate purpose. It is possible to customize the certificate purpose flags, but this is not
1412
Chapter 145. Certificates NXLog User Guide
required if the certificate will be used only within NXLog Manager and with NXLog. After clicking Create, the new
certificate should appear. The following screenshot shows the information page of a certificate.
145.4. Exporting
To export a certificate, click Export on the certificate general information page or below the certificate list after
selecting and entry. The following options will appear.
In order to support external certificate tools and PKI systems, certificates can be exported in different formats.
The NXLog agents use PEM formatted X509 certificates.
1413
NXLog User Guide Chapter 145. Certificates
145.5. Importing
In order to support external certificate tools and PKI systems, certificates can be imported in different formats.
Generally it is not a good idea to have multiple valid certificates with the same subject. If a
NOTE certificate has been superseeded by a new one (e.g. already pushed to to the agent), make sure
to revoke the former.
• First time the 'admin' user logs-in, NXLog-Manager generates random encryption key with predefined length.
This key is only kept in application memory space and certificate keys will be encrypted with it.
• NXLog-Manager then encrypts this key with authorized user password and saves it in the user settings in the
database. When NXLog-Manager has been restarted, the authorized user with a key must login to decrypt
this key with his password, so it’ll be available for certificate keys encryption/decryption.
1414
Chapter 145. Certificates NXLog User Guide
Authorized user eligible for this key is any user with one of the roles ROLE_ADMINISTRATOR or
NOTE
ROLE_CERTIFICATE (by default 'admin' user has ROLE_ADMINISTRATOR).
When new authorized users are added later to the system, the encryption key must also be
saved in DB and encrypted with their own password. At the time of writing this manual this can
NOTE only happen if the user logs-in in the same application session for which this key is already
available (authorized user with stored key has logged-in to unlock the key). In the future there
will be enhancements in NXLog-Manager to skip the log-in step for new authorized users.
1415
NXLog User Guide Chapter 145. Certificates
If reset certificates and encryption key is the last resort and there is no other option, this can be done from this
dialog. This will update also the certificates for the connected agents with the renewed ones, so it’s good
outcome if as many agents are currently connected as possible (for this the manager should be already running -
with non-encrypted keys). It must be noticed all offline agents during this operation must be updated locally with
the new certificates, they won’t be able to connect to the manager when it is running with new certificates for
authentication.
There will be notifications for each change/failure in UI, also in the logs.
1416
Chapter 146. Settings NXLog User Guide
The above screenshot shows the Agent manager tab where its parameters can be configured.
The agent manager can both accept and initiate connections to the agents. Enable the Accept agent connections
checkbox to let the agent manager accept incoming connections from agents.. Enable the Initiate connection to
agents checkbox to let the agent manager initiate the connection.
For these settings to work, the agents must be configured accordingly. See the Agent
NOTE
Connection type configuration parameter.
1417
NXLog User Guide Chapter 146. Settings
Listen address
When Accept agent connections is requested, the IP address of the interface must be specified. Use 0.0.0.0 to
listen on all interfaces.
Port
When Accept agent connections is requested, the port number must be specified where the agent manager
will listen on for incoming connections.
CA
The CA configured here is used to verify the certificate presented by the NXLog agent during the SSL
handshake.
Certificate
The certificate configured here will be used to authenticate to the NXLog agent during the SSL handshake.
For security reasons certificate private keys in the database are stored in an encypted form. These are encrypted
with a master key which is accessible to users who have ROLE_ADMINISTRATOR and/or ROLE_CERTIFICATE access
rights. The agent manager’s private key is required to be able to estabilish the trusted control connection with
the agents. Enable the Don’t encrypt agent manager’s private key option for the system to be able to operate in
an unattended mode. Otherwise the agent manager connection will only work after a reboot/restart after a
successfull admin login.
Warn if untrusted.
When this option is selected, agent manager will accept agents which try to authorize with Subject Name
other than their reverse DNS, and will mark them as Forged.
Reject agent.
When this option is selected, agent manager will reject agents which try to authorize with Subject Name other
than their reverse DNS.
Disable.
When this option is selected, agent manager will ignore the mismatch between Subject Name and reverse
DNS for connected agents.
Due to Subject Name Authorization and the specifics of some networks, like NAT for example, agent manager
must have some policy for names of connected agents which will appear on the Agent list. Agent manager
supports 3 options for Agent name:
When one of last 2 options is selected and a NXLog agent doesn’t authorize with valid client
NOTE
certificate, but the manager demands Subject Name, the agent will be rejected.
There can be defined also per agent rules for Subject Name Authorization and Agent Name by clicking the button
"Add override". The following dialog will appear:
1418
Chapter 146. Settings NXLog User Guide
There are 3 types of hosts which can be defined: exact name or IP address; name or IP address regular
expression and IP address range. An option exists to verify host definition against real host. The overridden rules
will appear as list under the global manager rules.
Click Save & Restart to apply the changes. The Status field will display the status of the agent manager.
146.2. Certificates
This form is divided in two sections: Certificate defaults and Certificates provider:
1419
NXLog User Guide Chapter 146. Settings
Certificate defaults
This form can be used to set common parameters which are used during certificate creation. Most of these
attributes are pretty common, though there are some that deserve a direct mention:
By default on a new system with a blank database, this setting will be disabled. If this
setting is enabled, you must always have an available administrator user which can
IMPORTANT
unlock the keys after log-in. Losing the encryption key in one way or another will make
private keys practically lost and the certificates unusable.
IMPORTANT This feature must be taken very seriously and practice special care when enabling it.
Keystore type
This is the type that NXLog Manager will use during runtime when dealing with certificates. By default it is
BKS, which is considered more secure than default java keystore JKS. However on rare occasions BKS does
not have enough support for some certificates, one of which is Elliptic Curve certificates, that is created by
some external tools (NXLog Manager uses only RSA encryption). If such certificates are planned for use,
there is an option to change the keystore type to JCEKS instead.
RSA encryption is the default type until another type of certificate has been used. For example, if
NOTE
EC certificate is imported in the system, it switches to EC encryption.
Key size
By default - 2048. Currently considered as unbreakable. In the near future it is recommended that a
longer length be used. Currently 3072 is considered safe until year 2030 with existing hardware
architectures. A length of 4096 is practically unbreakable.
Certificates provider
The Certificates provider option makes it possible to use a PKCS11 compliant backend to store certificates
and private keys instead of using the default configuration database. The PKCS11 API is implemented by most
smart cards and HSM devices, which can be used to securely store private keys.
146.3. Mail
To be able to send notification emails, an SMTP server is required. The Mail tab provides a form where the SMTP
server settings can be specified.
1420
Chapter 146. Settings NXLog User Guide
146.5. License
The License tab provides a form where the license file can be uploaded and the license details are shown.
1421
NXLog User Guide Chapter 146. Settings
If the license is invalid or expired, a message will be displayed in a horizontal red band as shown in the following
image.
1422
Chapter 146. Settings NXLog User Guide
Settings
The User Settings tab allows to the logged in user to change his/her name, email address, user interface
language and theme. The email address will be used for system notifications.
Change password
The Change Password tab allows to the logged in user to change his/her password.
1423
NXLog User Guide Chapter 147. Users, Roles, and Access Control
147.1. Users
The user management interface can be accesed by clicking on the USERS menu item under the ADMIN menu.
The default installation has only the admin user. To add a new user, click on the Add User below the left panel as
seen in the following screenshot.
The following dialog window will appear where the user’s details and credentials can be provided.
1424
Chapter 147. Users, Roles, and Access Control NXLog User Guide
Make sure to toggle the Enable user checkbox. After clicking on Submit, the newly created user should appear in
the list.
You can select the user in the list and click Edit. This lets you change the user information and user’s roles.
The assigned roles are shown in the second block in the right hand side. Click Edit to modify the user’s roles. The
following fragment will appear:
1425
NXLog User Guide Chapter 147. Users, Roles, and Access Control
Select the roles needed for this user. When all required roles are added, click Save. If ROLE_ADMINISTRATOR or
ROLE_CERTIFICATE is assigned in this box, the application will ask for user’s password in order to generate his
certificates encryption key. If the user is LDAP user, no password is required as in "Add user" dialog.
By default the roles are with read-write permissions. To restrict certain roles to read-only, click
NOTE
once at the selected role.
147.2. Roles
The role management interface can be accesed by clicking on the ROLES menu item under the ADMIN menu.
By default NXLog Manager comes with a built-in set of roles which are listed in the following screenshot on the
left.
1426
Chapter 147. Users, Roles, and Access Control NXLog User Guide
ROLE_ADMINISTRATOR
All functions are available to the user who has this role.
ROLE_AGENT
The AGENTS menu is not visible and the user may not configure, view or manage the agents without this role
(or ROLE_ADMINISTRATOR).
ROLE_CERTIFICATE
The user may not access the PKI system (CERTIFICATES menu) and issue, modify or access certificates in any
way without this role (or ROLE_ADMINISTRATOR).
ROLE_CORRELATION
The user may not create, modify or access any correlation rules and the CORRELATION menu without this role
(or ROLE_ADMINISTRATOR).
ROLE_PATTERN
The user may not create, modify or delete patterns without this role (or ROLE_ADMINISTRATOR).
ROLE_READONLY
This is a special role which denies any modification to the system by the user who has this.
ROLE_USER_MANAGEMENT
The user may not access the user and role management system to create, modify or delete users and roles
without this role (or ROLE_ADMINISTRATOR).
The above built-in roles may not be removed from the system.
It may be necessary to create special roles for more sophisticated access control Click Add role below the role
1427
NXLog User Guide Chapter 147. Users, Roles, and Access Control
Click Submit after filling in the role’s name. It should appear in the list.
1428
NXLog User Guide
NXLog Add-Ons
Various add-ons are available for NXLog, which provide specialized integration with various software and
services.
1429
NXLog User Guide Chapter 148. Amazon S3
NXLog can both receive events from and send events to Amazon S3 cloud storage. The NXLog Python modules
for input and output (im_python and om_python) are used for this, as well as Boto3, the AWS SDK for Python. For
more information about Boto3, see AWS SDK for Python (Boto3) on Amazon AWS.
NOTE The python2-boto3 package requires the installation of the EPEL repository.
~/.aws/config
[default]
region=eu-central-1
~/.aws/credentials
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
The region and credential configuration can also be hardcoded in the scripts, but this is not
NOTE
recommended.
Both the input and output Python scripts interact with a single bucket on Amazon S3. The scripts will not create,
delete, or alter the bucket or any of its properties, permissions, or management options. It is the responsibility of
the user to create the bucket, provide the appropriate permissions (ACL), and further configure any lifecycle,
replication, encryption, or other options. Similarly, the scripts do not alter the storage class of the objects stored
or any other properties or permissions.
We selected a schema where we store events on a single bucket and each object has a key that references the
server (or service) name, the date, and the event received time. Though Amazon S3 uses a flat structure to store
1430
Chapter 148. Amazon S3 NXLog User Guide
objects, objects with similar key prefixes are grouped together resembling the structure of a file system. The
following is a visual representation of the naming scheme used. Note that the key name in the deepest level
represents a time—however, Amazon S3 uses the colon (:) as a special character and to avoid escaping we
selected the dot (.) character to substitute it.
• MYBUCKET/
◦ SERVER01/
▪ 2018-05-17/
▪ 12.36.34.1
▪ 12.36.35.1
▪ 2018-05-18/
▪ 10.46.34.1
▪ 10.46.35.1
▪ 10.46.35.2
▪ 10.46.36.1
◦ SERVER02/
▪ 2018-05-16/
▪ 14.23.12.1
▪ 2018-05-17/
▪ 17.03.52.1
▪ 17.03.52.2
▪ 17.03.52.3
Events are stored in the Amazon S3 bucket with object key names comprised from the server name, date in
YYYY-MM-DD format, time in HH.MM.SS format, and a counter (since multiple events can be received during the
same second).
1431
NXLog User Guide Chapter 148. Amazon S3
This configuration reads raw events from a file with im_file and uses om_python to forward them, without
any additional processing, to the configured S3 storage.
nxlog.conf
1 <Input file>
2 Module im_file
3 File "input.log"
4 # These may be helpful for testing
5 SavePos FALSE
6 ReadFromLast FALSE
7 </Input>
8
9 <Output s3>
10 Module om_python
11 PythonCode s3_write.py
12 </Output>
13
14 <Route file_to_s3>
15 Path file => s3
16 </Route>
The script keeps track of the last object retrieved from Amazon S3 by means of a file called lastkey.log, which
is stored locally. Even in the event of an abnormal termination, the script will continue from where it stopped.
The lastkey.log file can be deleted to reset that behavior (or edited if necessary).
2. Edit the BUCKET, SERVER, and POLL_INTERVAL variables in the code. The POLL_INTERVAL is the time the script
will wait before checking again for new events. The MAXKEYS variable should be fine in all cases with the
default value of 1000 keys.
3. Configure NXLog with an im_python instance.
1432
Chapter 148. Amazon S3 NXLog User Guide
This configuration collects events from the configured S3 storage with im_python and writes the raw events
to file with om_file (without performing any additional processing).
nxlog.conf
1 <Input s3>
2 Module im_python
3 PythonCode s3_read.py
4 </Input>
5
6 <Output file>
7 Module om_file
8 File "output.log"
9 </Output>
10
11 <Route s3_to_file>
12 Path s3 => file
13 </Route>
Pickling Events
import pickle
all = {}
for field in event.get_names():
all.update({field: event.get_field(field)})
newraw = pickle.dumps(all)
out = StringIO.StringIO()
with gzip.GzipFile(fileobj=out, mode="w") as f:
f.write(newraw)
gzallraw = out.getvalue()
1433
NXLog User Guide Chapter 149. Box
The Box add-on can be used to pull events from Box using their REST API. Events will be passed to NXLog in
Syslog format with the JSON event in the message field.
2. Edit the configuration entries in the script as necessary, or use arguments to pass configuration to the script
as shown in the example below.
3. Configure NXLog to collect events with the im_exec module.
The script saves the current timestamp to a state file in order to properly resume when it is terminated. If the
state file does not exist, the script will collect logs beginning with the current time. To manually specify a starting
timestamp (in milliseconds since the epoch), pass it as an argument: ./box-pull.pl
--stream_position=1440492435762.
1434
Chapter 149. Box NXLog User Guide
This configuration uses the im_exec module to run the script, which connects to Box and returns Syslog-
encapsulated JSON. The xm_syslog parse_syslog() and xm_json parse_json() procedures are used to parse
each event into internal NXLog fields. Additional modification to the fieldset can be added, as required, in
the Input instance Exec block.
For the sake of demonstration, all internal fields are then converted back to JSON and written to file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input box>
10 Module im_exec
11 Command /opt/nxlog/lib/nxlog/box-pull.pl
12 Arg --client_id=YEKigehUh0u4pXeKSgKzwTbfii2stCwU
13 Arg --client_secret=3VRiqMuPDuUYeTXA5Ds9R0B4TnL35WRy
14 Arg --enterprise_id=591376
15 Arg --oauthurl=https://api.box.com/oauth2/token
16 Arg --certkeyfile=privkey.pem
17 Arg --baseurl=https://api.box.com/2.0
18 Arg --pollinterval=5
19 Arg --statefile=/opt/nxlog/var/lib/nxlog/box-pull.dat
20 Arg --syslogpri=⑬
21 <Exec>
22 parse_syslog();
23 parse_json($Message);
24 </Exec>
25 </Input>
26
27 <Output file>
28 Module om_file
29 File '/tmp/output'
30 Exec to_json();
31 </Output>
1435
NXLog User Guide Chapter 150. Cisco FireSIGHT eStreamer
The eStreamer add-on can be used with NXLog to collect events from a Cisco FireSIGHT System. The Cisco Event
Streamer (eStreamer) API is used for communication between NXLog and the FireSIGHT System. This section
describes how to set up FireSIGHT and NXLog and start collecting events.
For more information about eStreamer, see FireSIGHT System eStreamer Integration Guide v5.4 on Cisco.com. To
download the full Firepower eStreamer SDK, see eStreamer SDK Version 6.1 on Cisco Community.
Depending on the Cisco system, the eStreamer configuration and client creation page
NOTE location may differ. In other systems, the same page can be found under System → Local →
Registration → eStreamer.
2. Select the event types that should be sent and then click [Save].
3. Enter an IP address or a resolvable name in the Hostname field and optionally a password. Click [Save].
4. Click on the download arrow to download the certificate for the client. Place the PKCS12 certificate in the
same directory as the Perl client.
1436
Chapter 150. Cisco FireSIGHT eStreamer NXLog User Guide
1. Make sure the following required Perl modules, which are part of the FireSIGHT eStreamer SDK, are present
in the same directory: SFStreamer.pm, SFPkcs12.pm, SFRecords.pm, and SFRNABlocks.pm.
2. Edit the script and set the configuration options. The available options include the following.
◦ The server address and port
◦ The file name and password used for the PKCS12 certificate
◦ Enable/disable verbose output
◦ The start time for receiving events: using bookmarks (by setting to bookmark) ensures that no events will
be lost or duplicated.
◦ The output mode: typically this is set to \&send_nxlog; however there is a \&send_stdout_raw output
where all data and meta-data is printed to standard output (for debugging purposes).
3. In the $OUTPUT_PLUGIN section of the script, the type of event request can be customised. Refer to the
FireSIGHT System eStreamer Integration Guide for more information.
4. Finally, the output mode subroutine \&send_nxlog might require modification if the presentation of the data
needs to be altered or alternative data or metadata need to be included or excluded. The \&send_stdout
subroutine can be used to show the output sent to NXLog and the \&send_stdout_raw can be used to show
the full contents of the data stream. Remember to set the $conf_opt->{output} variable to the appropriate
subroutine.
1437
NXLog User Guide Chapter 150. Cisco FireSIGHT eStreamer
This configuration uses the im_perl module to execute the Perl script. The resulting internal NXLog fields
are then converted to JSON format before being written to file with om_file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Input estreamer>
6 Module im_perl
7 PerlCode /opt/nxlog/bin/estreamer.pl
8 </Input>
9
10 <Output file>
11 Module om_file
12 File '/tmp/output.log'
13 Exec to_json();
14 </Output>
15
16 <Route estreamer_to_file>
17 Path estreamer => file
18 </Route>
Output Sample
{
"EventTime": "2018-1-24 11:50:23.939847",
"AlertPriority": 3,
"SourceIp": "192.168.99.2",
"SourcePort": 0,
"DestinationIp": "192.168.98.2",
"DestinationPort": 0,
"EventMessage": "PROTOCOL-ICMP Echo Reply",
"EventReceivedTime": "2018-01-24 11:50:29",
"SourceModuleName": "perl",
"SourceModuleType": "im_perl"
}
{
"EventTime": "2018-1-24 11:50:34.499867",
"AlertPriority": 3,
"SourceIp": "192.168.98.2",
"SourcePort": 0,
"DestinationIp": "192.168.99.2",
"DestinationPort": 0,
"EventMessage": "PROTOCOL-ICMP Echo Reply",
"EventReceivedTime": "2018-01-24 11:50:35",
"SourceModuleName": "perl",
"SourceModuleType": "im_perl"
}
An ICMP Echo Reply is not typically an intrusion detection event; however, it was a
NOTE
convenient way to simulate one.
1438
Chapter 151. Cisco Intrusion Prevention Systems (CIDEE) NXLog User Guide
The Cisco IPS add-on supports collection of alerts from an IPS-enabled device. The Security Device Event
Exchange (SDEE) API is used for communication between NXLog and the IPS.
151.1. Setup
1. Install the add-on.
2. Set the correct connection details in the script by editing the sdee("cisco","cisco","192.168.100.254",
"http","cgi-bin/sdee-server/","yes"); line in the read_data() subroutine. Set the appropriate
username, password, hostname or IP address, protocol, path, and force subscription.
◦ For username and password, a suitable user with the appropriate privilege level must be selected.
◦ The protocol can be http or https; however, HTTPS requires that the appropriate SSL options are
enabled further down in the sdee() subroutine.
◦ The default path for the SDEE service can be changed if necessary.
◦ We recommend using force subscription, but the default of yes can be changed to no if required.
3. Upon start-up, the script will open a connection to the device and request a subscription ID. It will then
periodically ask for new alerts. The interval that the device is queried for new alerts can be set by changing
the set_read_timer() NXLog function in the script.
Once alerts are available on the device the script will parse the XML source, format the alert, and pass it to
NXLog.
The script only collects alerts, but it can be modified to collect status and error messages too.
The primary subroutine that sorts out the information received is idsmxml_parse_alerts(). If
NOTE
the device uses a different CIDEE version, or to filter/modify information, modify the code there.
The final format of the alert messages is specified in the generate_raw_event() subroutine.
1439
NXLog User Guide Chapter 151. Cisco Intrusion Prevention Systems (CIDEE)
The configuration below collects IPS alerts from the configured Cisco IPS device. For simplicity, the output is
saved to a file in this example.
nxlog.conf
1 <Input perl>
2 Module im_perl
3 PerlCode /opt/nxlog/bin/cisco-ips.pl
4 </Input>
5
6 <Output file>
7 Module om_file
8 File '/tmp/output.log'
9 </Output>
10
11 <Route perl_to_file>
12 Path perl => file
13 </Route>
Input Sample
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<sd:events
xmlns:cid="http://www.cisco.com/cids/2003/08/cidee"
xmlns:sd="http://example.org/2003/08/sdee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example.org/2003/08/sdee sdee.xsd
http://www.cisco.com/cids/2003/08/cidee cidee.xsd">
<sd:evIdsAlert eventId="15117815226791" vendor="Cisco" severity="medium">
<sd:originator>
<sd:hostId>R1</sd:hostId>
</sd:originator>
<sd:time offset="0" timeZone="UTC">1511781522011779176</sd:time>
<sd:signature description="SYN Flood DOS" id="6009" version="S593">
<cid:subsigId>0</cid:subsigId>
<cid:sigDetails>SYN Flood DOS</cid:sigDetails>
</sd:signature>
<cid:protocol>tcp</cid:protocol>
<cid:riskRatingValue>63</cid:riskRatingValue>
<sd:participants>
<sd:attacker>
<sd:addr>192.168.100.1</sd:addr>
<sd:port>53760</sd:port>
</sd:attacker>
<sd:target>
<sd:addr>192.168.99.10</sd:addr>
<sd:port>2717</sd:port>
</sd:target>
<sd:vrf_name>NONE</sd:vrf_name>
</sd:participants>
<sd:actions></sd:actions>
<cid:interface>Fa0/0</cid:interface>
<cid:vrf_name>NONE</cid:vrf_name>
</sd:evIdsAlert>
<sd:evIdsAlert eventId="15117815236793" vendor="Cisco" severity="informational">
<sd:originator>
<sd:hostId>R1</sd:hostId>
1440
Chapter 151. Cisco Intrusion Prevention Systems (CIDEE) NXLog User Guide
</sd:originator>
<sd:time offset="0" timeZone="UTC">1511781523475744440</sd:time>
<sd:signature description="Back Door Probe (TCP 1234)" id="9007" version="S256">
<cid:subsigId>0</cid:subsigId>
<cid:sigDetails>SYN to TCP 1234</cid:sigDetails>
</sd:signature>
<cid:protocol>tcp</cid:protocol>
<cid:riskRatingValue>18</cid:riskRatingValue>
<sd:participants>
<sd:attacker>
<sd:addr>192.168.100.1</sd:addr>
<sd:port>57422</sd:port>
</sd:attacker>
<sd:target>
<sd:addr>192.168.99.10</sd:addr>
<sd:port>1234</sd:port>
</sd:target>
<sd:vrf_name>NONE</sd:vrf_name>
</sd:participants>
<sd:actions></sd:actions>
<cid:interface>Fa0/0</cid:interface>
<cid:vrf_name>NONE</cid:vrf_name>
</sd:evIdsAlert>
</sd:events>
</env:Body>
</env:Envelope>
Output Sample
2017-11-28 22:29:41 UTC+0; eventid="15119009816528; hostId="R1"; severity="medium";
app_name=""; appInstanceId=""; signature="6009"; subSigid="0"; description="SYN Flood DOS";
attacker="192.168.100.1"; attacker_port="40784""; target="192.168.99.10"; target_port="4003;
protocol="tcp"; risk_rating="63"; target_value_rating=""; interface="Fa0/0";
interface_group=""; vlan=""↵
2017-11-28 22:29:44 UTC+0; eventid="15119009846539; hostId="R1"; severity="informational";
app_name=""; appInstanceId=""; signature="9007"; subSigid="0"; description="SYN to TCP 1234";
attacker="192.168.100.1"; attacker_port="43242""; target="192.168.99.10"; target_port="1234;
protocol="tcp"; risk_rating="18"; target_value_rating=""; interface="Fa0/0";
interface_group=""; vlan=""↵
NOTE The two samples are from different but similar alerts.
1441
NXLog User Guide Chapter 152. Exchange (nxlog-xchg)
Microsoft Exchange provides two types of audit logs: administrator audit logging and mailbox audit logging. For
more information, see
The nxlog-xchg add-on can be used to retrieve administrator audit logs and mailbox audit logs. These logs include
actions taken by users or administrators who make changes in the organization, mailbox actions, and mailbox
logins including access by users other than the mailbox owner. For more information, see Administrator audit
logging in Exchange 2016 and Mailbox audit logging in Exchange 2016 on TechNet.
nxlog-xchg periodically queries an Exchange server via Windows Remoting (WinRM) and writes the result to
standard output in JSON format for further processing by NXLog. The add-on is executed by NXLog via the
im_exec module, and may be configured on either the Exchange server itself or another system.
The required steps may vary from those provided below based on the organization and domain
NOTE
topology and configuration.
152.1. Requirements
Server side requirements include:
NOTE The server and client can reside on the same machine.
WinRM remote login is only allowed for users in the local Administrator group, or Domain
NOTE Administrator group. The user created for login via WinRM must be a member of one of
these groups.
2. Windows Remoting (WinRM) will accept the connections from nxlog-xchg. By default, WinRM will listen on TCP
port 5985 for HTTP (insecure) requests. WinRM should be configured to listen for secure connections on
TCP/5986. Check if it is configured:
If the command above does not return any results, then on the Exchange server, from an elevated command
1442
Chapter 152. Exchange (nxlog-xchg) NXLog User Guide
line (cmd), run the following command to enable WinRM HTTPS transport.
3. If there is an error message about the system not having an appropriate (server authentication) certificate,
issue one for the server or create a self-signed one. To create a self signed certificate, open a Powershell
window and run these commands.
If you are having trouble creating a self-signed certificate (getting unaccessible private keys
NOTE in Windows 10 or Windows 2016), try using the Self-signed certificate generator from
Microsoft Script Center.
4. After the certificate has been prepared, open a PowerShell window and run:
5. After this it should not be necessary to run the quick config for WinRM and the HTTP listener can be removed
(assuming it is no longer needed otherwise).
6. The "Audit Logs" role most be added to the Active Directory user to access the "Search-AdminAuditLog" and
"Search-MailboxAuditLog" Exchange cmdlets.
PS> New-ManagementRoleAssignment -Name nxlog-xchg-mr -Role "Audit Logs" -User "Active Directory
User Name"
8. Mailbox audit logging can be enabled on a per user basis, using the Exchange Management shell. nxlog-xchg
respects the options configured in the Exchange server. To enable mailbox audit logging for a single user,
open an Exchange Management Shell and run:
To enable audit logging for all user mailboxes in the organization, run:
For more information about mailbox audit logging (including more logging options), see Enable or disable
mailbox audit logging for a mailbox on Microsoft Docs.
1443
NXLog User Guide Chapter 152. Exchange (nxlog-xchg)
[WinRM]
Url=https://host.yourdomain.com:5986/wsman
User=winrmuser@yourdomain.com
Password=winrmuser_password
CheckCertificate=TRUE
[Exchange]
HostFQDN=exchange.yourdomain.com
ExchangeUser=ex_user@yourdomain.com
ExchangePassword=exuser_password
ExchangeAuth=KERBEROS
[Options]
SearchAdminLog=TRUE
SearchMailboxLog=TRUE
ResultSize=5000
Nxlog section:
SavePos
This optional boolean directive specifies whether the last record number should be saved when nxlog-xchg
exits. The default is TRUE.
PollInterval
This optional directive specifies the time (in seconds) between polls. Valid values are 3-3600; the default is 30
seconds.
WinRM section:
Url
This specifies the URL of the WinRM listener (for example,
https://exchangeserver.mydomain.com:5986/wsman).
User
This specifies the user that has permission to log on to the Exchange Server system.
Password
This should be set to the password of the user defined in User above.
1444
Chapter 152. Exchange (nxlog-xchg) NXLog User Guide
Auth
The authentication method to use when establishing a WinRM connection (KERBEROS or NTLM). NTLM is the
default authentication method used if this is not set.
CheckCertificate
This optional boolean directive specifies whether the server certificate should be verified. The default is TRUE
(the certificate is validated).
Exchange section:
HostURI
This sets the full URI to use for the remote PowerShell connection (for example,
http://name.domain.tld/PowerShell/).
ExchangeUser
This specifies the user that has permission to query the Exchange Server.
ExchangePassword
This should be set to the password of the user defined in ExchangeUser above.
ExchangeAuth
The authentication method to use when establishing a connection to PowerShell on the Exchange server
(KERBEROS or NTLM). Kerberos is the default is authentication method used if this is not set.
Options section:
QueryAdminLog
This optional boolean directive specifies whether the administrator audit log should be queried. The default is
TRUE (the administrator audit log is queried).
QueryMailboxLog
This optional boolean directive specifies whether the mailbox audit log should be queried. The default is
TRUE (the mailbox audit log is queried).
ResultSize
This optional directive specifies the maximum number of log entries to retrieve. The default is 5000 entries.
1445
NXLog User Guide Chapter 152. Exchange (nxlog-xchg)
This configuration uses the im_exec module to receive logs from nxlog-xchg, and writes them to file locally
with om_file.
nxlog.conf
1 <Input in>
2 Module im_exec
3 Command 'C:\Program Files (x86)\nxlog-exchange\nxlog-xchg.exe'
4 Arg -c
5 Arg C:\Program Files (x86)\nxlog-xchg\nxlog-xchg.cfg
6 </Input>
7
8 <Output out>
9 Module om_file
10 File "C:\\logs\\exchange_audit_log.txt"
11 </Output>
12
13 <Route ex>
14 Path in => out
15 </Route>
152.4. Performance
It is important to configure nxlog-xchg so the server is not polled too frequently (running nxlog-xchg too often) or
infrequently (requiring the collection of a very large result set). If PollInterval is properly adjusted, there should
not be any performance issue.
152.5. Troubleshooting
Nxlog-xchg does not launch from NXLog
Make sure the quotations in the im_exec block are correct. This can be tested by placing a simple batch script
(containing echo "Hello world", for example) into the same directory as nxlog-xchg.exe and calling that
batch file from im_exec.
No events received
If no events are being received, make sure the relevant logging is enabled in Exchange. For admin audit
logging run:
1446
Chapter 153. Microsoft Azure and Office 365 NXLog User Guide
This NXLog add-on can retrieve information about various user, admin, system, and policy actions and events
from Microsoft Azure and Office 365. Once configured, the add-on prints Syslog events, each with a JSON
payload, to standard output for processing by NXLog.
The add-on supports getting logs from the following reports corresponding to the supported Microsoft REST-
based APIs:
• Azure Active Directory reports (based on Microsoft Graph API) — Sign-In events and directory audit log
events.
• Office 365 Management Activity API — Azure Active Directory Audit events, Exchange Audit events and
Sharepoint Audit events using the Audit.AzureActiveDirectory, Audit.Exchange, and Audit.SharePoint
parameters.
• Office 365 Service Communications API — Status, service and message related events, using the
CurrentStatus, HistoricalStatus, Messages, and Services parameters.
For more information about the log sources, see the links below:
153.1. Prerequisites
In order to complete the steps in this section and collect logs from the above mentioned APIs, the following
prerequisites laid out in this section will need to be met.
During the steps explained in this section you need to make a note of the following data:
• client_id
• tenant_domain <domainname>.onmicrosoft.com
• tenant_id
• certthumbprint
• certkeyfile <certkey.pem>
Some of the add-on arguments (parameters) require certain permissions set in MS Azure. They are listed in the
table below with a reference to the Microsoft documentation. Their configuration is detailed in the Parameters
section below.
1447
NXLog User Guide Chapter 153. Microsoft Azure and Office 365
Azure AD
Microsoft Docs
Parameter API used permissions
link
required
--service_communication_operatio An Office 365 license, or a license that includes it See reference link
ns
--management_activity_sources An Office 365 license, or a license that includes it See reference link
For troubleshooting/debugging purposes, the list of active license SKUs can be retrieved through the --license
-details switch.
As Microsoft’s licensing information can be subject to change at any time, always double-
IMPORTANT check your current requirements with the licensing/service plan documentation. The
required licenses can be managed in the Microsoft 365 admin center.
NOTE The above table with the licensing requirements are for informational purposes only.
1448
Chapter 153. Microsoft Azure and Office 365 NXLog User Guide
153.2.1. Installing the Microsoft Azure and Office 365 NXLog Add-On
1. Install the add-on with dpkg:
# dpkg -i nxlog-msazure-<version>.deb
# apt-get -f install
Once the new application has been registered, make note of the Application (client) ID (this will be the
client_id), as well as the Directory (tenant) ID (this will be tenant_id) on the Overview page for the new
application.
1449
NXLog User Guide Chapter 153. Microsoft Azure and Office 365
• AuditLog.Read.All
• Directory.Read.All
• ActivityFeed.Read
• ServiceHealth.Read
Once your permissions are set up and the Admin consent is granted, your permission list should look like the
one below.
The gencertkey.sh script depends on the openssl toolkit and the uuidgen program. Install the corresponding
packages if necessary.
On Debian-based platforms:
On Centos/RedHat platforms:
Follow the steps below to generate the X.509 certificate and insert the relevant portion into the manifest file in
MS Azure:
1. Generate the certificate with the gencertkey.sh script on the computer where the add-on is installed.
1450
Chapter 153. Microsoft Azure and Office 365 NXLog User Guide
$ ./gencertkey.sh
Generating a RSA private key
............+++++
................................................+++++
writing new private key to 'certkey.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
ThumbPrint:0nFt3fB0JP7zuSmHaRQtmsFNYqo=
"keyCredentials": [
{
"customKeyIdentifier":"0nFt3fB0JP7zuSmHaRQtmsFNYqo=",
"keyId":"629ab88d-1059-454b-b258-4ca05b46dee4",
"type":"AsymmetricX509Cert",
"usage":"Verify",
"value":"MIIDXTCCAkWgAwIBAgIJAP+XrnwhAxjOMA0GCSqGSIb3DQEBCwUAMEUxCzAJB..."
}
],
Make note of the the base64-encoded certificate fingerprint value after ThumbPrint: (certthumbprint), and
the KeyCredentials portion (which will be used in the following steps).
2. In the App registration page in MS Azure, select Manifest on the left side and click Download.
3. Edit the downloaded manifest file and replace the "empty" KeyCredentials section with the previously
1451
NXLog User Guide Chapter 153. Microsoft Azure and Office 365
generated output.
From
"keyCredentials": [],
To
"keyCredentials": [
{
"customKeyIdentifier":"0nFt3fB0JP7zuSmHaRQtmsFNYqo=",
"keyId":"629ab88d-1059-454b-b258-4ca05b46dee4",
"type":"AsymmetricX509Cert",
"usage":"Verify",
"value":"MIIDXTCCAkWgAwIBAgIJAP+XrnwhAxjOMA0GCSqGSIb3DQEBCwUAMEUxCzAJB..."
}
],
Follow the steps below to move the generated certificate files to their intended directory as well as make the
required permission changes:
1. Move the certificates you generated into the /opt/nxlog-msazure/conf directory. This directory is used
later on as a value for the --working_directory parameter.
$ mv cert* /opt/nxlog-msazure/conf/
2. Set the file ownership and permissions to be in agreement with the User and Group directives (NXLog runs
under the nxlog user and nxlog group by default).
153.3. Parameters
Certain parameters need to be passed to the NXLog Microsoft Azure and Office 365 add-on as arguments in
1452
Chapter 153. Microsoft Azure and Office 365 NXLog User Guide
order to achieve the desired outcome. These parameters can be passed to the add-on by using the Arg directive.
--client_id=
The Azure App registration Application (client) ID
--tenant_id=
The Azure App registration Directory (tenant) ID
--certthumbprint=
The certificate fingerprint value
--tenant_domain=
The domain name created in MS Azure AD <domainname>.onmicrosoft.com
--certkeyfile=
The certificate key file certkey.pem
--working_directory=
The path where the add-on is run, which is /opt/nxlog-msazure/conf by default
--enable-azure-ad-reports
Active Directory sign-in events and directory audit logs ( based on Microsoft Graph API ). This parameter does
not require any value to be passed to it.
--management_activity_sources=
Office 365 Management Activity API
--service_communication_operations=
Office 365 Service Communications API
--top=n
The top parameter works only with Azure Active Directory reports and events. It returns a subset of the
entries for the given report, consisting of the first n entries, where n is a positive integer. top=5 returns the 5
most recent audit report events. top will be overridden where start_date and end_date can be used—top is
1453
NXLog User Guide Chapter 153. Microsoft Azure and Office 365
lower priority.
--start_date=YYYY-MM-DDTHH:MM:SSZ|amonthago|aweekago|yesterday
--end_date=YYYY-MM-DDTHH:MM:SSZ|amonthago|aweekago|yesterday|now
The start_date and end_date parameters specify the time range of content to return. These parameters
work with all Office 365 reports and most of the Azure Active Directory reports. Where start/end ranges are
not supported, the add-on uses top. The amonthago, aweekago, yesterday, and now values are dynamic and
calculated in every loop.
--log_errors=path
For troubleshooting purposes, the --log_errors argument is available. The value of this parameter is a path
to a file where the add-on will write all its error messages.
The Microsoft documentation lists API errors and responses respectively in the Office 365
NOTE
API errors and Microsoft Graph error responses pages.
--add_syslog_header=true|false|yes|no
Enable or disable the Syslog header.
--infinity=true|false|yes|no
Indicates that the script should never stop and should pull logs in an endless loop. The default is true. This
can be set to false for special cases or debugging, when the script should run once and then exit.
--skip_state_file=true|false|yes|no
If true, the script will neither read from nor write to the state files. The default is false.
--sleep=n
The script will sleep n seconds between loops.
--verbose=true|false|yes|no
For debugging; if true, provides as much detail as possible about what the script is doing. The default is
false. In normal mode, the script should print only events, logs, and reports (data it retrieves from the APIs).
The script emits all diagnostic messages to standard error.
--license-details=true|false|yes|no
For troubleshooting/debugging purposes; if true, a list of active license SKUs will be retrieved. The default is
false.
1454
Chapter 153. Microsoft Azure and Office 365 NXLog User Guide
This configuration collects all the Azure Active Directory report events, such as user creation, group
membership, permission changes and so on. The output provided by Microsoft is in JSON format.
nxlog.conf
1 <Input msazurepull>
2 Module im_exec
3 Command /opt/nxlog-msazure/bin/msazure-pull.sh
4 Arg --client_id=912497ba-9780-46bc-a6a6-3a56a4c14278
5 Arg --tenant_id=e681b493-14a8-438b-8bbf-d65abdc826c2
6 Arg --certthumbprint=D64Rm2IkRQxp26XK4Da7Bcbqu2o=
7 Arg --tenant_domain=contoso.onmicrosoft.com
8 Arg --certkeyfile=certkey.pem
9 Arg --working_directory=/opt/nxlog-msazure/conf
10 Arg --enable-azure-ad-reports
11 <Exec>
12 parse_syslog();
13 </Exec>
14 </Input>
1455
NXLog User Guide Chapter 153. Microsoft Azure and Office 365
This configuration collects Office 365 related events, such as document creation, deletion, permission
changes and so on. The output provided by Microsoft is in JSON format.
nxlog.conf
1 <Input msazurepull>
2 Module im_exec
3 Command /opt/nxlog-msazure/bin/msazure-pull.sh
4 Arg --client_id=912497ba-9780-46bc-a6a6-3a56a4c14278
5 Arg --tenant_id=e681b493-14a8-438b-8bbf-d65abdc826c2
6 Arg --certthumbprint=D64Rm2IkRQxp26XK4Da7Bcbqu2o=
7 Arg --tenant_domain=contoso.onmicrosoft.com
8 Arg --certkeyfile=certkey.pem
9 Arg --working_directory=/opt/nxlog-msazure/conf
10 Arg
--service_communication_operations=Services,CurrentStatus,HistoricalStatus,Messages
11 Arg
--management_activity_sources=Audit.Exchange,Audit.SharePoint,Audit.AzureActiveDirectory
12 <Exec>
13 parse_syslog();
14 </Exec>
15 </Input>
The first NXLog configuration example above would look like the one below if it were invoked from a terminal
1456
Chapter 153. Microsoft Azure and Office 365 NXLog User Guide
console. In this case, the received events would be continuously printed to the terminal.
$ /opt/nxlog-msazure/bin/msazure-pull.sh \
--client_id=912497ba-9780-46bc-a6a6-3a56a4c14278 \
--tenant_id=e681b493-14a8-438b-8bbf-d65abdc826c2 \
--certthumbprint=D64Rm2IkRQxp26XK4Da7Bcbqu2o= \
--tenant_domain=contoso.onmicrosoft.com \
--certkeyfile=certkey.pem \
--working_directory=/opt/nxlog-msazure/conf \
--enable-azure-ad-reports
1457
NXLog User Guide Chapter 154. MSI for NXLog Agent Setup
This add-on provides an example for building an MSI package which can be used to bootstrap an NXLog agent on
a Windows system. Normally this would be used to set up the agent for management by NXLog Manager—it
installs a custom configuration and a CA certificate. The package can be installed alongside the NXLog MSI.
1. The Windows Installer XML Toolset (Wix) is required to build the custom MSI. Wix is free software available
for download from wixtoolset.org.
2. Install Wix. Make a note where the binary folder of Wix is located (containing the candle.exe and light.exe
executables, typically C:\Program Files (x86)\WiX Toolset v3.11\bin).
3. Save the add-on files in a folder of your choosing and make sure the path to the binary folder is correct in
the pkgmsi32.bat (or pkgmsi64.bat) script by editing the WIX_BUILD_LOCATION variable.
4. For NXLog version 5.x add the custom agent-ca.pem and managed.conf files in the folder.
5. For NXLog version 4.x add the custom agent-ca.pem and log4ensics.conf files in the folder.
7. Finally, execute either the pkgmsi32.bat or the pkgmsi64.bat script, depending on the targeted
architecture. While both the resulting MSIs include platform independent files, we strongly advise to build
and install the appropriate custom configuration MSI that matches the NXLog installation.
8. The script will proceed to build the MSI. Depending on the architecture selected, the result will be either
nxlog-conf_x86.msi or nxlog-conf_x64.msi.
9. The custom configuration MSI can now be deployed alongside the NXLog installer, using one the same
methods (interactively, with Msiexec, or via Group Policy).
1458
Chapter 155. Okta NXLog User Guide
The Okta add-on can be used to pull events from Okta using their REST API. Events will be passed to NXLog in
Syslog format with the JSON event in the message field.
The script saves the current timestamp to a state file in order to properly resume when it is terminated. If the
state file does not exist, the script will collect logs beginning with the current time. To manually specify a starting
timestamp, pass it as an argument: ./okta-pull.pl --startdate="2014-10-29T17:13:24.000Z".
This configuration uses the im_exec module to run the script, which connects to Okta and returns Syslog-
encapsulated JSON. The xm_syslog parse_syslog() and xm_json parse_json() procedures are used to parse
each event into internal NXLog fields. Additional modification to the fieldset can be added, as required, in
the Input instance Exec block.
For the sake of demonstration, all internal fields are then converted back to JSON and written to file.
nxlog.conf
1 <Extension _json>
2 Module xm_json
3 </Extension>
4
5 <Extension _syslog>
6 Module xm_syslog
7 </Extension>
8
9 <Input okta>
10 Module im_exec
11 Command /opt/nxlog-okta/bin/okta-pull.pl
12 <Exec>
13 parse_syslog();
14 parse_json($Message);
15 </Exec>
16 </Input>
17
18 <Output file>
19 Module om_file
20 File '/tmp/output'
21 Exec to_json();
22 </Output>
1459
NXLog User Guide Chapter 156. Perlfcount
The perlfcount add-on is a Perl script that can be used with NXLog to collect system information and statistics on
Linux platforms.
1460
Chapter 157. Salesforce NXLog User Guide
The Salesforce add-on provides support for fetching Event Log Files from Salesforce with NXLog. The script
collects Event Log Files from a Salesforce instance by periodically running SOQL queries via the REST API. The
Events can then be passed to NXLog by different means, depending how the data collection is configured.
For more information about the Event Log File API, see EventLogFile in the Salesforce SOAP API Developer Guide.
The Event Logs feature of Salesforce is a a paid add-on feature. Make sure this feature is
NOTE
enabled on the Salesforce instance before continuing.
collect.conf.json
{
"log_level": "DEBUG",
"log_file": "var/collector.log",
"user": "user@example.com",
"password": "UxQqx847sQ",
"token": "ZsQO0k5gAgJch3mLUtEqt0K",
"url": "https://login.salesforce.com/services/Soap/u/39.0/",
"checkpoint": "var/checkpoint/",
"keep_csv": "True",
"output": "structured",
"header": "none",
"mode": "across",
"transport": "stdout",
"target": "file",
"limit": "5",
"delay": "3",
"request_delay": "3600"
}
A compact view of the command line options is shown below. Use salesforce.py -h to get help, including a
short explanation of the options.
salesforce.py usage
usage: salesforce.py [-h] [--config CONFIG] [--user USER]
[--password PASSWORD] [--token TOKEN] [--url URL]
[--checkpoint CHECKPOINT] [--keep_csv {True,False}]
[--output {json,structured}] [--header {none,syslog}]
[--mode {loop,across}] [--target TARGET] [--delay DELAY]
[--limit LIMIT] [--request_delay REQUEST_DELAY]
[--transport {file,socket,pipe,stdout}]
[--log_level {CRITICAL,ERROR,WARNING,INFO,DEBUG,NOTSET}]
[--log_file LOG_FILE]
1461
NXLog User Guide Chapter 157. Salesforce
It is not possible to find the security token of an existing profile. The solution is to reset it as
NOTE
described in Reset Your Security Token on Salesforce Help.
Depending on your setup, the mode parameter can be set to loop so that the script will look for new events
continuously or to across so that once all the available events are retrieved the script will terminate. When in
loop mode, the request_delay can be configured for the script to wait the specified number of seconds before
requesting more events.
Directories and files are created automatically when an event of that type is logged by
NOTE
Salesforce.
var/checkpoint/ApexExecution:
2018-02-08T00:00:00.000+0000.csv
2018-02-08T00:00:00.000+0000.state
var/checkpoint/LightningError:
2018-02-08T00:00:00.000+0000.csv
2018-02-08T00:00:00.000+0000.state
var/checkpoint/Login:
2018-02-08T00:00:00.000+0000.csv
2018-02-08T00:00:00.000+0000.state
var/checkpoint/Logout:
2018-02-08T00:00:00.000+0000.csv
2018-02-08T00:00:00.000+0000.state
var/checkpoint/PackageInstall:
2018-03-01T00:00:00.000+0000.csv
2018-03-01T00:00:00.000+0000.state
If this directory structure is removed, the script will be unable to determine the state and all
available events stored in your Salesforce instance will be retrieved and passed to NXLog
WARNING
again. However, after testing and determining that everything is configured correctly,
remember to delete the directory structure to reset the state.
Once all the available events have been downloaded and the script determines that no other events has been
added, it will proceed to process them and produce the final output. The limit and delay parameters can be set
to throttle the processing by limiting by number of records and delaying between blocks of records in seconds.
The script will delete the CSV files once those are processed. However, the keep_csv parameter can be set to
True to preserve them.
1462
Chapter 157. Salesforce NXLog User Guide
Structured Output
CLIENT_IP="46.198.211.113" OS_NAME="LINUX"
DEVICE_SESSION_ID="33ddcf5f751fdaf4b6a010d73014710ed2f13e33" BROWSER_NAME="CHROME"
BROWSER_VERSION="64" USER_AGENT=""Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/64.0.3282.186 Safari/537.36"" CLIENT_ID="" REQUEST_ID=""
SESSION_KEY="qomr/wgmbMU73iG6" DEVICE_ID="" CONNECTION_TYPE="" EVENT_TYPE="LightningError"
SDK_APP_VERSION="" SDK_APP_TYPE="" UI_EVENT_SOURCE="storage" SDK_VERSION="" UI_EVENT_SEQUENCE_NUM=""
LOGIN_KEY="5ujU+09kPSKatTxR" UI_EVENT_TYPE="error" PAGE_START_TIME="1519928816975" DEVICE_MODEL=""
USER_TYPE="Standard" ORGANIZATION_ID="00D1r000000rH0F" OS_VERSION=""
USER_ID_DERIVED="0051r000007NyeqAAC" UI_EVENT_ID="ltng:error" APP_NAME="one:one"
UI_EVENT_TIMESTAMP="1519928819334" USER_ID="0051r000007Nyeq" TIMESTAMP="20180301182702.187"
TIMESTAMP_DERIVED="2018-03-01T18:27:02.187Z" DEVICE_PLATFORM="SFX:BROWSER:DESKTOP"↵
JSON Output
{"CLIENT_IP": "Salesforce.com IP", "REQUEST_ID": "4GVCi4pxSjCESP-qby__7-", "SESSION_KEY": "",
"API_TYPE": "", "EVENT_TYPE": "Login", "SOURCE_IP": "46.198.211.113", "RUN_TIME": "143",
"LOGIN_KEY": "", "USER_NAME": "user@example.com", "CPU_TIME": "57", "BROWSER_TYPE": "Mozilla/5.0
(X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"URI": "/index.jsp", "ORGANIZATION_ID": "00D1r000000rH0F", "USER_ID_DERIVED": "0051r000007NyeqAAC",
"DB_TOTAL_TIME": "47093446", "LOGIN_STATUS": "LOGIN_NO_ERROR", "USER_ID": "0051r000007Nyeq",
"TIMESTAMP": "20180302083919.878", "TLS_PROTOCOL": "TLSv1.2", "REQUEST_STATUS": "", "CIPHER_SUITE":
"ECDHE-RSA-AES256-GCM-SHA384", "TIMESTAMP_DERIVED": "2018-03-02T08:39:19.878Z", "URI_ID_DERIVED":
"", "API_VERSION": "9998.0"}
NOTE The samples above are not from the same event.
The formatted output can then be displayed in standard output, passed to another program by a named pipe,
saved to a file, or sent to another program using Unix Domain Sockets (UDS). This can be controlled by setting
the transport parameter to stdout, pipe, file, or socket respectively. When the transport is pipe, file, or socket the
target parameter can be used to set the name of the pipe, file, or socket.
A first scenario is that NXLog is running the script directly and consumes the data from the script. To do this, the
script should be running in loop mode, so that events are fetched periodically from Salesforce.
1463
NXLog User Guide Chapter 157. Salesforce
NXLog executes salesforce.py, which in turn collects events every hour, processes them, formats them as
JSON with a Syslog header, and forwards them to NXLog.
collect.conf.json
{
"log_level": "DEBUG",
"log_file": "var/collector.log",
"user": "user@example.com",
"password": "UxQqx847sQ",
"token": "ZsQO0k5gAgJch3mLUtEqt0K",
"url": "https://login.salesforce.com/services/Soap/u/39.0/",
"checkpoint": "var/checkpoint/",
"keep_csv": "True",
"output": "json",
"header": "syslog",
"mode": "loop",
"transport": "stdout",
"target": "file",
"limit": "100",
"delay": "3",
"request_delay": "3600"
}
nxlog.conf
1 <Extension _syslog>
2 Module xm_syslog
3 </Extension>
4
5 <Extension _json>
6 Module xm_json
7 </Extension>
8
9 <Input messages>
10 Module im_exec
11 Command ./salesforce.py
12 <Exec>
13 parse_syslog();
14 parse_json($Message);
15 </Exec>
16 </Input>
17
18 <Output out>
19 Module om_file
20 File "output.log"
21 </Output>
22
23 <Route messages_to_file>
24 Path messages => out
25 </Route>
A second scenario: set up NXLog to listen on a UDS for events and use either NXLog or an external scheduler to
run salesforce.py. In this case, salesforce.py runs in across mode.
1464
Chapter 157. Salesforce NXLog User Guide
Be sure to provide ample time for the script to finish executing before the scheduler starts
WARNING a new execution. Or use a shell script that prevents running multiple instances
simultaneously.
collect.conf.json
{
"log_level": "DEBUG",
"log_file": "var/collector.log",
"user": "user@example.com",
"password": "UxQqx847sQ",
"token": "ZsQO0k5gAgJch3mLUtEqt0K",
"url": "https://login.salesforce.com/services/Soap/u/39.0/",
"checkpoint": "var/checkpoint/",
"keep_csv": "True",
"output": "structured",
"header": "none",
"mode": "across",
"transport": "socket",
"target": "uds_socket",
"limit": "100",
"delay": "3",
"request_delay": "3600"
}
nxlog.conf
1 <Extension exec>
2 Module xm_exec
3 <Schedule>
4 Every 1 hour
5 <Exec>
6 log_info("Scheduled execution at " + now());
7 exec_async("./salesforce.py");
8 </Exec>
9 </Schedule>
10 </Extension>
11
12 <Input messages>
13 Module im_uds
14 UDS ./uds_socket
15 UDSType stream
16 </Input>
17
18 <Output out>
19 Module om_file
20 File "output.log"
21 </Output>
22
23 <Route messages_to_file>
24 Path messages => out
25 </Route>
It is even possible to manually start the salesforce.py in loop mode with a large request_delay and collect via
UDS (as shown above) without the xm_exec instance. Or set the transport to file and configure NXlog to read
events with im_file.
1465
NXLog User Guide Chapter 157. Salesforce
Though events are captured in real time, Salesforce generates the Event Log Files during non-
NOTE
peak hours.
1466