Skip to content
BleemeoBleemeo

NATS

Auto-Detection
Built-in Metrics

Bleemeo monitors the NATS messaging server through automatic service detection and built-in metrics gathered from the monitoring endpoint.

Glouton automatically detects NATS instances running on the host. To enable metrics collection, you must enable the NATS monitoring endpoint. See NATS Server Monitoring for details.

By default, Glouton assumes the monitoring endpoint runs on port 8222. If the auto-detected parameters are incorrect, you can override them manually.

Terminal window
sudo tee /etc/glouton/conf.d/99-nats.conf > /dev/null << 'EOF'
service:
# For a NATS running outside a container
- type: "nats"
address: "127.0.0.1"
port: 4222
stats_port: 8222
# For an additional NATS running outside a container
- type: "nats"
instance: "NAME_ASSOCIATED_WITH_YOUR_ADDITIONAL_SERVICE"
address: "127.0.0.1"
port: 4222
stats_port: 8222
# For a NATS running in a Docker container
- type: "nats"
instance: "CONTAINER_NAME"
port: 4222
stats_port: 8222
EOF
MetricDescription
service_statusStatus of NATS
nats_uptimeTime since the NATS server started in nanoseconds
nats_routesNumber of registered routes
nats_slow_consumersNumber of slow consumers
nats_subscriptionsNumber of active subscriptions
nats_in_bytesAmount of incoming bytes
nats_out_bytesAmount of outgoing bytes
nats_in_msgsNumber of incoming messages
nats_out_msgsNumber of outgoing messages
nats_connectionsNumber of currently active clients
nats_total_connectionsTotal number of created clients

See Troubleshoot a Service Check or Missing Metrics for what applies to every service: finding the address and port Glouton really uses, what each check message means, and how to read the collection error — which does not appear in the agent logs at the default level.

The check only opens the TCP port — it sends no command — so it fails when the port is wrong (Connection refused), when a firewall drops the packets (connection timed out after 10 seconds), or when the configured address cannot be parsed (Invalid TCP address). A green check proves the port is open, and nothing more.

A passing check says nothing about the metrics: they are collected separately.

Metrics come from the NATS monitoring endpoint, on a different port than the client port: stats_port if set, otherwise 8222.

Reproduce what Glouton does, from the machine where the agent runs:

Terminal window
curl -s http://127.0.0.1:8222/varz | head -5
What you see Cause Fix
a connection error on port 8222 The monitoring endpoint is not enabled Set http_port: 8222 in the NATS configuration and restart the server
a connection error The monitoring endpoint is on another port Set stats_port to match
a connection error The endpoint is bound to another address Bind it to an address the agent can reach
a TLS error Monitoring is served over HTTPS (https_port) Glouton fetches it over plain HTTP; expose http_port on 127.0.0.1