Documentation
¶
Index ¶
- func ContainerEnvToMap(env []string) map[string]string
- func MustNewAPIVersion(version string) string
- func NewAPIVersion(version string) (string, error)
- func VersionIsValidAndGTE(version, gte string) error
- type Client
- func (dc *Client) ContainerEventLoop(ctx context.Context)
- func (dc *Client) Containers() []Container
- func (dc *Client) Events(ctx context.Context, options dtypes.EventsOptions) (<-chan devents.Message, <-chan error)
- func (dc *Client) FetchContainerStats(ctx context.Context, container Container) (dtypes.ContainerStats, error)
- func (dc *Client) FetchContainerStatsAsJSON(ctx context.Context, container Container) (*dtypes.StatsJSON, error)
- func (dc *Client) InspectAndPersistContainer(ctx context.Context, cid string) (*dtypes.ContainerJSON, bool)
- func (dc *Client) LoadContainerList(ctx context.Context) error
- func (dc *Client) RemoveContainer(cid string)
- type Config
- type Container
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerEnvToMap ¶
func MustNewAPIVersion ¶ added in v0.93.0
MustNewAPIVersion evaluates version as a client api version and panics if invalid.
func NewAPIVersion ¶ added in v0.93.0
func VersionIsValidAndGTE ¶ added in v0.93.0
VersionIsValidAndGTE evalutes version as a client api version and returns an error if invalid or less than gte. gte is assumed to be valid (easiest if result of MustNewAPIVersion on initialization)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the core metric gathering functionality from the Docker Daemon. It retrieves container information in two forms to produce metric data: dtypes.ContainerJSON from client.ContainerInspect() for container information (id, name, hostname, labels, and env) and dtypes.StatsJSON from client.ContainerStats() for metric values.
func NewDockerClient ¶
func (*Client) ContainerEventLoop ¶
func (*Client) Containers ¶
Containers provides a slice of Container to use for individual FetchContainerStats calls.
func (*Client) Events ¶ added in v0.39.0
func (dc *Client) Events(ctx context.Context, options dtypes.EventsOptions) (<-chan devents.Message, <-chan error)
Events exposes the underlying Docker clients Events channel. Caller should close the events channel by canceling the context. If an error occurs, processing stops and caller must reinvoke this method.
func (*Client) FetchContainerStats ¶
func (dc *Client) FetchContainerStats( ctx context.Context, container Container, ) (dtypes.ContainerStats, error)
FetchContainerStats will query the desired container stats and return them as ContainerStats
func (*Client) FetchContainerStatsAsJSON ¶
func (dc *Client) FetchContainerStatsAsJSON( ctx context.Context, container Container, ) (*dtypes.StatsJSON, error)
FetchContainerStatsAsJSON will query the desired container stats and return them as StatsJSON
func (*Client) InspectAndPersistContainer ¶ added in v0.39.0
func (dc *Client) InspectAndPersistContainer(ctx context.Context, cid string) (*dtypes.ContainerJSON, bool)
InspectAndPersistContainer queries inspect api and returns *ContainerJSON and true when container should be queried for stats, nil and false otherwise. Persists the container in the cache if container is running and not excluded.
func (*Client) LoadContainerList ¶
LoadContainerList will load the initial running container maps for inspection and establishing which containers warrant stat gathering calls by the receiver.
func (*Client) RemoveContainer ¶ added in v0.39.0
type Config ¶
type Config struct { // The URL of the docker server. Default is "unix:///var/run/docker.sock" // on non-Windows and "npipe:////./pipe/docker_engine" on Windows Endpoint string `mapstructure:"endpoint"` // The maximum amount of time to wait for docker API responses. Default is 5s Timeout time.Duration `mapstructure:"timeout"` // A list of filters whose matching images are to be excluded. Supports literals, globs, and regex. ExcludedImages []string `mapstructure:"excluded_images"` // Docker client API version. DockerAPIVersion string `mapstructure:"api_version"` }
func NewConfig ¶
func NewConfig(endpoint string, timeout time.Duration, excludedImages []string, apiVersion string) (*Config, error)
NewConfig creates a new config to be used when creating a docker client
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig creates a new config with default values to be used when creating a docker client