# Show events from an S3 bucket

Load an archive of events from an Amazon S3 bucket, and see the events at the times when they occurred.

Source: https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-events-from-s3

Many systems keep a copy of their events as files in an S3 bucket.
The `streamview serve` command reads these files. It puts each event at the time that the record gives.

You need the AWS command line (`aws`), with access to the bucket.
The files must have JSON records: one on each line, or one directly after the other. A file can be a gzip file.

streamview does not connect to S3. The `aws` command reads the objects, and streamview reads its output.

## Look at one object

1. Find the fields of a record. Print the first record of an object:

```
aws s3 cp s3://my-bucket/events/orders-partition-0.json.gz - | gunzip | head -n 1
```

```
{"eventType": "order.placed", "occurredAt": "2026-12-01T10:00:00.064767Z", "orderId": "ord_0", "total": 43, "country": "IE"}
```

2. Find these three fields in the record:

- The field that gives the kind of event. In the example: `eventType`.
- The field that gives the time. In the example: `occurredAt`.
- The field that connects the events of one order. In the example: `orderId`.

3. Send the object to streamview, with the names of the three fields:

```
aws s3 cp s3://my-bucket/events/orders-partition-0.json.gz - | streamview serve - \
  --db archive.db --type-field eventType --time-field occurredAt \
  --correlation-field orderId --sort --open
```

The browser opens. When the command reaches the end of the object, the page shows the events at their times.
The terminal shows a line such as this:

```
-: end of input, 588 events accepted, 0 rejected
```

Use `--db` with a new file name. Do not load an archive into a store that has newer events.
See [Time and sequence of events](https://www.eventcatalog.dev/tools/streamview/docs/explanation/time-and-sequence) for the reason.

## Load all objects below a prefix

1. Copy the objects to a directory:

```
aws s3 sync s3://my-bucket/events/ archive
```

2. Send all files to streamview:

```
cat archive/* | streamview serve - \
  --db archive.db --type-field eventType --time-field occurredAt \
  --correlation-field orderId --sort --open
```

The files can be gzip files or text files, but not the two kinds together.

`--sort` is necessary here. Each file has its own time range, and the ranges of two files are frequently the same.
With `--sort`, streamview holds all events until the end of the input, and then puts them in time sequence.

## If a record does not give the kind of event

Give one type to all records with `--type`:

```
cat archive/* | streamview serve - --db archive.db --type payment --time-field ts --sort --open
```

If you give no type option, streamview looks at the usual field names, for example `type`, `event`, and `detail-type`.
See [Events from plain JSON records](https://www.eventcatalog.dev/tools/streamview/docs/reference/event-format#events-from-plain-json-records).

## If a record does not give the time

streamview then uses the time when it read the record. All records are at one point on the timeline.

Look for a time field one level down, and give its path with periods. For example: `--time-field metadata.timestamp`.

The time can be text, such as `2026-12-01T10:00:00Z`, or a number of seconds or milliseconds from 1970.

## Read the archive again

Run the same command again with the same `--db` file. streamview does not add the records a second time.

To start from zero, delete the `--db` file.

## Use a different object store

The steps are the same for each store that has a command that prints an object.
We tested these steps with MinIO, which is an S3-compatible store, and with the `aws` command.

## Related

- [Show events from any command](https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-events-from-any-command)
- [Show events from a file, a program, or HTTP](https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-your-own-events)
- [Events from plain JSON records](https://www.eventcatalog.dev/tools/streamview/docs/reference/event-format#events-from-plain-json-records)
- [Command line: streamview serve](https://www.eventcatalog.dev/tools/streamview/docs/reference/command-line#streamview-serve)
