The amqp() driver publishes messages using the AMQP (Advanced Message Queuing Protocol).

The amqp() destination has the following options:

auth-method()

Accepted values: plain | external
Default: plain

Description: The amqp() driver supports the following types of authentication:

  • plain: Authentication happens using username and password. This is the default.

  • external: Authentication happens using an out-of-band mechanism, for example, x509 certificate peer verification, client IP address range, or similar. For more information, see the RabbitMQ documentation.

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 OSE 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 OSE flushes the messages only if batch-timeout() expires, or the batch reaches the limit set in batch-bytes().

Available in syslog-ng OSE version 3.19 and later.

batch-lines()

Type: number
Default: 1

Description: Specifies how many lines are flushed to a destination in one batch. The syslog-ng OSE 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 OSE waits for 100 messages.

If the batch-timeout() option is disabled, the syslog-ng OSE 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 OSE or in case of network sources, the connection with the client is closed, syslog-ng OSE automatically sends the unsent messages to the destination.

Note that if the batch-timeout() option is enabled and the queue becomes empty, syslog-ng OSE 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 OSE 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.

batch-timeout()

Type: time in milliseconds
Default: -1 (disabled)

Description: Specifies the time syslog-ng OSE waits for lines to accumulate in the output buffer. The syslog-ng OSE 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 OSE sends messages to the destination at most once every batch-timeout() milliseconds.

body()

Type: string
Default: empty string

Description: The body of the AMQP message. You can also use macros and templates.

ca-file()

Type: File name
Default: empty

Description: Optional. The name of a file that contains a set of trusted CA certificates in PEM format. The syslog-ng OSE application uses the CA certificates in this file to validate the certificate of the peer.

Example format in configuration:

ca-file("/etc/pki/tls/certs/ca-bundle.crt")

NOTE: The ca-file() option can be used together with the ca-dir() option, and it is relevant when peer-verify() is set to other than no or optional-untrusted.

NOTE: During a TLS handshake, syslog-ng OSE automatically sets the certificate_authorities field of the certificate request based on the ca-file() and ca-dir() options.

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

destination  d_amqp {
    amqp(
        host("127.0.0.1")
        port(5672)
        username("test")
        password("test")        
        tls(
            ca-file("ca")
            cert-file("cert") 
            key-file("key")
            peer-verify(yes|no)
        )
    );
};

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

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 OSE application uses this certificate to authenticate the syslog-ng OSE 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 into a tls() block and specify it there, together with any other TLS options. This allows you to separate these options and ensure better readability.

destination  d_amqp {
    amqp(
        host("127.0.0.1")
        port(5672)
        username("test")
        password("test")        
        tls(
            ca-file("ca")
            cert-file("cert") 
            key-file("key")
            peer-verify(yes|no)
        )
    );
};

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

disk-buffer()

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

capacity-bytes()

Type: number (bytes)
Default: 1 MiB

Description: This is a required option. The maximum size of the disk-buffer 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.

In syslog-ng OSE version 4.2 and earlier, this option was called disk-buf-size().

compaction()

Type: yes/no
Default: no

Description: If set to yes, syslog-ng OSE prunes the unused space in the LogMessage representation, making the disk queue size smaller at the cost of some CPU time. Setting the compaction() argument to yes is recommended when numerous name-value pairs are unset during processing, or when the same names are set multiple times.

NOTE: Simply unsetting these name-value pairs by using the unset() rewrite operation is not enough, as due to performance reasons that help when syslog-ng OSE is CPU bound, the internal representation of a LogMessage will not release the memory associated with these name-value pairs. In some cases, however, the size of this overhead becomes significant (the raw message size can grow up to four times its original size), which unnecessarily increases the disk queue file size. For these cases, the compaction will drop unset values, making the LogMessage representation smaller at the cost of some CPU time required to perform compaction.

dir()

Type: string
Default: N/A

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

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

syslog-ng OSE 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 OSE will look for or create disk-buffer files in their old location. To ensure that syslog-ng OSE 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.

flow-control-window-bytes()

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. 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.

In syslog-ng OSE version 4.2 and earlier, this option was called mem-buf-size().

flow-control-window-size()

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.

In syslog-ng OSE version 4.2 and earlier, this option was called mem-buf-length().

front-cache-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 already exists, the change will take effect when the disk-buffer becomes empty.

Options reliable() and capacity-bytes() are required options.

In syslog-ng OSE version 4.2 and earlier, this option was called qout-size().

prealloc()

Type: yes/no
Default: no

Description: By default, syslog-ng OSE doesn’t reserve the disk space for the disk-buffer file, since in a properly configured and sized environment the disk-buffer is practically empty, so a large preallocated disk-buffer file is just a waste of disk space. But a preallocated buffer can prevent other data from using the intended buffer space (and elicit a warning from the OS if disk space is low), preventing message loss if the buffer is actually needed. To avoid this problem, when using syslog-ng OSE 4.0 or later, you can preallocate the space for your disk-buffer files by setting prealloc(yes).

In addition to making sure that the required disk space is available when needed, preallocated disk-buffer files provide radically better (3-4x) performance as well: in case of an outage the amount of messages stored in the disk-buffer is continuously growing, and using large continuous files is faster, than constantly waiting on a file to change its size.

If you are running syslog-ng OSE on a dedicated host (always recommended for any high-volume settings), use prealloc(yes).

Available in syslog-ng OSE 4.0 and later.

reliable()

Type: yes/no
Default: no

Description: If set to yes, syslog-ng OSE cannot lose logs in case of reload/restart, unreachable destination or syslog-ng OSE 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 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, the messages stored in the disk-buffer will be lost.

truncate-size-ratio()

Type: number((between 0 and 1))
Default: 1 (do not truncate)

Description: Limits the truncation of the disk-buffer file. Truncating the disk-buffer file can slow down the disk IO operations, but it saves disk space. By default, syslog-ng OSE version 4.0 and later doesn’t truncate disk-buffer files by default (truncate-size-ratio(1)). Earlier versions freed the disk-space when at least 10% of the disk-buffer file could be freed (truncate-size-ratio(0.1)).

syslog-ng OSE only truncates the file if the possible disk gain is more than truncate-size-ratio() times capacity-bytes().

  • Smaller values free disk space quicker.
  • Larger ratios result in better performance.

If you want to avoid performance fluctuations:

  • use truncate-size-ratio(1) (never truncate), or
  • use prealloc(yes) to reserve the entire size of the disk-buffer on disk.

CAUTION: It is not recommended to change truncate-size-ratio(). Only change its value if you understand the performance implications of doing so.

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(
                flow-control-window-bytes(10000)
                capacity-bytes(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(
                flow-control-window-size(10000)
                capacity-bytes(2000000)
                reliable(no)
                dir("/tmp/disk-buffer")
            )
        );
    };

exchange()

Type: string
Default: syslog

Description: The name of the AMQP exchange where syslog-ng OSE sends the message. Exchanges take a message and route it into zero or more queues.

exchange-declare()

Type: yes | no
Default: no

Description: By default, syslog-ng OSE does not create non-existing exchanges. Use the exchange-declare(yes) option to automatically create exchanges.

exchange-type()

Type: direct | fanout | topic | headers
Default: fanout

Description: The type of the AMQP exchange.

frame-size()

Type: integer
Default:  

Description: Sets maximal frame size (the frame-max option described in the AMQP Reference Guide.

heartbeat()

Type: number [seconds]
Default: 0 (disabled)

Description: If enabled, the syslog-ng OSE amqp destination sends heartbeat messages to the server periodically. During negotiation, both the amqp server and the client provide a heartbeat parameter, and the smaller is chosen for heartbeat interval. For example:

destination { amqp(
    vhost("/")
    exchange("logs")
    body("hello world")
    heartbeat(10)
    username(guest) password(guest)
    );
};

Available in syslog-ng OSE version 3.21 and later.

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 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.

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

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.

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

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.

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

host()

Type: hostname or IP address
Default: 127.0.0.1

Description: The hostname or IP address of the AMQP server.

key-file()

Accepted values: Filename
Default: none

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

max-channel()

Type: integer
Default:  

Description: Sets maximal number of channels (the channel-max option described in the AMQP Reference Guide).

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

destination  d_amqp {
    amqp(
        host("127.0.0.1")
        port(5672)
        username("test")
        password("test")        
        tls(
            ca-file("ca")
            cert-file("cert") 
            key-file("key")
            peer-verify(yes|no)
        )
    );
};

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

password()

Type: string
Default: N/A

Description: The password used to authenticate on the AMQP server.

peer-verify()

Accepted values: optional-trusted | optional-untrusted | required-trusted | required-untrusted | yes | no
Default: required-trusted

Description: Verification method of the peer, the four possible values is a combination of two properties of validation:

  • Whether the peer is required to provide a certificate (required or optional prefix).

  • Whether the certificate provided needs to be valid or not.

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 optional-untrusted TLS-encryption TLS-encryption TLS-encryption
  optional-trusted TLS-encryption rejected connection TLS-encryption
  required-untrusted rejected connection TLS-encryption TLS-encryption
  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 OSE 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 OSE will reject the connection.

Starting with syslog-ng OSE version 3.10, you can also use a simplified configuration method for the peer-verify option, simply setting it to yes or no. 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

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

destination  d_amqp {
    amqp(
        host("127.0.0.1")
        port(5672)
        username("test")
        password("test")        
        tls(
            ca-file("ca")
            cert-file("cert") 
            key-file("key")
            peer-verify(yes|no)
        )
    );
};

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

persistent()

Type: yes | no
Default: yes

Description: If this option is enabled, the AMQP server server or broker will store the messages on its hard disk. That way, the messages will be retained if the AMQP server server is restarted, if the message queue is set to be durable on the AMQP server server.

port()

Type: number
Default: 5672

Description: The port number of the AMQP server.

retries()

Type: number (of attempts)
Default: 3

Description: If syslog-ng OSE cannot send a message, it will try again until the number of attempts reaches retries().

If the number of attempts reaches retries(), syslog-ng OSE will wait for time-reopen() time, then tries sending the message again.

routing-key()

Type: string
Default: empty string

Description: Specifies a routing key for the exchange. The routing key selects certain messages published to an exchange to be routed to the bound queue. In other words, the routing key acts like a filter. The routing key can include macros and templates.

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 disk-buffer as well to avoid the risk of losing messages. Specifying 0 or a lower value sets the output limit to unlimited.

time-reopen()

Accepted values: number [seconds]
Default: 60

Description: The time to wait in seconds before a dead connection is reestablished.

username()

Type: string
Default: N/A

Description: The username used to authenticate on the AMQP server.

value-pairs()

Type: parameter list of the value-pairs() option
Default: scope(“selected-macros” “nv-pairs”)

Description: The value-pairs() option creates structured name-value pairs from the data and metadata of the log message. For details on using value-pairs(), see Structuring macros, metadata, and other value-pairs.

NOTE: Empty keys are not logged.

vhost()

Type: string
Default: /

Description: The name of the AMQP virtual host to send the messages to.

Updated: