Set up the Kafka Message Stream Viewer
The Message Stream Viewer requires configuration in two places before any user can stream messages:
- The stream server in axon-agent, which reads from Kafka and serves the WebSocket connection. It is disabled by default.
- The streaming endpoint in the AxonOps dashboard, which tells the browser where to connect.
Both halves are required. Where only one is configured, the Stream page still loads, but Connect does not establish a session.
Prerequisites
Section titled “Prerequisites”Requires axon-agent 2.0.20, axon-server 2.0.27, and axon-dash 2.0.27 or later. Streaming from a timestamp rather than an offset requires axon-agent 2.0.21, axon-server 2.0.28, and axon-dash 2.0.29 or later.
- axon-agent installed and reporting on at least one node in the Kafka cluster. See axon-agent installation.
- On each node that will run the stream server, the
kafka.kafka_clientblock configured with broker addresses and any SASL or TLS credentials. See Kafka agent configuration. The stream server reads from Kafka through that client, so a node whosekafka_clientcannot reach the brokers cannot serve a stream. - A network path from the browsers that will use the viewer to the address the stream server binds to.
- An AxonOps user with the Admin role, which is required to save the streaming settings.
- A Schema Registry endpoint, only where topic messages are encoded with Avro, Protobuf, or JSON Schema. Topics carrying plain text need none.
Configure the stream server on axon-agent
Section titled “Configure the stream server on axon-agent”The stream server is configured under kafka_stream_server: within the kafka: section of /etc/axonops/axon-agent.yml.
kafka: node_type: "broker" kafka_client: brokers: ["broker1.example.com:9093"] kafka_stream_server: enabled: true addr: "0.0.0.0:8443" tls: certFilepath: "/etc/axonops/cert.crt" keyFilepath: "/etc/axonops/cert.key"| Setting | Meaning |
|---|---|
enabled | Runs the stream server on this agent. Defaults to false. |
addr | Address the WebSocket server binds to, as host:port. There is no default; a value must be supplied when enabled is true. |
tls.certFilepath | Server certificate presented to connecting browsers. |
tls.keyFilepath | Private key for the server certificate. |
kafka_stream_server.tls also accepts caFilepath and insecureSkipTlsVerify. The listener reads neither of them, so setting them changes nothing. Only the certificate and key affect how it serves.
The server serves WebSocket connections at the path /ws on addr. Where both tls.certFilepath and tls.keyFilepath are set, it runs over TLS and the endpoint scheme is wss://. Where either is absent, the endpoint scheme is plain ws://.
The agent must be restarted for a change to kafka_stream_server to take effect.
addr is the address the agent binds to on its own host, which is not necessarily the address a browser uses to reach it. 0.0.0.0:8443 binds every interface on the host; the value entered in the dashboard is the address that resolves to that host, or to whatever fronts it. Entering a bind address such as 0.0.0.0:8443 in the dashboard produces an endpoint no browser can reach.
Where to run the stream server
Section titled “Where to run the stream server”The stream server is enabled per agent, so it runs only on the nodes where it is configured, and one node is enough. Enabling it on further nodes does not give the viewer a second agent to fall back to: AxonOps stores exactly one streaming endpoint, and the browser connects to that address alone. Redundancy across several agents requires a load balancer or ingress in front of them, stood up and health-checked separately, with its address configured as the endpoint.
The node also has to be one whose kafka_client can reach the brokers holding the topic's partitions. Running the stream server on a broker host satisfies that by default, at the cost of accepting inbound browser connections on a host that otherwise serves only Kafka traffic. Running it on a separate agent node keeps user-facing connections off the broker hosts, at the cost of another node to maintain and another set of Kafka client credentials.
Environment variable equivalents
Section titled “Environment variable equivalents”Every setting has an environment variable equivalent, for container deployments where the configuration file is not mounted.
| YAML setting | Environment variable |
|---|---|
enabled | KAFKA_STREAM_SERVER_ENABLED |
addr | KAFKA_STREAM_SERVER_ADDR |
tls.certFilepath | KAFKA_STREAM_SERVER_TLS_CERT_FILEPATH |
tls.keyFilepath | KAFKA_STREAM_SERVER_TLS_KEY_FILEPATH |
serde.caFilepath | KAFKA_STREAM_SERVER_SERDE_CA_FILEPATH |
serde.certFilepath | KAFKA_STREAM_SERVER_SERDE_CERT_FILEPATH |
serde.keyFilepath | KAFKA_STREAM_SERVER_SERDE_KEY_FILEPATH |
serde.username | KAFKA_STREAM_SERVER_SERDE_USERNAME |
serde.password | KAFKA_STREAM_SERVER_SERDE_PASSWORD |
serde.insecureSkipTlsVerify | KAFKA_STREAM_SERVER_SERDE_SKIP_VERIFY |
Reachability from the browser
Section titled “Reachability from the browser”Message payloads travel from the agent to the browser and are not routed through axon-server. The browser opens the WebSocket connection to addr directly, so:
- The address must resolve and be reachable from the workstations of the users who will use the viewer, not only from within the Kafka network. Where the agents sit behind a load balancer or an ingress, the address configured in the dashboard is the address of that load balancer, and it must forward the
/wspath to the agents. - Firewall rules must permit inbound connections to the chosen port on the agent hosts from those workstations.
- For
wss://, the certificate intls.certFilepathmust be one those browsers trust, and must match the hostname used in the endpoint. A browser that rejects the certificate closes the connection, and the viewer reports a failed connection rather than a certificate error.
An agent whose stream server starts successfully but is unreachable from the browser produces a viewer that connects to nothing.
The listener is reachable from user workstations, and falls back to plain text
Enabling the stream server opens an inbound connection path from user workstations to the agent host, which on a broker node is a host that otherwise accepts only Kafka traffic. Restrict it to the source networks that need it, or place a load balancer or VPN between the users and the agent. Where the exposure is not wanted, disable the stream server.
TLS is not enforced. Where either tls.certFilepath or tls.keyFilepath is missing or unreadable, the agent does not fail to start: it serves plain ws://, and Kafka message payloads then cross that network unencrypted. Confirm the endpoint is wss:// rather than assuming TLS from having set a certificate path.
Disable the stream server
Section titled “Disable the stream server”Set kafka_stream_server.enabled to false, or remove the block, and restart axon-agent. Close the inbound firewall rule that was opened for the port, and clear the AxonOps Streaming Endpoint field in the dashboard so the viewer does not offer a connection that cannot be made.
To confirm it took effect, check that the node no longer lists a stream server service and that the reachability probe above now fails. Editing the configuration and restarting the agent is repeatable, so a sequence interrupted part way can be run again from the start.
Configure the streaming endpoint in AxonOps
Section titled “Configure the streaming endpoint in AxonOps”Open the Kafka cluster, select Settings, then Kafka, and use the Streaming section. Saving any of these settings requires the Admin role.
| Setting | Value |
|---|---|
| AxonOps Streaming Endpoint | The host and port of the agent's stream server, entered as address:port. |
| Secure with TLS | Selects the URL scheme. On produces wss://, off produces ws://. |
| Schema Registry Endpoint | The Schema Registry URL. The value must start with http:// or https://. |
| Rotate Streaming Keys | Rotates the key pair used to sign stream tokens. |
AxonOps stores the streaming endpoint as a full URL, assembled from the switch and the field: wss://<address:port>/ws where Secure with TLS is on, and ws://<address:port>/ws where it is off. The path is added automatically and must not be typed into the field.
The Secure with TLS switch and the endpoint field are stored together by the save button beside the endpoint field. Changing the switch alone has no effect until that button is used.
The TLS choice must match how the agent is configured. An agent serving TLS with the switch off, or an agent serving plain WebSocket with the switch on, fails to connect.
The Schema Registry Endpoint has its own save button. AxonOps passes this URL to the agent with the stream request, and the agent uses it to resolve schemas for encoded messages.
Configure Schema Registry access on the agent
Section titled “Configure Schema Registry access on the agent”The serde settings under kafka_stream_server supply the credentials and TLS material the agent uses when it calls Schema Registry to decode messages. The agent calls the Confluent Schema Registry REST API, so the registry must implement that API; Karapace and Apicurio Registry do, in their compatibility modes. Avro is supported by every version of Confluent Schema Registry; Protobuf and JSON Schema require Confluent Platform 5.5 or later, where support for them was added. They are needed only for topics whose values are encoded with Avro, Protobuf, or JSON Schema and are read with Schema encoded selected in the viewer. Plain text payloads require none of them.
kafka: kafka_stream_server: enabled: true addr: "0.0.0.0:8443" serde: caFilepath: "/etc/axonops/schema-registry-ca.crt" certFilepath: "/etc/axonops/schema-registry-client.crt" keyFilepath: "/etc/axonops/schema-registry-client.key" username: "registry_user" password: "registry_password" insecureSkipTlsVerify: falseserde.username and serde.password are used for HTTP basic authentication against Schema Registry. serde.certFilepath and serde.keyFilepath are used together as a client certificate; setting only one of them leaves the client without a certificate. Where serde.caFilepath is set but the file cannot be read or does not contain a usable certificate, the agent logs an error and continues with the system trust store, which may then reject the Schema Registry connection at request time.
Stream token signing keys
Section titled “Stream token signing keys”Operators do not configure a shared secret for stream authorization. axon-server generates an RSA key pair for the cluster and distributes the public key to the agents. Each stream token carries a key identifier, and the agent validates the token signature against the matching public key. A token signed by a key the agent does not hold is rejected, and no Kafka read takes place.
Rotate Streaming Keys in the Streaming settings generates a new key pair.
Key rotation invalidates every existing stream token
Rotating the streaming keys immediately invalidates all stream tokens issued under the previous key pair. Users with an open stream lose it and must reconnect and re-authorize before streaming can continue. Rotate keys during a maintenance window, or when a token is believed to be compromised.
Verify the setup
Section titled “Verify the setup”- Restart axon-agent on each node where the stream server was enabled. See axon-agent installation for the restart commands.
- Confirm the port answers from a workstation on the same network as the viewer's users, before involving the dashboard:
openssl s_client -connect <address:port> </dev/nullfor a TLS listener, which prints the certificate chain and ends withVerify return code: 0 (ok)where the certificate is trusted, ornc -vz <address> <port>for a plain one. A probe that fails here is a network or certificate problem, not an AxonOps one. - Confirm the node reports a
stream serverservice. AxonOps lists it alongside the node's other Kafka services, such askafkaandschema registry. The agent tests that the listener is reachable and reports the result; a listener that fails this test raises amessage-stream Connection Erroralert against the node, which appears in Logs & Events. - Open Topics, select Stream, and click Connect. The status changes to connected.
- Grant the test user stream access for a topic, under Topics → Stream Access, as described in Use the Kafka Message Stream Viewer. No user streams anything without a grant, including a user holding the Admin role.
- Select that topic and click Start Stream. Messages appear in the table.
See Use the Kafka Message Stream Viewer for the full streaming workflow, including stream access grants.
Failure semantics
Section titled “Failure semantics”| Symptom | Cause to check |
|---|---|
The node reports no stream server service | enabled is not set to true, addr is unset or already bound, or the agent was not restarted after the change. |
| Connect fails with no agent reached | addr is not reachable from the browser, or the dashboard endpoint names an address that does not route to an agent. |
| Connect fails despite a reachable agent | The TLS choice differs between the agent and the Secure with TLS switch, or the browser does not trust the certificate the agent presents. |
| The stream is refused after connecting | The user holds no stream access grant covering the requested topic, or the token was invalidated by a key rotation. |
| The stream starts but messages are unreadable | Schema encoded was not selected for an encoded topic, or the Schema Registry endpoint or the agent serde credentials are wrong. |
| An open stream stops returning messages | The stream token expired, or the streaming keys were rotated. The session must be re-authorized. |
| No stream can be started at all, while the dashboard is otherwise unresponsive | axon-server is unreachable. Stream tokens are issued there, so a new session cannot be authorized until it returns. |
| The stream is authorized but returns nothing for a topic | The agent's kafka_client cannot reach the brokers holding that topic's partitions. |
Where the agent is stopped or loses its connection to Kafka mid-stream, the browser session ends. Messages already displayed remain in the table until it is cleared or the page is reloaded. Restarting the stream reads from the position selected in Partition Mode, so a stream restarted with Latest does not return records produced while it was down, whereas Earliest, a partition offset, or a timestamp returns them subject to what the topic still holds.
What a topic still holds is governed by its cleanup.policy. A topic using delete, the default, removes records once they age out of retention.ms or retention.bytes. A topic using compact instead removes an older record for a key once a newer record for that key exists, and does not expire records by age or size unless compact,delete is set. A record removed by either mechanism cannot be streamed, whichever start position is chosen.
A timestamp start position resolves to the earliest offset whose record timestamp is at or after the value given. How exact that is depends on the topic's message.timestamp.type. LogAppendTime timestamps are set by the broker's clock as the record is appended and increase monotonically under one leader, though a leader change can move them backwards where the new leader's clock lags. CreateTime timestamps are set by the producer and need not increase at all, so on a CreateTime topic the first record returned may not be the first record produced after that moment.
Related pages
Section titled “Related pages”- Kafka Message Stream Viewer describes what the feature does and when to use it.
- Kafka Message Stream Viewer Architecture covers the security model, token issuance, and the data boundary between the control plane and the message path.
- Use the Kafka Message Stream Viewer covers granting stream access and running a stream.
- axon-agent installation covers installing and configuring the agent on Kafka nodes.