add_kubernetes_metadata

package
v6.2.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2018 License: Apache-2.0 Imports: 14 Imported by: 473

Documentation

Index

Constants

View Source
const (
	ContainerIndexerName = "container"
	PodNameIndexerName   = "pod_name"
	IPPortIndexerName    = "ip_port"
)
View Source
const (
	FieldMatcherName       = "fields"
	FieldFormatMatcherName = "field_format"
)

Variables

View Source
var Indexing = NewRegister()

Indexing is the singleton Register instance where all Indexers and Matchers are stored

Functions

func IndexerPlugin

func IndexerPlugin(name string, c IndexerConstructor) map[string][]interface{}

func MatcherPlugin

func MatcherPlugin(name string, m MatcherConstructor) map[string][]interface{}

Types

type ContainerIndexer

type ContainerIndexer struct {
	// contains filtered or unexported fields
}

ContainerIndexer indexes pods based on all their containers IDs

func (*ContainerIndexer) GetIndexes

func (c *ContainerIndexer) GetIndexes(pod *kubernetes.Pod) []string

GetIndexes returns the indexes for the given Pod

func (*ContainerIndexer) GetMetadata

func (c *ContainerIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex

GetMetadata returns the composed metadata list from all registered indexers

type Enabled

type Enabled struct {
	Enabled bool `config:"enabled"`
}

type FieldFormatMatcher

type FieldFormatMatcher struct {
	Codec codec.Codec
}

func (*FieldFormatMatcher) MetadataIndex

func (f *FieldFormatMatcher) MetadataIndex(event common.MapStr) string

type FieldMatcher

type FieldMatcher struct {
	MatchFields []string
}

func (*FieldMatcher) MetadataIndex

func (f *FieldMatcher) MetadataIndex(event common.MapStr) string

type IPPortIndexer

type IPPortIndexer struct {
	// contains filtered or unexported fields
}

IPPortIndexer indexes pods based on all their host:port combinations

func (*IPPortIndexer) GetIndexes

func (h *IPPortIndexer) GetIndexes(pod *kubernetes.Pod) []string

GetIndexes returns the indexes for the given Pod

func (*IPPortIndexer) GetMetadata

func (h *IPPortIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex

GetMetadata returns metadata for the given pod, if it matches the index

type Indexer

type Indexer interface {
	// GetMetadata generates event metadata for the given pod, then returns the
	// list of indexes to create, with the metadata to put on them
	GetMetadata(pod *kubernetes.Pod) []MetadataIndex

	// GetIndexes return the list of indexes the given pod belongs to. This function
	// must return the same indexes than GetMetadata
	GetIndexes(pod *kubernetes.Pod) []string
}

Indexer take known pods and generate all the metadata we need to enrich events in a efficient way. By preindexing the metadata in the way it will be checked when matching events

func NewContainerIndexer

func NewContainerIndexer(_ common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error)

NewContainerIndexer initializes and returns a ContainerIndexer

func NewIPPortIndexer

func NewIPPortIndexer(_ common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error)

NewIPPortIndexer creates and returns a new indexer for pod IP & ports

func NewPodNameIndexer

func NewPodNameIndexer(_ common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error)

NewPodNameIndexer initializes and returns a PodNameIndexer

type IndexerConstructor

type IndexerConstructor func(config common.Config, metaGen kubernetes.MetaGenerator) (Indexer, error)

IndexerConstructor builds a new indexer from its settings

type Indexers

type Indexers struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewIndexers

func NewIndexers(configs PluginConfig, metaGen kubernetes.MetaGenerator) *Indexers

NewIndexers builds indexers object

func (*Indexers) Empty

func (i *Indexers) Empty() bool

Empty returns true if indexers list is empty

func (*Indexers) GetIndexes

func (i *Indexers) GetIndexes(pod *kubernetes.Pod) []string

GetIndexes returns the composed index list from all registered indexers

func (*Indexers) GetMetadata

func (i *Indexers) GetMetadata(pod *kubernetes.Pod) []MetadataIndex

GetMetadata returns the composed metadata list from all registered indexers

type Matcher

type Matcher interface {
	// MetadataIndex returns the index string to use in annotation lookups for the given
	// event. A previous indexer should have generated that index for this to work
	// This function can return "" if the event doesn't match
	MetadataIndex(event common.MapStr) string
}

Matcher takes a new event and returns the index

func NewFieldFormatMatcher

func NewFieldFormatMatcher(cfg common.Config) (Matcher, error)

func NewFieldMatcher

func NewFieldMatcher(cfg common.Config) (Matcher, error)

type MatcherConstructor

type MatcherConstructor func(config common.Config) (Matcher, error)

type Matchers

type Matchers struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMatchers

func NewMatchers(configs PluginConfig) *Matchers

func (*Matchers) Empty

func (m *Matchers) Empty() bool

func (*Matchers) MetadataIndex

func (m *Matchers) MetadataIndex(event common.MapStr) string

MetadataIndex returns the index string for the first matcher from the Registry returning one

type MetadataIndex

type MetadataIndex struct {
	Index string
	Data  common.MapStr
}

MetadataIndex holds a pair of index -> metadata info

type PluginConfig

type PluginConfig []map[string]common.Config

type PodNameIndexer

type PodNameIndexer struct {
	// contains filtered or unexported fields
}

PodNameIndexer implements default indexer based on pod name

func (*PodNameIndexer) GetIndexes

func (p *PodNameIndexer) GetIndexes(pod *kubernetes.Pod) []string

GetIndexes returns the indexes for the given Pod

func (*PodNameIndexer) GetMetadata

func (p *PodNameIndexer) GetMetadata(pod *kubernetes.Pod) []MetadataIndex

GetMetadata returns metadata for the given pod, if it matches the index

type Register

type Register struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Register contains Indexer and Matchers to use on pod indexing and event matching

func NewRegister

func NewRegister() *Register

NewRegister creates and returns a new Register.

func (*Register) AddDefaultIndexerConfig

func (r *Register) AddDefaultIndexerConfig(name string, config common.Config)

AddIndexer to the register

func (*Register) AddDefaultMatcherConfig

func (r *Register) AddDefaultMatcherConfig(name string, config common.Config)

AddMatcher to the register

func (*Register) AddIndexer

func (r *Register) AddIndexer(name string, indexer IndexerConstructor)

AddIndexer to the register

func (*Register) AddMatcher

func (r *Register) AddMatcher(name string, matcher MatcherConstructor)

AddMatcher to the register

func (*Register) GetDefaultIndexerConfigs

func (r *Register) GetDefaultIndexerConfigs() map[string]common.Config

func (*Register) GetDefaultMatcherConfigs

func (r *Register) GetDefaultMatcherConfigs() map[string]common.Config

func (*Register) GetIndexer

func (r *Register) GetIndexer(name string) IndexerConstructor

AddIndexer to the register

func (*Register) GetMatcher

func (r *Register) GetMatcher(name string) MatcherConstructor

AddMatcher to the register

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL