Some customers have enabled gNMI (gRPC Network Management Interface) on their Junos devices but experience difficulties retrieving specific hierarchical levels of configuration features from the configuration file.
Commonly, users want to access particular segments, such as interface or system-level hierarchies, rather than the entire configuration.
Juniper TAC has conducted tests in the lab and provided the following commands to assist customers in gathering parts of the configuration using gNMI with the get request.
get
Customers can utilize the following commands to retrieve specific hierarchy stanzas:
To access the interfaces hierarchy, use the command:
root@Ubuntu:~# gnmic -a host:port -u user -p password --insecure get --type CONFIG --encoding json_ietf --path "juniper:/interfaces"
To access the system hierarchy, use the command:
root@Ubuntu:~# gnmic -a host:port -u user -p password --insecure get --type CONFIG --encoding json_ietf --path "juniper:/system"
To access the routing instances hierarchy, use the command:
root@Ubuntu:~# gnmic -a host:port -u user -p password --insecure get --type CONFIG --encoding json_ietf --path "juniper:/routing-instances"
When successfully retrieving the interfaces configuration, the expected output may look like this:
[ { "source": "Devie IP:Port", "timestamp": 1729103693125550193, "time": "2024-10-16T18:34:53.125550193Z", "updates": [ { "Path": "juniper:interfaces", "values": { "interfaces": { "interface": [ { "description": "TEST xe-0/0/0", "name": "xe-0/0/0", "unit": [ { "family": { "inet": { "address": [ { "name": "1.1.1.1/30" } ] } }, "name": 0 } ] }, { "description": "TEST xe-0/0/4", "name": "xe-0/0/4" } ] } } } ] } ]
By using the commands outlined above, customers should be able to successfully retrieve the desired hierarchical data from their Junos devices using gNMI/gRPC.
If issues persist, consider verifying the connection settings and permissions or reaching out for further support.