cadvisor: github.com/google/cadvisor/collector Index | Files

package collector

import "github.com/google/cadvisor/collector"

Index

Package Files

collector_manager.go config.go fakes.go generic_collector.go prometheus_collector.go types.go util.go

func GetCollectorConfigs Uses

func GetCollectorConfigs(labels map[string]string) map[string]string

type Collector Uses

type Collector interface {
    // Collect metrics from this collector.
    // Returns the next time this collector should be collected from.
    // Next collection time is always returned, even when an error occurs.
    // A collection time of zero means no more collection.
    Collect(map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error)

    // Return spec for all metrics associated with this collector
    GetSpec() []v1.MetricSpec

    // Name of this collector.
    Name() string
}

Metric collector.

type CollectorManager Uses

type CollectorManager interface {
    // Register a collector.
    RegisterCollector(collector Collector) error

    // Collect from collectors that are ready and return the next time
    // at which a collector will be ready to collect from.
    // Next collection time is always returned, even when an error occurs.
    // A collection time of zero means no more collection.
    Collect() (time.Time, map[string][]v1.MetricVal, error)

    // Get metric spec from all registered collectors.
    GetSpec() ([]v1.MetricSpec, error)
}

Manages and runs collectors.

func NewCollectorManager Uses

func NewCollectorManager() (CollectorManager, error)

Returns a new CollectorManager that is thread-compatible.

type Config Uses

type Config struct {
    // the endpoint to hit to scrape metrics
    Endpoint EndpointConfig `json:"endpoint"`

    // holds information about different metrics that can be collected
    MetricsConfig []MetricConfig `json:"metrics_config"`
}

type EndpointConfig Uses

type EndpointConfig struct {
    // The full URL of the endpoint to reach
    URL string
    // A configuration in which an actual URL is constructed from, using the container's ip address
    URLConfig URLConfig
}

func (*EndpointConfig) UnmarshalJSON Uses

func (ec *EndpointConfig) UnmarshalJSON(b []byte) error

type FakeCollectorManager Uses

type FakeCollectorManager struct {
}

func (*FakeCollectorManager) Collect Uses

func (fkm *FakeCollectorManager) Collect(metric map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error)

func (*FakeCollectorManager) GetSpec Uses

func (fkm *FakeCollectorManager) GetSpec() ([]v1.MetricSpec, error)

func (*FakeCollectorManager) RegisterCollector Uses

func (fkm *FakeCollectorManager) RegisterCollector(collector Collector) error

type GenericCollector Uses

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

func NewCollector Uses

func NewCollector(collectorName string, configFile []byte, metricCountLimit int, containerHandler container.ContainerHandler, httpClient *http.Client) (*GenericCollector, error)

Returns a new collector using the information extracted from the configfile

func (*GenericCollector) Collect Uses

func (collector *GenericCollector) Collect(metrics map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error)

Returns collected metrics and the next collection time of the collector

func (*GenericCollector) GetSpec Uses

func (collector *GenericCollector) GetSpec() []v1.MetricSpec

func (*GenericCollector) Name Uses

func (collector *GenericCollector) Name() string

Returns name of the collector

type GenericCollectorManager Uses

type GenericCollectorManager struct {
    Collectors         []*collectorData
    NextCollectionTime time.Time
}

func (*GenericCollectorManager) Collect Uses

func (cm *GenericCollectorManager) Collect() (time.Time, map[string][]v1.MetricVal, error)

func (*GenericCollectorManager) GetSpec Uses

func (cm *GenericCollectorManager) GetSpec() ([]v1.MetricSpec, error)

func (*GenericCollectorManager) RegisterCollector Uses

func (cm *GenericCollectorManager) RegisterCollector(collector Collector) error

type MetricConfig Uses

type MetricConfig struct {
    // the name of the metric
    Name string `json:"name"`

    // enum type for the metric type
    MetricType v1.MetricType `json:"metric_type"`

    // metric units to display on UI and in storage (eg: MB, cores)
    // this is only used for display.
    Units string `json:"units"`

    // data type of the metric (eg: int, float)
    DataType v1.DataType `json:"data_type"`

    // the frequency at which the metric should be collected
    PollingFrequency time.Duration `json:"polling_frequency"`

    // the regular expression that can be used to extract the metric
    Regex string `json:"regex"`
}

metricConfig holds information extracted from the config file about a metric

type Prometheus Uses

type Prometheus struct {
    // the endpoint to hit to scrape metrics
    Endpoint EndpointConfig `json:"endpoint"`

    // the frequency at which metrics should be collected
    PollingFrequency time.Duration `json:"polling_frequency"`

    // holds names of different metrics that can be collected
    MetricsConfig []string `json:"metrics_config"`
}

type PrometheusCollector Uses

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

func NewPrometheusCollector Uses

func NewPrometheusCollector(collectorName string, configFile []byte, metricCountLimit int, containerHandler container.ContainerHandler, httpClient *http.Client) (*PrometheusCollector, error)

Returns a new collector using the information extracted from the configfile

func (*PrometheusCollector) Collect Uses

func (collector *PrometheusCollector) Collect(metrics map[string][]v1.MetricVal) (time.Time, map[string][]v1.MetricVal, error)

Returns collected metrics and the next collection time of the collector

func (*PrometheusCollector) GetSpec Uses

func (collector *PrometheusCollector) GetSpec() []v1.MetricSpec

func (*PrometheusCollector) Name Uses

func (collector *PrometheusCollector) Name() string

Returns name of the collector

type URLConfig Uses

type URLConfig struct {
    // the protocol to use for connecting to the endpoint. Eg 'http' or 'https'
    Protocol string `json:"protocol"`

    // the port to use for connecting to the endpoint. Eg '8778'
    Port json.Number `json:"port"`

    // the path to use for the endpoint. Eg '/metrics'
    Path string `json:"path"`
}

Package collector imports 16 packages (graph) and is imported by 110 packages. Updated 2020-05-20. Refresh now. Tools for package owners.