Description

The following article describes an example of how to configure telemetry for gRPC(Junos Telemetry Interface or JTI) and gNMI with telegraf.

Symptoms

The telemetry configuration for gRPC or gNMI not working with Telegraf.

Solution

Configure the telemetry sensor and SSH:

set system services ssh
set system services extension-service request-response grpc clear-text address 10.0.0.2
set system services extension-service request-response grpc clear-text port 32767
set system services extension-service request-response grpc skip-authentication
set system services extension-service notification allow-clients address 10.0.0.1/32
 

Configure the ubuntu server. For this example, we are using the Telegraf server which can be installed as follows:

# echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
# sudo apt-get install influxdb
# sudo service influxdb start
 


This is the configuration file for Telegraf, and it is located under /etc/telegraf/telegraf.conf
- gRPC(JTI OpenConfig Telemetry)

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = "0s"
  hostname = ""

[[outputs.prometheus_client]]
   listen = ":9273"
   path = "/metrics"

[[inputs.jti_openconfig_telemetry]]
    servers = ["10.0.0.2:32767"] <<< Use switch IP.
    sample_frequency = "10000ms"
    username = "root" 
    password = "Juniper"
    client_id = "Switch"
    sensors = [
    "/junos/system/linecard/cpu/memory",
    "/junos/system/linecard/firewall/",
    "/junos/system/linecard/interface/",
    "/junos/system/linecard/interface/logical/usage",
    "/junos/system/linecard/packet/usage/",
    "/network-instances/network-instance[instance-name='name']/protocols/protocol/evpn/irb-interfaces/",
    "/interfaces/interface/state/",
    "/junos/system/linecard/environment",
    "/junos/system/linecard/optics/",
    ]
    collection_jitter = "0s"
    flush_interval = "15s"
    flush_jitter = "0s"
- gNMI
[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = "0s"
  hostname = ""

[[outputs.prometheus_client]]
   listen = ":9273"
   path = "/metrics"

[[inputs.gnmi]]
   addresses = ["10.0.0.2:32767"]    <<< Use switch IP.

   [[inputs.gnmi.subscription]]
      name = "ifcounters"
      origin = "openconfig-interfaces"
      path = "/interfaces/interface/state/counters"
      subscription_mode = "sample"
      sample_interval = "10s"

   [[inputs.gnmi.subscription]]
      name = "component"
      origin = "openconfig-system"
      path = "/components/component/state/name"
      subscription_mode = "sample"
      sample_interval = "10s"
*'outputs' may vary depending on the exporter who use.

Once this is configured, the interface in the VM is configured and reachability has been established, start the Telegraf server with:
root@ubuntu:/etc/telegraf# systemctl restart telegraf
root@ubuntu:/etc/telegraf# systemctl status telegraf
● telegraf.service - Telegraf
   Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2023-04-12 10:00:41 PDT; 5s ago
    Docs: https://github.com/influxdata/telegraf
  Main PID: 80274 (telegraf)
   Tasks: 7 (limit: 2237)
   Memory: 21.5M
    CPU: 159ms
   CGroup: /system.slice/telegraf.service
       └─80274 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Available plugins: 235 inputs, 9 aggregators, 27 processors, 22 parsers, 57 outputs, >
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Loaded inputs: jti_openconfig_telemetry
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Loaded aggregators:
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Loaded processors:
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Loaded secretstores:
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Loaded outputs: prometheus_client
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! Tags enabled: host=ubuntu
Apr 12 10:00:41 ubuntu systemd[1]: Started Telegraf.
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"ubuntu", Flush Interval:10s
Apr 12 10:00:41 ubuntu telegraf[80274]: 2023-04-12T17:00:41Z I! [outputs.prometheus_client] Listening on http://[::]:9273/metrics
To review the status of sensors, use the following, change the keyword "sensors" as needed:
root@ubuntu:/etc/telegraf# curl localhost:9273/metrics | grep optics
 

 

Modification History

2023-04-12: KB created.
2024-02-20: gNMI is added.

2025-04-15-updated link

Related Information

 

https://github.com/Juniper/yang/tree/master/23.4/23.4R1/openconfig/models
https://github.com/influxdata/telegraf/blob/master/plugins/inputs/jti_openconfig_telemetry/README.md
https://github.com/influxdata/telegraf/blob/master/plugins/inputs/gnmi/README.md