Skip to content

Show events from a file, a program, or HTTP

View as Markdown

Use streamview serve when your events do not come from Kafka, NATS, or RabbitMQ.

Each line of the input is one JSON object: a CloudEvent, or a plain JSON record. A CloudEvent has the fields id, source, and type. See Event format for all fields. streamview makes an event from a plain JSON record. See Show plain JSON records.

  1. Put one event on each line of a file, for example events.jsonl.
  2. Run this command:
streamview serve events.jsonl --open

Use - as the file name. streamview then reads from standard input.

my-program | streamview serve - --open

The program must print one event on each line. See Show events from any command for a log file, a container, a database table, and an HTTP API.

  1. Run streamview serve --open.
  2. Send a POST request to http://localhost:4747/events.

The body of the request can be one event, a JSON array of events, or one event on each line.

curl -X POST http://localhost:4747/events \
-d '{"specversion":"1.0","id":"1","source":"/shop","type":"order.placed","data":{"country":"GB"}}'

The answer gives the number of events that streamview accepted and rejected:

{"accepted":1,"rejected":0}

A plain JSON record is a JSON object that is not a CloudEvent, for example a line of a log or of an archive. Tell streamview which fields of the record to use:

streamview serve records.jsonl --type-field eventType --time-field occurredAt --correlation-field orderId --open
Option The field that it gives
--type-field The kind of event. Each kind is one lane.
--time-field The time of the event.
--correlation-field The ID that connects the events of one order.
  • Use a period to go into an object, as in metadata.timestamp.
  • Use --type TEXT to give one type to all records.
  • The file can be a gzip file.
  • If the records are not in time sequence, add --sort. The page then shows the events when streamview reaches the end of the file.

The same options apply to the records that you send to POST /events.

streamview stores each event in a SQLite file. The default file is streamview.db in the current directory. To use a different file, add --db and a path.

When you start the server again with the same file, it loads the stored events. Open pages connect again automatically.