github.com/influxdata/influxdb/v2@v2.7.6/telegraf/plugins/inputs/docker.go (about) 1 package inputs 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 // Docker is based on telegraf Docker plugin. 9 type Docker struct { 10 baseInput 11 Endpoint string `json:"endpoint"` 12 } 13 14 // PluginName is based on telegraf plugin name. 15 func (d *Docker) PluginName() string { 16 return "docker" 17 } 18 19 // UnmarshalTOML decodes the parsed data to the object 20 func (d *Docker) UnmarshalTOML(data interface{}) error { 21 dataOK, ok := data.(map[string]interface{}) 22 if !ok { 23 return errors.New("bad endpoint for docker input plugin") 24 } 25 if d.Endpoint, ok = dataOK["endpoint"].(string); !ok { 26 return errors.New("endpoint is not a string value") 27 } 28 return nil 29 } 30 31 // TOML encodes to toml string 32 func (d *Docker) TOML() string { 33 return fmt.Sprintf(`[[inputs.%s]] 34 ## Docker Endpoint 35 ## To use TCP, set endpoint = "tcp://[ip]:[port]" 36 ## To use environment variables (ie, docker-machine), set endpoint = "ENV" 37 endpoint = "%s" 38 # 39 ## Set to true to collect Swarm metrics(desired_replicas, running_replicas) 40 gather_services = false 41 # 42 ## Only collect metrics for these containers, collect all if empty 43 container_names = [] 44 # 45 ## Set the source tag for the metrics to the container ID hostname, eg first 12 chars 46 source_tag = false 47 # 48 ## Containers to include and exclude. Globs accepted. 49 ## Note that an empty array for both will include all containers 50 container_name_include = [] 51 container_name_exclude = [] 52 # 53 ## Container states to include and exclude. Globs accepted. 54 ## When empty only containers in the "running" state will be captured. 55 ## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] 56 ## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] 57 # container_state_include = [] 58 # container_state_exclude = [] 59 # 60 ## Timeout for docker list, info, and stats commands 61 timeout = "5s" 62 # 63 ## Whether to report for each container per-device blkio (8:0, 8:1...), 64 ## network (eth0, eth1, ...) and cpu (cpu0, cpu1, ...) stats or not. 65 ## Usage of this setting is discouraged since it will be deprecated in favor of 'perdevice_include'. 66 ## Default value is 'true' for backwards compatibility, please set it to 'false' so that 'perdevice_include' setting 67 ## is honored. 68 perdevice = true 69 # 70 ## Specifies for which classes a per-device metric should be issued 71 ## Possible values are 'cpu' (cpu0, cpu1, ...), 'blkio' (8:0, 8:1, ...) and 'network' (eth0, eth1, ...) 72 ## Please note that this setting has no effect if 'perdevice' is set to 'true' 73 # perdevice_include = ["cpu"] 74 # 75 ## Whether to report for each container total blkio and network stats or not. 76 ## Usage of this setting is discouraged since it will be deprecated in favor of 'total_include'. 77 ## Default value is 'false' for backwards compatibility, please set it to 'true' so that 'total_include' setting 78 ## is honored. 79 total = false 80 # 81 ## Specifies for which classes a total metric should be issued. Total is an aggregated of the 'perdevice' values. 82 ## Possible values are 'cpu', 'blkio' and 'network' 83 ## Total 'cpu' is reported directly by Docker daemon, and 'network' and 'blkio' totals are aggregated by this plugin. 84 ## Please note that this setting has no effect if 'total' is set to 'false' 85 # total_include = ["cpu", "blkio", "network"] 86 # 87 ## Which environment variables should we use as a tag 88 ##tag_env = ["JAVA_HOME", "HEAP_SIZE"] 89 # 90 ## docker labels to include and exclude as tags. Globs accepted. 91 ## Note that an empty array for both will include all labels as tags 92 docker_label_include = [] 93 docker_label_exclude = [] 94 # 95 ## Optional TLS Config 96 # tls_ca = "/etc/telegraf/ca.pem" 97 # tls_cert = "/etc/telegraf/cert.pem" 98 # tls_key = "/etc/telegraf/key.pem" 99 ## Use TLS but skip chain & host verification 100 # insecure_skip_verify = false 101 `, d.PluginName(), d.Endpoint) 102 }