Document and add support to input plugins for logging alias (#6357)

This commit is contained in:
Greg
2019-09-23 16:39:50 -06:00
committed by Daniel Nelson
parent e42d2e39c6
commit 817c9a69a9
111 changed files with 961 additions and 659 deletions

View File

@@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"regexp"
"strconv"
@@ -45,6 +44,8 @@ type Docker struct {
ContainerStateInclude []string `toml:"container_state_include"`
ContainerStateExclude []string `toml:"container_state_exclude"`
Log telegraf.Logger
tlsint.ClientConfig
newEnvClient func() (Client, error)
@@ -107,8 +108,10 @@ var sampleConfig = `
## Whether to report for each container per-device blkio (8:0, 8:1...) and
## network (eth0, eth1, ...) stats or not
perdevice = true
## Whether to report for each container total blkio and network stats or not
total = false
## Which environment variables should we use as a tag
##tag_env = ["JAVA_HOME", "HEAP_SIZE"]
@@ -274,7 +277,7 @@ func (d *Docker) gatherSwarmInfo(acc telegraf.Accumulator) error {
fields["tasks_running"] = running[service.ID]
fields["tasks_desired"] = tasksNoShutdown[service.ID]
} else {
log.Printf("E! Unknow Replicas Mode")
d.Log.Error("Unknown replica mode")
}
// Add metrics
acc.AddFields("docker_swarm",

View File

@@ -252,6 +252,7 @@ func TestDocker_WindowsMemoryContainerStats(t *testing.T) {
var acc testutil.Accumulator
d := Docker{
Log: testutil.Logger{},
newClient: func(string, *tls.Config) (Client, error) {
return &MockClient{
InfoF: func(ctx context.Context) (types.Info, error) {
@@ -390,6 +391,7 @@ func TestContainerLabels(t *testing.T) {
}
d := Docker{
Log: testutil.Logger{},
newClient: newClientFunc,
LabelInclude: tt.include,
LabelExclude: tt.exclude,
@@ -511,6 +513,7 @@ func TestContainerNames(t *testing.T) {
}
d := Docker{
Log: testutil.Logger{},
newClient: newClientFunc,
ContainerInclude: tt.include,
ContainerExclude: tt.exclude,
@@ -625,7 +628,10 @@ func TestContainerStatus(t *testing.T) {
return &client, nil
}
d = Docker{newClient: newClientFunc}
d = Docker{
Log: testutil.Logger{},
newClient: newClientFunc,
}
)
// mock time
@@ -675,6 +681,7 @@ func TestContainerStatus(t *testing.T) {
func TestDockerGatherInfo(t *testing.T) {
var acc testutil.Accumulator
d := Docker{
Log: testutil.Logger{},
newClient: newClient,
TagEnvironment: []string{"ENVVAR1", "ENVVAR2", "ENVVAR3", "ENVVAR5",
"ENVVAR6", "ENVVAR7", "ENVVAR8", "ENVVAR9"},
@@ -824,6 +831,7 @@ func TestDockerGatherInfo(t *testing.T) {
func TestDockerGatherSwarmInfo(t *testing.T) {
var acc testutil.Accumulator
d := Docker{
Log: testutil.Logger{},
newClient: newClient,
}
@@ -931,6 +939,7 @@ func TestContainerStateFilter(t *testing.T) {
}
d := Docker{
Log: testutil.Logger{},
newClient: newClientFunc,
ContainerStateInclude: tt.include,
ContainerStateExclude: tt.exclude,
@@ -992,6 +1001,7 @@ func TestContainerName(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
d := Docker{
Log: testutil.Logger{},
newClient: tt.clientFunc,
}
var acc testutil.Accumulator