Skip to main content
Read records from a stream.

Read from the beginning

s2 read s2://my-basin/my-stream -s 0 -n 10
⦿ 54 bytes (3 records in range 0..=2)
hello world
foo bar
third record

JSON output

s2 read s2://my-basin/my-stream -s 0 -n 3 --format json
{"seq_num":0,"timestamp":1771390606217,"body":"hello world"}
{"seq_num":1,"timestamp":1771390606217,"body":"foo bar"}
{"seq_num":2,"timestamp":1771390606217,"body":"third record"}

Read from a timestamp

# Absolute (milliseconds since epoch)
s2 read s2://my-basin/my-stream --timestamp 1771390606217

# Relative
s2 read s2://my-basin/my-stream --ago 1h

Read from a tail offset

s2 read s2://my-basin/my-stream --tail-offset 100

Follow for new records

Without a limit (-n or -b), read keeps tailing and waits for new records indefinitely:
s2 read s2://my-basin/my-stream -s 0

Options

FlagDescription
-s, --seq-numStarting sequence number (inclusive)
--timestampStarting timestamp in milliseconds since epoch
--agoStarting timestamp as a human-friendly delta (e.g. 1h, 30m)
--tail-offsetStart from N records before the tail
-n, --countLimit number of records
-b, --bytesLimit number of bytes
--untilStop at this timestamp (exclusive, milliseconds since epoch)
--clampClamp the start position at the tail
--formatOutput format: text (default), json, json-base64
-o, --outputWrite to a file instead of stdout

Tail

Like tail on Unix — shows the last N records from a stream.
s2 tail s2://my-basin/my-stream -n 5
Follow for new records with -f:
s2 tail s2://my-basin/my-stream -f