Version 3.87.0.4 of syslog-ng PE can directly post log messages to web services using the HTTP protocol, without having to use Java.

Limitations

The current implementation of the http() destination has the following limitations:

  • Only the PUT and the POST methods are supported.

  • HTTPS connections, as well as password-based and certificate-based authentication, are supported.

  • If the server returns a status code beginning with 4 (for example, 404) to the POST or PUT request, syslog-ng PE drops the message without attempting to resend it.

NOTE: Typically, only the central syslog-ng PE server uses this destination. For more information on the server mode, see Server mode.

Example: Client certificate authentication with HTTPS
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")
            )
        [...]
    );
};
Declaration
destination d_http {
    http(
        url("<web-service-IP-or-hostname>")
        method("<HTTP-method>")
        user-agent("<USER-AGENT-message-value>")
        user("<username>")
        password("<password>")
    );
};
Example: Sending log data to a web service

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);
};