Skip to content

feat: add cluster name to leaf monitoring data#7981

Open
joeriddles wants to merge 1 commit intonats-io:mainfrom
joeriddles:monitoring-leaf-cluster
Open

feat: add cluster name to leaf monitoring data#7981
joeriddles wants to merge 1 commit intonats-io:mainfrom
joeriddles:monitoring-leaf-cluster

Conversation

@joeriddles
Copy link
Copy Markdown
Contributor

Add cluster name to leaf monitoring data.

This would be useful for downstream consumers of monitoring data and topology visualizations.

Signed-off-by: Joe Riddle joe@synadia.com


Tested locally with the following configs:

server_name: "hub"
listen: "127.0.0.1:4222"
http: "127.0.0.1:8222"

leafnodes {
  listen: "127.0.0.1:7422"
}
server_name: "leaf1"
listen: "127.0.0.1:4223"
http: "127.0.0.1:8223"

cluster {
  name: "leaf-cluster"
  listen: "127.0.0.1:6223"
}

leafnodes {
  remotes [{
    url: "nats-leaf://127.0.0.1:7422"
  }]
}
❯ curl -s http://127.0.0.1:8222/leafz | jq .leafs
[
  {
    "id": 5,
    "name": "leaf1",
+    "cluster": "leaf-cluster",
    "is_spoke": false,
    "account": "$G",
    "ip": "127.0.0.1",
    "port": 51218,
    "rtt": "154µs",
    "in_msgs": 0,
    "out_msgs": 0,
    "in_bytes": 0,
    "out_bytes": 0,
    "subscriptions": 5,
    "compression": "s2_uncompressed"
  }
]

Signed-off-by: Joe Riddle <joe@synadia.com>
@joeriddles joeriddles requested a review from a team as a code owner March 23, 2026 23:10
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8cf7b6d1fb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

lni := &LeafInfo{
ID: ln.cid,
Name: ln.leaf.remoteServer,
Cluster: ln.leaf.remoteCluster,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hide synthetic leaf cluster names from /leafz

When a remote leaf has leafnodes.remotes and a server_name but no cluster block, Server.New intentionally fabricates opts.Cluster.Name = opts.ServerName only for internal bookkeeping (server/server.go:820-825), and /varz already strips that back out (server/monitor.go:1708-1711). leafNodeResumeConnectProcess still sends this synthetic value in the leaf CONNECT (server/leafnode.go:3367-3375, server/leafnode.go:976-978), so exposing ln.leaf.remoteCluster here makes /leafz report standalone leaves as if they belonged to a real cluster named after the server. Any topology consumer using /leafz will misclassify non-clustered leaves whenever server_name is configured.

Useful? React with 👍 / 👎.

@joeriddles joeriddles closed this Mar 24, 2026
@joeriddles joeriddles reopened this Mar 24, 2026
@joeriddles
Copy link
Copy Markdown
Contributor Author

@wallyqs thanks for the review. I didn't mean to close this PR. Re-opened it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants