Skip to main content

S3 ingestion

This document explains what S3 ingestion is, how a bucket connection and an ingestion-error bucket set it up for the organization, which folder S3 ingestion reads for each usage-event collection, and which files S3 ingestion reads.

S3 ingestion: usage events from files in Amazon S3

S3 ingestion is the import of usage events from files in an Amazon S3 bucket of the organization. S3 ingestion is one of the four ways to send usage events. It fits files of usage that your systems write on a regular schedule. See Ways to send usage events. S3 ingestion needs two settings. The organization has one bucket connection to Zenskar. Each usage-event collection then has its own folder in that bucket. Zenskar reads each file when it arrives in a folder. It stores the usage events of the file in the usage-event collection of that folder. A billable metric reads them like any other usage events. Files that are in a folder before S3 ingestion is set up are not read. For example, a nightly job writes the API calls of the day to the file api_calls/2026-10-01.csv. The folder api_calls belongs to the usage-event collection API calls. Zenskar reads the file when it arrives. Zenskar stores the rows of the file as usage events of API calls.

Bucket connections: one bucket for the organization

A bucket connection is the setting that tells Zenskar which S3 bucket of the organization holds the files of usage events.
An organization has one bucket connection. Its bucket must be in the AWS region us-east-1.
The bucket stays in the AWS account of the organization. Zenskar reads the files in it. Zenskar never changes or deletes them. Zenskar uses two AWS resources of its own for S3 ingestion. The processor role is the AWS IAM role that Zenskar uses to read the files in the bucket of a bucket connection. The Zenskar SQS queue is the Amazon SQS queue of Zenskar that receives a notification when a new file arrives in the bucket of a bucket connection. The processor role and the Zenskar SQS queue each have an ARN. Two AWS settings on the bucket use them: The event notification must go directly from the bucket to the Zenskar SQS queue. Zenskar does not read a file whose notification passes through Amazon SNS or Amazon EventBridge. Zenskar does not test a bucket connection when it is saved. A bucket connection counts as connected as soon as it is saved. If the bucket policy is wrong, Zenskar cannot read the files. Zenskar then rejects them. If the event notification is wrong, Zenskar never learns that the files arrived. Each usage-event collection keeps the bucket that was connected when its S3 ingestion was last saved. When the bucket connection changes to another bucket, S3 ingestion reads the new bucket for a usage-event collection only after the S3 ingestion of that usage-event collection is saved again. Disconnecting a bucket connection turns off S3 ingestion on every usage-event collection. It also clears the folder and the error folder of each usage-event collection. Connecting a bucket again does not restore them.

Prepare the bucket in AWS

This guide shows how to set up the bucket policy and the event notification of the bucket.

Connect the bucket in Zenskar

This guide shows how to create, change, and remove the bucket connection.

Ingestion-error buckets: where rejected files go

An ingestion-error bucket is an S3 bucket of the organization in which Zenskar writes an error file for each file that S3 ingestion rejects. An ingestion-error bucket is optional. The organization sets it together with its bucket connection. It can be the bucket of the bucket connection or another bucket. An ingestion-error bucket must be in the AWS region us-east-1. Its bucket policy grants the processor role write access. With this access, Zenskar can add error files. A rejected file adds no usage events, even when only some of its rows fail. See Files that S3 ingestion reads. An error file is a CSV file that Zenskar writes to an ingestion-error bucket about a file that S3 ingestion rejects. Zenskar writes one of two error files. In the name of an error file, <ID> identifies the processing of the file. Zenskar writes the error files to the error folder of the usage-event collection. Without an error folder, it writes them to the folder errors. Without an ingestion-error bucket, Zenskar keeps no record of the files that it rejects. A file that Zenskar does not read gets no error file. This applies to a file whose name does not end in .csv. It also applies to a file in a folder that belongs to no usage-event collection.

Prepare an ingestion-error bucket

This guide shows how to let Zenskar write error files to a bucket.

Folders of usage-event collections

Each usage-event collection with S3 ingestion has its own folder in the bucket of the bucket connection. S3 ingestion is turned on or off for each usage-event collection. By default, the folder has the name of the API slug of the usage-event collection. Two usage-event collections cannot have the same folder. A folder is a path in the bucket, such as api_calls or usage/api_calls. The path has no trailing slash. No part of the path is . or ... Zenskar reads a file only when the folder of the file matches the folder of a usage-event collection exactly. The folder of a file is the whole path before its name. For example, the folder of usage/api_calls/2026-10-01.csv is usage/api_calls. For the usage-event collection with the folder usage/api_calls, Zenskar does not read usage/api_calls/old/2026-09-30.csv. Zenskar never reads a file at the top level of the bucket. An error folder is a folder of the ingestion-error bucket in which Zenskar writes the error files of one usage-event collection. The error folder is optional. It is available only when the organization has an ingestion-error bucket. It cannot be the folder of any usage-event collection. Turning off S3 ingestion for a usage-event collection stops Zenskar from reading its folder right away. It also clears the folder and the error folder of the usage-event collection.

Set up S3 ingestion for a usage-event collection

This guide shows how to turn on S3 ingestion and choose its folders.

Files that S3 ingestion reads

S3 ingestion reads CSV files. Zenskar reads a file only when its name ends in .csv. The ending can be in uppercase or lowercase letters, such as .CSV. It ignores all other files. The first row of a file is a header row. Each column of the header names one field of the data schema of the usage-event collection. The header must name every field, including the root fields customer_id and timestamp. It cannot name a column that the data schema does not have. The data. prefix of a data field is optional in the header. For example, the header quantity names the data field data.quantity. Each value must fit the data type of its field. See Data fields. A file can be at most 200 MB. An empty file is rejected. Zenskar checks every row of a file before it stores any row. If one row fails the check, Zenskar rejects the whole file. If the organization has an ingestion-error bucket, the error file lists each rejected row. See Ingestion-error buckets.

This conceptual diagram shows how S3 ingestion processes one file.

A file with the same content as a file that Zenskar already stored adds no usage events. A change to one value is enough to make a file count again. Zenskar downloads a file when it processes it. If the processing fails, Zenskar can download the file again to retry it. After the usage events of a file appear in the usage-event collection, the file can be deleted from the bucket.

Check that S3 ingestion works

This guide shows how to upload a test file and find its error file.