Fork me on GitHub

TCP transport for logstash-gelf

The TCP transport for logstash-gelf allows to configure TCP-specific options. Options are configured in a URI Query-String style:

Plaintext

tcp:hostname?readTimeout=10s&connectionTimeout=1000ms&deliveryAttempts=5&keepAlive=true

SSL

ssl:hostname?readTimeout=10s&connectionTimeout=1000ms&deliveryAttempts=5&keepAlive=true

Options

  • URI scheme specifies whether to use plaintext tcp or SSL ssl.
  • readTimeout Socket Read-Timeout (SO_TIMEOUT). The unit can be specified as suffix (see below). A timeout of zero is interpreted as an infinite timeout. Defaults to 2s.
  • connectionTimeout Socket Connection-Timeout (SO_TIMEOUT). The unit can be specified as suffix (see below). A timeout of zero is interpreted as an infinite timeout. Defaults to 2s.
  • deliveryAttempts Number of Delivery-Attempts. Will retry to deliver the message and reconnect if necessary. A number of zero is interpreted as an infinite attempts. Defaults to 1.
  • keepAlive Enable TCP keepAlive. Defaults to false.
  • writeBackoffTime Delay between subsequent attempts to write to a socket when a backoff is activated. Backoff is activated if a socket sender buffer is full and several attempts to write to the socket are unsuccessful due to it. The unit can be specified as suffix (see below). Defaults to 50ms.
  • writeBackoffThreshold Attempts to write to a socket before a backoff will be activated. Defaults to 10.
  • maxWriteBackoffTime Maximum time spent for awaiting during a backoff for a single message send operation. The unit can be specified as suffix (see below). Default equals to connectionTimeout.

SSL

TCP with SSL uses the JVM's truststore settings. You can specify a truststore by configuring the location to the truststore by setting javax.net.ssl.trustStore. Make sure this system property is set before bootstrapping any SSL-related components. Once the default SSL context is initialized, changes to javax.net.ssl.trustStore are not applied.

A customized javax.net.ssl.SSLContext can be provided by implementing an own GelfSenderProvider that configures GelfTCPSSLSender.

Timeout Units

Timeout values can be specified with or without a time-unit. The time-unit is appended directly to the numeric timeout value. A not specified time-unit defaults to MILLISECONDS

Available time-units are:

  • nsNANOSECONDS
  • usMICROSECONDS
  • msMILLISECONDS
  • sSECONDS
  • mMINUTES
  • hHOURS
  • dDAYS

Examples:

  • 2s – 2 seconds
  • 1000 – 1000 milliseconds
  • 5m – 5 minutes

Buffer size

The TCP sender uses pooled buffers to reduce GC pressure. The size defaults to 811.008 bytes (99 * 8192). The size can be controlled by setting the logstash-gelf.buffer.size property (system property). Buffering is disabled if logstash-gelf.buffer.size is set to 0 (zero).

Maximum Message Size

IP packets are subject to packet fragmentation during transport unless the DF bit is set or an active network component isn't capable of fragmentation. In such cases, make sure to adjust the maximumMessageSize to your MTU size with considering a 12 bytes GELF header.