I manage to pull out some interface stats using Cisco genie and below is the JSON (apology for the long JSON).
As you can see, the Interface name is not static. Can I know how do I pull out the Interface Name together with other stats using json_query?
I use this query msg.genie.interface.*.{Bandwidth: bandwidth, crc: counters.in_errors, mac: mac_address, duplex: duplex_mode, speed: port_speed, vrf: vrf, oper: oper_status}
and the result is this.
I am just missing the Interface name. Any suggestion on how do include the Interface name in the output?
JMESPath query:
msg.genie.interface.*.{Bandwidth: bandwidth, crc: counters.in_errors, mac: mac_address, duplex: duplex_mode, speed: port_speed, vrf: vrf, oper: oper_status}
outputs:
[
{
"Bandwidth": 1000000,
"crc": 0,
"mac": "2cab.eb8c.59ff",
"duplex": "auto",
"speed": "auto speed",
"vrf": "Mgmt-intf",
"oper": "down"
},
{
"Bandwidth": 1000000,
"crc": 0,
"mac": "2cab.eb8c.5970",
"duplex": "full",
"speed": "1000mbps",
"vrf": null,
"oper": "up"
}
]
Full JSON from the Cisco genie pull:
{
"msg": {
"changed": false,
"failed": false,
"genie": {
"interface": {
"GigabitEthernet0": {
"auto_negotiate": true,
"bandwidth": 1000000,
"counters": {
"in_broadcast_pkts": 0,
"in_crc_errors": 0,
"in_errors": 0,
"in_mac_pause_frames": 0,
"in_multicast_pkts": 0,
"in_octets": 0,
"in_pkts": 0,
"last_clear": "never",
"out_errors": 0,
"out_mac_pause_frames": 0,
"out_octets": 0,
"out_pkts": 0,
"rate": {
"in_rate": 0,
"in_rate_pkts": 0,
"load_interval": 300,
"out_rate": 0,
"out_rate_pkts": 0
}
},
"delay": 10,
"duplex_mode": "auto",
"enabled": false,
"encapsulation": {
"encapsulation": "arpa"
},
"flow_control": {
"receive": false,
"send": false
},
"mac_address": "2cab.eb8c.59ff",
"mtu": 1500,
"oper_status": "down",
"phys_address": "2cab.eb8c.59ff",
"port_channel": {
"port_channel_member": false
},
"port_speed": "auto speed",
"switchport_enable": false,
"type": "RP management port",
"vrf": "Mgmt-intf"
},
"GigabitEthernet0/0/0": {
"accounting": {
"arp": {
"chars_in": 1253820,
"chars_out": 1347648,
"pkts_in": 20897,
"pkts_out": 21057
},
"cdp": {
"chars_in": 93408529,
"chars_out": 93849340,
"pkts_in": 198326,
"pkts_out": 220327
},
"ip": {
"chars_in": 43533539576,
"chars_out": 243171224580,
"pkts_in": 51407196,
"pkts_out": 272100765
},
"ipv6": {
"chars_in": 351879534,
"chars_out": 0,
"pkts_in": 2933568,
"pkts_out": 0
},
"other": {
"chars_in": 1330840333,
"chars_out": 95196860,
"pkts_in": 18437333,
"pkts_out": 241382
},
"spanning tree": {
"chars_in": 2276096512,
"chars_out": 0,
"pkts_in": 35564008,
"pkts_out": 0
}
},
"auto_negotiate": true,
"bandwidth": 1000000,
"counters": {
"in_broadcast_pkts": 0,
"in_crc_errors": 0,
"in_errors": 0,
"in_mac_pause_frames": 0,
"in_multicast_pkts": 27276714,
"in_octets": 45638217915,
"in_pkts": 78759308,
"last_clear": "never",
"out_errors": 0,
"out_mac_pause_frames": 0,
"out_octets": 243268978899,
"out_pkts": 272342613,
"rate": {
"in_rate": 25000,
"in_rate_pkts": 5,
"load_interval": 300,
"out_rate": 73000,
"out_rate_pkts": 5
}
},
"delay": 10,
"duplex_mode": "full",
"enabled": true,
"encapsulation": {
"encapsulation": "dot1q",
"first_dot1q": "1"
},
"flow_control": {
"receive": false,
"send": false
},
"mac_address": "2cab.eb8c.5970",
"mtu": 1500,
"oper_status": "up",
"phys_address": "2cab.eb8c.5970",
"port_channel": {
"port_channel_member": false
},
"port_speed": "1000mbps",
"switchport_enable": false,
"type": "ISR4321-2x1GE"
}
}
}
}
}