beats: github.com/elastic/beats/libbeat/common/docker Index | Files

package docker

import "github.com/elastic/beats/libbeat/common/docker"

Index

Package Files

client.go helpers.go watcher.go

func DeDotLabels Uses

func DeDotLabels(labels map[string]string, dedot bool) common.MapStr

DeDotLabels returns a new common.MapStr containing a copy of the labels where the dots have been converted into nested structure, avoiding possible mapping errors

func ExtractContainerName Uses

func ExtractContainerName(names []string) string

ExtractContainerName strips the `/` characters that frequently appear in container names

func NewClient Uses

func NewClient(host string, httpClient *http.Client, httpHeaders map[string]string) (*client.Client, error)

NewClient builds and returns a new Docker client. On the first request the client will negotiate the API version with the server unless DOCKER_API_VERSION is set in the environment.

type Client Uses

type Client interface {
    ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
    ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
    Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
}

Client for docker interface

type Container Uses

type Container struct {
    ID          string
    Name        string
    Image       string
    Labels      map[string]string
    IPAddresses []string
    Ports       []types.Port
}

Container info retrieved by the watcher

type TLSConfig Uses

type TLSConfig struct {
    CA          string `config:"certificate_authority"`
    Certificate string `config:"certificate"`
    Key         string `config:"key"`
}

TLSConfig for docker socket connection

type Watcher Uses

type Watcher interface {
    // Start watching docker API for new containers
    Start() error

    // Stop watching docker API for new containers
    Stop()

    // Container returns the running container with the given ID or nil if unknown
    Container(ID string) *Container

    // Containers returns the list of known containers
    Containers() map[string]*Container

    // ListenStart returns a bus listener to receive container started events, with a `container` key holding it
    ListenStart() bus.Listener

    // ListenStop returns a bus listener to receive container stopped events, with a `container` key holding it
    ListenStop() bus.Listener
}

Watcher reads docker events and keeps a list of known containers

func NewWatcher Uses

func NewWatcher(log *logp.Logger, host string, tls *TLSConfig, storeShortID bool) (Watcher, error)

NewWatcher returns a watcher running for the given settings

func NewWatcherWithClient Uses

func NewWatcherWithClient(log *logp.Logger, client Client, cleanupTimeout time.Duration, storeShortID bool) (Watcher, error)

NewWatcherWithClient creates a new Watcher from a given Docker client

type WatcherConstructor Uses

type WatcherConstructor func(logp *logp.Logger, host string, tls *TLSConfig, storeShortID bool) (Watcher, error)

WatcherConstructor represent a function that creates a new Watcher from giving parameters

Package docker imports 16 packages (graph) and is imported by 95 packages. Updated 2020-03-16. Refresh now. Tools for package owners.