Visualize your NATS subjects on a live timeline

To visualize NATS subjects, run streamview nats --servers localhost:4222. streamview subscribes to all subjects and draws each subject as one lane on a live timeline in your browser. For subjects that a JetStream stream stores, it also shows the history. It is open source, it runs on your computer, and it does not take messages from your queue groups or work queues.

By the EventCatalog team Updated

The streamview page with ten NATS subjects of a food-delivery system. Each subject is one lane on a timeline, and bars show how many messages arrived in each interval.
Ten subjects of an example food-delivery system on a real NATS server with JetStream. Each subject is one lane, and all lanes use the same clock.

Why nats sub is not enough

The usual way to look at NATS is nats sub '>' in a terminal. It prints each message as it arrives. That tells you what is in one message. It does not tell you what your system does.

When something is wrong, you ask different questions:

  • Which subjects are active at this moment, and which subjects stopped?
  • When did a service become slow, and when did it recover?
  • What came after this message, on the other subjects?

These are questions about time. A picture of time gives the answer faster than a scrolling terminal.

streamview draws time from left to right, and gives each subject one lane. One message is one thin mark. When you zoom out, many messages become a bar, and a taller bar means more messages. All lanes use the same clock, so you can compare one subject with a different subject.

What you see on the timeline

The screenshots on this page are from a real NATS server with JetStream. They show the example of the NATS tutorial: a food-delivery system with four services that send messages only through NATS.

A slow service has a shape

In this example, a dinner rush comes every seven minutes. The kitchen cannot cook all orders, so it rejects some of them.

The timeline during a dinner rush. The kitchen.rejected lane has a group of red marks, and the kitchen.ready lane becomes thin while orders.created continues.
During the rush, kitchen.rejected becomes active, and the orders that the kitchen accepted take longer to become ready.

You did not write a query to find this, and you did not read a message. The red marks and the thinner lanes are visible as soon as you look at the page.

A changed payload is amber

A release of the courier service sent the distanceKm field as text, not as a number.

An amber message of the delivery.completed subject is open. The panel shows the label Shape drift, and says that the field distanceKm is usually a number and was sent as a string.
streamview flags a message that has a different shape from the usual messages of its subject. The panel names the field.

streamview learns the usual fields of each subject from its first 20 messages. You do not give it a schema. A message with a missing field, a new field, or a field of a different type gets a flag. How streamview flags an event has the details.

One order goes through many subjects

Click a message. streamview finds all messages that have the same correlation ID, on all subjects.

One message is open. A blue line on the timeline connects the messages of the same order on different subjects, and the panel lists them with the time after the first message.
The trace of one order, from orders.created to notify.sent: seven messages on seven subjects. The panel shows the time after the first message.

If your messages are plain JSON, tell streamview which field connects them, for example --correlation-field orderId. streamview also reads the correlationid, Correlation-Id, and traceparent headers.

Get started

You need macOS or Linux, and Node.js for the NATS command.

  1. Install streamview
    curl -fsSL https://github.com/event-catalog/streamview/releases/latest/download/install.sh | sh
  2. Start it with the address of your NATS server
    streamview nats --servers localhost:4222

    The first start installs the NATS adapter. This takes some seconds.

  3. Look at your subjects

    The browser opens at http://localhost:4747. Drag across the timeline to zoom in, and click a mark to open a message.

These options are useful for a first look:

Option What it does
--subjects 'orders.>,payments.*' Reads only these subjects. You can use the * and > wildcards.
--depth 2 Makes one lane from the subjects that have the same first two parts.
--latest Does not read the history of the streams.
--correlation-field orderId Connects the messages that have the same value in this field.

Connect to NATS has all options.

If you do not have a NATS server, the NATS tutorial starts the example of this page with Docker. You can also run streamview demo, which shows a mock order system and needs no setup.

Is it safe to connect it to a real server?

streamview only reads.

Your servicessend messagesNATSsubjects, streamsYour servicesget each messagea subscription of its ownstreamviewonly readsYour browserthe timelineStreams with limits retention give history.Other subjects show new messages only.

NATS sends each message to all subscriptions that match its subject. streamview makes a usual subscription, so it gets a copy. A queue group still gets each message once.

JetStream is different, because a consumer on some streams changes what the stream keeps. streamview looks at the retention of each stream before it reads it:

Limits retentionkeeps a message until a limitAn ordered consumertemporary, and it removes nothingHistory and newfrom the first messageWork-queue streamdeletes a message after a readNo consumer on the streama read takes the messageNew messages onlyno historyInterest streamkeeps what consumers needNo consumer on the streama consumer changes what it keepsNew messages onlyno history

There are limits that you must know before you connect it to production:

  • The page has no login. Each person who can open it can read all messages. By default, it accepts connections only from your computer.
  • The NATS adapter has no TLS options. We did not test the login options against a server with authentication.
  • streamview reads JSON. It does not decode Protobuf or other binary formats.

How streamview reads without taking messages and Limits have the full lists.

What happens, and what must happen

A timeline shows what happens on your subjects. It does not tell you what must happen:

  • What is this subject for?
  • Which services publish to it, and which services subscribe to it?
  • Which schema do its messages have, and who owns it?

Those answers are documentation. For that, the same team makes EventCatalog, an open source tool that documents an event-driven architecture: the events, the channels such as NATS subjects, the services, the schemas, and the owners. EventCatalog also draws the architecture from that documentation, and it has an AsyncAPI integration.

The two views go together. The catalog tells you that kitchen.ready comes after kitchen.accepted. The timeline shows you that during the dinner rush, it came much later.

Document your NATS subjects with EventCatalog

streamview shows your subjects in real time. EventCatalog documents them: what each subject is for, which services use it, and who owns it.

Go to eventcatalog.dev

Questions and answers

How do I visualize NATS subjects?

Install streamview, then run streamview nats --servers localhost:4222 with the address of your server. Your browser opens a live timeline with one lane for each subject. There is nothing to configure, and you do not write a schema.

Does streamview take messages from my queue groups?

No. streamview makes a usual subscription, by default to >. NATS sends a copy to it, and it still sends each message to one member of your queue group. streamview does not read work-queue streams or interest streams, because a consumer on those streams changes what your services get.

Does streamview show the history of a subject?

For a subject that a JetStream stream with limits retention stores, yes. streamview reads that stream from its first message with a temporary ordered consumer, and deletes the consumer when it stops. For all other subjects, it shows only the messages that come after it starts. Add --latest to skip the history.

My subjects contain IDs. Do I get one lane for each ID?

Add --depth with the number of subject parts that make one lane. With --depth 2, telemetry.courier.7 and telemetry.courier.8 are one lane, telemetry.courier. The full subject stays in the subject field of each message.

Can it connect to a server that needs a login or TLS?

streamview has --user and --password, --token, and --creds, but we did not test them against a server with authentication. The NATS adapter has no TLS options, and we did not test it with a hosted NATS service.

Do my messages need a schema or a special format?

No. streamview reads plain JSON messages and CloudEvents. It does not decode Protobuf or other binary formats.

Is streamview free?

Yes. streamview is open source with the Apache License 2.0. It runs on your computer, and it stores the messages in a file on your computer.

What is the difference between streamview and EventCatalog?

streamview shows the messages on your subjects in real time. EventCatalog documents your architecture, which includes what each subject is for, which services use it, and who owns it. The same team makes both, and both are open source.

Where to go next