Monitoring

    To enable the monitoring server, start the NATS Streaming Server with the monitoring flag -m (or -ms) and specify the monitoring port.

    Monitoring options

    To enable monitoring via the configuration file, use or https: "host:port". There is no explicit configuration flag for the monitoring interface.

    For example, after running this:

    1. nats-streaming-server -m 8222
    1. [19339] 2019/06/24 15:02:38.251091 [INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.15.1
    2. [19339] 2019/06/24 15:02:38.251238 [INF] STREAM: ServerID: 0Z2HXClEM6BPsGaKcoHg5N
    3. [19339] 2019/06/24 15:02:38.251862 [INF] Starting nats-server version 2.0.0
    4. [19339] 2019/06/24 15:02:38.251873 [INF] Git commit [not set]
    5. [19339] 2019/06/24 15:02:38.252173 [INF] Starting http monitor on 0.0.0.0:8222
    6. (...)

    You can then point your browser (or curl) to http://localhost:8222/streaming

    To start via the configuration file you can define the monitoring port as follows:

    Then use the -sc flag to customize the NATS Streaming configuration:

    1. nats-streaming-server -sc nats-streaming.conf -ns nats://demo.nats.io:4222 -SDV

    Confirm that the monitoring endpoint is enabled by sending a request:

    1. curl 127.0.0.1:8222/streaming/channelsz
    2. {
    3. "cluster_id": "test-cluster",
    4. "now": "2019-06-24T15:18:37.388938-07:00",
    5. "limit": 1024,
    6. "count": 0,
    7. "total": 0
    8. }

    In this case, 3 is the size of the quorum of NATS Streaming Server nodes. In case of a single instance backed by a relational database we would set it to 1:

    1. sum(rate(nss_chan_msgs_total{channel="foo"}[5m])) by (channel) / 3

    msgs-per-sec

    Example of combining the rate of messages with the pending count to detect whether processing is getting behind:

    1. sum(rate(nss_chan_msgs_total{channel="foo"}[5m])) by (channel) / 3