Decoding Junos Telemetry Interface Data With UNIX Utilities
You can use UNIX utilities to decode Junos telemetry interface data on a server, or collector, that is streaming data from a Juniper Networks device. The example in this section shows you how to decode a single packet of streamed data.
Preparing the Collector to Decode Data
This example requires the following:
UNIX OS with the Netcat (nc) utility.
Protocol buffers compiler.
Junos telemetry interface protocol buffers files.
This procedure shows how to prepare the collector to decode data using the Ubuntu OS.
Install the Netcat utility.
sudo apt-get install netcat
Install the protocol buffers compiler.
sudo apt-get install protobuf-compiler
Install the protocol buffers developer’s library.
sudo apt-get install libprotobuf-dev
Verify that the library files are installed.
ls /usr/include/google/protobuf/descriptor.proto /usr/include/google/protobuf/descriptor.proto
Download and install the latest version of the Junos Telemetry interface protocol buffers files.
From a Web browser, navigate to the All Junos Platforms software download URL on the Juniper Networks page: https://www.juniper.net/support/downloads/. After you select the name of the Junos OS platform and the release number, go to the Tools section and download the Junos telemetry interface Data Model Files package.
tar –xvzf junos-telemetry-interface-15.1F6.9.tgz junos-telemetry-interface/telemetry_top.proto junos-telemetry-interface/logical_port.proto junos-telemetry-interface/lsp_mon.proto junos-telemetry-interface/firewall.proto junos-telemetry-interface/lsp_stats.proto junos-telemetry-interface/port.proto junos-telemetry-interface/NOTICE junos-telemetry-interface/license.txt
Note:Be sure to note the location of the extracted files.
Decoding Data on the Collector
This procedure shows you how to capture data, decode raw data, and use the protocol buffers files to decode data.
To decode data:
Capture the data.
Run netcat on a destination streaming telemetry server, or collector, in UDP listener mode to store all incoming datagrams into a file. Use the destination port number configured in streaming-server profile on your Juniper Networks device.
nc -ul 0.0.0.0 20000 > data.gpb
Note:This command stores datagrams into a file named
data.gpb. Run this program to capture data. When you want to stop receiving data, stop with the program by sending the break signal (Control + C)Decode raw data.
Note:This step is optional. It is not required if you know the encoded message type of the data.
Decode the message from the
data.gpbfile.protoc --decode_raw < ../data.gpb 1: "hillrock:160.1.1.25" 2: 0 4: "S1:/junos/system/linecard/interface/logical/usage/:/junos/system/linecard/interface/logical/usage/:PFE" 5: 65265 6: 1477686534474 7: 1 8: 1 101 { 2636 { 7 { 1 { 1: "et-0/0/4:2.32767" 2: 1477642750 3: 813 4 { 12: 0x37363732332e3165 } . . .The next nested structure under
2636identifies the sensor type. The numerical value2636identifies theJuniperNetworksSensormessage, which is defined in thetelemetry_top.protofile. In this example, the numerical identifier7corresponds to theLogicalPortmessage defined in thelogical_port.protofile. Use this information in the next step to generate more detailed output.Decode the message to include field names.
Run the protocol buffers compiler with the decode option. Additionally, specify the top-level message type (
TelemetryStream) and the file with the message definition,logical_port.proto. You must also include the Goggle protocol buffers (gpb) library.protoc --decode TelemetryStream logical_port.proto -I /usr/include -I . < data.gpb system_id: "hillrock:160.1.1.25" component_id: 0 sensor_name: "S1:/junos/system/linecard/interface/logical/usage/:/junos/system/linecard/interface/logical/usage/:PFE" sequence_number: 65268 timestamp: 1477686536484 version_major: 1 version_minor: 1 enterprise { [juniperNetworks] { [jnprLogicalInterfaceExt] { interface_info { if_name: "et-0/0/4:2.32767" init_time: 1477642750 snmp_if_index: 813 parent_ae_name: "ae1.32767" ingress_stats { if_packets: 0 if_octets: 0 } egress_stats { if_packets: 0 if_octets: 0 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/7:3.0" init_time: 1477642750 snmp_if_index: 520 parent_ae_name: "ae0.0" ingress_stats { if_packets: 61203309 if_octets: 6487548454 } egress_stats { if_packets: 87416547 if_octets: 9266153982 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.0" init_time: 1477642750 snmp_if_index: 2512 ingress_stats { if_packets: 26266247 if_octets: 2784214806 } egress_stats { if_packets: 26247215 if_octets: 2781829290 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.1" init_time: 1477642750 snmp_if_index: 2522 ingress_stats { if_packets: 26266249 if_octets: 2784214972 } egress_stats { if_packets: 26249115 if_octets: 2781935590 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.2" init_time: 1477642750 snmp_if_index: 2523 ingress_stats { if_packets: 26266248 if_octets: 2784214912 } egress_stats { if_packets: 26249106 if_octets: 2781935086 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.3" init_time: 1477642750 snmp_if_index: 2524 ingress_stats { if_packets: 26266248 if_octets: 2784214820 } egress_stats { if_packets: 26248520 if_octets: 2781902320 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.4" init_time: 1477642750 snmp_if_index: 2525 ingress_stats { if_packets: 26266247 if_octets: 2784214760 } egress_stats { if_packets: 26247302 if_octets: 2781834112 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.5" init_time: 1477642750 snmp_if_index: 2526 ingress_stats { if_packets: 26266247 if_octets: 2784214760 } egress_stats { if_packets: 26247209 if_octets: 2781828904 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.6" init_time: 1477642750 snmp_if_index: 2527 ingress_stats { if_packets: 26266248 if_octets: 2784214820 } egress_stats { if_packets: 26247196 if_octets: 2781828226 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.7" init_time: 1477642750 snmp_if_index: 2528 ingress_stats { if_packets: 26266247 if_octets: 2784214760 } egress_stats { if_packets: 26247203 if_octets: 2781828618 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.8" init_time: 1477642750 snmp_if_index: 2529 ingress_stats { if_packets: 26266247 if_octets: 2784214760 } egress_stats { if_packets: 26247225 if_octets: 2781829850 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.9" init_time: 1477642750 snmp_if_index: 2530 ingress_stats { if_packets: 26266247 if_octets: 2784214760 } egress_stats { if_packets: 26247209 if_octets: 2781828954 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.32767" init_time: 1477642750 snmp_if_index: 648 ingress_stats { if_packets: 4 if_octets: 240 } egress_stats { if_packets: 0 if_octets: 0 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/4:2.32767" init_time: 1477642750 snmp_if_index: 813 parent_ae_name: "ae1.32767" ingress_stats { if_packets: 0 if_octets: 0 } egress_stats { if_packets: 0 if_octets: 0 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/7:3.0" init_time: 1477642750 snmp_if_index: 520 parent_ae_name: "ae0.0" ingress_stats { if_packets: 61206122 if_octets: 6487846632 } egress_stats { if_packets: 87420567 if_octets: 9266580102 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.0" init_time: 1477642750 snmp_if_index: 2512 ingress_stats { if_packets: 26267458 if_octets: 2784343172 } egress_stats { if_packets: 26248420 if_octets: 2781957020 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.1" init_time: 1477642750 snmp_if_index: 2522 ingress_stats { if_packets: 26267460 if_octets: 2784343338 } egress_stats { if_packets: 26250320 if_octets: 2782063320 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.2" init_time: 1477642750 snmp_if_index: 2523 ingress_stats { if_packets: 26267459 if_octets: 2784343278 } egress_stats { if_packets: 26250311 if_octets: 2782062816 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.3" init_time: 1477642750 snmp_if_index: 2524 ingress_stats { if_packets: 26267460 if_octets: 2784343292 } egress_stats { if_packets: 26249725 if_octets: 2782030050 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.4" init_time: 1477642750 snmp_if_index: 2525 ingress_stats { if_packets: 26267459 if_octets: 2784343232 } egress_stats { if_packets: 26248507 if_octets: 2781961842 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.5" init_time: 1477642750 snmp_if_index: 2526 ingress_stats { if_packets: 26267459 if_octets: 2784343232 } egress_stats { if_packets: 26248414 if_octets: 2781956634 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.6" init_time: 1477642750 snmp_if_index: 2527 ingress_stats { if_packets: 26267460 if_octets: 2784343292 } egress_stats { if_packets: 26248401 if_octets: 2781955956 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.7" init_time: 1477642750 snmp_if_index: 2528 ingress_stats { if_packets: 26267459 if_octets: 2784343232 } egress_stats { if_packets: 26248408 if_octets: 2781956348 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.8" init_time: 1477642750 snmp_if_index: 2529 ingress_stats { if_packets: 26267459 if_octets: 2784343232 } egress_stats { if_packets: 26248430 if_octets: 2781957580 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.9" init_time: 1477642750 snmp_if_index: 2530 ingress_stats { if_packets: 26267459 if_octets: 2784343232 } egress_stats { if_packets: 26248414 if_octets: 2781956684 } op_state { operational_status: "up" } } interface_info { if_name: "et-0/0/13:0.32767" init_time: 1477642750 snmp_if_index: 648 ingress_stats { if_packets: 4 if_octets: 240 } egress_stats { if_packets: 0 if_octets: 0 } op_state { operational_status: "up" } } } } }
Decoding Junos Telemetry Interface UDP Data at the Collector
The collector must start a listener on the remote address or port combination to read the incoming data. The incoming data can be decoded using the telemetry_top.proto and the sensor proto files.
To simplify the decoding procedure, the collectors can load all the proto files shipped as part of the Telemetry Software package to decode the incoming data.
- Verify streaming data on both management and WAN interfaces. Specify the appropriate address in the streaming server profile.
- Enums and float are streamed as strings for UDP streaming. Enums will be retained as strings as gNMI uses the same format.
- The handling of float data type is scoped for a future release.
When telemetry data is streamed over UDP, ensure that data is decoded correctly, and unknown fields are not decoded at the collector.
Below are some issues observed while streaming telemetry data over UDP:
- Incorrect Decoding: Incorrect decoding implies that telemetry data is not
correctly streamed over UDP. In the following example, the data highlighted in bold
indicates that the data was not decoded correctly. This behaviour is either due to
incorrect encoding or wrong proto file packaging.
system_id: "r02.dtw01.icn" component_id: 65535 sensor_name: "mpls:/network-instances/network-instance/mpls:/network-instances/network-instance/mpls:rpd" sequence_number: 2421 timestamp: 1715024560793 version_major: 1 version_minor: 0 enterprise: { [juniperNetworks]: { [jnpr_network_instances_rsvp_ext]: { network_instance: { name: "master" mpls: { 153 { 151 { 152{ 151{ 51: "r02.dtw01.icn-r01.bos02.icn-01" 152{ 151{ 51: "AUTO" 52: 0 53: 12873154 } 152{ 151{ 51:1 52:200000 53: 0 54: 300 55: 1 61: 1549061 } 152 {Below is the example of the data being decoded correctly:
system_id: "r0-RE0" component_id: 65535 sub_component_id: 0 sensor_name: "test_chassisd:/network-instances/:/network-instances/:rpd" sequence_number: 0 timestamp: 1719126223900 version_major: 1 version_minor: 0 enterprise { [juniperNetworks] { [jnpr_network_instances_ni_226_ext] { network_instance { name: "DEFAULT" protocols { protocol { identifier: "STATIC" name: "DEFAULT" static_routes { static { prefix: "10.0.0.0/8" state { prefix: "10.0.0.0/8" set_tag: "0" } next_hops { next_hop { index: "1" state { index: "1" next_hop: "10.220.127.254" metric: 0 recurse: false } interface_ref { state { interface: "re0:mgmt-0" subinterface: 0 } } } } } - Incomplete data streaming: Streaming of incomplete data must be verified through data validation in the output file.