-
Notifications
You must be signed in to change notification settings - Fork 183
/
docker.go
54 lines (45 loc) · 1.83 KB
/
docker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// +build linux
package docker
//go:generate collectd-template-to-go docker.tmpl
import (
"github.com/signalfx/signalfx-agent/internal/core/config"
"github.com/signalfx/signalfx-agent/internal/monitors"
"github.com/signalfx/signalfx-agent/internal/monitors/collectd"
log "github.com/sirupsen/logrus"
)
const monitorType = "collectd/docker"
// MONITOR(collectd/docker): Pulls container stats from the Docker Engine. We
// strongly recommend using the
// [docker-container-stats](./docker-container-stats.md) monitor instead, as it
// will scale to large number of containers much better.
//
// See https://github.com/signalfx/docker-collectd-plugin.
func init() {
monitors.Register(monitorType, func() interface{} {
return &Monitor{
*collectd.NewMonitorCore(CollectdTemplate),
}
}, &Config{})
}
// Config is the monitor-specific config with the generic config embedded
type Config struct {
config.MonitorConfig
// A set of dimensions to add to container metrics (see
// https://github.com/signalfx/docker-collectd-plugin#extracting-additional-dimensions).
Dimensions map[string]string `yaml:"dimensions"`
// URL of the Docker engine, can be a unix socket path.
DockerURL string `yaml:"dockerURL" validate:"required"`
ExcludedImages []string `yaml:"excludedImages"`
ExcludedNames []string `yaml:"excludedNames"`
ExcludedLabels map[string]string `yaml:"excludedLabels"`
CollectNetworkStats bool `yaml:"collectNetworkStats"`
}
// Monitor is the main type that represents the monitor
type Monitor struct {
collectd.MonitorCore
}
// Configure configures and runs the plugin in collectd
func (rm *Monitor) Configure(conf *Config) error {
log.Warn("The collectd/docker monitor is deprecated in favor of the docker-container-stats monitor.")
return rm.SetConfigurationAndRun(conf)
}