Monitoring

Monitoring NATS

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 about the following:

All endpoints return a JSON object.

The NATS monitoring endpoints support JSONP and CORS, making it easy to create single page monitoring web applications. Part of the NATS ecosystem is a tool called nats-top that visualizes data from these endpoints on the command line.

{% hint style=”warning” %} nats-server does not have authentication/authorization for the monitoring endpoint. When you plan to open your nats-server to the internet make sure to not expose the monitoring port as well. By default, monitoring binds to every interface 0.0.0.0 so consider setting monitoring to localhost or have appropriate firewall rules. {% endhint %}

Enabling monitoring

Monitoring can be enabled in server configuration or as a server command-line option. The conventional port is 8222.

As server configuration:

  1. http_port: 8222

As a command-line option:

  1. nats-server -m 8222

Once the server is running using one of the two methods, go to http://localhost:8222 to browse the available endpoints detailed below.

Monitoring Endpoints

General Information

The /varz endpoint returns general information about the server state and configuration.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

N/A

Example

https://demo.nats.io:8222/varz

Response

  1. {
  2. "server_id": "NACDVKFBUW4C4XA24OOT6L4MDP56MW76J5RJDFXG7HLABSB46DCMWCOW",
  3. "version": "2.0.0",
  4. "proto": 1,
  5. "go": "go1.12",
  6. "host": "0.0.0.0",
  7. "port": 4222,
  8. "max_connections": 65536,
  9. "ping_interval": 120000000000,
  10. "ping_max": 2,
  11. "http_host": "0.0.0.0",
  12. "http_port": 8222,
  13. "https_port": 0,
  14. "auth_timeout": 1,
  15. "max_control_line": 4096,
  16. "max_payload": 1048576,
  17. "max_pending": 67108864,
  18. "cluster": {},
  19. "gateway": {},
  20. "leaf": {},
  21. "tls_timeout": 0.5,
  22. "write_deadline": 2000000000,
  23. "start": "2019-06-24T14:24:43.928582-07:00",
  24. "now": "2019-06-24T14:24:46.894852-07:00",
  25. "uptime": "2s",
  26. "mem": 9617408,
  27. "cores": 4,
  28. "gomaxprocs": 4,
  29. "cpu": 0,
  30. "connections": 0,
  31. "total_connections": 0,
  32. "routes": 0,
  33. "remotes": 0,
  34. "leafnodes": 0,
  35. "in_msgs": 0,
  36. "out_msgs": 0,
  37. "in_bytes": 0,
  38. "out_bytes": 0,
  39. "slow_consumers": 2,
  40. "subscriptions": 0,
  41. "http_req_stats": {
  42. "/": 0,
  43. "/connz": 0,
  44. "/gatewayz": 0,
  45. "/routez": 0,
  46. "/subsz": 0,
  47. "/varz": 1
  48. },
  49. "config_load_time": "2019-06-24T14:24:43.928582-07:00",
  50. "slow_consumer_stats": {
  51. "clients": 1,
  52. "routes": 1,
  53. "gateways": 0,
  54. "leafs": 0
  55. }
  56. }

Connection Information

The /connz endpoint reports more detailed information on current and recently closed connections. It uses a paging mechanism which defaults to 1024 connections.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
sort (see sort options) Sorts the results. Default is connection ID.
auth true, 1, false, 0 Include username. Default is false.
subs true, 1, false, 0 or detail Include subscriptions. Default is false. When set to detail a list with more detailed subscription information will be returned.
offset number > 0 Pagination offset. Default is 0.
limit number > 0 Number of results to return. Default is 1024.
cid number, valid id Return a connection by its id
state open, *closed, any Return connections of particular state. Default is open.
mqtt_client string Filter the connection with this MQTT client ID.

The server will default to holding the last 10,000 closed connections.

Sort Options

Option Sort by
cid Connection ID
start Connection start time, same as CID
subs Number of subscriptions
pending Amount of data in bytes waiting to be sent to client
msgs_to Number of messages sent
msgs_from Number of messages received
bytes_to Number of bytes sent
bytes_from Number of bytes received
last Last activity
idle Amount of inactivity
uptime Lifetime of the connection
stop Stop time for a closed connection
reason Reason for a closed connection
rtt Round trip time

Examples

Get up to 1024 connections: https://demo.nats.io:8222/connz

Control limit and offset: https://demo.nats.io:8222/connz?limit=16\&offset=128.

Get closed connection information: https://demo.nats.io:8222/connz?state=closed.

You can also report detailed subscription information on a per connection basis using subs=1. For example: https://demo.nats.io:8222/connz?limit=1\&offset=1\&subs=1.

Response

  1. {
  2. "server_id": "NACDVKFBUW4C4XA24OOT6L4MDP56MW76J5RJDFXG7HLABSB46DCMWCOW",
  3. "now": "2019-06-24T14:28:16.520365-07:00",
  4. "num_connections": 2,
  5. "total": 2,
  6. "offset": 0,
  7. "limit": 1024,
  8. "connections": [
  9. {
  10. "cid": 5,
  11. "kind": "Client",
  12. "type": "nats",
  13. "ip": "127.0.0.1",
  14. "port": 62714,
  15. "start": "2021-09-09T23:16:43.040862Z",
  16. "last_activity": "2021-09-09T23:16:43.042364Z",
  17. "rtt": "95µs",
  18. "uptime": "5s",
  19. "idle": "5s",
  20. "pending_bytes": 0,
  21. "in_msgs": 0,
  22. "out_msgs": 0,
  23. "in_bytes": 0,
  24. "out_bytes": 0,
  25. "subscriptions": 1,
  26. "name": "NATS Benchmark",
  27. "lang": "go",
  28. "version": "1.12.1"
  29. },
  30. {
  31. "cid": 6,
  32. "kind": "Client",
  33. "type": "nats",
  34. "ip": "127.0.0.1",
  35. "port": 62715,
  36. "start": "2021-09-09T23:16:43.042557Z",
  37. "last_activity": "2021-09-09T23:16:43.042811Z",
  38. "rtt": "100µs",
  39. "uptime": "5s",
  40. "idle": "5s",
  41. "pending_bytes": 0,
  42. "in_msgs": 0,
  43. "out_msgs": 0,
  44. "in_bytes": 0,
  45. "out_bytes": 0,
  46. "subscriptions": 1,
  47. "name": "NATS Benchmark",
  48. "lang": "go",
  49. "version": "1.12.1"
  50. },
  51. {
  52. "cid": 7,
  53. "kind": "Client",
  54. "type": "mqtt",
  55. "ip": "::1",
  56. "port": 62718,
  57. "start": "2021-09-09T23:16:45.391459Z",
  58. "last_activity": "2021-09-09T23:16:45.395869Z",
  59. "rtt": "0s",
  60. "uptime": "2s",
  61. "idle": "2s",
  62. "pending_bytes": 0,
  63. "in_msgs": 0,
  64. "out_msgs": 0,
  65. "in_bytes": 0,
  66. "out_bytes": 0,
  67. "subscriptions": 2,
  68. "mqtt_client": "mqtt_sub"
  69. }
  70. ]
  71. }

Route Information

The /routez endpoint reports information on active routes for a cluster. Routes are expected to be low, so there is no paging mechanism with this endpoint.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
subs true, 1, false, 0 or detail Include subscriptions. Default is false. When set to detail a list with more detailed subscription information will be returned.

As noted above, the routez endpoint does support the subs argument from the /connz endpoint. For example: https://demo.nats.io:8222/routez?subs=1

Example

Response

  1. {
  2. "server_id": "NACDVKFBUW4C4XA24OOT6L4MDP56MW76J5RJDFXG7HLABSB46DCMWCOW",
  3. "now": "2019-06-24T14:29:16.046656-07:00",
  4. "num_routes": 1,
  5. "routes": [
  6. {
  7. "rid": 1,
  8. "remote_id": "de475c0041418afc799bccf0fdd61b47",
  9. "did_solicit": true,
  10. "ip": "127.0.0.1",
  11. "port": 61791,
  12. "pending_size": 0,
  13. "in_msgs": 0,
  14. "out_msgs": 0,
  15. "in_bytes": 0,
  16. "out_bytes": 0,
  17. "subscriptions": 0
  18. }
  19. ]
  20. }

Gateway Information

The /gatewayz endpoint reports information about gateways used to create a NATS supercluster. Like routes, the number of gateways are expected to be low, so there is no paging mechanism with this endpoint.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
accs true, 1, false, 0 Include account information. Default is false.
gw_name string Return only remote gateways with this name.
acc_name string Limit the list of accounts to this account name.

Examples

Response

  1. {
  2. "server_id": "NANVBOU62MDUWTXWRQ5KH3PSMYNCHCEUHQV3TW3YH7WZLS7FMJE6END6",
  3. "now": "2019-07-24T18:02:55.597398-06:00",
  4. "name": "region1",
  5. "host": "2601:283:4601:1350:1895:efda:2010:95a1",
  6. "port": 4501,
  7. "outbound_gateways": {
  8. "region2": {
  9. "configured": true,
  10. "connection": {
  11. "cid": 7,
  12. "ip": "127.0.0.1",
  13. "port": 5500,
  14. "start": "2019-07-24T18:02:48.765621-06:00",
  15. "last_activity": "2019-07-24T18:02:48.765621-06:00",
  16. "uptime": "6s",
  17. "idle": "6s",
  18. "pending_bytes": 0,
  19. "in_msgs": 0,
  20. "out_msgs": 0,
  21. "in_bytes": 0,
  22. "out_bytes": 0,
  23. "subscriptions": 0,
  24. "name": "NCXBIYWT7MV7OAQTCR4QTKBN3X3HDFGSFWTURTCQ22ZZB6NKKJPO7MN4"
  25. }
  26. },
  27. "region3": {
  28. "configured": true,
  29. "connection": {
  30. "cid": 5,
  31. "ip": "::1",
  32. "port": 6500,
  33. "start": "2019-07-24T18:02:48.764685-06:00",
  34. "last_activity": "2019-07-24T18:02:48.764685-06:00",
  35. "uptime": "6s",
  36. "idle": "6s",
  37. "pending_bytes": 0,
  38. "in_msgs": 0,
  39. "out_msgs": 0,
  40. "in_bytes": 0,
  41. "out_bytes": 0,
  42. "subscriptions": 0,
  43. "name": "NCVS7Q65WX3FGIL2YQRLI77CE6MQRWO2Y453HYVLNMBMTVLOKMPW7R6K"
  44. }
  45. }
  46. },
  47. "inbound_gateways": {
  48. "region2": [
  49. {
  50. "configured": false,
  51. "connection": {
  52. "cid": 9,
  53. "ip": "::1",
  54. "port": 52029,
  55. "start": "2019-07-24T18:02:48.76677-06:00",
  56. "last_activity": "2019-07-24T18:02:48.767096-06:00",
  57. "uptime": "6s",
  58. "idle": "6s",
  59. "pending_bytes": 0,
  60. "in_msgs": 0,
  61. "out_msgs": 0,
  62. "in_bytes": 0,
  63. "out_bytes": 0,
  64. "subscriptions": 0,
  65. "name": "NCXBIYWT7MV7OAQTCR4QTKBN3X3HDFGSFWTURTCQ22ZZB6NKKJPO7MN4"
  66. }
  67. }
  68. ],
  69. "region3": [
  70. {
  71. "configured": false,
  72. "connection": {
  73. "cid": 4,
  74. "ip": "::1",
  75. "port": 52025,
  76. "start": "2019-07-24T18:02:48.764577-06:00",
  77. "last_activity": "2019-07-24T18:02:48.764994-06:00",
  78. "uptime": "6s",
  79. "idle": "6s",
  80. "pending_bytes": 0,
  81. "in_msgs": 0,
  82. "out_msgs": 0,
  83. "in_bytes": 0,
  84. "out_bytes": 0,
  85. "subscriptions": 0,
  86. "name": "NCVS7Q65WX3FGIL2YQRLI77CE6MQRWO2Y453HYVLNMBMTVLOKMPW7R6K"
  87. }
  88. },
  89. {
  90. "configured": false,
  91. "connection": {
  92. "cid": 8,
  93. "ip": "127.0.0.1",
  94. "port": 52026,
  95. "start": "2019-07-24T18:02:48.766173-06:00",
  96. "last_activity": "2019-07-24T18:02:48.766999-06:00",
  97. "uptime": "6s",
  98. "idle": "6s",
  99. "pending_bytes": 0,
  100. "in_msgs": 0,
  101. "out_msgs": 0,
  102. "in_bytes": 0,
  103. "out_bytes": 0,
  104. "subscriptions": 0,
  105. "name": "NCKCYK5LE3VVGOJQ66F65KA27UFPCLBPX4N4YOPOXO3KHGMW24USPCKN"
  106. }
  107. }
  108. ]
  109. }
  110. }

Leaf Node Information

The /leafz endpoint reports detailed information about the leaf node connections.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
subs true, 1, false, 0 Include internal subscriptions. Default is false.

As noted above, the leafz endpoint does support the subs argument from the /connz endpoint. For example: https://demo.nats.io:8222/leafz?subs=1

Example

Response

  1. {
  2. "server_id": "NC2FJCRMPBE5RI5OSRN7TKUCWQONCKNXHKJXCJIDVSAZ6727M7MQFVT3",
  3. "now": "2019-08-27T09:07:05.841132-06:00",
  4. "leafnodes": 1,
  5. "leafs": [
  6. {
  7. "account": "$G",
  8. "ip": "127.0.0.1",
  9. "port": 6223,
  10. "rtt": "200µs",
  11. "in_msgs": 0,
  12. "out_msgs": 10000,
  13. "in_bytes": 0,
  14. "out_bytes": 1280000,
  15. "subscriptions": 1,
  16. "subscriptions_list": ["foo"]
  17. }
  18. ]
  19. }

Subscription Routing Information

The /subsz endpoint reports detailed information about the current subscriptions and the routing data structure. It is not normally used.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
subs true, 1, false, 0 Include subscriptions. Default is false.
offset integer > 0 Pagination offset. Default is 0.
limit integer > 0 Number of results to return. Default is 1024.
test subject Test whether a subsciption exists.

Example

Response

  1. {
  2. "num_subscriptions": 2,
  3. "num_cache": 0,
  4. "num_inserts": 2,
  5. "num_removes": 0,
  6. "num_matches": 0,
  7. "cache_hit_rate": 0,
  8. "max_fanout": 0,
  9. "avg_fanout": 0
  10. }

Account Information

The /accountz endpoint reports information on a server’s active accounts. The default behavior is to return a list of all accounts known to the server.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)
Argument Value Description
acc account name Include metrics for the specified account. Default is empty. When not set, a list of all accounts is included.

Example

Response

Default behavior:

  1. {
  2. "server_id": "NAB2EEQ3DLS2BHU4K2YMXMPIOOOAOFOAQAC5NQRIEUI4BHZKFBI4ZU4A",
  3. "now": "2021-02-08T17:31:29.551146-05:00",
  4. "system_account": "AAAXAUVSGK7TCRHFIRAS4SYXVJ76EWDMNXZM6ARFGXP7BASNDGLKU7A5",
  5. "accounts": ["AAAXAUVSGK7TCRHFIRAS4SYXVJ76EWDMNXZM6ARFGXP7BASNDGLKU7A5", "$G"]
  6. }

Retrieve specific account:

  1. {
  2. "server_id": "NAB2EEQ3DLS2BHU4K2YMXMPIOOOAOFOAQAC5NQRIEUI4BHZKFBI4ZU4A",
  3. "now": "2021-02-08T17:37:55.80856-05:00",
  4. "system_account": "AAAXAUVSGK7TCRHFIRAS4SYXVJ76EWDMNXZM6ARFGXP7BASNDGLKU7A5",
  5. "account_detail": {
  6. "account_name": "AAAXAUVSGK7TCRHFIRAS4SYXVJ76EWDMNXZM6ARFGXP7BASNDGLKU7A5",
  7. "update_time": "2021-02-08T17:31:22.390334-05:00",
  8. "is_system": true,
  9. "expired": false,
  10. "complete": true,
  11. "jetstream_enabled": false,
  12. "leafnode_connections": 0,
  13. "client_connections": 0,
  14. "subscriptions": 42,
  15. "exports": [
  16. {
  17. "subject": "$SYS.DEBUG.SUBSCRIBERS",
  18. "type": "service",
  19. "response_type": "Singleton"
  20. }
  21. ],
  22. "jwt": "eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJqdGkiOiJVVlU2VEpXRU8zS0hYWTZVMkgzM0RCVklET1A3U05DTkJPMlM0M1dPNUM2T1RTTDNVSUxBIiwiaWF0IjoxNjAzNDczNzg4LCJpc3MiOiJPQlU1TzVGSjMyNFVEUFJCSVZSR0Y3Q05FT0hHTFBTN0VZUEJUVlFaS1NCSElJWklCNkhENjZKRiIsIm5hbWUiOiJTWVMiLCJzdWIiOiJBQUFYQVVWU0dLN1RDUkhGSVJBUzRTWVhWSjc2RVdETU5YWk02QVJGR1hQN0JBU05ER0xLVTdBNSIsInR5cGUiOiJhY2NvdW50IiwibmF0cyI6eyJsaW1pdHMiOnsic3VicyI6LTEsImNvbm4iOi0xLCJsZWFmIjotMSwiaW1wb3J0cyI6LTEsImV4cG9ydHMiOi0xLCJkYXRhIjotMSwicGF5bG9hZCI6LTEsIndpbGRjYXJkcyI6dHJ1ZX19fQ.CeGo16i5oD0b1uBJ8UdGmLH-l9dL8yNqXHggkAt2T5c88fM7k4G08wLguMAnlvzrdlYvdZvOx_5tHLuDZmGgCg",
  23. "issuer_key": "OBU5O5FJ324UDPRBIVRGF7CNEOHGLPS7EYPBTVQZKSBHIIZIB6HD66JF",
  24. "name_tag": "SYS",
  25. "decoded_jwt": {
  26. "jti": "UVU6TJWEO3KHXY6U2H33DBVIDOP7SNCNBO2S43WO5C6OTSL3UILA",
  27. "iat": 1603473788,
  28. "iss": "OBU5O5FJ324UDPRBIVRGF7CNEOHGLPS7EYPBTVQZKSBHIIZIB6HD66JF",
  29. "name": "SYS",
  30. "sub": "AAAXAUVSGK7TCRHFIRAS4SYXVJ76EWDMNXZM6ARFGXP7BASNDGLKU7A5",
  31. "nats": {
  32. "limits": {
  33. "subs": -1,
  34. "data": -1,
  35. "payload": -1,
  36. "imports": -1,
  37. "exports": -1,
  38. "wildcards": true,
  39. "conn": -1,
  40. "leaf": -1
  41. },
  42. "default_permissions": {
  43. "pub": {},
  44. "sub": {}
  45. },
  46. "type": "account",
  47. "version": 1
  48. }
  49. },
  50. "sublist_stats": {
  51. "num_subscriptions": 42,
  52. "num_cache": 6,
  53. "num_inserts": 42,
  54. "num_removes": 0,
  55. "num_matches": 6,
  56. "cache_hit_rate": 0,
  57. "max_fanout": 1,
  58. "avg_fanout": 0.8333333333333334
  59. }
  60. }
  61. }

Account Statistics

The /accstatz endpoint reports per-account statistics such as the number of connections, messages/bytes in/out, etc.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
unused true, 1, false, 0 If true, include accounts that do not have any current connections. Default is false.

Examples

Response

  1. {
  2. "server_id": "NDJ5M4F5WAIBUA26NJ3QMH532AQPN7QNTJP3Y4SBHSHL4Y7QUAKNJEAF",
  3. "now": "2022-10-19T17:16:20.881296749Z",
  4. "account_statz": [
  5. {
  6. "acc": "default",
  7. "conns": 31,
  8. "leafnodes": 2,
  9. "total_conns": 33,
  10. "num_subscriptions": 45,
  11. "sent": {
  12. "msgs": 1876970,
  13. "bytes": 246705616
  14. },
  15. "received": {
  16. "msgs": 1347454,
  17. "bytes": 219438308
  18. },
  19. "slow_consumers": 29
  20. },
  21. {
  22. "acc": "$G",
  23. "conns": 1,
  24. "leafnodes": 0,
  25. "total_conns": 1,
  26. "num_subscriptions": 3,
  27. "sent": {
  28. "msgs": 0,
  29. "bytes": 0
  30. },
  31. "received": {
  32. "msgs": 107,
  33. "bytes": 1094
  34. },
  35. "slow_consumers": 0
  36. }
  37. ]
  38. }

JetStream Information

The /jsz endpoint reports more detailed information on JetStream. For accounts, it uses a paging mechanism that defaults to 1024 connections.

Note: If you’re in a clustered environment, it is recommended to retrieve the information from the stream’s leader in order to get the most accurate and up-to-date data.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
acc account name Include metrics for the specified account. Default is unset.
accounts true, 1, false, 0 Include account specific JetStream information. Default is false.
streams true, 1, false, 0 Include streams. When set, implies accounts=true. Default is false.
consumers true, 1, false, 0 Include consumer. When set, implies streams=true. Default is false.
config true, 1, false, 0 When stream or consumer are requested, include their respective configuration. Default is false.
leader-only true, 1, false, 0 Only the leader responds. Default is false.
offset number > 0 Pagination offset. Default is 0.
limit number > 0 Number of results to return. Default is 1024.
raft true, 1, false, 0 Include information details about the Raft group. Default is false.

Examples

Get basic JetStream information: https://demo.nats.io:8222/jsz

Request accounts and control limit and offset: https://demo.nats.io:8222/jsz?accounts=true\&limit=16\&offset=128.

You can also report detailed consumer information on a per connection basis using consumer=true. For example: https://demo.nats.io:8222/jsz?consumers=true.

Response

  1. {
  2. "server_id": "NCVIDODSZ45C5OD67ZD7EJUIJPQDP6CM74SJX6TJIF2G7NLYS5LCVYHS",
  3. "now": "2021-02-08T19:08:30.555533-05:00",
  4. "config": {
  5. "max_memory": 10485760,
  6. "max_storage": 10485760,
  7. "store_dir": "/var/folders/9h/6g_c9l6n6bb8gp331d_9y0_w0000gn/T/srv_7500251552558",
  8. "unique_tag": "az"
  9. },
  10. "memory": 0,
  11. "storage": 66,
  12. "api": {
  13. "total": 5,
  14. "errors": 0
  15. },
  16. "total_streams": 1,
  17. "total_consumers": 1,
  18. "total_messages": 1,
  19. "total_message_bytes": 33,
  20. "meta_cluster": {
  21. "name": "cluster_name",
  22. "replicas": [
  23. {
  24. "name": "server_5500",
  25. "current": false,
  26. "active": 2932926000
  27. }
  28. ]
  29. },
  30. "account_details": [
  31. {
  32. "name": "BCC_TO_HAVE_ONE_EXTRA",
  33. "id": "BCC_TO_HAVE_ONE_EXTRA",
  34. "memory": 0,
  35. "storage": 0,
  36. "api": {
  37. "total": 0,
  38. "errors": 0
  39. }
  40. },
  41. {
  42. "name": "ACC",
  43. "id": "ACC",
  44. "memory": 0,
  45. "storage": 66,
  46. "api": {
  47. "total": 5,
  48. "errors": 0
  49. },
  50. "stream_detail": [
  51. {
  52. "name": "my-stream-replicated",
  53. "cluster": {
  54. "name": "cluster_name",
  55. "replicas": [
  56. {
  57. "name": "server_5500",
  58. "current": false,
  59. "active": 2931517000
  60. }
  61. ]
  62. },
  63. "state": {
  64. "messages": 1,
  65. "bytes": 33,
  66. "first_seq": 1,
  67. "first_ts": "2021-02-09T00:08:27.623735Z",
  68. "last_seq": 1,
  69. "last_ts": "2021-02-09T00:08:27.623735Z",
  70. "consumer_count": 1
  71. },
  72. "consumer_detail": [
  73. {
  74. "stream_name": "my-stream-replicated",
  75. "name": "my-consumer-replicated",
  76. "created": "2021-02-09T00:08:27.427631Z",
  77. "delivered": {
  78. "consumer_seq": 0,
  79. "stream_seq": 0
  80. },
  81. "ack_floor": {
  82. "consumer_seq": 0,
  83. "stream_seq": 0
  84. },
  85. "num_ack_pending": 0,
  86. "num_redelivered": 0,
  87. "num_waiting": 0,
  88. "num_pending": 1,
  89. "cluster": {
  90. "name": "cluster_name",
  91. "replicas": [
  92. {
  93. "name": "server_5500",
  94. "current": false,
  95. "active": 2933232000
  96. }
  97. ]
  98. }
  99. }
  100. ]
  101. }
  102. ]
  103. }
  104. ]
  105. }

Health

The /healthz endpoint returns OK if the server is able to accept connections.

Result Return Code
Success 200 (OK)
Error 400 (Bad Request)

Arguments

Argument Values Description
js-enabled-only true, 1 Returns an error if JetStream is disabled.
js-server-only true, 1 Skip health check of accounts, streams, and consumers.
js-enabled true, 1 Returns an error if JetStream is disabled. (Deprecated: use js-enabled-only instead).

Example

Response

  1. { "status": "ok" }

Creating Monitoring Applications

NATS monitoring endpoints support JSONP and CORS. You can easily create single page web applications for monitoring. To do this you simply pass the callback query parameter to any endpoint.

For example:

  1. https://demo.nats.io:8222/connz?callback=cb

Here is a JQuery example implementation:

  1. $.getJSON("https://demo.nats.io:8222/connz?callback=?", function (data) {
  2. console.log(data);
  3. });

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, and there are Grafana dashboards available for you to visualize the server metrics.

See the Walkthrough of Monitoring NATS with Prometheus and Grafana for more details.