2020-08-12 04:10:41 +08:00
|
|
|
# gNMI (gRPC Network Management Interface) Input Plugin
|
2019-06-05 05:39:46 +08:00
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
This plugin consumes telemetry data based on the [gNMI][1] Subscribe method. TLS
|
|
|
|
|
is supported for authentication and encryption. This input plugin is
|
|
|
|
|
vendor-agnostic and is supported on any platform that supports the gNMI spec.
|
2019-06-05 05:39:46 +08:00
|
|
|
|
2021-11-25 02:56:55 +08:00
|
|
|
For Cisco devices:
|
2019-06-05 05:39:46 +08:00
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
It has been optimized to support gNMI telemetry as produced by Cisco IOS XR
|
|
|
|
|
(64-bit) version 6.5.1, Cisco NX-OS 9.3 and Cisco IOS XE 16.12 and later.
|
|
|
|
|
|
|
|
|
|
[1]: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md
|
2019-06-05 05:39:46 +08:00
|
|
|
|
2023-07-10 22:33:52 +08:00
|
|
|
Please check the [troubleshooting section](#troubleshooting) in case of
|
|
|
|
|
problems, e.g. when getting an *empty metric-name warning*!
|
|
|
|
|
|
2023-03-27 20:12:35 +08:00
|
|
|
## Service Input <!-- @/docs/includes/service_input.md -->
|
|
|
|
|
|
|
|
|
|
This plugin is a service input. Normal plugins gather metrics determined by the
|
|
|
|
|
interval setting. Service plugins start a service to listens and waits for
|
|
|
|
|
metrics or events to occur. Service plugins have two key differences from
|
|
|
|
|
normal plugins:
|
|
|
|
|
|
|
|
|
|
1. The global or plugin specific `interval` setting may not apply
|
|
|
|
|
2. The CLI options of `--test`, `--test-wait`, and `--once` may not produce
|
|
|
|
|
output for this plugin
|
|
|
|
|
|
2022-10-27 03:58:36 +08:00
|
|
|
## Global configuration options <!-- @/docs/includes/plugin_config.md -->
|
|
|
|
|
|
|
|
|
|
In addition to the plugin-specific configuration settings, plugins support
|
|
|
|
|
additional global and plugin configuration settings. These settings are used to
|
|
|
|
|
modify metrics, tags, and field or create aliases and configure ordering, etc.
|
|
|
|
|
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|
|
|
|
|
2023-01-12 23:55:21 +08:00
|
|
|
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins
|
2022-10-27 03:58:36 +08:00
|
|
|
|
2021-11-25 02:56:55 +08:00
|
|
|
## Configuration
|
2019-06-05 05:39:46 +08:00
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
```toml @sample.conf
|
2022-04-08 06:01:21 +08:00
|
|
|
# gNMI telemetry input plugin
|
2020-07-01 14:19:16 +08:00
|
|
|
[[inputs.gnmi]]
|
|
|
|
|
## Address and port of the gNMI GRPC server
|
2019-06-05 05:39:46 +08:00
|
|
|
addresses = ["10.49.234.114:57777"]
|
|
|
|
|
|
|
|
|
|
## define credentials
|
|
|
|
|
username = "cisco"
|
|
|
|
|
password = "cisco"
|
|
|
|
|
|
2020-11-03 00:11:28 +08:00
|
|
|
## gNMI encoding requested (one of: "proto", "json", "json_ietf", "bytes")
|
2019-06-05 05:39:46 +08:00
|
|
|
# encoding = "proto"
|
|
|
|
|
|
|
|
|
|
## redial in case of failures after
|
2023-01-27 17:11:29 +08:00
|
|
|
# redial = "10s"
|
|
|
|
|
|
|
|
|
|
## gRPC Maximum Message Size
|
|
|
|
|
# max_msg_size = "4MB"
|
2019-06-05 05:39:46 +08:00
|
|
|
|
2023-05-24 22:14:06 +08:00
|
|
|
## Enable to get the canonical path as field-name
|
|
|
|
|
# canonical_field_names = false
|
|
|
|
|
|
2023-07-06 17:20:11 +08:00
|
|
|
## Remove leading slashes and dots in field-name
|
|
|
|
|
# trim_field_names = false
|
|
|
|
|
|
2023-11-01 00:51:05 +08:00
|
|
|
## Guess the path-tag if an update does not contain a prefix-path
|
|
|
|
|
## If enabled, the common-path of all elements in the update is used.
|
|
|
|
|
# guess_path_tag = false
|
|
|
|
|
|
2019-06-05 05:39:46 +08:00
|
|
|
## enable client-side TLS and define CA to authenticate the device
|
2022-10-05 16:07:28 +08:00
|
|
|
# enable_tls = false
|
2019-06-05 05:39:46 +08:00
|
|
|
# tls_ca = "/etc/telegraf/ca.pem"
|
2022-08-09 19:36:47 +08:00
|
|
|
## Minimal TLS version to accept by the client
|
|
|
|
|
# tls_min_version = "TLS12"
|
|
|
|
|
## Use TLS but skip chain & host verification
|
2019-06-05 05:39:46 +08:00
|
|
|
# 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"
|
|
|
|
|
|
2020-07-01 14:19:16 +08:00
|
|
|
## gNMI subscription prefix (optional, can usually be left empty)
|
2019-06-05 05:39:46 +08:00
|
|
|
## See: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#222-paths
|
|
|
|
|
# origin = ""
|
|
|
|
|
# prefix = ""
|
|
|
|
|
# target = ""
|
|
|
|
|
|
2023-04-27 23:30:21 +08:00
|
|
|
## Vendor specific options
|
|
|
|
|
## This defines what vendor specific options to load.
|
|
|
|
|
## * Juniper Header Extension (juniper_header): some sensors are directly managed by
|
|
|
|
|
## Linecard, which adds the Juniper GNMI Header Extension. Enabling this
|
|
|
|
|
## allows the decoding of the Extension header if present. Currently this knob
|
2023-11-29 21:47:39 +08:00
|
|
|
## adds component, component_id & sub_component_id as additional tags
|
2023-04-27 23:30:21 +08:00
|
|
|
# vendor_specific = []
|
|
|
|
|
|
2023-01-10 03:35:13 +08:00
|
|
|
## Define additional aliases to map encoding paths to measurement names
|
2020-07-01 14:19:16 +08:00
|
|
|
# [inputs.gnmi.aliases]
|
2019-06-05 05:39:46 +08:00
|
|
|
# ifcounters = "openconfig:/interfaces/interface/state/counters"
|
|
|
|
|
|
2020-07-01 14:19:16 +08:00
|
|
|
[[inputs.gnmi.subscription]]
|
2019-06-05 05:39:46 +08:00
|
|
|
## Name of the measurement that will be emitted
|
|
|
|
|
name = "ifcounters"
|
|
|
|
|
|
|
|
|
|
## 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
|
2023-01-10 03:35:13 +08:00
|
|
|
## and path to a specific substructure 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
|
2022-07-13 02:59:00 +08:00
|
|
|
origin = "openconfig-interfaces"
|
2019-06-05 05:39:46 +08:00
|
|
|
path = "/interfaces/interface/state/counters"
|
|
|
|
|
|
2023-01-10 03:35:13 +08:00
|
|
|
## Subscription mode ("target_defined", "sample", "on_change") and interval
|
2019-06-05 05:39:46 +08:00
|
|
|
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"
|
2022-02-07 23:18:53 +08:00
|
|
|
|
2023-01-10 03:35:13 +08:00
|
|
|
## Tag subscriptions are applied as tags to other subscriptions.
|
|
|
|
|
# [[inputs.gnmi.tag_subscription]]
|
|
|
|
|
# ## When applying this value as a tag to other metrics, use this tag name
|
|
|
|
|
# name = "descr"
|
2023-02-09 02:30:05 +08:00
|
|
|
#
|
2023-01-10 03:35:13 +08:00
|
|
|
# ## All other subscription fields are as normal
|
|
|
|
|
# origin = "openconfig-interfaces"
|
|
|
|
|
# path = "/interfaces/interface/state"
|
|
|
|
|
# subscription_mode = "on_change"
|
2023-02-09 02:30:05 +08:00
|
|
|
#
|
|
|
|
|
# ## Match strategy to use for the tag.
|
|
|
|
|
# ## Tags are only applied for metrics of the same address. The following
|
|
|
|
|
# ## settings are valid:
|
|
|
|
|
# ## unconditional -- always match
|
|
|
|
|
# ## name -- match by the "name" key
|
|
|
|
|
# ## This resembles the previsou 'tag-only' behavior.
|
|
|
|
|
# ## elements -- match by the keys in the path filtered by the path
|
|
|
|
|
# ## parts specified `elements` below
|
|
|
|
|
# ## By default, 'elements' is used if the 'elements' option is provided,
|
|
|
|
|
# ## otherwise match by 'name'.
|
|
|
|
|
# # match = ""
|
|
|
|
|
#
|
|
|
|
|
# ## For the 'elements' match strategy, at least one path-element name must
|
|
|
|
|
# ## be supplied containing at least one key to match on. Multiple path
|
|
|
|
|
# ## elements can be specified in any order. All given keys must be equal
|
|
|
|
|
# ## for a match.
|
|
|
|
|
# # elements = ["description", "interface"]
|
2019-06-05 05:39:46 +08:00
|
|
|
```
|
|
|
|
|
|
2022-07-08 05:06:44 +08:00
|
|
|
## Metrics
|
|
|
|
|
|
|
|
|
|
Each configured subscription will emit a different measurement. Each leaf in a
|
|
|
|
|
GNMI SubscribeResponse Update message will produce a field reading in the
|
|
|
|
|
measurement. GNMI PathElement keys for leaves will attach tags to the field(s).
|
|
|
|
|
|
2021-11-25 02:56:55 +08:00
|
|
|
## Example Output
|
|
|
|
|
|
2023-04-04 19:43:49 +08:00
|
|
|
```text
|
2022-02-07 23:18:53 +08:00
|
|
|
ifcounters,path=openconfig-interfaces:/interfaces/interface/state/counters,host=linux,name=MgmtEth0/RP0/CPU0/0,source=10.49.234.115,descr/description=Foo in-multicast-pkts=0i,out-multicast-pkts=0i,out-errors=0i,out-discards=0i,in-broadcast-pkts=0i,out-broadcast-pkts=0i,in-discards=0i,in-unknown-protos=0i,in-errors=0i,out-unicast-pkts=0i,in-octets=0i,out-octets=0i,last-clear="2019-05-22T16:53:21Z",in-unicast-pkts=0i 1559145777425000000
|
|
|
|
|
ifcounters,path=openconfig-interfaces:/interfaces/interface/state/counters,host=linux,name=GigabitEthernet0/0/0/0,source=10.49.234.115,descr/description=Bar out-multicast-pkts=0i,out-broadcast-pkts=0i,in-errors=0i,out-errors=0i,in-discards=0i,out-octets=0i,in-unknown-protos=0i,in-unicast-pkts=0i,in-octets=0i,in-multicast-pkts=0i,in-broadcast-pkts=0i,last-clear="2019-05-22T16:54:50Z",out-unicast-pkts=0i,out-discards=0i 1559145777425000000
|
2019-06-05 05:39:46 +08:00
|
|
|
```
|
2023-07-10 22:33:52 +08:00
|
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
|
|
|
|
|
Some devices (e.g. Juniper) report spurious data with response paths not
|
|
|
|
|
corresponding to any subscription. In those cases, Telegraf will not be able
|
|
|
|
|
to determine the metric name for the response and you get an
|
|
|
|
|
*empty metric-name warning*
|
|
|
|
|
|
|
|
|
|
For examplem if you subscribe to `/junos/system/linecard/cpu/memory` but the
|
|
|
|
|
corresponding response arrives with path
|
|
|
|
|
`/components/component/properties/property/...` To avoid those issues, you can
|
|
|
|
|
manually map the response to a metric name using the `aliases` option like
|
|
|
|
|
|
|
|
|
|
```toml
|
|
|
|
|
[[inputs.gnmi]]
|
|
|
|
|
addresses = ["..."]
|
|
|
|
|
|
|
|
|
|
[inputs.gnmi.aliases]
|
|
|
|
|
memory = "/components"
|
|
|
|
|
|
|
|
|
|
[[inputs.gnmi.subscription]]
|
|
|
|
|
name = "memory"
|
|
|
|
|
origin = "openconfig"
|
|
|
|
|
path = "/junos/system/linecard/cpu/memory"
|
|
|
|
|
subscription_mode = "sample"
|
|
|
|
|
sample_interval = "60s"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
If this does *not* solve the issue, please follow the warning instructions and
|
|
|
|
|
open an issue with the response, your configuration and the metric you expect.
|