[PR #5775] [CLOSED] add peer groups to status JSON/YAML output #28517

Open
opened 2026-08-05 08:06:29 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5775
Author: @Paulpatou
Created: 4/2/2026
Status: Closed

Base: mainHead: feature/add-groups-to-status-json-output


📝 Commits (3)

  • 29b7276 add peer groups to status JSON/YAML output
  • 6c1d27f sort group names in GetPeerGroupNames for deterministic output
  • 27cae9c regenerate .pb.go files with correct upstream tool versions

📊 Changes

17 files changed (+543 additions, -310 deletions)

View changed files

📝 client/anonymize/anonymize.go (+18 -0)
📝 client/anonymize/anonymize_test.go (+27 -0)
📝 client/internal/engine.go (+8 -0)
📝 client/internal/peer/status.go (+18 -0)
📝 client/internal/peer/status_test.go (+24 -0)
📝 client/proto/daemon.pb.go (+11 -2)
📝 client/proto/daemon.proto (+1 -0)
📝 client/status/status.go (+18 -0)
📝 client/status/status_test.go (+15 -2)
📝 management/internals/controllers/network_map/controller/controller.go (+4 -0)
📝 management/internals/shared/grpc/conversion.go (+4 -3)
📝 management/internals/shared/grpc/server.go (+13 -0)
📝 management/server/types/account.go (+15 -0)
📝 management/server/types/account_test.go (+39 -0)
📝 management/server/types/network.go (+13 -0)
📝 shared/management/proto/management.pb.go (+313 -303)
📝 shared/management/proto/management.proto (+2 -0)

📄 Description

Describe your changes

This PR adds group membership information (group names) to each peer in the netbird status --json and netbird status --yaml output.

Problem

When using netbird status --json or netbird status --yaml to inventory peers programmatically, group membership was missing from the output. This made the CLI output impractical for automation use cases where peers need to be filtered or categorized by group.

The API already exposes this information, but not everyone can use the API in their tooling architecture - they rely on the CLI status output.

Solution

Added a groups field to each peer entry in the status JSON/YAML output, containing the list of group names the peer belongs to.

Before:

{
  "peers": {
    "details": [
      {
        "fqdn": "peer.example.netbird.cloud",
        "netbirdIp": "100.64.0.1",
        "status": "Connected"
      }
    ]
  }
}

After:

{
  "peers": {
    "details": [
      {
        "fqdn": "peer.example.netbird.cloud",
        "netbirdIp": "100.64.0.1",
        "status": "Connected",
        "groups": ["All", "Production"]
      }
    ]
  }
}

Changes

The feature is implemented across the full data pipeline:

Management server → client sync

  • shared/management/proto/management.proto — add repeated string groupsNames = 6 to RemotePeerConfig
  • management/server/types/network.go — add PeerGroupsNames map[string][]string to NetworkMap
  • management/server/types/account.go — add GetPeerGroupNames(peerID string) []string helper
  • management/internals/shared/grpc/conversion.go — populate GroupsNames in appendRemotePeerConfig
  • management/internals/controllers/network_map/controller/controller.go — fill PeerGroupsNames before ToSyncResponse
  • management/internals/shared/grpc/server.go — fill PeerGroupsNames via GetAccountGroups in sendInitialSync

Client daemon → CLI

  • client/proto/daemon.proto — add repeated string groups = 20 to PeerState
  • client/internal/peer/status.go — add Groups []string to State, add UpdatePeerGroups() method, include groups in ToProto()
  • client/internal/engine.go — call UpdatePeerGroups in addNewPeer and modifyPeers

CLI output

  • client/status/status.go — add Groups []string \json:"groups" yaml:"groups"`toPeerStateDetailOutput, populate in mapPeers()`

https://github.com/netbirdio/netbird/issues/5714

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

Documentation

  • I added/updated documentation for this change
  • Documentation is not needed for this change

This is a feature addition that exposes existing group membership data in the CLI status output. The API already provides this information; we're just making it visible in the JSON/YAML status output for automation use cases.

Docs PR URL (required if "docs added" is checked)

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features

    • Peer group membership is now recorded and shown in peer status/details and network sync payloads.
    • Remote peer configurations and sync responses include per-peer group names.
    • Status output and anonymized exports now include anonymized group labels when applicable.
  • Tests

    • Added unit tests covering group tracking, status output, and label anonymization.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/5775 **Author:** [@Paulpatou](https://github.com/Paulpatou) **Created:** 4/2/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/add-groups-to-status-json-output` --- ### 📝 Commits (3) - [`29b7276`](https://github.com/netbirdio/netbird/commit/29b72769f733afa913d359453c5f6be00e3db23a) add peer groups to status JSON/YAML output - [`6c1d27f`](https://github.com/netbirdio/netbird/commit/6c1d27f0745f18fc966c458639960e2c9bee239e) sort group names in GetPeerGroupNames for deterministic output - [`27cae9c`](https://github.com/netbirdio/netbird/commit/27cae9c42b8616a305ad4f3041a1dcfe9c8b2a51) regenerate .pb.go files with correct upstream tool versions ### 📊 Changes **17 files changed** (+543 additions, -310 deletions) <details> <summary>View changed files</summary> 📝 `client/anonymize/anonymize.go` (+18 -0) 📝 `client/anonymize/anonymize_test.go` (+27 -0) 📝 `client/internal/engine.go` (+8 -0) 📝 `client/internal/peer/status.go` (+18 -0) 📝 `client/internal/peer/status_test.go` (+24 -0) 📝 `client/proto/daemon.pb.go` (+11 -2) 📝 `client/proto/daemon.proto` (+1 -0) 📝 `client/status/status.go` (+18 -0) 📝 `client/status/status_test.go` (+15 -2) 📝 `management/internals/controllers/network_map/controller/controller.go` (+4 -0) 📝 `management/internals/shared/grpc/conversion.go` (+4 -3) 📝 `management/internals/shared/grpc/server.go` (+13 -0) 📝 `management/server/types/account.go` (+15 -0) 📝 `management/server/types/account_test.go` (+39 -0) 📝 `management/server/types/network.go` (+13 -0) 📝 `shared/management/proto/management.pb.go` (+313 -303) 📝 `shared/management/proto/management.proto` (+2 -0) </details> ### 📄 Description ## Describe your changes This PR adds group membership information (group names) to each peer in the `netbird status --json` and `netbird status --yaml` output. ### Problem When using `netbird status --json` or `netbird status --yaml` to inventory peers programmatically, group membership was missing from the output. This made the CLI output impractical for automation use cases where peers need to be filtered or categorized by group. The API already exposes this information, but not everyone can use the API in their tooling architecture - they rely on the CLI status output. ### Solution Added a `groups` field to each peer entry in the status JSON/YAML output, containing the list of group names the peer belongs to. **Before:** ```json { "peers": { "details": [ { "fqdn": "peer.example.netbird.cloud", "netbirdIp": "100.64.0.1", "status": "Connected" } ] } } ``` **After:** ```json { "peers": { "details": [ { "fqdn": "peer.example.netbird.cloud", "netbirdIp": "100.64.0.1", "status": "Connected", "groups": ["All", "Production"] } ] } } ``` ### Changes The feature is implemented across the full data pipeline: #### Management server → client sync - `shared/management/proto/management.proto` — add `repeated string groupsNames = 6` to `RemotePeerConfig` - `management/server/types/network.go` — add `PeerGroupsNames map[string][]string` to `NetworkMap` - `management/server/types/account.go` — add `GetPeerGroupNames(peerID string) []string` helper - `management/internals/shared/grpc/conversion.go` — populate `GroupsNames` in `appendRemotePeerConfig` - `management/internals/controllers/network_map/controller/controller.go` — fill `PeerGroupsNames` before `ToSyncResponse` - `management/internals/shared/grpc/server.go` — fill `PeerGroupsNames` via `GetAccountGroups` in `sendInitialSync` #### Client daemon → CLI - `client/proto/daemon.proto` — add `repeated string groups = 20` to `PeerState` - `client/internal/peer/status.go` — add `Groups []string` to `State`, add `UpdatePeerGroups()` method, include groups in `ToProto()` - `client/internal/engine.go` — call `UpdatePeerGroups` in `addNewPeer` and `modifyPeers` #### CLI output - `client/status/status.go` — add `Groups []string \`json:"groups" yaml:"groups"\`` to `PeerStateDetailOutput`, populate in `mapPeers()` ## Issue ticket number and link https://github.com/netbirdio/netbird/issues/5714 ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) ### Documentation - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change This is a feature addition that exposes existing group membership data in the CLI status output. The API already provides this information; we're just making it visible in the JSON/YAML status output for automation use cases. ### Docs PR URL (required if "docs added" is checked) https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Peer group membership is now recorded and shown in peer status/details and network sync payloads. * Remote peer configurations and sync responses include per-peer group names. * Status output and anonymized exports now include anonymized group labels when applicable. * **Tests** * Added unit tests covering group tracking, status output, and label anonymization. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:06:29 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#28517