Chat now with support
Chat with Support

syslog-ng Premium Edition 7.0.33 - Administration Guide

Preface Introduction to syslog-ng The concepts of syslog-ng Installing syslog-ng PE The syslog-ng PE quick-start guide The syslog-ng PE configuration file Collecting log messages — sources and source drivers
How sources work default-network-drivers: Receive and parse common syslog messages internal: Collecting internal messages file: Collecting messages from text files google-pubsub: collecting messages from the Google Pub/Sub messaging service wildcard-file: Collecting messages from multiple text files linux-audit: Collecting messages from Linux audit logs mssql, oracle, sql: collecting messages from an SQL database network: Collecting messages using the RFC3164 protocol (network() driver) office365: Fetching logs from Office 365 osquery: Collect and parse osquery result logs pipe: Collecting messages from named pipes program: Receiving messages from external applications python: writing server-style Python sources python-fetcher: writing fetcher-style Python sources snmptrap: Read Net-SNMP traps syslog: Collecting messages using the IETF syslog protocol (syslog() driver) system: Collecting the system-specific log messages of a platform systemd-journal: Collecting messages from the systemd-journal system log storage systemd-syslog: Collecting systemd messages using a socket tcp, tcp6,udp, udp6: Collecting messages from remote hosts using the BSD syslog protocol udp-balancer: Receiving UDP messages at very high rate unix-stream, unix-dgram: Collecting messages from UNIX domain sockets windowsevent: Collecting Windows event logs
Sending and storing log messages — destinations and destination drivers
elasticsearch2>: Sending messages directly to Elasticsearch version 2.0 or higher (DEPRECATED) elasticsearch-http: Sending messages to Elasticsearch HTTP Event Collector file: Storing messages in plain-text files google_pubsub(): Sending logs to the Google Cloud Pub/Sub messaging service google_pubsub-managedaccount(): Sending logs to the Google Cloud Pub/Sub messaging service authenticated by Google Cloud managed service account hdfs: Storing messages on the Hadoop Distributed File System (HDFS) http: Posting messages over HTTP kafka(): Publishing messages to Apache Kafka (Java implementation) (DEPRECATED) kafka-c(): Publishing messages to Apache Kafka using the librdkafka client (C implementation) logstore: Storing messages in encrypted files mongodb: Storing messages in a MongoDB database network: Sending messages to a remote log server using the RFC3164 protocol (network() driver) pipe: Sending messages to named pipes program: Sending messages to external applications python: writing custom Python destinations sentinel(): Sending logs to the Microsoft Azure Sentinel cloud snmp: Sending SNMP traps smtp: Generating SMTP messages (email) from logs splunk-hec: Sending messages to Splunk HTTP Event Collector sql(): Storing messages in an SQL database stackdriver: Sending logs to the Google Stackdriver cloud syslog: Sending messages to a remote logserver using the IETF-syslog protocol syslog-ng(): Forward logs to another syslog-ng node tcp, tcp6, udp, udp6: Sending messages to a remote log server using the legacy BSD-syslog protocol (tcp(), udp() drivers) unix-stream, unix-dgram: Sending messages to UNIX domain sockets usertty: Sending messages to a user terminal — usertty() destination Client-side failover
Routing messages: log paths, flags, and filters Global options of syslog-ng PE TLS-encrypted message transfer Advanced Log Transport Protocol Reliability and minimizing the loss of log messages Manipulating messages parser: Parse and segment structured messages Processing message content with a pattern database Correlating log messages Enriching log messages with external data Monitoring statistics and metrics of syslog-ng Multithreading and scaling in syslog-ng PE Troubleshooting syslog-ng Best practices and examples The syslog-ng manual pages Glossary

splunk-hec destination options

The splunk-hec destination of syslog-ng PE can directly post log messages to a Splunk deployment using the HTTP Event Collector (HEC) over the HTTP and Secure HTTP (HTTPS) protocols. The splunk-hec destination has the following options. The required options are: index(), token(), and url().

batch-bytes()
Accepted values: number [bytes]
Default: none

Description: Sets the maximum size of payload in a batch. If the size of the messages reaches this value, syslog-ng PE sends the batch to the destination even if the number of messages is less than the value of the batch-lines() option.

Note that if the batch-timeout() option is enabled and the queue becomes empty, syslog-ng PE flushes the messages only if batch-timeout() expires, or the batch reaches the limit set in batch-bytes().

Available in syslog-ng PE version 7.0.12 and later.

For details on how this option influences batch mode, see splunk-hec: Sending messages to Splunk HTTP Event Collector

batch-lines()
Type: number
Default: 25

Description: Specifies how many lines are flushed to a destination in one batch. The syslog-ng PE application waits for this number of lines to accumulate and sends them off in a single batch. Increasing this number increases throughput as more messages are sent in a single batch, but also increases message latency.

For example, if you set batch-lines() to 100, syslog-ng PE waits for 100 messages.

If the batch-timeout() option is disabled, the syslog-ng PE application flushes the messages if it has sent batch-lines() number of messages, or the queue became empty. If you stop or reload syslog-ng PE or in case of network sources, the connection with the client is closed, syslog-ng PE automatically sends the unsent messages to the destination.

If the batch-timeout() option is enabled and the queue becomes empty, syslog-ng PE flushes the messages only if batch-timeout() expires, or the batch reaches the limit set in batch-lines().

For optimal performance, make sure that the syslog-ng PE source that feeds messages to this destination is configured properly: the value of the log-iw-size() option of the source must be higher than the batch-lines()*workers() of the destination. Otherwise, the size of the batches cannot reach the batch-lines() limit.

For details on how this option influences batch mode, see splunk-hec: Sending messages to Splunk HTTP Event Collector

batch-timeout()
Type: time [milliseconds]
Default: -1 (disabled)

Description: Specifies the time syslog-ng PE waits for lines to accumulate in the output buffer. The syslog-ng PE application sends batches to the destinations evenly. The timer starts when the first message arrives to the buffer, so if only few messages arrive, syslog-ng PE sends messages to the destination once every batch-timeout() milliseconds at most.

For details on how this option influences batch mode, see splunk-hec: Sending messages to Splunk HTTP Event Collector

body-prefix()
Accepted values: string
Default: none

Description: The string syslog-ng PE puts at the beginning of the body of the HTTP request, before the log message. Available in syslog-ng PE version 7.0.11 and later.

For details on how this option influences batch mode, see splunk-hec: Sending messages to Splunk HTTP Event Collector

body-suffix()
Accepted values: string
Default: none

Description: The string syslog-ng PE puts to the end of the body of the HTTP request, after the log message. Available in syslog-ng PE version 7.0.11 and later.

For details on how this option influences batch mode, see splunk-hec: Sending messages to Splunk HTTP Event Collector

ca-dir()
Accepted values: directory name
Default: none

Description: Name of a directory, that contains a set of trusted CA certificates in PEM format. The CA certificate files have to be named after the 32-bit hash of the subject's name. This naming can be created using the c_rehash utility in OpenSSL. For an example, see Configuring TLS on the syslog-ng clients. The syslog-ng PE application uses the CA certificates in this directory to validate the certificate of the peer.

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
ca-file()
Accepted values: Filename
Default: none

Description: Name of a file that contains an X.509 CA certificate (or a certificate chain) in PEM format. The syslog-ng PE application uses this certificate to validate the certificate of the HTTPS server. If the file contains a certificate chain, the file must begin with the certificate of the host, followed by the CA certificate that signed the certificate of the host, and any other signing CAs in order.

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
cert-file()
Accepted values: Filename
Default: none

Description: Name of a file, that contains an X.509 certificate (or a certificate chain) in PEM format, suitable as a TLS certificate, matching the private key set in the key-file() option. The syslog-ng PE application uses this certificate to authenticate the syslog-ng PE client on the destination server. If the file contains a certificate chain, the file must begin with the certificate of the host, followed by the CA certificate that signed the certificate of the host, and any other signing CAs in order.

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
cipher-suite()
Accepted values: Name of a cipher, or a colon-separated list
Default: Depends on the OpenSSL version that syslog-ng PE uses

Description: Specifies the cipher, hash, and key-exchange algorithms used for the encryption, for example, ECDHE-ECDSA-AES256-SHA384. The list of available algorithms depends on the version of OpenSSL used to compile syslog-ng PE. To specify multiple ciphers, separate the cipher names with a colon, and enclose the list between double-quotes, for example:

cipher-suite("ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384")

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
delimiter()
Accepted values: string
Default: newline character

Description: By default, syslog-ng PE separates the log messages of the batch with a newline character. You can specify a different delimiter by using the delimiter() option.

For details on how this option influences batch mode, see splunk-hec: Sending messages to Splunk HTTP Event Collector

disk-buffer()

Description: This option enables putting outgoing messages into the disk-buffer file of the destination to avoid message loss in case of a system failure on the destination side. It has the following options:

dir()
Type: string
Default: N/A

Description: Defines the folder where the disk-buffer files are stored.

Note that changing the value the dir() option will not move or copy existing files from the old directory to the new one.

Caution:

When creating a new dir() option for a disk-buffer file, or modifying an existing one, make sure you delete the persist file.

syslog-ng PE creates disk-buffer files based on the path recorded in the persist file. Therefore, if the persist file is not deleted after modifying the dir() option, then following a restart, syslog-ng PE will look for or create disk-buffer files in their old location. To ensure that syslog-ng PE uses the new dir() setting, the persist file must not contain any information about the destinations which the disk-buffer file in question belongs to.

disk-buf-size()
Type: number [bytes]
Default:

Description: This is a required option. The maximum size of the disk-buffer file in bytes. The minimum value is 1048576 bytes. If you set a smaller value, the minimum value will be used automatically. It replaces the old log-disk-fifo-size() option.
mem-buf-length()
Type: number [messages]
Default: 10000
Description: Use this option if the option reliable() is set to no. This option contains the number of messages stored in overflow queue. It replaces the old log-fifo-size() option. It inherits the value of the global log-fifo-size() option if provided. If it is not provided, the default value is 10000 messages. Note that this option will be ignored if the option reliable() is set to yes.
mem-buf-size()
Type: number [bytes]
Default: 163840000
Description: Use this option if the option reliable() is set to yes. This option contains the size of the messages in bytes that is used in the memory part of the disk-buffer file. It replaces the old log-fifo-size() option. It does not inherit the value of the global log-fifo-size() option, even if it is provided. Note that this option will be ignored if the option reliable() is set to no.
quot-size()
Type: number [messages]
Default: 1000

Description: The number of messages stored in the output buffer of the destination. Note that if you change the value of this option and the disk-buffer file already exists, the change will take effect when the disk-buffer file becomes empty.

reliable()
Type: yes|no
Default: no

Description: If set to yes, syslog-ng PE cannot lose logs in case of reload/restart, unreachable destination or syslog-ng PE crash. This solution provides a slower, but reliable disk-buffer option. It is created and initialized at startup and gradually grows as new messages arrive. If set to no, the normal disk-buffer option will be used. This provides a faster, but less reliable disk-buffer option.

Caution: Hazard of data loss!

If you change the value of reliable() option when there are messages in the disk-buffer file, the messages stored in the disk-buffer file will be lost.

truncate-size-ratio()
Type: number (for percentage) between 0 and 1
Default: 0.1 (10%)

Description: Limits the truncation of the disk-buffer file. Truncating the disk-buffer file can slow down disk I/O operations, but it saves disk space. As a result, syslog-ng PE only truncates the file if the possible disk gain is more than truncate-size-ratio() times disk-buf-size().

Caution:

One Identity recommends that you do not modify the value of the truncate-size-ratio() option unless you are fully aware of the potential performance implications.

Example: Examples for using disk-buffer()

In the following case, reliable disk-buffer() is used.

destination d_demo {
    network("127.0.0.1"
        port(3333)
        disk-buffer(
            mem-buf-size(10000)
            disk-buf-size(2000000)
            reliable(yes)
            dir("/tmp/disk-buffer")
        )
    );
};

In the following case normal disk-buffer() is used.

destination d_demo {
    network("127.0.0.1"
        port(3333)
        disk-buffer(
            mem-buf-length(10000)
            disk-buf-size(2000000)
            reliable(no)
            dir("/tmp/disk-buffer")
        )
    );
};
event()
Type: template
Default: ${S_ISODATE} ${HOST} ${MSGHDR}${MSG}\n

Description: The body of the message that syslog-ng PE sends to Splunk. The content of the events (the value of the ${MSG} macro) is sent in JSON format.

hook-commands()

Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands() can be used with all source and destination drivers with the exception of the usertty() and internal() drivers.

NOTE: The syslog-ng PE application must be able to start and restart the external program, and have the necessary permissions to do so. For example, if your host is running AppArmor or SELinux, you might have to modify your AppArmor or SELinux configuration to enable syslog-ng PE to execute external applications.

Using the hook-commands() when syslog-ng PE starts or stops

To execute an external program when syslog-ng PE starts or stops, use the following options:

startup()
Type: string
Default: N/A

Description: Defines the external program that is executed when syslog-ng PE starts.

shutdown()
Type: string
Default: N/A

Description: Defines the external program that is executed when syslog-ng PE stops.

Using the hook-commands() when syslog-ng PE reloads

To execute an external program when the syslog-ng PE configuration is initiated or torn down (for example, on startup/shutdown or during a syslog-ng PE reload), use the following options:

setup()
Type: string
Default: N/A

Description: Defines an external program that is executed when the syslog-ng PE configuration is initiated, for example, on startup or during a syslog-ng PE reload.

teardown()
Type: string
Default: N/A

Description: Defines an external program that is executed when the syslog-ng PE configuration is stopped or torn down, for example, on shutdown or during a syslog-ng PE reload.

Example: Using the hook-commands() with a network source

In the following example, the hook-commands() is used with the network() driver and it opens an iptables port automatically when syslog-ng PE is started/stopped.

The assumption in this example is that the LOGCHAIN chain is part of a larger ruleset that routes traffic to it. Whenever the syslog-ng PE created rule is there, packets can flow (otherwise the port is closed).

source {
  network(transport(udp)
    hook-commands(
      startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
      shutdown("iptables -D LOGCHAIN 1")
    ;)
  );
};
host()
Type: template
Default: ${HOST}

Description: The hostname for the message that syslog-ng PE sends to Splunk. In Splunk, the message will appear as it has been sent by this host.

index()
Accepted values: string
Default: None

Description: The name of the Splunk index where Splunk will store the messages received from syslog-ng PE. This option is mandatory for this destination.

log-fifo-size()
Type: number
Default: Use global setting.

Description: The number of messages that the output queue can store.

key-file()
Accepted values: Filename
Default: none

Description: Path and name of a file that contains a private key in PEM format, suitable as a TLS key. If properly configured, the syslog-ng PE application uses this private key and the matching certificate (set in the cert-file() option) to authenticate the syslog-ng PE client on the destination server.

This destination supports only unencrypted key files (that is, the private key cannot be password-protected).

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
method()
Type: POST | PUT
Default: POST

Description: Specifies the HTTP method to use when sending the message to the server.

password()
Type: string
Default:

Description: The password that syslog-ng PE uses to authenticate on the server where it sends the messages.

peer-verify()
Accepted values: yes | no
Default: yes

Description: Verification method of the peer. The following table summarizes the possible options and their results depending on the certificate of the peer.

The remote peer has:
no certificate invalid certificate valid certificate
Local peer-verify() setting no (optional-untrusted) TLS-encryption TLS-encryption TLS-encryption
yes (required-trusted) rejected connection rejected connection TLS-encryption

For untrusted certificates only the existence of the certificate is checked, but it does not have to be valid — syslog-ng accepts the certificate even if it is expired, signed by an unknown CA, or its CN and the name of the machine mismatches.

Caution:

When validating a certificate, the entire certificate chain must be valid, including the CA certificate. If any certificate of the chain is invalid, syslog-ng PE will reject the connection.

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
persist-name()
Type: string
Default:

None

Description:If you receive the following error message during syslog-ng PE startup, set the persist-name() option of the duplicate drivers:

Error checking the uniqueness of the persist names, please override it with persist-name option. Shutting down.

This error occurs if you use identical drivers in multiple sources, for example, if you configure two file sources to read from the same file. In this case, set the persist-name() of the drivers to a custom string, for example, persist-name("example-persist-name1").

proxy()
Type: The proxy server address, in proxy("PROXY_IP:PORT") format.

For example, proxy("http://myproxy:3128")

Default:

None

Description:

The proxy() option enables you to configure the splunk-hec driver to use a specific HTTP proxy for all HTTP-based destinations, instead of using the proxy that is configured for the system.

If you do not set the proxy() option, the splunk-hec driver uses the http_proxy and https_proxy environment variables, as shown in CURLOPT_PROXY explained.

NOTE: Configuring the proxy() option overwrites the default http_proxy and https_proxy environment variables.

retries()
Type: number [of attempts]
Default: 3

Description: The number of times syslog-ng PE attempts to send a message to this destination. If syslog-ng PE could not send a message, it will try again until the number of attempts reaches retries(), then drops the message.

To handle HTTP error responses, if the HTTP server returns 5xx codes, syslog-ng PE will attempt to resend messages until the number of attempts reaches retries. If the HTTP server returns 4xx codes, syslog-ng PE will drop the messages.

source()
Type: string
Default: syslog-ng

Description: The value of the source field in Splunk.

sourcetype()
Type: string
Default: .app.name:-syslog

Description: The source type that you set in Splunk for the token that syslog-ng PE uses. For details about source types, see the Splunk documentation.

ssl-version()
Type: string
Default: None, uses the libcurl default

Description: Specifies the permitted SSL/TLS version. Possible values: sslv2, sslv3, tlsv1, tlsv1_0, tlsv1_1, tlsv1_2, tlsv1_3.

An alternative way to specify this option is to put it into a tls() block, together with any other TLS options. This allows you to separate these options and ensure better readability.

Make sure that you specify TLS options either using their own dedicated option (ca-dir(), ca-file(), cert-file(), cipher-suite(), key-file(), peer-verify(), and ssl-version()), or using the tls() block and inserting the relevant options within tls(). Avoid mixing the two methods. If you do specify TLS options in both ways, the one that comes later in the configuration file will take effect.

Declaration
destination d_splunk-hec {
	splunk-hec(
		url("http://your-splunk-server3:8088/services/collector/event")
		tls(
			ca-dir("dir")
			ca-file("ca")
			cert-file("cert")
			cipher-suite("cipher")
			key-file("key")
			peer-verify(yes|no)
			ssl-version(<the permitted SSL/TLS version>)
		)
	);
};
template()
Type: string
Default: A format conforming to the default logfile format.

Description: Specifies a template defining the logformat to be used in the destination. Macros are described in Macros of syslog-ng PE. Please note that for network destinations it might not be appropriate to change the template as it changes the on-wire format of the syslog protocol which might not be tolerated by stock syslog receivers (like syslogd or syslog-ng itself). For network destinations make sure the receiver can cope with the custom format defined.

throttle()
Type: number
Default: 0

Description: Sets the maximum number of messages sent to the destination per second. Use this output-rate-limiting functionality only when using the disk-buffer option as well to avoid the risk of losing messages. Specifying 0 or a lower value sets the output limit to unlimited.

time()
Type: template
Default: ${S_UNIXTIME}.${S_MSEC}

Description: The timestamp for the message that syslog-ng PE sends to Splunk.

timeout()
Type: number [seconds]
Default: 10

Description: The value (in seconds) to wait for an operation to complete, and attempt to reconnect the server if exceeded.

token()
Accepted values: string
Default: None

Description: The Splunk HTTP Event Collector token that permits syslog-ng PE to send messages to Splunk. For details, see Set up and use HTTP Event Collector in Splunk Web. This option is mandatory for this destination.

url()
Type: URL or list of URLs, for example, url("site1" "site2")
Default: http://localhost:8088/services/collector/event

Description: Specifies the hostname or IP address and optionally the port number of the Splunk indexer. Use a colon (:) after the address to specify the port number of the server. For example: http://your-splunk-indexer.server:8088/services/collector/event

This option is mandatory for this destination.

Make sure that the URL ends with event, this is the Splunk API endpoint that properly parses the messages sent by syslog-ng PE.

In case the server on the specified URL returns a redirect request, syslog-ng PE automatically follows maximum 3 redirects. Only HTTP and HTTPS based redirections are supported.

Starting with version 7.0.12, you can specify multiple URLs, for example, url("site1" "site2"). In this case, syslog-ng PE sends log messages to the specified URLs in a load-balance fashion. This means that syslog-ng PE sends each message to only one URL. For example, you can use this to send the messages to a set of ingestion nodes or indexers of your SIEM solution if a single node cannot handle the load. Note that the order of the messages as they arrive on the servers can differ from the order syslog-ng PE has received them, so use load-balancing only if your server can use the timestamp from the messages. If the server uses the timestamp when it receives the messages, the order of the messages will be incorrect.

Caution:

If you set multiple URLs in the url() option, set the persist-name() option as well to avoid data loss.

user-agent()
Type: string
Default: syslog-ng [version]/libcurl[version]

Description: The value of the USER-AGENT header in the messages sent to the server.

user()
Type: string
Default:

Description: The username that syslog-ng PE uses to authenticate on the server where it sends the messages.

use-system-cert-store()
Type: yes | no
Default: no

Description: Use the certificate store of the system for verifying HTTPS certificates. For details, see the curl documentation.

workers()
Type: integer
Default: 4

Description: Specifies the number of worker threads (at least 1) that syslog-ng PE uses to send messages to the server. Increasing the number of worker threads can drastically improve the performance of the destination.

Caution:

Hazard of data loss!

When you use more than one worker threads together with the disk-buffer option, syslog-ng PE creates a separate disk-buffer file for each worker thread. This means that decreasing the number of workers can result in losing data currently stored in the disk-buffer files. Do not decrease the number of workers when the disk-buffer files are in use.

If you are using load-balancing (that is, you have configured multiple servers in the url() option), increase the number of worker threads at least to the number of servers. For example, if you have set three URLs (url("site1" "site2" "site3")), set the workers() option to 3 or more.

sql(): Storing messages in an SQL database

The sql() driver sends messages into an SQL database. Currently the Microsoft SQL (MSSQL), MySQL, Oracle, PostgreSQL, and SQLite databases are supported.

NOTE: To use this destination, syslog-ng Premium Edition (syslog-ng PE) must run in server mode. Typically, only the central syslog-ng PE server uses this destination. For more information on the server mode, see Server mode.

Declaration
sql(database_type host_parameters database_parameters [options]);

The sql() driver has the following required parameters: type(), database(), table(), columns(), and values().

Caution:

The syslog-ng Premium Edition (syslog-ng PE) application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists.

Currently the syslog-ng PE application has default schemas for the different databases and uses these defaults if the database schema (for example, columns and column types) is not defined in the configuration file. However, these schemas will be deprecated and specifying the exact database schema will be required in later versions of syslog-ng PE.

NOTE: In addition to the standard syslog-ng PE packages, the sql() destination requires database-specific packages to be installed. These packages are automatically installed by the binary syslog-ng PE installer.

The sql() driver is currently not available for every platform that is supported by syslog-ng PE. .

The table and value parameters can include macros to create tables and columns dynamically (for details, see Macros of syslog-ng PE).

Caution:

When using macros in table names, note that some databases limit the maximum allowed length of table names. Consult the documentation of the database for details.

Inserting the records into the database is performed by a separate thread. The syslog-ng PE application automatically performs the escaping required to insert the messages into the database.

Example: Using the sql() driver

The following example sends the log messages into a PostgreSQL database running on the logserver host. The messages are inserted into the logs database, the name of the table includes the exact date and the name of the host sending the messages. The syslog-ng PE application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.

destination d_sql {
    sql(
        type(pgsql)
        host("logserver")
        username("syslog-ng")
        password("password")
        database("logs")
        table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}")
        columns("datetime", "host", "program", "pid", "message")
        values("{$R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}")
        indexes("datetime", "host", "program", "pid", "message")
    );
};

The following example specifies the type of the database columns as well:

destination d_sql {
    sql(
        type(pgsql)
        host("logserver")
        username("syslog-ng")
        password("password")
        database("logs")
        table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}")
        columns("datetime varchar(16)", "host varchar(32)", "program  varchar(20)", "pid varchar(8)", "message  varchar(200)")
        values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}")
        indexes("datetime", "host", "program", "pid", "message")
    );
};

Using the sql() driver with an Oracle database

The Oracle sql() destination has some special aspects that are important to note.

  • There are two ways to set the hostname of the database server:

    • Set the hostname in the tnsnames.ora file, not in the host parameter of the sql() destination.

      If the tnsnames.ora file is not located in the /etc directory (or in the /var/opt/oracle directory on Solaris), set the following Oracle-related environment variables, so syslog-ng PE will find the file: ORACLE_BASE, ORACLE_HOME, and ORACLE_SID. For details, see the documentation of the Oracle Instant Client.

      Note that in this case you cannot use the same database() settings in more than one destination, because the database() option of the SQL driver is just a reference to the connection string of the tnsnames.ora file. To overcome this problem, you can duplicate the connections in the tnsnames.ora file under a different name, and use a different table in each Oracle destination in syslog-ng PE.

    • Set the hostname in the host() option of the destination, and set the ignore-tns-ora() to yes. In this case, syslog-ng PE ignores the tnsnames.ora file, and you can use the same database settings in multiple destinations. Note that the ignore-tns-ora() option is available in syslog-ng Premium Edition version 7.0.9.

  • As certain database versions limit the maximum length of table names, macros in the table names should be used with care.

  • In the current version of syslog-ng PE, the types of database columns must be explicitly set for the Oracle destination. The column used to store the text part of the syslog messages should be able to store messages as long as the longest message permitted by syslog-ng PE, therefore it is usually recommended to use the varchar2 or clob column type. (The maximum length of the messages can be set using the log-msg-size() option.) For details, see the following example.

  • The Oracle Instant Client used by syslog-ng PE supports only the following character sets:

    • Single-byte character sets: US7ASCII, WE8DEC, WE8MSWIN1252, and WE8ISO8859P1

    • Unicode character sets: UTF8, AL16UTF16, and AL32UTF8

Example: Using the sql() driver with an Oracle database

The following example sends the log messages into an Oracle database running on the logserver host, which must be set in the /etc/tnsnames.ora file. The messages are inserted into the LOGS database, the name of the table includes the exact date when the messages were sent. The syslog-ng PE application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.

destination d_sql {
    sql(
        type(oracle)
        username("syslog-ng")
        password("password")
        database("LOGS")
        table("msgs_${R_YEAR}${R_MONTH}${R_DAY}")
        columns("datetime varchar(16)", "host varchar(32)", "program varchar(32)", "pid varchar(8)", "message varchar2")
        values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}")
        indexes("datetime", "host", "program", "pid", "message")
    );
};

The Oracle Instant Client retrieves the address of the database server from the /etc/tnsnames.ora file. Edit or create this file as needed for your configuration. A sample is provided below.

LOGS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)
(HOST = logserver)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = EXAMPLE.SERVICE)
)
)

Using the sql() driver with a Microsoft SQL database

The mssql() database driver can access Microsoft SQL (MSSQL) destinations. This driver has some special aspects that are important to note.

  • The date format used by the MSSQL database must be explicitly set in the /etc/locales.conf file of the syslog-ng PE server. For details, see the following example.

  • As certain database versions limit the maximum length of table names, macros in the table names should be used with care.

  • In the current version of syslog-ng PE, the types of database columns must be explicitly set for the MSSQL destination.

    Caution:

    The following column types cannot be used in MSSQL destinations: nchar, nvarchar, ntext, and xml.

  • The column used to store the text part of the syslog messages should be able to store messages as long as the longest message permitted by syslog-ng PE. The varchar column type can store maximum 4096 bytes-long messages. The maximum length of the messages can be set using the log-msg-size() option. For details, see the following example.

  • Remote access for SQL users must be explicitly enabled on the Microsoft Windows host running the Microsoft SQL Server. For details, see Configuring Microsoft SQL Server to accept logs from syslog-ng.

Example: Using the sql() driver with an MSSQL database

The following example sends the log messages into an MSSQL database running on the logserver host. The messages are inserted into the syslogng database, the name of the table includes the exact date when the messages were sent. The syslog-ng PE application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.

destination d_mssql {
    sql(
        type(mssql)
        host("logserver")
        port("1433")
        username("syslogng")
        password("syslogng")
        database("syslogng")
        table("msgs_${R_YEAR}${R_MONTH}${R_DAY}")
        columns("datetime varchar(16)", "host varchar(32)", "program varchar(32)", "pid varchar(8)", "message varchar(4096)")
        values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}")
        indexes("datetime", "host", "program", "pid")
    );
};

The date format used by the MSSQL database must be explicitly set in the /etc/locales.conf file of the syslog-ng PE server. Edit or create this file as needed for your configuration.

You can copy and customize the following sample:

[default]
date = "%Y-%m-%d %H:%M:%S"
Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating