api

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

View Source
const ContextOptionsHelp = `
 sourceContext          := { identity | namespace | pod }
 destinationContext     := { identity | namespace | pod }`

ContextOptionsHelp is the help text for context options

View Source
const (
	// DefaultPrometheusNamespace is the default namespace (prefix) used
	// for all Hubble related Prometheus metrics
	DefaultPrometheusNamespace = "hubble"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextIdentifier

type ContextIdentifier int

ContextIdentifier describes the identification method of a transmission or receiving context

const (
	// ContextDisabled disables context identification
	ContextDisabled ContextIdentifier = iota
	// ContextIdentity uses the full set of identity labels for identification purposes
	ContextIdentity
	// ContextNamespace uses the namespace name for identification purposes
	ContextNamespace
	// ContextPod uses the pod name for identification purposes
	ContextPod
	// ContextPodShort uses a short version of the pod name. It should
	// typically map to the deployment/replicaset name
	ContextPodShort
)

func (ContextIdentifier) String

func (c ContextIdentifier) String() string

String return the context identifier as string

type ContextOptions

type ContextOptions struct {
	// Destination is the destination context to include in metrics
	Destination ContextIdentifier
	// Source is the source context to include in metrics
	Source ContextIdentifier
}

ContextOptions is the set of options to define whether and how to include sending and/or receiving context information

func ParseContextOptions

func ParseContextOptions(options Options) (*ContextOptions, error)

ParseContextOptions parses a set of options and extracts the context relevant options

func (*ContextOptions) GetLabelNames

func (o *ContextOptions) GetLabelNames() (labels []string)

GetLabelNames returns a slice of label names required to fulfil the configured context description requirements

func (*ContextOptions) GetLabelValues

func (o *ContextOptions) GetLabelValues(flow v1.Flow) (labels []string)

GetLabelValues returns the values of the context relevant labels according to the configured options. The order of the values is the same as the order of the label names returned by GetLabelNames()

func (*ContextOptions) Status

func (o *ContextOptions) Status() string

Status returns the configuration status of context options suitable for use with Handler.Status

type Handler

type Handler interface {
	// Init must initialize the metric handler by validating and parsing
	// the options and then registering all required metrics with the
	// specifies Prometheus registry
	Init(registry *prometheus.Registry, options Options) error

	// ProcessFlow must processes a flow event and perform metrics
	// accounting
	ProcessFlow(flow v1.Flow)

	// Status returns the configuration status of the metric handler
	Status() string
}

Handler is a metric handler. It is called upon receival of raw event data and is responsible to perform metrics accounting according to the scope of the metrics plugin.

type Handlers

type Handlers []Handler

Handlers is a slice of metric handler

func (Handlers) ProcessFlow

func (h Handlers) ProcessFlow(flow v1.Flow)

ProcessFlow processes a flow by calling ProcessFlow it on to all enabled metric handlers

type Map

type Map map[string]Options

Map is a set of metrics with their corresponding options

func ParseMetricList

func ParseMetricList(enabledMetrics []string) (m Map)

ParseMetricList parses a slice of metric options and returns a map of enabled metrics

type Options

type Options map[string]string

Options are options provided to a metric handler

func ParseOptions

func ParseOptions(s string) (options Options)

ParseOptions parses a metric handler option string into a options map

type Plugin

type Plugin interface {
	// NewHandler returns a new metric handler of the respective plugin
	NewHandler() Handler

	// HelpText returns a human readable help text including a description
	// of the options
	HelpText() string
}

Plugin is a metric plugin. A metric plugin is associated a name and is responsible to spawn metric handlers of a certain type.

type Registry

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

Registry holds a set of registered metric handlers

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns the default registry of all available metric plugins

func NewRegistry

func NewRegistry(log logrus.FieldLogger) *Registry

NewRegistry returns a new Registry

func (*Registry) ConfigureHandlers

func (r *Registry) ConfigureHandlers(registry *prometheus.Registry, enabled Map) (Handlers, error)

ConfigureHandlers enables a set of metric handlers and initializes them. Only metrics handlers which have been previously registered via the Register() function can be configured.

func (*Registry) Register

func (r *Registry) Register(name string, p Plugin)

Register registers a metrics handler plugin with the manager. After registration, the metrics handler plugin can be enabled via HandlerManager.ConfigureHandlers().

Jump to

Keyboard shortcuts

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