Fix inconsistency with input error counting (#7077)
This commit is contained in:
@@ -7,7 +7,10 @@ import (
|
||||
"github.com/influxdata/telegraf/selfstat"
|
||||
)
|
||||
|
||||
var GlobalMetricsGathered = selfstat.Register("agent", "metrics_gathered", map[string]string{})
|
||||
var (
|
||||
GlobalMetricsGathered = selfstat.Register("agent", "metrics_gathered", map[string]string{})
|
||||
GlobalGatherErrors = selfstat.Register("agent", "gather_errors", map[string]string{})
|
||||
)
|
||||
|
||||
type RunningInput struct {
|
||||
Input telegraf.Input
|
||||
@@ -26,10 +29,12 @@ func NewRunningInput(input telegraf.Input, config *InputConfig) *RunningInput {
|
||||
tags["alias"] = config.Alias
|
||||
}
|
||||
|
||||
logger := &Logger{
|
||||
Name: logName("inputs", config.Name, config.Alias),
|
||||
Errs: selfstat.Register("gather", "errors", tags),
|
||||
}
|
||||
inputErrorsRegister := selfstat.Register("gather", "errors", tags)
|
||||
logger := NewLogger("inputs", config.Name, config.Alias)
|
||||
logger.OnErr(func() {
|
||||
inputErrorsRegister.Incr(1)
|
||||
GlobalGatherErrors.Incr(1)
|
||||
})
|
||||
setLogIfExist(input, logger)
|
||||
|
||||
return &RunningInput{
|
||||
@@ -116,3 +121,7 @@ func (r *RunningInput) Gather(acc telegraf.Accumulator) error {
|
||||
func (r *RunningInput) SetDefaultTags(tags map[string]string) {
|
||||
r.defaultTags = tags
|
||||
}
|
||||
|
||||
func (r *RunningInput) Log() telegraf.Logger {
|
||||
return r.log
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user