chore(inputs.gnmi): Add more response information for easier debugging (#15297)
This commit is contained in:
parent
d4367b6be4
commit
079f6a901e
|
|
@ -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.`
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue