Documentation ¶
Index ¶
- Constants
- Variables
- func CopyLegacyMetricsMap(m map[string]map[uint32]uint64) map[string]map[uint32]uint64
- func ListEventProbes() []string
- func ListMetricsProbes() []string
- func MustRegisterEventProbe(name string, creator interface{})
- func MustRegisterMetricsProbe(name string, creator interface{})
- func NewLegacyBatchMetrics(module string, metrics []string, collector LegacyCollector) prometheus.Collector
- func NewLegacyBatchMetricsWithUnderscore(module string, metrics []string, collector LegacyCollector) prometheus.Collector
- type BatchMetrics
- type BatchMetricsOpts
- type Collector
- type Emit
- type Event
- type EventProbe
- type EventType
- type Label
- type LegacyCollector
- type MetricsProbe
- type Probe
- type RawEvent
- type SimpleProbe
- type SingleMetricsOpts
- type State
- type Type
Constants ¶
const ( ProbeTypeMetrics = iota ProbeTypeEvent ProbeTypeCount )
const ( ProbeStateStopped = iota ProbeStateStarting ProbeStateRunning ProbeStateStopping ProbeStateFailed )
const LegacyMetricsNamespace = "inspector"
const MetricsNamespace = "kubeskoop"
Variables ¶
var ( ErrProbeNotExists = errors.New("probe not exists") ErrProbeAlreadyExists = errors.New("probe already exists") ErrInvalidProbeState = errors.New("invalid probe state") )
var (
ErrUndeclaredMetrics = errors.New("undeclared metrics")
)
Functions ¶
func CopyLegacyMetricsMap ¶ added in v1.0.0
func ListEventProbes ¶ added in v1.0.0
func ListEventProbes() []string
func ListMetricsProbes ¶ added in v1.0.0
func ListMetricsProbes() []string
func MustRegisterEventProbe ¶ added in v1.0.0
func MustRegisterEventProbe(name string, creator interface{})
MustRegisterEventProbe registers the event probe by given name and creator. The creator is a function that creates EventProbe. Return values of the creator must be (EventProbe, error). The creator can accept one parameter of type chan<- *Event, or struct/map as an extra parameter. When the creator specifies the extra parameter, the configuration of the probe in the configuration file will be passed to the creator when the probe is created. For example:
The creator accepts no extra args.
func eventProbeCreator(sink chan<- *Event) (EventProbe, error)
The creator accepts struct "probeArgs" as args. Names of struct fields are case-insensitive.
// Config in yaml args: argA: test argB: 20 argC: - a // Struct definition type probeArgs struct { ArgA string ArgB int ArgC []string } // The creator function: func eventProbeCreator(sink chan<- *Event, args probeArgs) (EventProbe, error)
The creator can also use a map with string keys as parameters. However, if you use a type other than interface{} as the value type, errors may occur during the configuration parsing process.
func metricsProbeCreator(sink chan<- *Event, args map[string]string) (EventProbe, error) func metricsProbeCreator(sink chan<- *Event, args map[string]interface{} (EventProbe, error)
func MustRegisterMetricsProbe ¶ added in v1.0.0
func MustRegisterMetricsProbe(name string, creator interface{})
MustRegisterMetricsProbe registers the metrics probe by given name and creator. The creator is a function that creates MetricProbe. Return values of the creator must be (MetricsProbe, error). The creator can accept no parameter, or struct/map as a parameter. When the creator specifies the parameter, the configuration of the probe in the configuration file will be passed to the creator when the probe is created. For example:
The creator accepts no extra args.
func metricsProbeCreator() (MetricsProbe, error)
The creator accepts struct "probeArgs" as args. Names of struct fields are case-insensitive.
// Config in yaml args: argA: test argB: 20 argC: - a // Struct definition type probeArgs struct { ArgA string ArgB int ArgC []string } // The creator function: func metricsProbeCreator(args probeArgs) (MetricsProbe, error)
The creator can also use a map with string keys as parameters. However, if you use a type other than interface{} as the value type, errors may occur during the configuration parsing process.
func metricsProbeCreator(args map[string]string) (MetricsProbe, error) func metricsProbeCreator(args map[string]interface{} (MetricsProbe, error)
func NewLegacyBatchMetrics ¶ added in v1.0.0
func NewLegacyBatchMetrics(module string, metrics []string, collector LegacyCollector) prometheus.Collector
func NewLegacyBatchMetricsWithUnderscore ¶ added in v1.0.0
func NewLegacyBatchMetricsWithUnderscore(module string, metrics []string, collector LegacyCollector) prometheus.Collector
Types ¶
type BatchMetrics ¶ added in v1.0.0
type BatchMetrics struct { ProbeCollector Collector // contains filtered or unexported fields }
func NewBatchMetrics ¶ added in v1.0.0
func NewBatchMetrics(opts BatchMetricsOpts, probeCollector Collector) *BatchMetrics
func (*BatchMetrics) Collect ¶ added in v1.0.0
func (b *BatchMetrics) Collect(metrics chan<- prometheus.Metric)
func (*BatchMetrics) Describe ¶ added in v1.0.0
func (b *BatchMetrics) Describe(descs chan<- *prometheus.Desc)
type BatchMetricsOpts ¶ added in v1.0.0
type EventProbe ¶ added in v1.0.0
type EventProbe interface { Probe }
func CreateEventProbe ¶ added in v1.0.0
func CreateEventProbe(name string, sink chan<- *Event, args map[string]interface{}) (EventProbe, error)
func NewEventProbe ¶ added in v1.0.0
func NewEventProbe(name string, simpleProbe SimpleProbe) EventProbe
type Label ¶ added in v1.0.0
func EventMetaByNetNS ¶ added in v1.0.0
func LagacyEventLabels ¶ added in v1.0.0
type LegacyCollector ¶ added in v1.0.0
type MetricsProbe ¶ added in v1.0.0
type MetricsProbe interface { Probe prometheus.Collector }
func CreateMetricsProbe ¶ added in v1.0.0
func CreateMetricsProbe(name string, args map[string]interface{}) (MetricsProbe, error)
func NewMetricsProbe ¶ added in v1.0.0
func NewMetricsProbe(name string, simpleProbe SimpleProbe, collector prometheus.Collector) MetricsProbe
type Probe ¶ added in v1.0.0
type Probe interface { Start(ctx context.Context) error Stop(ctx context.Context) error State() State Name() string }
func NewProbe ¶ added in v1.0.0
func NewProbe(name string, probe SimpleProbe) Probe