fix(inputs.gnmi): Do not provide empty prefix for subscription request. (#12275)

This commit is contained in:
Sven Rebhan 2022-11-28 20:58:43 +01:00 committed by GitHub
parent c6dbc3f689
commit 54f4a3a38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -255,6 +255,12 @@ func (c *GNMI) newSubscribeRequest() (*gnmiLib.SubscribeRequest, error) {
return nil, err
}
// Do not provide an empty prefix. Required for Huawei NE40 router v8.21
// (and possibly others). See https://github.com/influxdata/telegraf/issues/12273.
if gnmiPath.Origin == "" && gnmiPath.Target == "" && len(gnmiPath.Elem) == 0 {
gnmiPath = nil
}
if c.Encoding != "proto" && c.Encoding != "json" && c.Encoding != "json_ietf" && c.Encoding != "bytes" {
return nil, fmt.Errorf("unsupported encoding %s", c.Encoding)
}