Skip to main content

SLS Logger Configuration

The sls-logger plugin sends gateway access logs to Alibaba Cloud Simple Log Service through RFC 5424 Syslog over TLS. Configuration covers plugin parameters and plugin metadata.

Parameters​

See plugin common configurations for configuration options available to all plugins.

  • host

    string

    required


    Project-qualified Alibaba Cloud SLS Syslog hostname.

  • port

    integer

    required


    TLS Syslog port. Alibaba Cloud SLS uses 10009.

  • project

    string

    required


    SLS Project name encoded into each event.

  • logstore

    string

    required


    SLS Logstore name encoded into each event.

  • access_key_id

    string

    required


    Alibaba Cloud RAM AccessKey ID.

  • access_key_secret

    string

    required


    Alibaba Cloud RAM AccessKey secret. API7 Gateway encrypts the value with AES at rest. APISIX encrypts it before etcd storage when apisix.data_encryption.enable_encrypt_fields is enabled.

  • timeout

    integer

    default: 5000

    valid value:

    greater than or equal to 1

    TCP/TLS send timeout in milliseconds.

  • ssl_verify

    boolean

    default: true


    If true, verify the SLS TLS certificate. Introduced in API7 Enterprise 3.9.18 and 3.10.5, and in APISIX 3.18.0.

  • log_format

    object


    Custom log format. APISIX supports nesting up to five levels; API7 Gateway supports flat fields.

  • log_format_extra

    object


    Fields added to the default log entry. Ignored when log_format is configured.

  • include_req_body

    boolean

    default: false


    If true, include the request body in the default log entry.

  • include_req_body_expr

    array[array]

    valid value:

    at least one condition

    Conditions in APISIX expression format that control proactive body reading and whether the default request.body field is included. Used only when include_req_body is true.

    A custom format that references $request_body can still include a body already buffered by NGINX when the conditions are false. Do not use this field as a data-redaction boundary.

  • include_resp_body

    boolean

    default: false


    If true, include the response body in the default log entry.

  • include_resp_body_expr

    array[array]

    valid value:

    at least one condition

    Conditions in APISIX expression format that control when the response body is logged. Used only when include_resp_body is true.

  • max_req_body_bytes

    integer

    default: 524288

    valid value:

    greater than or equal to 1

    Maximum request-body bytes included in the log.

  • max_resp_body_bytes

    integer

    default: 524288

    valid value:

    greater than or equal to 1

    Maximum response-body bytes collected before decoding.

  • name

    string

    default: sls-logger


    Batch-processor identifier exported in batch-processing metrics.

  • batch_max_size

    integer

    default: 1000

    valid value:

    greater than or equal to 1

    Maximum entries in one batch. A value of 1 sends each entry immediately; larger values buffer entries until a size or time limit is reached.

    Buffered entries are concatenated as RFC 5424 messages before they are sent over TLS.

    Batch processors are local to each gateway worker, so requests handled by different workers can be sent in separate batches.

  • inactive_timeout

    integer

    default: 5

    valid value:

    greater than or equal to 1

    Seconds without a new entry before the current batch is sent. For timely flushing, set this value lower than buffer_duration.

  • buffer_duration

    integer

    default: 60

    valid value:

    greater than or equal to 1

    Maximum age in seconds of the oldest entry before a batch is sent.

  • retry_delay

    integer

    default: 1

    valid value:

    greater than or equal to 0

    Seconds between failed send attempts.

  • max_retry_count

    integer

    default: 0

    valid value:

    greater than or equal to 0

    Failed retries allowed before a batch is dropped.

Plugin Metadata​

The following attributes configure shared SLS Logger formatting through plugin metadata.

  • log_format

    object


    Default custom log format for plugin instances.

  • log_format_extra

    object


    Default extra fields for plugin instances.

  • max_pending_entries

    integer

    default: 8192

    valid value:

    greater than or equal to 1

    Maximum number of entries waiting in the batch processor. New entries are discarded when the backlog reaches the limit.

    Introduced with a default of 8192 in API7 Enterprise 3.9.19 and 3.10.6, and in APISIX 3.18.0. Earlier versions do not support this field.

    See Batch Processor for sizing and verification guidance.