Topic: tech juniper jaut prev next
tech juniper jaut > Junos Platform Automation and DevOps (JAUT)
Telemetry refers to the process of sending data from a remote device to a central point. It is important in DevOps and NRE, as both these processes depend on feedback.
Traditional models such as SNMP imposes limits on network element scale and efficiency. JTI relies on an asynchronous push model which eliminates polling. The management station subscribes once. This makes the JTI highly scaleable, up to thousands of sensors per devices. It support high granularity, with reporting intervals down to two seconds. No additional licence is required.
Messages are structured using Google protocol buffer (gpb) and use a Juniper-defined open and extensible data model. Messages use UDP transport.
Alternatively, gRPC messages can be encapsulated in HTTP and optionally SSL.
The main different between using gpb over UDP and OpenConfig sensors using gRPC over TCP is that, in the latter, a network agent runs on the routing engine, which receives messages from the line card micro-kernels and forwards them to the application. In contrast, gpb over UDP bypasses the routing engine, allowing the line cards to send packets directly.
Sensors native to Junos provide granular information using a Juniper-defined data model. Messages are structured using protocol buffers (gpb) and encapsulated in UDP. Proto files are available from the Juniper website. They output data directly from the PFE (packet forwarding engine) components, bypassing the RE (routing engine). They are configured at the edit services analytics
hierarchy. They provide high performance, scale and granularity.
An example sensor;
services {
analytics {
streaming-server my-collector {
remote-address ...;
remote-port ...;
}
export-profile my-profile {
local-address ...;
reporting-rate 5;
format gpb;
transport udp;
}
sensor my-ifl-usage-sensor {
server-name my-collector;
export-name my-profile;
resource /junos/system/linecard/interface/logical/usage/;
resource-filter ge-*;
}
}
}
The sensor can be verified with ‘show agent sensors
’. Supported sensors can be found using the ‘?
’ as in ‘set services analytics sensor my-ifl-usage-sensor resource ?
’.
Install the protobuf tools;
apt-get install protobuf-compiler libprotobuf-dev
Capture packets using netcat;
nc -ul address port > ifl-data.gpb
Decode the raw telemetry data. Proto files are not required for this step, however, the proto files are generally needed to understand the meaning of the data.
protoc --decode_raw
To see the field names, download the JTI data model files and use the ‘protoc --decode
’ command. Provide paths to the JTI proto files and the Google gpb library.
Proto files can be downloaded from the Juniper website.
The ‘telemetry_top.proto
’ file in the archive defienes the top level TelemetryStream message used for all Juniper telemetry packets. Other .proto
files define specific telemetry messages. The ‘agent.proto
’ file is used by OpenConfig and gRPC sensors. Received telemetry messages align to the schema in the .proto
files.
Read the protocol buffers with the --decode
option. Provide the .proto
file to use, and include directories for protoc
to load other .proto
files as required;
protoc --decode TelemetryStream ./junos-telemetry-interface/logical_port.proto -I /usr/include/ -I ./junos-telemetry-interface < ifl-data.gpb
The Telemetry Sensor Explorer Tool provides information about the available sensors. The Junos Network Agent package provides a framework to support OpenConfig and JTI on a Junos device. It acts as a gateway between JTI and gRPC.
Enable gRPC over clear text, for lab use;
set system services extension-serevice request-response grpc clear-text
set system services extension-serevice request-response grpc clear-text port 50001
It is recommended to use SSL;
set system services extension-serevice request-response grpc ssl local-certificate ...
See Junos technical documentation to learn how to generate the certificate.
Compile the agent.proto
file into code files in the preferred programming language;
python -m grpc_tools.protoc -I junos-telemetry-interface/ --python-out=. junos-telemetry-interface/agent.proto
channel = grpc.insecure_channel(DEVICE + ":" + PORT)
auth_stub = LoginStub(channel)
login_request = LoginRequest(user_name=APP_USER, password=APP_PASSWORD, client_id=CLIENT_ID)
login_response = auth_stub.LoginCheck(login_request, APP_TIMEOUT)
if login_response.result is not True:
print("ErrorL gRPC connection failed" + login_response.result)
sys.exit(1)
telemetry_stub = OpenConfigTelemetryStub(channel)
path1 = Path(path=SENSOR_PATH, sample_frequency=SAMPLE_FREQUENCY_MS)
request = SubscriptionRequest(path_list=[path1])
print("Telemetry sensor data:")
for data in telemetry_stub.telemetrySubscribe(request, TIME_TO_WORK):
print(data)