# Show events from a file, a program, or HTTP

Send CloudEvents to streamview from a file, from the output of a different program, or with an HTTP request.

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

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](https://www.eventcatalog.dev/tools/streamview/docs/reference/event-format) for all fields.
streamview makes an event from a plain JSON record. See [Show plain JSON records](#show-plain-json-records).

## Send events from a file

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

```
streamview serve events.jsonl --open
```

## Send events from a different program

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](https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-events-from-any-command) for a log file, a container, a database table, and an HTTP API.

## Send events with HTTP

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}
```

## 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 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`.

## 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.

## Related

- [Show events from any command](https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-events-from-any-command)
- [Show events from an S3 bucket](https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-events-from-s3)
- [Show webhooks](https://www.eventcatalog.dev/tools/streamview/docs/how-to/show-webhooks)
- [Event format](https://www.eventcatalog.dev/tools/streamview/docs/reference/event-format)
- [HTTP endpoints](https://www.eventcatalog.dev/tools/streamview/docs/reference/http-endpoints)
- [Make test events](https://www.eventcatalog.dev/tools/streamview/docs/how-to/make-test-events)
