Version
This destination is only supported on the Linux platform.
Only HTTP connections are supported, HTTPS is not.
This destination requires Java. For an http destination that does not use Java, see http: Posting messages over HTTP without Java.
@module mod-java java( class-path("/syslog-ng/install_dir/lib/syslog-ng/java-modules/*.jar") class-name("org.syslog_ng.http.HTTPDestination") option("url", "http://<server-address>:<port-number>") );
The following example defines an http destination.
@module mod-java destination d_http { java( class-path("/syslog-ng/install_dir/lib/syslog-ng/java-modules/*.jar") class-name("org.syslog_ng.http.HTTPDestination") option("url", "http://192.168.1.1:80") ); }; log { source(s_file); destination(d_http); flags(flow-control); };
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.
The http destination of syslog-ng OSE can directly post log messages to web services using the HTTP protocol. The http destination has the following options. Some of these options are directly used by the Java code underlying the http destination, therefore these options must be specified in the following format:
option("<option-name>", "<option-value>")
For example, option("url", "http://<server-address>:<port-number>"). The exact format to use is indicated in the description of the option.
The following options are required: url(). Note that to use http, you must add the following line to the beginning of your syslog-ng OSE configuration:
@module mod-java
Type: | string |
Default: | N/A |
Description: The name of the class (including the name of the package) that includes the destination driver to use.
For the http destination, use this option as class-name("org.syslog_ng.http.HTTPDestination").
Type: | string |
Default: | The syslog-ng OSE module directory: /opt/syslog-ng/lib/syslog-ng/java-modules/ |
Description: The list of the paths where the required Java classes are located. For example, class-path("/opt/syslog-ng/lib/syslog-ng/java-modules/:/opt/my-java-libraries/libs/"). If you set this option multiple times in your syslog-ng OSE configuration (for example, because you have multiple Java-based destinations), syslog-ng OSE will merge every available paths to a single list.
For the http destination, include the path to the java modules of syslog-ng OSE, for example, class-path("/syslog-ng/install_dir/lib/syslog-ng/java-modules/*.jar").
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 OSE 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 OSE to execute external applications.
To execute an external program when syslog-ng OSE starts or stops, use the following options:
startup() | |
Type: | string |
Default: | N/A |
Description: Defines the external program that is executed as syslog-ng OSE starts. |
shutdown() | |
Type: | string |
Default: | N/A |
Description: Defines the external program that is executed as syslog-ng OSE stops. |
To execute an external program when the syslog-ng OSE configuration is initiated or torn down, for example, on startup/shutdown or during a syslog-ng OSE reload, use the following options:
setup() | |
Type: | string |
Default: | N/A |
Description: Defines an external program that is executed when the syslog-ng OSE configuration is initiated, for example, on startup or during a syslog-ng OSE reload. |
teardown() | |
Type: | string |
Default: | N/A |
Description: Defines an external program that is executed when the syslog-ng OSE configuration is stopped or torn down, for example, on shutdown or during a syslog-ng OSE reload. |
In the following example, the hook-commands() is used with the network() driver and it opens an iptables port automatically as syslog-ng OSE 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 OSE 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") ) ); };
Type: | list |
Default: | N/A |
Description: Specify the Java Virtual Machine (JVM) settings of your Java destination from the syslog-ng OSE configuration file.
For example:
jvm-options("-Xss1M -XX:+TraceClassLoading")
You can set this option only as a global option, by adding it to the options statement of the syslog-ng configuration file.
Type: | number |
Default: | Use global setting. |
Description: The number of messages that the output queue can store.
Type: | DELETE | HEAD | GET | OPTIONS | POST | PUT | TRACE |
Default: | PUT |
Description: Specifies the HTTP method to use when sending the message to the server.
Type: | number (of attempts) |
Default: | 3 |
Description: The number of times syslog-ng OSE attempts to send a message to this destination. If syslog-ng OSE could not send a message, it will try again until the number of attempts reaches retries, then drops the message.
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 OSE. 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.
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 disk-buffer as well to avoid the risk of losing messages. Specifying 0 or a lower value sets the output limit to unlimited.
Type: | URL |
Default: |
Description: Specifies the hostname or IP address and optionally the port number of the web service that can receive log data via HTTP. Use a colon (:) after the address to specify the port number of the server. You can also use macros, templates, and template functions in the URL, for example: http://host.example.com:8080/${MACRO1}/${MACRO2}/script")
Version
Only the PUT and the POST methods are supported.
HTTPS connection, as well as password- and certificate-based authentication is supported.
If the server returns a status code beginning with 2 (for example, 200), syslog-ng OSE assumes the message was successfully sent. For other response codes, see HTTP destination options. You can override the behavior of syslog-ng OSE using the response-action() option.
destination d_https { http( [...] tls( ca-file("/<path-to-certificate-directory>/ca-crt.pem") ca-dir("/<path-to-certificate-directory>/") cert-file("/<path-to-certificate-directory>/server-crt.pem") key-file("/<path-to-certificate-directory>/server-key.pem") ) [...] ); };
destination d_http { http( url("<web-service-IP-or-hostname>") method("<HTTP-method>") user-agent("<USER-AGENT-message-value>") user("<username>") password("<password>") ); };
The driver automatically uses the proxy settings of the host, there is no option to set it in the syslog-ng OSE configuration. Specifically, the driver uses the settings of the http_proxy and https_proxy environment variables.
The following example defines an http destination.
destination d_http { http( url("http://127.0.0.1:8000") method("PUT") user-agent("syslog-ng User Agent") user("user") password("password") headers("HEADER1: header1", "HEADER2: header2") body("${ISODATE} ${MESSAGE}") ); }; log { source(s_file); destination(d_http); flags(flow-control); };
You can also use the http() destination to forward log messages to Splunk using syslog-ng OSE.
Starting with version
The batch-lines(), batch-lines(), and batch-timeout() options of the destination determine how many log messages syslog-ng OSE sends in a batch. The batch-lines() option determines the maximum number of messages syslog-ng OSE puts in a batch in. This can be limited based on size and time:
syslog-ng OSE sends a batch every batch-timeout() milliseconds, even if the number of messages in the batch is less than batch-lines(). That way the destination receives every message in a timely manner even if suddenly there are no more messages.
syslog-ng OSE sends the batch if the total size of the messages in the batch reaches batch-bytes() bytes.
To increase the performance of the destination, increase the number of worker threads for the destination using the workers() option, or adjust the batch-bytes(), batch-lines(), batch-timeout() options.
By default, syslog-ng OSE separates the log messages of the batch with a newline character. You can specify a different delimiter by using the delimiter() option.
If the target application or server requires a special beginning or ending to recognize batches, use the body-prefix() and body-suffix() options to add a beginning and ending to the batch. For example, you can use these options to create JSON-encoded arrays as POST payloads, which is required by a number of REST APIs. The body of a batch HTTP request looks like this:
value of body-prefix() option log-line-1 (as formatted in the body() option) log-line-2 (as formatted in the body() option) .... log-line-n (the number of log lines is batch-lines(), or less if batch-timeout() has elapsed or the batch would be longer than batch-bytes()) value of body-suffix() option
The following destination sends log messages to an Elasticsearch server using the bulk API. A batch consists of 100 messages, or a maximum of 512 kilobytes, and is sent every 10 seconds (10000 milliseconds).
destination d_http { http(url("http://your-elasticsearch-server/_bulk") method("POST") batch-lines(100) batch-bytes(512Kb) batch-timeout(10000) headers("Content-Type: application/x-ndjson") body-suffix("\n") body('{ "index":{} } $(format-json --scope rfc5424 --key ISODATE)') ); };
Starting with version
|
Caution:
If you set multiple URLs in the url() option, set the persist-name() option as well to avoid data loss. |
Starting with version syslog-ng OSE version
url("server1", "server2", "server3"); # comma-separated strings url("server1" "server2" "server3"); # space-separated strings url("server1 server2 server3"); # space-separated within a single string url("server1,server2,server3"); # comma-separated within a single string
The following destination sends log messages to an Elasticsearch server using the bulk API, to 3 different ingest nodes. Each node is assigned a separate worker thread. A batch consists of 100 messages, or a maximum of 512 kilobytes, and is sent every 10 seconds (10000 milliseconds).
destination d_http { http(url("http://your-elasticsearch-server/_bulk" "http://your-second-ingest-node/_bulk" "http://your-third-ingest-node/_bulk") method("POST") batch-lines(100) batch-bytes(512Kb) batch-timeout(10000) workers(3) headers("Content-Type: application/x-ndjson") body-suffix("\n") body('{ "index":{} } $(format-json --scope rfc5424 --key ISODATE)') persist-name("d_http-load-balance") ); };
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.
© 2024 One Identity LLC. ALL RIGHTS RESERVED. 使用条款 隐私 Cookie Preference Center