Enabling Monitoring
NATS Server Monitoring
To monitor the NATS messaging system, nats-server
provides a lightweight HTTP server on a dedicated monitoring port. The monitoring server provides several endpoints, providing statistics and other information.
The NATS monitoring endpoints support JSONP and CORS, making it easy to create single page monitoring web applications.
Warning:
nats-server
does not have authentication/authorization for the monitoring endpoint. When you plan to open yournats-server
to the internet make sure to not expose the monitoring port as well. By default monitoring binds to every interface0.0.0.0
so consider setting monitoring tolocalhost
or have appropriate firewall rules.
Enabling monitoring from the command line
To enable the monitoring server, start the NATS server with the monitoring flag -m
and the monitoring port, or turn it on in the configuration file.
Example:
To test, run nats-server -m 8222
, then go to http://localhost:8222/
Enable monitoring from the configuration file
You can also enable monitoring using the configuration file as follows:
Binding to localhost
as well:
For example, to monitor this server locally, the endpoint would be http://localhost:8222/varz. It reports various general statistics.
Monitoring Tools
In addition to writing custom monitoring tools, you can monitor nats-server in Prometheus. The Prometheus NATS Exporter allows you to configure the metrics you want to observe and store in Prometheus. There's a sample Grafana dashboard that you can use to visualize the server metrics.
Last updated