gNMI Genstate Subscription
A gNMI Genstate subscription utilizes the gNMI protocol to retrieve state data from a network device, specifically focusing on data exposed through Genstate YANG data models. This allows you to monitor the operational state of the device, similar to data presented in CLI "show" commands, but through a streaming mechanism.
The Genstate model allows you to access operational state information in a structured, machine-readable format. The network device, acting as a gNMI server, sends telemetry data corresponding to the subscribed paths. This data can be used for monitoring, alerting, and other applications.
gNMI clients in gRPC dial-in environments can subscribe to a Genstate resource path and STREAM statistics in SAMPLE sub mode to a collector for telemetry data.
ON_CHANGE sub mode is not supported. For more information, see Guidelines for Telemetry Data Subscriptions over gNMI.
Use the following steps to set up gNMI Genstate subscription:
View or download the models from the Juniper/yang GitHub repository or Juniper Networks.
Obtain and load the gRPC server's certificate.
Enable your network device for gRPC services.
Specify the local certificate used for server authentication.
For Genstate subscription step details, see Configure gRPC Services.
The subscription example that follows uses a target device configured for mutual
authentication using X.509 certificates. The subscription request supplies the root CA
certificate required to verify the target device's local certificate, and it also
provides the client's key and certificate so that the target device can authenticate the
client. The subscription uses STREAM mode and submode SAMPLE and requests data for the
resource path genstate:/genstate/system-information/os-version
. The
telemetry data returned to the collector shows that the target device is operating with
Junos OS version 24.2R1.12-EVO
.
Junos OS supports several origin schemas including Juniper Native, OpenConfig, and
Genstate. The origin
is stated in the path before the colon where
genstate is the origin
in the path
genstate:/genstate/system-information/os-version
. For more
information on origin
in path, see gNMI Service.
user@controller:~$ gnmic sub -a 198.51.100.10:32767 --mode stream --stream-mode sample -u grpc-user -p secret --tls-ca certs/serverRootCA.crt --tls-cert certs/client.crt --tls-key certs/client.key --sample-interval 30s --path genstate:/genstate/system-information/os-version { "source": "198.51.100.10:32767", "subscription-name": "default-1708559603", "timestamp": 1708559609668499930, "time": "2024-02-21T15:53:29.66849993-08:00", "prefix": "genstate:genstate/system-information/os-version", "updates": [ { "Path": "os-version", "values": { "os-version": "24.2R1.12-EVO" } } ] }
The subscription example that follows again uses a target device configured for mutual
authentication using X.509 certificates. The subscription uses STREAM mode and submode
SAMPLE and requests data for the resource path
genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status
.
The admin-status
(administrative status) indicates whether the
interface is enabled (up) or disabled (down). The telemetry data returned to the
collector shows that physical interface et-1/0/1
is
up
.
user@controller:~$ gnmic sub -a 198.51.100.10:32767 --mode stream --stream-mode sample -u grpc-user -p secret --tls-ca certs/serverRootCA.crt --tls-cert certs/client.crt --tls-key certs/client.key --sample-interval 30s --path genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status { "source": "198.51.100.10:32767", "subscription-name": "default-1708561308", "timestamp": 1708561313983469233, "time": "2024-02-21T16:21:53.983469233-08:00", "prefix": "genstate:genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status", "updates": [ { "Path": "admin-status", "values": { "admin-status": "up" } } ] }
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.
genstate
models are
subscribable YANG models for operational state data on Junos devices. gNMI
clients can subscribe to resource paths defined in the models to retrieve
specific state data.