In this article, we will take a quick look at nats-top and see how we can use it for monitoring
What is nats-top?
nats-top is a top-like tool that provides a dynamic real-time view of a NATS server. This is a great tool for not only sys admins but developers to quickly glance at their NATS server statistics.
Installation
We can install nats-top
using go
$ go install github.com/nats-io/nats-top@latest
Or using the release binaries from here
Usage
Start the NATS server with the monitoring port enabled
$ nats-server -m 8222
If you’re using the config, then use the http_port
option
http_port: 8222
Let’s see how can we use nats-top
$ nats-top --help
usage: nats-top [-s server] [-m http_port] [-ms https_port] [-n num_connections] [-d delay_secs] [-r max] [-o FILE] [-l DELIMITER] [-sort by]
[-cert FILE] [-key FILE ][-cacert FILE] [-k] [-b]
We can configure our monitoring port, key, cert, and much more! For now, let’s start nats-top
with default options.
Here we can see some general data such as CPU and memory usage, and input/output bandwidth.
Notice the incredible msgs/sec
metric? NATS is quite performant!
Now let’s use the NATS CLI and do a simple benchmark to generate some publish/subscribe events.
$ nats bench test --msgs 10000000 --pub 5 --sub 5
Now if we look at the nats-top
we can see all the real-time info about our messages such as size, host, version, and even the programming language used by the client! Amazing right?
Conclusion
So in this short article, we looked at how we can use nats-top
for real-time monitoring. For advanced usage, make sure to explore the docs. In the next article, we will look at how you can do extensive historical monitoring of NATS clusters with the NATS Surveyor.
Top comments (0)