collector

package
v0.0.0-...-27b3d77 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGzipReaderWithClose

func NewGzipReaderWithClose(r io.ReadCloser) (*gzipReaderWithClose, error)

NewGzipReaderWithClose creates a new gzipReaderWithClose

Types

type ClientOpts

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

func (ClientOpts) WithDefaults

func (c ClientOpts) WithDefaults() ClientOpts

type LogCollectorOpts

type LogCollectorOpts struct {
	Create createFunc
}

type MetricsClient

type MetricsClient struct {
	NodeName string
	// 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)

func (*MetricsClient) FetchMetricsIterator

func (c *MetricsClient) FetchMetricsIterator(target string) (*prompb.Iterator, error)

func (*MetricsClient) Pods

func (c *MetricsClient) Pods() (corev1.PodList, error)

Pods returns a list of pods running on the node. This uses the kubelet API instead of the kubernetes API server.

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 {
	Static    bool
	Addr      string
	Namespace string
	Pod       string
	Container string
}

func (ScrapeTarget) Equals

func (t ScrapeTarget) Equals(other ScrapeTarget) bool

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

	// Labels to lift to columns
	LiftLabels []string

	AddAttributes  map[string]string
	LiftAttributes []string
	LiftResources  []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

	// WALFlushInterval is the interval at which the WAL segment is flushed to disk.  A higher value results in
	// better disk IO and less CPU usage but has a greater risk of data loss in the event of a crash.  A lower
	// value results in more frequent disk IO and higher CPU usage but less data loss in the event of a crash.
	// The default is 100ms and the value must be greater than 0.
	WALFlushInterval time.Duration
}

type StoreRemoteClient

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

func (*StoreRemoteClient) CloseIdleConnections

func (s *StoreRemoteClient) CloseIdleConnections()

func (*StoreRemoteClient) Write

func (s *StoreRemoteClient) Write(ctx context.Context, endpoint string, wr *prompb.WriteRequest) error

type StoreRequestWriter

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

func (*StoreRequestWriter) Write

Jump to

Keyboard shortcuts

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