Octet

How does gNMI work, and what are its subscription modes?

Show the answer

Say this first

gNMI is a gRPC service with four RPCs: Capabilities (which models and encodings the target supports), Get, Set (delete, replace and update in one atomic request) and Subscribe. A subscription can be ONCE (send everything and stop), POLL (send when the client asks) or STREAM. Stream subscriptions are SAMPLE (every interval), ON_CHANGE (only when a value changes) or TARGET_DEFINED (the device picks per path).

Go deeper

Paths

gNMI paths are XPath-like with keys in brackets and no quotes: /interfaces/interface[name=Ethernet1]/state/counters/in-octets. An optional origin (often openconfig) says which model tree the path belongs to.

Subscribe in practice

Shell
gnmic -a 10.0.0.31:6030 -u netops -p secret --insecure capabilities

gnmic -a 10.0.0.31:6030 -u netops -p secret --insecure \
  subscribe --path "/interfaces/interface[name=Ethernet1]/state/counters" \
  --stream-mode sample --sample-interval 10s

gnmic -a 10.0.0.31:6030 -u netops -p secret --insecure \
  subscribe --path "/interfaces/interface/state/oper-status" --stream-mode on-change

--insecure is plaintext gRPC for a lab. With TLS use --tls-ca to verify the device certificate, or --skip-verify to encrypt without checking it.

Which mode for what

DataModeWhy
Interface counters, CPU, memorySAMPLE, 10 to 30 sValues change constantly
Oper-status, BGP session state, LLDP neighborsON_CHANGERare, important changes, sent at once
Inventory, software versionONCE or POLLRarely changes

suppress_redundant and heartbeat_interval let SAMPLE skip unchanged values while still proving the stream is alive.

Related gRPC services

gNOI for operations (reboot, file transfer, certificates, ping), gRIBI for injecting routes, P4Runtime for programmable forwarding pipelines.

Enabling it

Arista EOS
management api gnmi
   transport grpc default

Other platforms have their own commands and default ports; check the release notes.

Traps

  • Using SAMPLE every second on thousands of paths and overloading the device CPU and the collector.
How did you do?