Show events from a file, a program, or HTTP
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.
Send events from a file
Section titled “Send events from a file”- Put one event on each line of a file, for example
events.jsonl. - Run this command:
streamview serve events.jsonl --openSend events from a different program
Section titled “Send events from a different program”Use - as the file name. streamview then reads from standard input.
my-program | streamview serve - --openThe 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.
Send events with HTTP
Section titled “Send events with HTTP”- Run
streamview serve --open. - Send a
POSTrequest tohttp://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}Show plain JSON records
Section titled “Show plain JSON records”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 TEXTto 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.
Keep the events in a different file
Section titled “Keep the events in a different file”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.