Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 2.75 KB

telegraf-gnmi.md

File metadata and controls

87 lines (64 loc) · 2.75 KB

Telegraf with gNMI plugin

Telegraf supports Subscribe RPC.

  1. Install influxdb, telegraf and chronograf
  2. Run influxdb and chronograf (they may have a service file)
  3. Run telegraf
  4. Open your browser on <machine IP>:8888 to have chronograf web page.

Create your telegraf configuration:

This configuration file allows you to define measurement name. It is clever to put as measurement name the xpath you are subscribing to if you want to know what you are receiving.

[[inputs.cisco_telemetry_gnmi]]
  ## Address and port of the GNMI GRPC server
  addresses = ["localhost:50051"]

  ## define credentials
  # username = "cisco"
  # password = "cisco"

  ## GNMI encoding requested (one of: "proto", "json", "json_ietf")
  encoding = "json_ietf"

  ## redial in case of failures after
  redial = "10s"

  ## enable client-side TLS and define CA to authenticate the device
  # enable_tls = true
  # tls_ca = "/etc/telegraf/ca.pem"
  # insecure_skip_verify = true

  ## define client-side TLS certificate & key to authenticate to the device
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## GNMI subscription prefix (optional, can usually be left empty)
  ## See: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#222-paths
  # origin = ""
  # prefix = ""
  # target = ""

  ## Define additional aliases to map telemetry encoding paths to simple measurement names
  # [inputs.cisco_telemetry_gnmi.aliases]
  #   ifcounters = "openconfig:/interfaces/interface/state/counters"

  [[inputs.cisco_telemetry_gnmi.subscription]]
    ## Name of the measurement that will be emitted
    name = "/ietf-interfaces:interfaces-state/interface"

    ## Origin and path of the subscription
    ## See: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#222-paths
    ##
    ## origin usually refers to a (YANG) data model implemented by the device
    ## and path to a specific substructe inside it that should be subscribed to (similar to an XPath)
    ## YANG models can be found e.g. here: https://github.com/YangModels/yang/tree/master/vendor/cisco/xr
    origin = "ietf-interfaces"
    path = "/interfaces-state/interface"

    # Subscription mode (one of: "target_defined", "sample", "on_change") and interval
    subscription_mode = "sample"
    sample_interval = "10s"

    ## Suppress redundant transmissions when measured values are unchanged
    # suppress_redundant = false

    ## If suppression is enabled, send updates at least every X seconds anyway
    # heartbeat_interval = "60s"

[[outputs.file]]
  files = ["stdout"]

[[outputs.influxdb]]
  url = "http://localhost:8086"
  database = "telemetry"
  precision = "s"

Run telegraf

telegraf --config telegraf.conf