XPath Formatting Rules for Streaming Telemetry
OcNOS Streaming Telemetry uses XPath expressions to subscribe to YANG-modeled data. Properly formatting XPath ensures accurate and consistent collection of telemetry data, regardless of whether users configure Dial-In, Dial-Out, or GET RPC modes.
XPath Formatting Rules for gnmic Subscriptions
OcNOS enforces specific formatting rules for XPath in gNMIc subscription commands.
1. | String Key Formatting: Xpath with string keys must be enclosed in double quotes ("" ). |
Example:
--path '/components/component[name="TEMPERATURE-MAC"]/state'
--path "/components/component[name=\"TEMPERATURE-MAC\"]/state"
2. | Integer Key Formatting: Xpath with integer keys must be provided without double quotes. |
Example:
--path "ipi:/bgp/bgp-instances/bgp-instance[bgp-as=100]/peers/peer[peer-address=\"1.1.1.1\"]/state"
--path 'ipi:/bgp/bgp-instances/bgp-instance[bgp-as=100]/peers/peer[peer-address="1.1.1.1"]/state'
3. | Implicit Wildcard Keys: Xpath with implicit wildcard keys can be provided with or without single quotes. |
Example:
--path '/components/component/state'
--path /components/component/state
4. | Key Order in Sensor Paths: When using multiple keys in sensor paths, key-value pairs must be configured in the same order as defined by the IPI data model sensor path list. Incorrect ordering may cause subscription failures or unexpected behavior in telemetry data collection. |
This key ordering is applicable only for Dial-Out operations.
Example: Incorrect Order (Invalid Configuration)
In this example, "vrf-name
" appears before "local-discriminator
", which does not match the expected order.
ipi:/bfd/sessions/session[vrf-name="default"][local-discriminator="2050"]/state/counters/packets/ipv4
Example: Correct Order (Valid Configuration)
In this example, "vrf-name
" appears after "local-discriminator
", which matches the expected order.
ipi:/bfd/sessions/session[local-discriminator="2050"][vrf-name="default"]/state/counters/packets/ipv4
XPath Format Support by Telemetry Mode
Dial-In XPath Formats
XPath Examples |
Command Line (CLI) Support |
YAML Support | Comments |
---|---|---|---|
"ipi:/interfaces/interface[name=\"eth0\"]/state" |
Yes |
Yes |
Valid path |
'ipi:/interfaces/interface[name="eth0"]/state' |
Yes |
Yes |
Valid path |
ipi:/interfaces/interface[name=\"eth0\"]/state |
Yes |
No |
Valid path for CLI and invalid path for YAML |
ipi:/interfaces/interface[name="eth0"]/state |
No |
Yes |
Invalid path for CLI and valid path for YAML |
'ipi:/interfaces/interface[name=\"eth0\"]/state' |
No |
No |
Invalid path |
Dial-Out XPath Formats
XPath Examples |
Command Line (CLI) Support |
Comments |
---|---|---|
ipi:/interfaces/interface[name="eth0"]/state |
Yes |
Valid path |
/interfaces/interface[name="eth0"]/state |
Yes |
Valid path (OpenConfig) |
/interfaces/interface[name=eth0]/state |
Yes |
Valid path (OpenConfig) |
"ipi:/interfaces/interface[name=\"eth0\"]/state" |
No |
Invalid path |
'ipi:/interfaces/interface[name="eth0"]/state' |
No |
Invalid path |
ipi:/interfaces/interface[name=\"eth0\"]/state |
No |
Invalid path |
Get RPC XPath Formats
XPath Examples |
Command Line (CLI) Support |
YAML Support | Comments |
---|---|---|---|
ipi:/interfaces/interface[name=eth0]/state |
Yes |
Yes |
Valid path |
ipi:/interfaces/interface[name="eth0"]/state |
Yes |
Yes |
Valid path |
'ipi:/interfaces/interface[name="eth0"]/state' |
Yes |
Yes |
Valid path |
'ipi:/interfaces/interface[name=eth0]/state' |
Yes |
Yes |
Valid path |
"ipi:/interfaces/interface[name=\"eth0\"]/state" |
Yes |
Yes |
Valid path |
/interfaces/interface[name=eth0]/state |
Yes |
Yes |
Valid path (OpenConfig) |
/interfaces/interface[name="eth0"]/state |
Yes |
Yes |
Valid path (OpenConfig) |
'ipi:/interfaces/interface[name=\"eth0\"]/state' |
No | No |
Invalid path |
The Get RPC response for string key values is returned without double quotes (“ ”), regardless of how the key values were specified in the requested XPath. The response below returns without double quotes (" ") for the po1
interface in the Path field: "Path": "ipi:interfaces/interface[name=po1]"
.
./gnmic -a 10.12.162.22:9339 -u admin -p admin --insecure get --path 'ipi:/interfaces/interface[name="po1"]' --encoding json_ietf --type config --timeout 120s
[
{
"source": "10.12.162.22:9339",
"timestamp": 1730122009406462625,
"time": "2024-10-28T13:26:49.406462625Z",
"updates": [
{
"Path": "ipi:interfaces/interface[name=po1]",
"values": {
"interfaces/interface": {
"interfaces": {
"interface": [
{
"config": {
"enable-switchport": "",
"mtu": "300",
"name": "po1"
},
"name": "po1"
}
]
}
}
}
}
]
}
]