Junos Genstate YANG Data Models
The Juniper Networks genstate YANG schema defines YANG data models for
operational state on Junos devices. gRPC Network Management Interface (gNMI) clients can
subscribe to the resource paths defined in the models to request state data.
Genstate YANG Data Models Overview
Starting in Junos OS Evolved Release 24.2R1, Juniper Networks publishes the genstate
YANG modules. The genstate models are subscribable YANG models for
operational state data on Junos devices. They are a YANG representation of the operational
command output. The genstate model comprises a top-level module augmented
by modules for each of the different operational state areas as they are published and made
available.
Junos devices have a rich set of native state data. You can retrieve operational state
information from Junos devices by executing operational commands or Junos XML RPCs on the
device. However, you must still parse the command output to extract specific data. Juniper
also provides the curated junos-state YANG data models that telemetry
collectors can consume, but the models include only a subset of operational areas and
states.
Junos devices expose a subset of Junos XML RPC response paths in telemetry under the
genstate origin (genstate:). The origin identifies the schema for the
subscription path. The corresponding telemetry YANG modules that define the schema are
referred to as the genstate YANG modules. A gNMI telemetry collector can
subscribe to the resource paths published in the genstate YANG modules to
query for the corresponding state data on a device.
gNMI clients can use the gNMI subscribe RPC to subscribe
to the genstate published paths. A client can use STREAM subscriptions in
SAMPLE mode to request the data. ON_CHANGE mode is not supported. For information about
using gNMI to subscribe to telemetry data, see the Junos Telemetry Interface User Guide.
The genstate YANG data models are published and updated in different
releases. You can check the available models and supported paths for a given release in the
following ways:
-
View or download the modules from the Juniper/yang GitHub repository.
-
Download the modules from the Juniper Networks website at https://www.juniper.net/support/downloads.
-
Emit the modules on Junos devices.
-
Emit available subscription paths on Junos devices as outlined in Map CLI Commands to Genstate Resource Paths and YANG Modules.
Benefits of the Genstate YANG State Models
-
Increase the surface area of operational state available through gNMI and thus enable you to make more informed usage decisions about the device and network when you use gNMI to monitor state.
-
Simplify how you monitor device state by enabling you to move toward a single northbound interface.
Genstate Modules Overview
The genstate YANG data models comprise a top-level root module augmented
by modules for each of the available operational state areas. The genstate
schema uses origin 'genstate'.
The top-level module is as follows:
module junos-genstate {
namespace "http://yang.juniper.net/junos/genstate/";
prefix jgs;
organization
"Juniper Networks, Inc.";
contact
"Juniper Networks, Inc.
1133 Innovation Way
Sunnyvale, CA
+1 888 314-5822
E-mail: yang-support@juniper.net";
description
"This module contains a collection of top level nodes for JUNOS genstate data.
Copyright (c) 2023 Juniper Networks, Inc.
All rights reserved.";
revision 2023-01-01 {
description "Junos: ";
}
grouping genstate-top {
description "Top-level grouping for JUNOS genstate data";
container genstate {
description "Encapsulating top-level state container for all JUNOS genstate data";
config false;
}
}
uses genstate-top;
}
The top-level genstate module is augmented by the modules published for
each operational state area. When you issue operational commands or RPCs on a Junos device,
the device returns the XML output enclosed in a top-level element. The root-level tag name
describes the enclosed data. For example, show interfaces commands return
XML output that is enclosed in an <interface-information> tag. The
genstate modules include this root tag name in the module name and
filename to easily identify the data described in the module. The module prefix is based on
the root tag name and so varies for each module.
For example, the junos-genstate-interface-information module describes the
data that would normally be included in the <interface-information>
element in Junos command and RPC output. Thus, the model defines the resource paths that are
available for subscription by telemetry collectors for interface state data.
module junos-genstate-interface-information {
namespace "http://yang.juniper.net/junos/genstate/interface-information";
prefix jgii;
import junos-genstate {
prefix jgs;
revision-date 2023-01-01;
}
import junos-common-types {
prefix jt;
revision-date 2023-01-01;
}
organization
"Juniper Networks, Inc.";
contact
"Juniper Networks, Inc.
1133 Innovation Way
Sunnyvale, CA
+1 888 314-5822
E-mail: yang-support@juniper.net";
description "Junos genstate data model for interface-information";
revision 2023-01-01 {
description "Junos: ";
}
grouping interface-information-top {
description "Top-level grouping";
container interface-information {
config false;
description "Top-level container";
list physical-interface {
leaf name {
type string;
description "Name of this item";
}
leaf oper-status {
type string;
description "Current operational state of the interface";
}
leaf local-index {
type int32;
description "Local kernel index for this interface";
}
leaf snmp-index {
type int32;
description "SNMP ifIndex for this interface";
}
container if-config-flags {
leaf iff-none {
type empty;
}
leaf iff-hardware-down {
type empty;
}
leaf iff-down {
type empty;
}
leaf iff-up {
type empty;
}
leaf iff-admin-down {
type empty;
}
leaf iff-admin-up {
type empty;
}
leaf iff-link-down {
type empty;
}
leaf iff-device-down {
type empty;
}
leaf iff-point-to-point {
type empty;
}
leaf iff-point-to-multipoint {
type empty;
}
leaf plp-to-clp {
type empty;
}
leaf iff-multiaccess {
type empty;
}
leaf iff-snmp-traps {
type empty;
}
leaf iff-looped {
type empty;
}
leaf iff-framing-conflict {
type empty;
}
leaf internal-flags {
type string;
description "Hexadecimal value of internal flag bits";
}
}
list logical-interface {
leaf name {
type string;
description "Name of this item";
}
leaf local-index {
type int32;
description "Local kernel index for this interface";
}
leaf snmp-index {
type int32;
description "SNMP ifIndex for this interface";
}
leaf generation {
type string;
description "Generation number used to distinguish between successive instances of this interface";
}
leaf description {
type string;
description "Description of this interface";
}
leaf link-address {
type string;
description "Link address on this logical interface";
}
leaf encapsulation {
type string;
description "Encapsulation on the logical interface";
}
leaf subunit {
type int32;
description "Subunit for this interface";
}
container if-config-flags {
leaf iff-none {
type empty;
}
leaf iff-hardware-down {
type empty;
}
leaf iff-down {
type empty;
}
leaf iff-up {
type empty;
}
leaf iff-admin-down {
type empty;
}
leaf iff-admin-up {
type empty;
}
leaf iff-link-down {
type empty;
}
leaf iff-device-down {
type empty;
}
leaf iff-point-to-point {
type empty;
}
leaf iff-point-to-multipoint {
type empty;
}
leaf plp-to-clp {
type empty;
}
leaf iff-multiaccess {
type empty;
}
leaf iff-snmp-traps {
type empty;
}
leaf iff-looped {
type empty;
}
leaf iff-framing-conflict {
type empty;
}
leaf internal-flags {
type string;
description "Hexadecimal value of internal flag bits";
}
}
leaf admin-status {
type string;
description "Desired state of the interface";
}
leaf oper-status {
type string;
description "Current operational state of the interface";
}
}
}
}
}
augment "/jgs:genstate" {
description "Adds interface-information to top-level genstate";
uses interface-information-top;
}
}
How to Construct genstate Resource Paths
A telemetry collector can subscribe to the different resource paths as defined in the
genstate models to query for state data on devices that support this
feature. The genstate model uses the following syntax:
origin:/root/operational-response-tag/optional-child-tags-to-resource
The path uses the origin genstate, a root tag named
genstate, and the top-level tag name for the operational state area. For
example, to subscribe to genstate resource paths for all
interface-information state data, you would use the following path:
genstate:/genstate/interface-information
You can include supported child tags to retrieve state data for a specific resource. For example, a gNMI client can use the following path to retrieve the operational state for all interfaces:
genstate:/genstate/interface-information/physical-interface/oper-status
The genstate resource paths can use simple path expressions to query data.
You can use path-based and key-based filters. Table 1 outlines the supported expressions and provides some sample resource paths. Other query
patterns are not supported. The path expressions support container, leaf, and key-based
filtering and align with gNMI conventions, as outlined in Schema path encoding conventions for gNMI.
| Filter Type | Example Paths |
|---|---|
|
Container |
|
|
Leaf |
|
|
List key |
|
|
Multiple list keys |
|
|
Wildcard list key |
|
Path-based filters can select containers, lists, or leaf nodes. Key-based filters select a subset of list elements and support using precise values, specifying wildcards, or omitting the value. Specifying a wildcard or omitting a list key value matches all entries within a particular list.
We recommend that you always enclose the path in quotation marks. This approach prevents parsing errors in most environments and handles paths with spaces or other special characters.
For example, the following command uses quotation marks around the entire path:
$ gnmic sub --mode stream --stream-mode sample --sample-interval 30s -a 198.51.100.1:32767 -u grpc-user -p secret --tls-ca certs/serverRootCA.crt --path "genstate:/genstate/license-summary-information/license-detail-usage-summary/feature-summary[name=FIB Scale]"
Map CLI Commands to Genstate Resource Paths and YANG Modules
You can use CLI pipe filter functions to discover the genstate YANG module
and corresponding resource paths for a given show command. The options include:
-
| display genstate subscription-paths—Display all resource paths available for subscription in thegenstateYANG module associated with the given command. -
| display genstate yang-module-name—Display the name of thegenstateYANG module that includes the data model and resource paths for the given command. -
| display xml genstate-path—Display the command output in XML and include thejunos:genstate-pathattribute for every emitted tag that is available for subscription. The attribute value is thegenstatesubscription path.
The following sections outline the options.
- Example: Retrieve the Genstate YANG Module Name
- Example: Retrieve All Subscription Paths in a Command's YANG Module
- Example: Retrieve Available Subscription Paths in Command Output
Example: Retrieve the Genstate YANG Module Name
You can use the | display genstate yang-module-name option to retrieve
the name of the genstate YANG module that includes the data model and
resource paths for the given show command. In the following example, the
junos-genstate-commit-revision-information YANG module defines the
subscription paths for the show system commit revision command
output.
user@host> show system commit revision | display genstate yang-module-name
Genstate Yang module name:
junos-genstate-commit-revision-information
The following commands save the corresponding YANG module to a file in the /var/tmp directory and then display the file.
user@host> show system schema module junos-genstate-commit-revision-information output-directory /var/tmp
user@host> file show /var/tmp/junos-genstate-commit-revision-information@2026-01-01.yang
module junos-genstate-commit-revision-information {
yang-version 1;
namespace "http://yang.juniper.net/junos/genstate/commit-revision-information";
prefix jgcri;
import junos-genstate {
prefix jgs;
revision-date 2026-01-01;
}
[... output omitted ...]Example: Retrieve All Subscription Paths in a Command's YANG Module
The following example uses the | display genstate subscription-paths
option to return all available subscription paths in the genstate YANG
module associated with the command. The module, and thus the list of paths, can include
data for multiple related commands.
user@host> show system commit revision | display genstate subscription-paths Subscription paths information: Node type Path ---------- ----- container genstate:/genstate/commit-revision-information leaf genstate:/genstate/commit-revision-information/revision leaf genstate:/genstate/commit-revision-information/date-time leaf genstate:/genstate/commit-revision-information/user leaf genstate:/genstate/commit-revision-information/client leaf genstate:/genstate/commit-revision-information/comment leaf genstate:/genstate/commit-revision-information/log leaf genstate:/genstate/commit-revision-information/db-modified leaf genstate:/genstate/commit-revision-information/new-db-revision leaf genstate:/genstate/commit-revision-information/old-db-revision
Example: Retrieve Available Subscription Paths in Command Output
You can use the | display xml genstate-path option to display
genstate resource paths directly in the command's XML output. The
output includes the junos:genstate-path attribute with the subscription
path for every emitted tag that is available for subscription.
user@host> show system commit revision | display xml genstate-path
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/26.2R1.12-EVO/junos">
<commit-revision-information junos:genstate-path="genstate:/genstate/commit-revision-information">
<revision junos:genstate-path="genstate:/genstate/commit-revision-information/revision">re0-1779123559-4</revision>
</commit-revision-information>
<cli>
<banner>{master}</banner>
</cli>
</rpc-reply>
Map Genstate Resource Paths to CLI Commands
You can map a genstate resource path to the CLI command that generates the
corresponding output. To map the genstate path to the command, use the show system
data-models genstate command. Include the appropriate option and provide the path
to the desired resource.
-
In Junos OS and Junos OS Evolved Release 26.2R1 and later releases, use the
genstate-path-cli-command-mappingoption.user@host> show system data-models genstate genstate-path-cli-command-mapping resource-path
-
In earlier releases, use the
xpath-cli-command-mappingoption.user@host> show system data-models genstate xpath-cli-command-mapping resource-path
The following example retrieves the command that generates the state data corresponding to
the genstate:/genstate/system-information/os-version resource path.
user@host> show system data-models genstate genstate-path-cli-command-mapping genstate:/genstate/system-information/os-version
Genstate Path:
genstate:/genstate/system-information/os-version
Mapped CLI Command:
show system information
Similarly, the following example maps the given resource path to the CLI command that includes that information in the output.
user@host> show system data-models genstate xpath-cli-command-mapping genstate:/genstate/interface-information/physical-interface/oper-status Genstate xpath to CLI command mapping information (sometimes multiple commands might be mapped): > show interfaces detail
You can include list key values in the genstate path. When you issue the command or corresponding RPC and specify a list key in the path, enclose the list key value in single quotation marks and enclose the path in double quotation marks. The following examples request the command for genstate paths that specify a key.
user@host> show system data-models genstate genstate-path-cli-command-mapping "genstate:/genstate/interface-information/physical-interface[name='et-1/0/1']/speed"
Genstate Path:
genstate:/genstate/interface-information/physical-interface[name='et-1/0/1']/speed
Mapped CLI Command:
show interfaces et-1/0/1 briefuser@host> show system data-models genstate genstate-path-cli-command-mapping "genstate:/genstate/license-summary-information/license-detail-usage-summary/feature-summary[name='FIB Scale']"
Genstate Path:
genstate:/genstate/license-summary-information/license-detail-usage-summary/feature-summary[name='FIB Scale']
Mapped CLI Command:
show system license detail
Similarly, you can use the corresponding RPC to retrieve the same information.
<rpc>
<get-genstate-path-cli-command-mapping>
<genstate-path>genstate:/genstate/interface-information/physical-interface[name='et-1/0/1']/speed</genstate-path>
</get-genstate-path-cli-command-mapping>
</rpc>Starting in Junos OS Release 26.2R1 and Junos OS Evolved Release 26.2R1, we've changed
the RPC to rename the request tag from
<get-genstate-xpath-cli-command-mapping> to
<get-genstate-path-cli-command-mapping> and rename the
<xpath> option to <genstate-path>.
If a device does not support a particular genstate path, the command returns an error. The message varies by release.
error: No command mapping information found for genstate-path 'path'. The tag 'tag' is not found under parent 'parent'; The path does not seem to be exposed in genstate;
If you do not have permission to execute a CLI command, you cannot access the corresponding genstate subscription path. You can only subscribe to genstate paths of commands for which you have valid permissions.
How to Obtain the genstate YANG Modules
You can download Junos native YANG modules from the Juniper Networks download site or the Juniper/yang GitHub repository. You can also generate the modules on the local device. For instructions on downloading the modules, see Use Juniper Networks YANG Modules.
To emit the genstate YANG module files on the local device issue the show system
schema format yang module module command. Specify an
individual module name to return a single genstate module, or specify
all-genstate to return all genstate modules. You must also specify an
output directory for the files.
user@host> show system schema format yang module module-name output-directory output-directory
For example, the following commands create a directory, write all the genstate modules to that directory, and view the directory listing.
user@host> file make-directory /var/tmp/yang user@host> show system schema format yang module all-genstate output-directory /var/tmp/yang user@host> file list /var/tmp/yang /var/tmp/yang: junos-genstate-arp-table-information@2025-01-01.yang junos-genstate-bgp-diagnostics-overview@2025-01-01.yang junos-genstate-bgp-diagnostics-warnings@2025-01-01.yang junos-genstate-bgp-fabric-advertise@2025-01-01.yang ...
To generate the YANG modules from a remote session, execute the
<get-yang-schema> Junos OS RPC or the
<get-schema> NETCONF operation with the appropriate options.
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.
show system data-models genstate command option from
xpath-cli-command-mapping to
genstate-path-cli-command-mapping.show system schema operational command or equivalent RPC to
view the genstate YANG data models on a device.