Event log messages collected by the Windows Event Collector for syslog-ng PE use this special source. To collect Windows event log messages, include this source in one of your source statements.
The Windows Event Collector tool for syslog-ng PE collects the log messages of Windows-based hosts in Unix datagram sockets, and then forwards them to a syslog-ng PE server over HTTPS (using TLS encryption and mutual authentication). syslog-ng PE reads the log messages using the windowsevent() source, and then parses the logs into key-value paris using the XML parser.
The XML parser uses the list-handling functionality to handle lists in the XML. Note that you cannot disable the list-handling functionality for the windowsevent() source.
For more information, see Windows Event Collector Administration Guide.
Declaration
source s_wec {
windowsevent(
prefix(".windowsevent.")
unix-domain-socket("`syslog-ng-root`/var/run/wec.sock")
);
};
Starting with version 7.0.13, the syslog-ng PEwindowsevent() source can process XML arrays and make the elements of the arrays available as name-value pairs. For example, the following XML array becomes available as name-value pairs:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<EventID>5059</EventID>
</System>
<EventData>
<Data Name="SubjectUserSid">S-1-5-18</Data>
<Data Name="SubjectUserName">WIN-K1678A68SQ6$</Data>
</EventData>
From the previous example, the following name-value pairs become available: ${Event.System.EventID} (5059), ${Event.EventData.SubjectUserSid} (S-1-5-18), ${Event.EventData.SubjectUserName} (WIN-K1678A68SQ6$).
NOTE: The name-value pairs are only created from EventData.Data xml paths, that is, only for <Data> tags that are the children of an <EventData> tag and have the Name attribute.
If the array-like structure is not a Data tag under EventData tag, or it misses the Name attribute, then the regular XML-parser logic is used.
The windowsevent() driver has the following options:
prefix()
Type: |
string |
Default: |
".windowsevent." |
Description: The prefix that you wish to append to the key-value pairs.
If you want to send Windows event logs to SDATA, then set prefix(".SDATA."). This can be useful, for example, when you forward Windows event logs to a syslog-ng Store Box.
unix-domain-socket()
Type: |
string |
Default: |
/opt/syslog-ng/var/run/wec.sock |
Description: The path to the Unix domain socket to read messages from.
Sending and storing log messages — destinations and destination drivers
A destination is where a log message is sent if the filtering rules match. Similarly to sources, destinations consist of one or more drivers, each defining where and how messages are sent.
TIP: If no drivers are defined for a destination, all messages sent to the destination are discarded. This is equivalent to omitting the destination from the log statement.
To define a destination, add a destination statement to the syslog-ng configuration file using the following syntax.
destination <identifier> {
destination-driver(params);
destination-driver(params);
...
};
Example: A simple destination statement
The following destination statement sends messages to the TCP port 1999 of the 10.1.2.3 host.
destination d_demo_tcp {
network("10.1.2.3" port(1999));
};
If name resolution is configured, you can use the hostname of the target server as well.
destination d_tcp {
network("target_host" port(1999));
};
|
Caution:
-
Do not define the same drivers with the same parameters more than once, because it will cause problems. For example, do not open the same file in multiple destinations.
-
Do not use the same destination in different log paths, because it can cause problems with most destination types. Instead, use filters and log paths to avoid such situations.
-
Sources and destinations are initialized only when they are used in a log statement. For example, syslog-ng PE starts listening on a port or starts polling a file only if the source is used in a log statement. For details on creating log statements, see Routing messages: log paths, flags, and filters.
-
Hazard of data loss! If your log files are on an NFS-mounted network file system, see Using syslog-ng PE with NFS or CIFS (or SMB) file system for log files. |
The following destination driver groups are available in syslog-ng PE:
Topics:
Starting with version 5.63.7 of syslog-ng PE can directly send log messages to Elasticsearch, allowing you to search and analyze your data in real time, and visualize it with Kibana.
NOTE: Typically, only the central syslog-ng PE server uses this destination. For more information on the server mode, see Server mode.
Note the following limitations when using the syslog-ng PE elasticsearch2 destination:
-
This destination is only supported on the Linux platform.
This destination is only supported on the Linux platforms that use the linux glibc2.11 installer, including: Red Hat ES 7, Ubuntu 14.04 (Trusty Tahr).
-
Since syslog-ng PE uses Java libraries, the elasticsearch2 destination has significant memory usage.
-
The log messages of the underlying client libraries are available in the internal() source of syslog-ng PE.
Declaration
@module mod-java
@include "scl.conf"
elasticsearch2(
index("syslog-ng_${YEAR}.${MONTH}.${DAY}")
type("test")
cluster("syslog-ng")
);
Example: Sending log data to Elasticsearch version 2.x and above
The following example defines an elasticsearch2 destination that sends messages in transport mode to an Elasticsearch server running on the localhost, using only the required parameters.
@module mod-java
@include "scl.conf"
destination d_elastic {
elasticsearch2(
index("syslog-ng_${YEAR}.${MONTH}.${DAY}")
type("test")
);
};
The following example sends 10000 messages in a batch, in transport mode, and includes a custom unique ID for each message.
@module mod-java
@include "scl.conf"
options {
threaded(yes);
use-uniqid(yes);
};
source s_syslog {
syslog();
};
destination d_elastic {
elasticsearch2(
index("syslog-ng_${YEAR}.${MONTH}.${DAY}")
type("test")
cluster("syslog-ng")
client-mode("transport")
custom-id("${UNIQID}")
flush-limit("10000")
);
};
log {
source(s_syslog);
destination(d_elastic);
flags(flow-control);
};
Example: Sending log data to Elasticsearch using the HTTP REST API
The following example send messages to Elasticsearch over HTTP using its REST API:
@include "scl.conf"
source s_network {
network(port(5555));
};
destination d_elastic {
elasticsearch2(
client-mode("http")
cluster("es-syslog-ng")
index("x201")
cluster-url("http://192.168.33.10:9200")
type("slng_test_type")
flush-limit("0")
);
};
log {
source(s_network);
destination(d_elastic);
flags(flow-control);
};
The elasticsearch2() driver is actually a reusable configuration snippet configured to receive log messages using the Java language-binding of syslog-ng PE. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of the elasticsearch configuration snippet on GitHub. For details on extending syslog-ng PE in Java, see the Getting started with syslog-ng development guide.
NOTE: If you delete all Java destinations from your configuration and reload syslog-ng, the JVM is not used anymore, but it is still running. If you want to stop JVM, stop syslog-ng and then start syslog-ng again.