diff --git a/plugins/inputs/gnmi/gnmi.go b/plugins/inputs/gnmi/gnmi.go index 1adef4dae..a3170b2ba 100644 --- a/plugins/inputs/gnmi/gnmi.go +++ b/plugins/inputs/gnmi/gnmi.go @@ -27,10 +27,10 @@ import ( var sampleConfig string // Define the warning to show if we cannot get a metric name. -const emptyNameWarning = `Got empty metric-name for response, usually indicating -configuration issues as the response cannot be related to any subscription. -Please open an issue on https://github.com/influxdata/telegraf including your -device model and the following response data: +const emptyNameWarning = `Got empty metric-name for response (field %q), usually +indicating configuration issues as the response cannot be related to any +subscription.Please open an issue on https://github.com/influxdata/telegraf +including your device model and the following response data: %+v This message is only printed once.` diff --git a/plugins/inputs/gnmi/handler.go b/plugins/inputs/gnmi/handler.go index 51a9aa227..e7da9c413 100644 --- a/plugins/inputs/gnmi/handler.go +++ b/plugins/inputs/gnmi/handler.go @@ -3,6 +3,7 @@ package gnmi import ( "context" "crypto/tls" + "encoding/json" "errors" "fmt" "io" @@ -237,7 +238,11 @@ func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, respon if name == "" { h.log.Debugf("No measurement alias for gNMI path: %s", field.path) if !h.emptyNameWarnShown { - h.log.Warnf(emptyNameWarning, response.Update) + if buf, err := json.Marshal(response); err == nil { + h.log.Warnf(emptyNameWarning, field.path, string(buf)) + } else { + h.log.Warnf(emptyNameWarning, field.path, response.Update) + } h.emptyNameWarnShown = true } }