# openconfig/gnmic architecture

> Architecture diagram of the GitHub repository openconfig/gnmic, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openconfig/gnmic
- Repository: https://github.com/openconfig/gnmic

## Overview

gnmic is both a gNMI CLI client and a configurable telemetry collector. The main user workflow is issuing gNMI RPC commands to network targets; the collector workflow receives target telemetry or external input, processes and routes messages to configured outputs, and can expose cached data through its own gNMI server. The graph retains major documented features such as clustering, tunnel dialout, and pipelines. Some subsystem paths and relationships are based on README descriptions or the source index; unsampled implementation details are not asserted.

Main entry points: [`pkg/cmd`](https://github.com/openconfig/gnmic/tree/main/pkg/cmd) (RPC commands), [`pkg/pipeline/pipeline.go`](https://github.com/openconfig/gnmic/blob/main/pkg/pipeline/pipeline.go) (Message pipeline), [`pkg/collector/managers/cluster/cluster_manager.go`](https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/cluster/cluster_manager.go) (Cluster manager), [`pkg/app/gnmi_client_subscribe.go`](https://github.com/openconfig/gnmic/blob/main/pkg/app/gnmi_client_subscribe.go) (Target subscriptions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["gNMI CLI"]
  node_entry["CLI entry<br/>[main.go]"]
  node_commands["RPC commands"]
  node_client["gNMI client<br/>[gnmi_client.go]"]
  node_subscriptions["Target subscriptions"]
end

subgraph group_runtime["Collector Runtime"]
  node_app["Application runtime<br/>[app.go]"]
  node_targetmgr["Target manager<br/>[targets_manager.go]"]
  node_inputs["Input manager<br/>[inputs_manager.go]"]
end

subgraph group_data["Telemetry Flow"]
  node_pipeline["Message pipeline<br/>[pipeline.go]"]
  node_formatters["Event processing"]
  node_outputs["Output manager<br/>[outputs_manager.go]"]
  node_output_plugins["Output integrations"]
  node_input_plugins["Input integrations"]
end

subgraph group_coord["Operations"]
  node_cluster["Cluster manager<br/>[cluster_manager.go]"]
  node_store[("Collector state<br/>[store.go]")]
  node_loaders["Target loaders"]
end

subgraph group_interfaces["Collector Interfaces"]
  node_cache[("Telemetry cache<br/>[oc_cache.go]")]
  node_collector_server["Collector gNMI<br/>[server.go]"]
  node_api_server["Management API<br/>[apiserver.go]"]
  node_tunnel["Tunnel server<br/>[tunnel.go]"]
end

node_operator(("Operator"))
node_network_targets(("gNMI targets"))
node_message_sources(("Message sources"))
node_message_sinks(("Message sinks"))

node_operator -->|"runs"| node_entry
node_entry -->|"dispatches"| node_commands
node_operator -->|"invokes RPCs"| node_commands
node_commands -->|"uses"| node_client
node_client -->|"sends RPCs"| node_network_targets
node_commands -->|"starts subscriptions"| node_subscriptions
node_subscriptions -->|"subscribes"| node_network_targets
node_operator -->|"configures collector"| node_app
node_app -->|"starts target streams"| node_subscriptions
node_targetmgr -->|"initializes loader"| node_loaders
node_inputs -->|"writes messages"| node_pipeline
node_message_sources -->|"provides events"| node_input_plugins
node_input_plugins -.->|"sends messages"| node_pipeline
node_pipeline -->|"carries events"| node_formatters
node_outputs -->|"initializes outputs"| node_output_plugins
node_output_plugins -->|"exports telemetry"| node_message_sinks
node_outputs -->|"sets cache"| node_cache
node_collector_server -->|"serves cached data"| node_cache
node_api_server -.->|"manages configuration"| node_store
node_cluster -->|"coordinates state"| node_store
node_cluster -->|"assigns targets"| node_targetmgr
node_tunnel -->|"receives dialout"| node_network_targets
node_operator -->|"deploys clustered"| node_cluster
node_message_sources -->|"feeds pipelines"| node_pipeline

click node_entry "https://github.com/openconfig/gnmic/blob/main/main.go"
click node_commands "https://github.com/openconfig/gnmic/tree/main/pkg/cmd"
click node_client "https://github.com/openconfig/gnmic/blob/main/pkg/app/gnmi_client.go"
click node_subscriptions "https://github.com/openconfig/gnmic/blob/main/pkg/app/gnmi_client_subscribe.go"
click node_app "https://github.com/openconfig/gnmic/blob/main/pkg/app/app.go"
click node_targetmgr "https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/targets/targets_manager.go"
click node_inputs "https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/inputs/inputs_manager.go"
click node_pipeline "https://github.com/openconfig/gnmic/blob/main/pkg/pipeline/pipeline.go"
click node_formatters "https://github.com/openconfig/gnmic/tree/main/pkg/formatters"
click node_outputs "https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/outputs/outputs_manager.go"
click node_output_plugins "https://github.com/openconfig/gnmic/tree/main/pkg/outputs"
click node_input_plugins "https://github.com/openconfig/gnmic/tree/main/pkg/inputs"
click node_cache "https://github.com/openconfig/gnmic/blob/main/pkg/cache/oc_cache.go"
click node_collector_server "https://github.com/openconfig/gnmic/blob/main/pkg/collector/api/gnmi/server.go"
click node_api_server "https://github.com/openconfig/gnmic/blob/main/pkg/collector/api/server/apiserver.go"
click node_cluster "https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/cluster/cluster_manager.go"
click node_store "https://github.com/openconfig/gnmic/blob/main/pkg/collector/store/store.go"
click node_loaders "https://github.com/openconfig/gnmic/tree/main/pkg/loaders"
click node_tunnel "https://github.com/openconfig/gnmic/blob/main/pkg/app/tunnel.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_commands,node_client,node_subscriptions toneBlue
class node_app,node_targetmgr,node_inputs toneAmber
class node_pipeline,node_formatters,node_outputs,node_output_plugins,node_input_plugins toneMint
class node_cluster,node_store,node_loaders toneRose
class node_cache,node_collector_server,node_api_server,node_tunnel,node_operator,node_network_targets,node_message_sources,node_message_sinks toneIndigo
```

## Components

### gNMI CLI

- [CLI entry](https://github.com/openconfig/gnmic/blob/main/main.go): `main.go`
- [RPC commands](https://github.com/openconfig/gnmic/tree/main/pkg/cmd): `pkg/cmd`
- [gNMI client](https://github.com/openconfig/gnmic/blob/main/pkg/app/gnmi_client.go): `pkg/app/gnmi_client.go`
- [Target subscriptions](https://github.com/openconfig/gnmic/blob/main/pkg/app/gnmi_client_subscribe.go): `pkg/app/gnmi_client_subscribe.go`

### Collector Runtime

- [Application runtime](https://github.com/openconfig/gnmic/blob/main/pkg/app/app.go): `pkg/app/app.go`
- [Target manager](https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/targets/targets_manager.go): `pkg/collector/managers/targets/targets_manager.go`
- [Input manager](https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/inputs/inputs_manager.go): `pkg/collector/managers/inputs/inputs_manager.go`

### Telemetry Flow

- [Message pipeline](https://github.com/openconfig/gnmic/blob/main/pkg/pipeline/pipeline.go): `pkg/pipeline/pipeline.go`
- [Event processing](https://github.com/openconfig/gnmic/tree/main/pkg/formatters): `pkg/formatters`
- [Output manager](https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/outputs/outputs_manager.go): `pkg/collector/managers/outputs/outputs_manager.go`
- [Output integrations](https://github.com/openconfig/gnmic/tree/main/pkg/outputs): `pkg/outputs`
- [Input integrations](https://github.com/openconfig/gnmic/tree/main/pkg/inputs): `pkg/inputs`

### Operations

- [Cluster manager](https://github.com/openconfig/gnmic/blob/main/pkg/collector/managers/cluster/cluster_manager.go): `pkg/collector/managers/cluster/cluster_manager.go`
- [Collector state](https://github.com/openconfig/gnmic/blob/main/pkg/collector/store/store.go): `pkg/collector/store/store.go`
- [Target loaders](https://github.com/openconfig/gnmic/tree/main/pkg/loaders): `pkg/loaders`

### Collector Interfaces

- [Telemetry cache](https://github.com/openconfig/gnmic/blob/main/pkg/cache/oc_cache.go): `pkg/cache/oc_cache.go`
- [Collector gNMI](https://github.com/openconfig/gnmic/blob/main/pkg/collector/api/gnmi/server.go): `pkg/collector/api/gnmi/server.go`
- [Management API](https://github.com/openconfig/gnmic/blob/main/pkg/collector/api/server/apiserver.go): `pkg/collector/api/server/apiserver.go`
- [Tunnel server](https://github.com/openconfig/gnmic/blob/main/pkg/app/tunnel.go): `pkg/app/tunnel.go`

### Other components

- **Operator**
- **gNMI targets**
- **Message sources**
- **Message sinks**

## Connections

- Operator → CLI entry: runs
- CLI entry → RPC commands: dispatches (evidence: `main.go`)
- Operator → RPC commands: invokes RPCs
- RPC commands → gNMI client: uses
- gNMI client → gNMI targets: sends RPCs
- RPC commands → Target subscriptions: starts subscriptions
- Target subscriptions → gNMI targets: subscribes (evidence: `pkg/app/gnmi_client_subscribe.go`)
- Operator → Application runtime: configures collector
- Application runtime → Target subscriptions: starts target streams (evidence: `pkg/app/app.go`)
- Target manager → Target loaders: initializes loader (evidence: `pkg/collector/managers/targets/targets_manager.go`)
- Input manager → Message pipeline: writes messages (evidence: `pkg/collector/managers/inputs/inputs_manager.go`)
- Message sources → Input integrations: provides events
- Input integrations → Message pipeline: sends messages
- Message pipeline → Event processing: carries events (evidence: `pkg/pipeline/pipeline.go`)
- Output manager → Output integrations: initializes outputs (evidence: `pkg/collector/managers/outputs/outputs_manager.go`)
- Output integrations → Message sinks: exports telemetry
- Output manager → Telemetry cache: sets cache (evidence: `pkg/collector/managers/outputs/outputs_manager.go`)
- Collector gNMI → Telemetry cache: serves cached data (evidence: `pkg/collector/api/gnmi/server.go`)
- Management API → Collector state: manages configuration
- Cluster manager → Collector state: coordinates state (evidence: `pkg/collector/managers/cluster/cluster_manager.go`)
- Cluster manager → Target manager: assigns targets (evidence: `pkg/collector/managers/cluster/cluster_manager.go`)
- Tunnel server → gNMI targets: receives dialout
- Operator → Cluster manager: deploys clustered
- Message sources → Message pipeline: feeds pipelines
