List streams
List all streams in a basin:Using S2 URI format
You can also specify the basin using an S2 URI:Filter by prefix
List only streams matching a prefix:Pagination
Limit results:Using the ls shortcut
Thels command lists streams when given a basin name or URI:
Create a stream
Create a stream with default settings:Configure stream properties
Set storage class, retention, and timestamping:Enable auto-deletion of empty streams
Automatically delete the stream when empty:Get stream configuration
View the current configuration of a stream:Reconfigure a stream
Update an existing stream’s configuration:Available reconfiguration options
--storage-class- Storage class (standard,express)--retention-policy- Retention policy (e.g.,7d,30d,infinite)--timestamping-mode- Timestamping mode (client-prefer,client-require,arrival)--timestamping-uncapped- Allow uncapped timestamps (true/false)--delete-on-empty-min-age- Minimum age before deleting empty streams (e.g.,1d)
Storage class changes only apply to newly appended records. Existing records retain their original storage class.
Delete a stream
Delete a stream:Check stream tail position
Get the current tail position (next sequence number and last timestamp):- Next sequence number:
12345 - Timestamp of last record:
1704067200000(milliseconds since Unix epoch)
Trim a stream
Set a trim point to delete old records:10000.
Output:
Trim with fencing token
Enforce a fencing token when trimming:Trim with sequence number match
Only trim if the next sequence number matches the expected value:Trimming is eventually consistent. Trimmed records may be visible briefly before deletion completes.
Fence a stream
Set a fencing token to coordinate writes:Enforce previous fencing token
Only set the new token if the current token matches:Fence with sequence number match
Common workflows
Create a stream for real-time events
Create a stream for archival logs
Migrate stream to different storage class
1
Create new stream with desired storage class
2
Copy records from old stream
3
Update application to use new stream
Deploy application changes to write to
events-new.4
Delete old stream
Cleanup old records periodically
Configuration reference
Storage classes
- standard - Cost-optimized, higher latency
- express - Low-latency, higher cost
Retention policies
Examples:Timestamping modes
- client-prefer - Use client timestamp if provided, otherwise server timestamp
- client-require - Reject records without client timestamp
- arrival - Always use server arrival timestamp