28Jun

Junos Telemetry Interface (JTI) Ingest using Telegraf

There are multiple official products from Juniper that allow you to ingest Junos Telemetry Interface (JTI) data. However, I ran into couple of situations where I needed to do very quick testing of JTI without full product setup (due to licensing, test scale, and sometimes air gapped infra, etc.).

Telegraf is an extensible, open source server agent to help you collect metrics from your stacks, sensors, and systems. With telegraf, you can use inputs to ingest incoming data from plenty of data sources and formats including OpenTelemetry gRPC, and then redirect them to outputs like InfluxDB or Splunk. The good news is that there exists a plugin for parsing UDP-based Native JTI with telegraf, but unfortunately it is no longer maintained since over 4 years.

I created a fork of the plugin and merged it with telegraf v1.22, and got to a point where it does serve me well for my quick test cases. Here’s how to do quick Junos Telemetry Interface ingest testing using telegraf:

You can download the linux binary from Github releases page  (also accessible from project side bar), or you can compile from source for other platforms as explained on the README.

[root@tig ~]# wget -q https://github.com/rootameen/telegraf-jti-udp/releases/download/v1.22.0/telegraf-jtiudp-1.22.0_linux_amd64.tar.gz

[root@tig ~]# tar -xvf telegraf-jtiudp-1.22.0_linux_amd64.tar.gz
telegraf

Telegraf Config:

After downloading and extracting the binary, you need to create a config file to define your inputs and outputs. For simplicity, let’s define only JTI input, with output redirection to a file:

[root@tig ~]# cat telegraf.conf
[[inputs.socket_listener]]

service_address = "udp://:29000"
data_format = "juniperUDP"

[[outputs.file]]
files = ["telemetry.out"]

Finally, start the service by using the following;

[root@tig ~]# ./telegraf --config telegraf.conf
2022-06-28T11:59:42Z I! Starting Telegraf
2022-06-28T11:59:42Z I! Loaded inputs: socket_listener
2022-06-28T11:59:42Z I! Loaded aggregators:
2022-06-28T11:59:42Z I! Loaded processors:
2022-06-28T11:59:42Z I! Loaded outputs: file
2022-06-28T11:59:42Z I! Tags enabled: host=tig
2022-06-28T11:59:42Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"tig", Flush Interval:10s
2022-06-28T11:59:42Z I! [inputs.socket_listener] Listening on udp://[::]:29000
Junos Config:

Next, configure your Junos device to send telemetry data to this server. Here’s a sample config:

ameen@vmx01> show configuration services analytics | display set
set services analytics streaming-server tgraf-telemetry remote-address 192.168.100.87
set services analytics streaming-server tgraf-telemetry remote-port 29000
set services analytics export-profile tgraf local-address 192.168.100.170
set services analytics export-profile tgraf local-port 21112
set services analytics export-profile tgraf dscp 20
set services analytics export-profile tgraf reporting-rate 10
set services analytics export-profile tgraf format gpb
set services analytics export-profile tgraf transport udp
set services analytics sensor cpu-mem server-name tgraf-telemetry
set services analytics sensor cpu-mem export-name tgraf
set services analytics sensor cpu-mem resource /junos/system/linecard/cpu/memory/

 

If things go well, you should start seeing data in the file “telemetry.out” with JTI data.

juniperNetworks.cpu_memory_util_ext,_seq=35,device=vmx01:192.168.100.170,host=tig sensor_name="cpu_memory_util_ext",utilization.name="Kernel",utilization.applicationUtilization.allocations="124",utilization.applicationUtilization.bytesAllocated="8012",utilization.applicationUtilization.frees="10",utilization.applicationUtilization.name="features iif",utilization.bytesAllocated="168585960",utilization.size="536866792",utilization.utilization=31,utilization.applicationUtilization.allocationsFailed="0",device="vmx01:192.168.100.170" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=36,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.bytesAllocated="6896",utilization.name="Kernel",utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocations="118",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.frees="4",utilization.size="536866792",utilization.utilization=31,utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.name="features oif" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=37,device=vmx01:192.168.100.170,host=tig utilization.bytesAllocated="168585960",utilization.size="536866792",utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.bytesAllocated="1952",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.name="Kernel",utilization.applicationUtilization.allocations="42",utilization.utilization=31,utilization.applicationUtilization.name="features stream",utilization.applicationUtilization.frees="0" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=38,device=vmx01:192.168.100.170,host=tig utilization.utilization=31,utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocations="4",device="vmx01:192.168.100.170",utilization.applicationUtilization.frees="0",utilization.size="536866792",utilization.applicationUtilization.allocationsFailed="0",utilization.name="Kernel",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.name="features bd_e",utilization.applicationUtilization.bytesAllocated="200" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=39,device=vmx01:192.168.100.170,host=tig utilization.size="536866792",utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.frees="0",utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocations="16",utilization.utilization=31,utilization.applicationUtilization.name="features default",utilization.applicationUtilization.bytesAllocated="908",utilization.name="Kernel",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=40,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.frees="0",utilization.size="536866792",utilization.utilization=31,utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.name="table",utilization.name="Kernel",utilization.bytesAllocated="168585960",utilization.applicationUtilization.bytesAllocated="4646772",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.allocations="72809" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=41,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.name="hash",utilization.size="536866792",utilization.applicationUtilization.allocationsFailed="0",utilization.name="Kernel",utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocations="7",device="vmx01:192.168.100.170",utilization.applicationUtilization.bytesAllocated="1652",utilization.applicationUtilization.frees="0",utilization.utilization=31,sensor_name="cpu_memory_util_ext" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=42,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.allocations="1039",utilization.applicationUtilization.bytesAllocated="4042656",utilization.size="536866792",utilization.name="Kernel",utilization.bytesAllocated="168585960",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.frees="262",utilization.utilization=31,utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.name="counters" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=43,device=vmx01:192.168.100.170,host=tig device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.name="class",utilization.applicationUtilization.bytesAllocated="20400",utilization.utilization=31,utilization.applicationUtilization.allocations="136",utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.frees="0",utilization.size="536866792",utilization.name="Kernel" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=44,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.bytesAllocated="1584",utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocations="12",device="vmx01:192.168.100.170",utilization.applicationUtilization.frees="0",utilization.utilization=31,utilization.applicationUtilization.name="iftable",sensor_name="cpu_memory_util_ext",utilization.size="536866792",utilization.applicationUtilization.allocationsFailed="0",utilization.name="Kernel" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=45,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.frees="404",utilization.size="536866792",utilization.name="Kernel",utilization.bytesAllocated="168585960",device="vmx01:192.168.100.170",utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.name="ktree",utilization.applicationUtilization.bytesAllocated="36220",utilization.utilization=31,utilization.applicationUtilization.allocations="1199",sensor_name="cpu_memory_util_ext" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=46,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.bytesAllocated="928",utilization.applicationUtilization.frees="0",utilization.size="536866792",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.allocations="1",utilization.applicationUtilization.name="pppoe",utilization.utilization=31,utilization.applicationUtilization.allocationsFailed="0",utilization.bytesAllocated="168585960",utilization.name="Kernel" 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=47,device=vmx01:192.168.100.170,host=tig device="vmx01:192.168.100.170",utilization.applicationUtilization.bytesAllocated="56",utilization.applicationUtilization.frees="0",utilization.applicationUtilization.allocations="3",utilization.bytesAllocated="168585960",utilization.name="Kernel",sensor_name="cpu_memory_util_ext",utilization.applicationUtilization.allocationsFailed="0",utilization.applicationUtilization.name="inline ka",utilization.size="536866792",utilization.utilization=31 1656416880486000000
juniperNetworks.cpu_memory_util_ext,_seq=48,device=vmx01:192.168.100.170,host=tig utilization.applicationUtilization.name="mdi",utilization.applicationUtilization.frees="0",utilization.applicationUtilization.allocationsFailed="0",utilization.utilization=31,utilization.applicationUtilization.bytesAllocated="116",utilization.name="Kernel",utilization.bytesAllocated="168585960",utilization.applicationUtilization.allocations="1",device="vmx01:192.168.100.170",sensor_name="cpu_memory_util_ext",utilization.size="536866792" 1656416880486000000

That’s it! Data representation using InfluxDB UI or Grafana could be done. I also don’t have enough info about how the original plugin used to perform either. I left a few notes on the README if someone wants to pick that up.

Bonus: gRPC Config

For reference, here’s how to do gRPC using telegraf (officially supported, and works in parallel with JTI in the fork’s binary):

[[inputs.jti_openconfig_telemetry]]
  servers = ["vmx01:50051",
"vmx02:50051",
"172.10.10.54:50051"]

  ## Authentication details. Username and password are must if device expects
  ## authentication. Client ID must be unique when connecting from multiple instances
  ## of telegraf to the same device
  username = "admin"
  password = "grpc_test"
  client_id = "telegraf"

  ## Frequency to get data
  sample_frequency = "60000ms"

  ## Sensors to subscribe for
  ## A identifier for each sensor can be provided in path by separating with space
  ## Else sensor path will be used as identifier
  ## When identifier is used, we can provide a list of space separated sensors.
  ## A single subscription will be created with all these sensors and data will
  ## be saved to measurement with this identifier name

  sensors = [
      "/junos/system/cmerror/configuration",
      "/junos/system/cmerror/counters",
      "/junos/system/linecard/cpu/memory/",
      "/junos/system/linecard/npu/utilization",
      "/junos/system/linecard/interface/traffic/"
  ]

  ## Delay between retry attempts of failed RPC calls or streams. Defaults to 1000ms.
  ## Failed streams/calls will not be retried if 0 is provided
  retry_delay = "30000ms"

  ## To treat all string values as tags, set this to true
  str_as_tags = false
Share this Story

One comment

  1. Hi,
    thanks for you JTI UDP convertor
    i have a question.
    have you figured out when the “_seq” tag appears and what does it mean?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Written with love ♥