collector

package
v0.0.0-...-1ce6954 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientOpts

type ClientOpts struct {
	DialTimeout         time.Duration
	TLSHandshakeTimeout time.Duration
	ScrapeTimeOut       time.Duration
}

func (ClientOpts) WithDefaults

func (c ClientOpts) WithDefaults() ClientOpts

type LogCollectorOpts

type LogCollectorOpts struct {
	Create createFunc
}

type MetricsClient

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

func NewMetricsClient

func NewMetricsClient(opts ClientOpts) (*MetricsClient, error)

func (*MetricsClient) Close

func (c *MetricsClient) Close() error

func (*MetricsClient) FetchMetrics

func (c *MetricsClient) FetchMetrics(target string) (map[string]*prom_model.MetricFamily, error)

type MetricsHandlerOpts

type MetricsHandlerOpts struct {
	AddLabels map[string]string

	// DropLabels is a map of metric names regexes to label name regexes.  When both match, the label will be dropped.
	DropLabels map[*regexp.Regexp]*regexp.Regexp

	// DropMetrics is a slice of regexes that drops metrics when the metric name matches.  The metric name format
	// should match the Prometheus naming style before the metric is translated to a Kusto table name.
	DropMetrics []*regexp.Regexp

	KeepMetrics []*regexp.Regexp

	KeepMetricsLabelValues map[*regexp.Regexp]*regexp.Regexp

	// DisableMetricsForwarding disables the forwarding of metrics to the remote write endpoint.
	DisableMetricsForwarding bool
	DefaultDropMetrics       bool
}

func (MetricsHandlerOpts) RequestTransformer

func (o MetricsHandlerOpts) RequestTransformer() *transform.RequestTransformer

type OtlpMetricsHandlerOpts

type OtlpMetricsHandlerOpts struct {
	// Optional. Path is the path where the OTLP/HTTP handler will be registered.
	Path string
	// Optional. GrpcPort is the port where the metrics OTLP/GRPC handler will listen.
	GrpcPort int

	MetricOpts MetricsHandlerOpts
}

type PrometheusRemoteWriteHandlerOpts

type PrometheusRemoteWriteHandlerOpts struct {
	// Path is the path where the handler will be registered.
	Path string

	MetricOpts MetricsHandlerOpts
}

type RemoteWriteClient

type RemoteWriteClient interface {
	Write(ctx context.Context, endpoint string, wr *prompb.WriteRequest) error
	CloseIdleConnections()
}

type ScrapeTarget

type ScrapeTarget struct {
	Addr      string
	Namespace string
	Pod       string
	Container string
}

func (ScrapeTarget) String

func (t ScrapeTarget) String() string

type Scraper

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

func NewScraper

func NewScraper(opts *ScraperOpts) *Scraper

func (*Scraper) Close

func (s *Scraper) Close() error

func (*Scraper) OnAdd

func (s *Scraper) OnAdd(obj interface{}, isInitialList bool)

func (*Scraper) OnDelete

func (s *Scraper) OnDelete(obj interface{})

func (*Scraper) OnUpdate

func (s *Scraper) OnUpdate(oldObj, newObj interface{})

func (*Scraper) Open

func (s *Scraper) Open(ctx context.Context) error

func (*Scraper) Targets

func (s *Scraper) Targets() []ScrapeTarget

type ScraperOpts

type ScraperOpts struct {
	NodeName string

	DefaultDropMetrics bool

	// AddLabels is a map of key/value pairs that will be added to all metrics.
	AddLabels map[string]string

	// DropLabels is a map of metric names regexes to label name regexes.  When both match, the label will be dropped.
	DropLabels map[*regexp.Regexp]*regexp.Regexp

	// DropMetrics is a slice of regexes that drops metrics when the metric name matches.  The metric name format
	// should match the Prometheus naming style before the metric is translated to a Kusto table name.
	DropMetrics []*regexp.Regexp

	KeepMetricsWithLabelValue map[*regexp.Regexp]*regexp.Regexp

	KeepMetrics []*regexp.Regexp

	// Database is the name of the database to write metrics to.
	Database string

	// ScrapeInterval is the interval at which to scrape metrics from the targets.
	ScrapeInterval time.Duration

	// ScrapeTimeout is the timeout for scraping metrics from a target.
	ScrapeTimeout time.Duration

	// DisableMetricsForwarding disables the forwarding of metrics to the remote write endpoint.
	DisableMetricsForwarding bool

	// DisableDiscovery disables the discovery of scrape targets.
	DisableDiscovery bool

	PodInformer *k8s.PodInformer

	// Targets is a list of static scrape targets.
	Targets []ScrapeTarget

	// MaxBatchSize is the maximum number of samples to send in a single batch.
	MaxBatchSize int

	Endpoints []string

	RemoteClient RemoteWriteClient
}

func (*ScraperOpts) RequestTransformer

func (s *ScraperOpts) RequestTransformer() *transform.RequestTransformer

type Service

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

func NewService

func NewService(opts *ServiceOpts) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Open

func (s *Service) Open(ctx context.Context) error

type ServiceOpts

type ServiceOpts struct {
	ListenAddr string
	NodeName   string
	Endpoints  []string

	// LogCollectionHandlers is the list of log collection handlers
	LogCollectionHandlers []LogCollectorOpts
	// PromMetricsHandlers is the list of prom-remote handlers
	PromMetricsHandlers []PrometheusRemoteWriteHandlerOpts
	// OtlpMetricsHandlers is the list of oltp metrics handlers
	OtlpMetricsHandlers []OtlpMetricsHandlerOpts
	// Scraper is the options for the prom scraper
	Scraper *ScraperOpts

	AddAttributes  map[string]string
	LiftAttributes []string

	// InsecureSkipVerify skips the verification of the remote write endpoint certificate chain and host name.
	InsecureSkipVerify bool

	TLSCertFile string
	TLSKeyFile  string

	// MaxBatchSize is the maximum number of samples to send in a single batch.
	MaxBatchSize int

	// MaxSegmentAge is the maximum time allowed before a segment is rolled over.
	MaxSegmentAge time.Duration

	// MaxSegmentSize is the maximum size allowed for a segment before it is rolled over.
	MaxSegmentSize int64

	// MaxDiskUsage is the max size in bytes to use for segment store.  If this value is exceeded, writes
	// will be rejected until space is freed.  A value of 0 means no max usage.
	MaxDiskUsage int64

	// StorageDir is the directory where the WAL will be stored
	StorageDir string

	// EnablePprof enables pprof endpoints.
	EnablePprof bool

	// Region is a location identifier
	Region string

	MaxConnections int
}

Jump to

Keyboard shortcuts

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