Skip to main content

Tcplog Receiver

Status Available in: contrib Maintainers: @VihasMakwana Source: opentelemetry-collector-contrib

Supported Telemetry

Logs

Overview

Configuration

FieldDefaultDescription
max_log_size1MiBThe maximum size of a log entry to read before failing. Protects against reading large amounts of data into memory
listen_addressrequiredA listen address of the form <ip>:<port>
tlsnilAn optional TLS configuration (see the TLS configuration section)
attributes{}A map of key: value pairs to add to the entry’s attributes
one_log_per_packetfalseSkip log tokenization, set to true if logs contains one log per record and multiline is not used. This will improve performance.
resource{}A map of key: value pairs to add to the entry’s resource
add_attributesfalseAdds net.* attributes according to [semantic convention][https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/network.md#network-attributes]
multilineA multiline configuration block. See below for details
encodingutf-8The encoding of the file being read. See the list of supported encodings below for available options
operators[]An array of operators. See below for more details
retry_on_failure.enabledfalseIf true, the receiver will pause reading a file and attempt to resend the current batch of logs if it encounters an error from downstream components.
retry_on_failure.initial_interval1sTime to wait after the first failure before retrying.
retry_on_failure.max_interval30sUpper bound on retry backoff interval. Once this value is reached the delay between consecutive retries will remain constant at the specified value.
retry_on_failure.max_elapsed_time5mMaximum amount of time (including retries) spent trying to send a logs batch to a downstream consumer. Once this value is reached, the data is discarded. Retrying never stops if set to 0.

TLS Configuration

The tcp_log receiver supports TLS, disabled by default. config more detail opentelemetry-collector#configtls.
FieldDefaultDescription
cert_filePath to the TLS cert to use for TLS required connections.
key_filePath to the TLS key to use for TLS required connections.
ca_filePath to the CA cert. For a client this verifies the server certificate. For a server this verifies client certificates. If empty uses system root CA.
client_ca_filePath to the TLS cert to use by the server to verify a client certificate. (optional)

Operators

Each operator performs a simple responsibility, such as parsing a timestamp or JSON. Chain together operators to process logs into a desired format.
  • Every operator has a type.
  • Every operator can be given a unique id. If you use the same type of operator more than once in a pipeline, you must specify an id. Otherwise, the id defaults to the value of type.
  • Operators will output to the next operator in the pipeline. The last operator in the pipeline will emit from the receiver. Optionally, the output parameter can be used to specify the id of another operator to which logs will be passed directly.
  • Only parsers and general purpose operators should be used.

Parsers with Embedded Operations

Many parsers operators can be configured to embed certain followup operations such as timestamp and severity parsing. For more information, see complex parsers.

multiline configuration

If set, the multiline configuration block instructs the tcp_log receiver to split log entries on a pattern other than newlines. The multiline configuration block must contain exactly one of line_start_pattern or line_end_pattern. These are regex patterns that match either the beginning of a new log entry, or the end of a log entry. The omit_pattern setting can be used to omit the start/end pattern from each entry.

Supported encodings

KeyDescription
nopNo encoding validation. Treats the file as a stream of raw bytes
utf-8UTF-8 encoding
utf-16leUTF-16 encoding with little-endian byte order
utf-16beUTF-16 encoding with little-endian byte order
asciiASCII encoding
big5The Big5 Chinese character encoding
Other less common encodings are supported on a best-effort basis. See https://www.iana.org/assignments/character-sets/character-sets.xhtml for other encodings available.

Example Configurations

Simple

Configuration:
receivers:
  tcp_log:
    listen_address: "0.0.0.0:54525"
The deprecated component type tcplog is still accepted:
receivers:
  tcplog:
    listen_address: "0.0.0.0:54525"

Advanced

Following configuration incorporates TLS, multiline config, operators and retry on failure:
receivers:
  tcp_log:
    listen_address: "0.0.0.0:54525"
    max_log_size: 2MiB
    one_log_per_packet: false
    add_attributes: true
    encoding: utf-8
    attributes:
      environment: "production"
      team: "backend"
    resource:
      service.name: "my-tcp-service"
      service.version: "1.0.0"
    tls:
      cert_file: "/etc/otel/certs/server.crt"
      key_file: "/etc/otel/certs/server.key"
      ca_file: "/etc/otel/certs/ca.crt"
      client_ca_file: "/etc/otel/certs/client-ca.crt"
    retry_on_failure:
      enabled: true
      initial_interval: 2s
      max_interval: 20s
      max_elapsed_time: 2m
    multiline:
      line_start_pattern: '^\d{4}-\d{2}-\d{2}' # logs starting with a date
      omit_pattern: true
    operators:
      - type: json_parser
        id: parse_json
        output: timestamp_parser

Configuration

Example Configuration

tcp_log:
  listen_address: "127.0.0.1:29018"
  retry_on_failure:
    enabled: false
    initial_interval: 1000000000
    max_interval: 30000000000
    max_elapsed_time: 300000000000

Last generated: 2026-04-13