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

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

Original Pull Request: https://github.com/netbirdio/netbird/pull/5775

State: closed
Merged: No


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.
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/5775 **State:** closed **Merged:** No --- ## 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 -->
saavagebueno added the pull-request label 2026-08-05 06:08:01 -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#23919