This section describes the options of the loki() destination in syslog-ng OSE.

The loki() driver sends messages to a Loki Grafana database and has the following options:

auth()

The auth() option can be used to set the authentication of the driver. The default state of this option is insecure, as it is not defined.

The following sub-options are available for auth().

adc()

This option is an authentication method that is only available for destinations. For more information, see Application Default Credentials.

alts()

This option is an accessible authentication available for Google infrastructures. Service accounts can be listed with the nested target-service-account() option, to match these against the server.

Example: configure a Loki destination using auth(alts())

destination {
    loki(
      port(1234)
      auth(alts())
    );
  };

insecure()

This option can be used to disable authentication: auth(insecure()).

tls()

The tls() option accepts the following nested sub-options.

Example: configure a Loki destination using auth(tls())

destination {
    loki(
      url("loki-server:123")
      auth(
        tls(
          ca-file("/path/to/ca.pem")
          key-file("/path/to/key.pem")
          cert-file("/path/to/cert.pem")
        )
      )
    );
  };

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.

channel-args()

Type:  
Default:  

Description: The channel-args() option is available in gRPC-based drivers. The option accepts name-value pairs and sets channel arguments defined in the GRPC Core library documentation.

Example: channel-args() declaration

    channel-args(
        "grpc.loadreporting" => 1
        "grpc.minimal_stack" => 0
    )

headers()

Type: arrow list
Default: empty

Available in syslog-ng OSE 4.8 and later versions.

Description: Adds custom gRPC headers to each RPC call. Currently only static header names and values are supported.

headers(
    "organization" => "org-name"
    "stream-name" => "org-stream"
  )

Copyright © 2024 Axoflow

keep-alive()

This option configures the forwarding of gRPC keepalive pings in syslog-ng OSE.

max-pings-without-data()

Type: integer
Default:  

Description: This option definies the maximum number of gRPC pings that are allowed to be sent when there is no data/header frame. Any pings succeeding this limit are not sent. Setting this option to 0 disables this restriction and keep sending pings.

time()

Type: number[milliseconds]
Default:  

Description: syslog-ng OSE sends a gRPC keepalive ping after the amount of time defined in the time() option elapsed.

timeout()

Type: number[milliseconds]
Default: 10

Description: The time syslog-ng OSE waits for an acknowledgement.

labels()

This option defines the labels applied to the message as they are sent to the destination.

Declaration:

labels(
    "label-output-name" => "field-of-the-message"
)

template()

Type: template or template-function
Default: ${ISODATE} ${HOST} ${MSGHDR} ${MSG}

Description: This option specifies a template that defines the logformat to be used in the destination. For more information on macros and template functions, see Macros of syslog-ng OSE and Template functions of syslog-ng OSE.

tenant-id()

Type: string
Default:  

Available in syslog-ng OSE 4.7 and later versions.

Description: This option sets the tenant ID for multi-tenant cases.

Declaration:

loki(
    url("localhost:9096")
    labels(
        "app" => "$PROGRAM",
        "host" => "$HOST",
    )

    tenant-id("testTenant")
);

timestamp()

Type: current, received, msg
Default: current

Description: This option sets the timestamp type to be used for messages sent to a Loki destination.

NOTE: Loki destinations only accept subsequent messages with increasing timestamps. Messages with timestamps deviating from this are rejected.

The timestamp types are the following.

  • current: The message procession output timestamp is used. This type guarantees an increasing timestamp order, but can deviate significantly from the message generation time.
  • msg: The original timestamp of the message is used.
  • received: The timestamp of message reception is used.

url()

Type: string
Default: localhost:9095

Description: This option specifies the URL of the Loki endpoint.

workers()

Type: integer
Default: 1

Description: Specifies the number of worker threads (at least 1) that syslog-ng OSE 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 disk-based buffering, syslog-ng OSE creates a separate disk buffer 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.

Updated: