Watch a NATS system
In this tutorial, you start a small food-delivery system that uses a real NATS server with JetStream. You see subjects with history and subjects without history. Then you follow one order.
You need Docker and Git. You do not need to install streamview or Node.js.
1. Start the example
Section titled “1. Start the example”Get the streamview source code, and start the example:
git clone https://github.com/event-catalog/streamviewcd streamview/example-natsdocker compose up -d --buildThe first build takes some minutes. The command starts a NATS server, four services, and streamview.
2. Open the page
Section titled “2. Open the page”Open http://localhost:4748 in your browser.
You see one lane for each subject, for example orders.created and kitchen.accepted.
3. Compare two kinds of subject
Section titled “3. Compare two kinds of subject”Click the time range button at the top right. Then click All. The view shows all events that streamview has.
orders.createdhas events from the time when the example started. A JetStream stream stores this subject.search.performedhas events only from the time when streamview started. NATS does not store this subject.
streamview reads a stored subject from the first message of its stream. For the other subjects, it sees only the new messages.
4. See how streamview makes one lane from many subjects
Section titled “4. See how streamview makes one lane from many subjects”Find the telemetry.courier lane.
Each courier sends to its own subject, for example telemetry.courier.7.
The example starts streamview with --depth 2. Thus all courier subjects are one lane.
5. Follow one order
Section titled “5. Follow one order”- Click the time range button. Then click Last 30 s.
- Drag across approximately five seconds of the timeline. Each event is now one thin mark.
- Click a mark in the
orders.createdlane.
The panel opens. The trace shows the steps of the order, for example kitchen.accepted and delivery.assigned.
An order takes some time, thus the last steps arrive later.
- Wait some seconds. Then press Escape, and click the mark again.
The trace now shows more steps.
6. Find the bad release
Section titled “6. Find the bad release”The example makes a bad release automatically, at intervals of some minutes.
During the bad release, the courier service sends distanceKm as text.
- Click the time range button. Then click All.
- Press
/, selectis, and then selectviolation.
If the bad release occurred, the delivery.completed lane shows amber events.
If the timeline is empty, wait some minutes and look again.
- Press Backspace in the empty search box to remove the filter.
7. Stop the example
Section titled “7. Stop the example”Run this command in the example-nats directory:
docker compose down -vThe command stops the containers and deletes their data.
What you did
Section titled “What you did”You saw a real NATS system on the timeline, with stored subjects and subjects that NATS does not store.
Next steps:
- Connect to NATS, to see your own subjects.
- How streamview reads without taking messages.