Amazon S3 (im_amazons3)

Amazon Simple Storage Service (S3) is an object storage service offering industry-leading scalability, data availability, security, and performance.

This module can be used to collect logs from Amazon S3 and compatible services.

Amazon S3 buckets, objects, keys, and structure

Amazon S3 stores objects inside containers called buckets. See Getting Started with Amazon S3 in the Amazon S3 User Guide for more information.

Every im_amazons3 instance interacts with a single bucket on Amazon S3. The module will not create, delete, or alter the bucket or any of its properties, permissions, or management options. Instead, you must create the bucket, provide the appropriate permissions (ACL), and further configure any lifecycle, replication, encryption, or other options. Similarly, the module does not alter the storage class of the objects or any other properties or permissions.

By default, the module uses a schema where each object has a key that references the server or service name, the date, and the time of the event. Although Amazon S3 uses a flat structure to store objects, it groups objects with similar key prefixes resembling a filesystem structure. The following is a visual representation of our default naming scheme.

MYBUCKET/
└── SERVER01/
    └── 2025-06-18/
        ├── 12.30.45.0
        ├── 12.30.45.1
        └── 12.30.45.2
└── SERVER02/
    └── 2025-06-17/
        ├── 14.23.12.0
        ├── 14.23.12.1
        └── 14.23.12.2

You can change the schema by specifying the KeyTemplate directive.

Configuration

The im_amazons3 module accepts the following directives in addition to the common module directives. The Bucket, Region, and Server directives are required.

The AccessKey and SecretKey directives are required if NXLog Agent is not running in the same tenant as the S3 bucket.

Required directives

The following directives are required for the module to start.

Bucket

This mandatory directive specifies the Amazon S3 bucket name.

PathStyle

This boolean directive changes how the module constructs the URL to cater to providers like MinIO, which accepts the bucket name in the path instead of a subdomain. The default is TRUE if the URL directive is specified. Otherwise, this directive is not used. If FALSE, the module will prefix the URL with the Bucket as a subdomain. So, for example, if the URL is https://s3-us-east-2.amazonaws.com and the bucket is mybucket, the resulting URL will be https://mybucket.s3-us-east-2.amazonaws.com.

Region

This mandatory directive specifies the service region code. It accepts any value when used in conjunction with the URL directive. Otherwise, the following codes are supported:

Provider Region Code

Amazon

US East (N. Virginia)

us-east-1

Amazon

US East (Ohio)

us-east-2

Amazon

US West (N. California)

us-west-1

Amazon

US West (Oregon)

us-west-2

Amazon

Canada (Central)

ca-central-1

Amazon

Africa (Cape Town)

af-south-1

Amazon

Asia Pacific (Hong Kong)

ap-east-1

Amazon

Asia Pacific (Mumbai)

ap-south-1

Amazon

Asia Pacific (Tokyo)

ap-northeast-1

Amazon

Asia Pacific (Seoul)

ap-northeast-2

Amazon

Asia Pacific (Osaka)

ap-northeast-3

Amazon

Asia Pacific (Singapore)

ap-southeast-1

Amazon

Asia Pacific (Sydney)

ap-southeast-2

Amazon

China (Beijing)

cn-north-1

Amazon

China (Ningxia)

cn-northwest-1

Amazon

Europe (Stockholm)

eu-north-1

Amazon

Europe (Frankfurt)

eu-central-1

Amazon

Europe (Ireland)

eu-west-1

Amazon

Europe (London)

eu-west-2

Amazon

Europe (Paris)

eu-west-3

Amazon

South America (São Paulo)

sa-east-1

Amazon

Middle East (Bahrain)

me-south-1

Digital Ocean

US East (New York City)

nyc3

Digital Ocean

Europe (Amsterdam)

ams3

Digital Ocean

Asia Pacific (Singapore)

sgp1

Digital Ocean

Europe (Frankfurt)

fra1

Yandex (Object Storage)

Russia

ru-central1

Wasabi

US East (N. Virginia)

wa-us-east-1

Wasabi

US East (N. Virginia)

wa-us-east-2

Wasabi

US West (Oregon)

wa-us-west-1

Wasabi

Europe (Amsterdam)

wa-eu-central-1

Server

This mandatory directive sets the object path prefix. The module will read object names starting with the specified value only. Use / to read all objects. See Amazon S3 buckets, objects, keys, and structure.

URL

Specify the URL for a custom endpoint. If the protocol is not specified, the module will use HTTPS.

HTTPS directives

The following directives configure secure data transfer via HTTPS.

HTTPSAllowExpired

Set this directive to TRUE to allow connections with remote hosts that present an expired certificate. The default is FALSE; the module rejects connections with expired certificates.

HTTPSAllowUntrusted

Set this directive to TRUE to allow connections with remote hosts regardless of certificate verification results. The default is FALSE; the module only accepts connections with trusted certificates.

HTTPSCADir

Set this directive to the path of a directory containing Certificate Authority (CA) certificates. The module uses these certificates to verify the certificate presented by the remote host. Name the certificate files using the OpenSSL hashed format: the hash of the certificate followed by .0, .1, and so on. To find the hash of a certificate using OpenSSL:

$ openssl x509 -hash -noout -in ca.crt

For example, if the certificate hash is e2f14e4a, name the certificate file e2f14e4a.0. If there is another certificate with the same hash, name it e2f14e4a.1, and so on.

To trust a remote host’s self-signed certificate, include a copy of it in this directory.

If this directive isn’t specified, NXLog Agent falls back to the default operating system root certificate store. Unix-like operating systems commonly store root certificates in /etc/ssl/certs. Windows operating systems use the Windows Certificate Store, while macOS uses the Keychain Access Application as the default certificate store. See Certification Authority (CA) certificates in the NXLog Platform User Guide for more information on using this directive.

In addition, Microsoft’s PKI repository contains root certificates for Microsoft services.

HTTPSCAFile

Set this directive to the path of the Certificate Authority (CA) certificate used to verify the certificate presented by the remote host. To trust a remote host’s self-signed certificate, specify the remote host’s certificate itself. For certificates signed by an intermediate CA, the specified certificate must contain the complete certificate chain (certificate bundle).

HTTPSCertFile

Set this directive to the path of the certificate file to present to the remote host during the HTTPS handshake.

HTTPSCertKeyFile

Set this directive to the path of the private key file corresponding to the certificate specified by HTTPSCertFile.

Optional directives

AccessKey

This optional directive specifies the AWS public access key ID. If AccessKey and SecretKey are missing, the module will try to read the credentials from the environment, STS, profile, or instance metadata. If none are available, the module will try to log in anonymously.

AddHeader

Set this directive to a custom header to add to each HTTP request. Specify this directive multiple times to add more than one header.

Compression

Set this directive to enable HTTP compression for outgoing HTTP messages. The accepted values are none, gzip, and deflate. The default is none; compression is disabled.

Some HTTP servers may not accept compressed HTTP requests. If the server doesn’t support the specified compression method, it may return 415 Unsupported Media Type errors.

HTTPBasicAuthPassword

Set this directive to the HTTP basic authentication password. This directive requires you to also set the HTTPBasicAuthUser directive to use HTTP authentication.

HTTPBasicAuthUser

Set this directive to the HTTP basic authentication username. If the HTTPBasicAuthPassword directive is not set, the module attempts HTTP Basic authentication using an empty password.

Reconnect

This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in every defined second. If it is not set, the reconnect interval will start at 1 second and double with every attempt. In the latter case, when the system decides that the reconnection is successful, the reconnect interval is immediately reset to 1 sec.

The Reconnect directive must be used with caution. If it is used on multiple systems, it can send reconnect requests simultaneously to the same destination, potentially overloading the destination system. It may also cause NXLog Agent to use unusually high system resources or cause NXLog Agent to become unresponsive.

ReconnectOnData

This optional directive defines the behavior when the connection with the remote host is lost. When set to TRUE, the module only attempts to reconnect when it has data to send. The default value is FALSE; it will always keep a connection open with the remote host.

AdjustLag

This optional boolean directive is used to activate or deactivate the polling interval adjustment mechanism. The default value is TRUE, the polling interval adjustment mechanism is active.

InputType

This directive is identical to the InputType common module directive.

The default is LineBased, meaning the module expects CRLF as the record terminator on Windows or LF on Unix.

KeyTemplate

Use this directive to change the naming scheme of objects in the bucket. The key template must match the naming scheme used when writing the data to the bucket. You can use the following placeholders:

Placeholder Description

{server}

Server name

{region}

AWS region

{hostname}

System hostname

{year}

UTC year (4 digits)

{month}

UTC month (2 digits)

{day}

UTC day (2 digits)

{hour}

UTC hour (2 digits)

{min}

UTC minutes (2 digits)

{sec}

UTC seconds (2 digits)

{index}

Integer counter (for disambiguation)

{uuid}

A full UUID generated for each chunk of data

{uuid8}

A partial 8-character UUID generated for each chunk of data

The {index} is only unique within an instance of im_amazons3. If used within multiple instances on the same or different hosts, it can cause a naming collision.

The value must adhere to the following requirements:

  • It must not exceed 1024 characters.

  • The {year}, {month}, {day}, {hour}, {min} are required and each must appear only once.

  • The {index} and {uuid} placeholders are mutually exclusive.

  • {index} or {uuid}/{uuid8} must be the last placeholder.

Refer to the Amazon S3 General purpose bucket naming rules.

The default value is {server}/{year}-{month}-{day}/{hour}.{min}.{sec}.{index}.

PollInterval

This optional directive specifies how frequently the module will check for new events in seconds. If this directive is not specified, it defaults to 60 seconds.

ReadFromLast

This boolean directive instructs the module on where to start reading events from the log source when NXLog Agent starts.

When TRUE, NXLog Agent will only read events logged after NXLog Agent started, unless SavePos is TRUE and a saved position for this log source exists in the cache file.

When FALSE, NXLog Agent will read all events from the log source, unless SavePos is TRUE and a saved position for this log source exists in the cache file.

The default is TRUE.

The following matrix shows the outcome of this directive in conjunction with the SavePos directive:

ReadFromLast SavePos Saved position Outcome

TRUE

TRUE

Yes

Reads events from the saved position.

TRUE

TRUE

No

Reads events that are logged after NXLog Agent is started.

TRUE

FALSE

Yes

Reads events that are logged after NXLog Agent is started.

TRUE

FALSE

No

Reads events that are logged after NXLog Agent is started.

FALSE

TRUE

Yes

Reads events from the saved position.

FALSE

TRUE

No

Reads all events.

FALSE

FALSE

Yes

Reads all events.

FALSE

FALSE

No

Reads all events.

If the NoCache directive is TRUE, it overrides the SavePos directive. In this case, the module behaves as if SavePos is FALSE.

SavePos

Set this directive to TRUE to save the position of the last processed event before NXLog Agent exits. On the next startup, the agent reads the saved position from the cache file and resumes from that point. Together with the ReadFromLast directive, this directive allows the agent to continue reading events from the saved position.

The default is TRUE; the position of the last read event is saved and will be read from the cache file on the next startup.

If the NoCache directive is TRUE, it overrides the SavePos directive. In this case, the module behaves as if SavePos is FALSE.

SecretKey

This optional directive specifies the AWS secret access key.

StartFrom

This optional directive specifies the time in RFC 3339 format of the first event to pull, e.g., 2022-11-19T16:39:57-08:00. If this directive is not specified, the module reads events according to the ReadFromLast directive. Default value is Now (the module’s startup time). If SavePos is true, the start time will be overridden by the last saved position.

Fields

The following fields are created by im_amazons3.

$raw_event (type: string)

A record from the stored object

Examples

Example 1. Collecting logs from an Amazon S3 bucket

This configuration uses the im_amazons3 input module to collect logs from an Amazon S3 Bucket named MYBUCKET. The Server directive specifies that only object names starting with SERVER01 should be collected.

<Input amazon_s3>
    Module       im_amazons3
    Region       us-east-1
    Bucket       MYBUCKET
    Server       SERVER01
    StartFrom    2022-09-15T10:23:00-06:00 (1)

    AccessKey    <YOUR_ACCESS_KEY> (2)
    SecretKey    <YOUR_SECRET_KEY> (3)
</Input>
1 StartFrom is an optional directive to specify the oldest event to pull.
2 The AccessKey directive specifies the AWS public access key ID.
3 The SecretKey directive specifies the AWS secret access key.
Example 2. Collecting logs from other Amazon S3-compatible services

This configuration uses the im_amazons3 input module to collect logs from a self-hosted MinIO S3 instance.

<Input amazon_s3>
    Module       im_amazons3
    URL          https://example.net (1)
    Region       myminio
    Bucket       MYBUCKET
    Server       SERVER01

    AccessKey    <YOUR_ACCESS_KEY> (2)
    SecretKey    <YOUR_SECRET_KEY> (3)
</Input>
1 The URL directive is specified to use a custom endpoint.
2 The AccessKey directive specifies the AWS public access key ID.
3 The SecretKey directive specifies the AWS secret access key.