prometheusreceiver

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

Prometheus Receiver

Receives metric data in Prometheus format. See the Design for additional information on this receiver.

Supported pipeline types: metrics

⚠️ Warning

Note: This component is currently work in progress. It has several limitations and please don't use it if the following limitations is a concern:

  • Collector cannot auto-scale the scraping yet when multiple replicas of the collector is run.
  • When running multiple replicas of the collector with the same config, it will scrape the targets multiple times.
  • Users need to configure each replica with different scraping configuration if they want to manually shard the scraping.
  • The Prometheus receiver is a stateful component.

Getting Started

This receiver is a drop-in replacement for getting Prometheus to scrape your services. It supports the full set of Prometheus configuration in scrape_config, including service discovery. Just like you would write in a YAML configuration file before starting Prometheus, such as with:

Note: Since the collector configuration supports env variable substitution $ characters in your prometheus configuration are interpreted as environment variables. If you want to use $ characters in your prometheus configuration, you must escape them using $$.

prometheus --config.file=prom.yaml

You can copy and paste that same configuration under:

receivers:
  prometheus:
    config:

For example:

receivers:
    prometheus:
      config:
        scrape_configs:
          - job_name: 'otel-collector'
            scrape_interval: 5s
            static_configs:
              - targets: ['0.0.0.0:8888']
          - job_name: k8s
            kubernetes_sd_configs:
            - role: pod
            relabel_configs:
            - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
              regex: "true"
              action: keep
            metric_relabel_configs:
            - source_labels: [__name__]
              regex: "(request_duration_seconds.*|response_duration_seconds.*)"
              action: keep

Documentation

Overview

Package prometheusreceiver autodiscovers and scrapes Prometheus metrics handlers, often served at /metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory added in v0.8.0

func NewFactory() component.ReceiverFactory

NewFactory creates a new Prometheus receiver factory.

Types

type Config

type Config struct {
	config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	PrometheusConfig        *promconfig.Config       `mapstructure:"-"`
	BufferPeriod            time.Duration            `mapstructure:"buffer_period"`
	BufferCount             int                      `mapstructure:"buffer_count"`
	UseStartTimeMetric      bool                     `mapstructure:"use_start_time_metric"`
	StartTimeMetricRegex    string                   `mapstructure:"start_time_metric_regex"`

	// ConfigPlaceholder is just an entry to make the configuration pass a check
	// that requires that all keys present in the config actually exist on the
	// structure, ie.: it will error if an unknown key is present.
	ConfigPlaceholder interface{} `mapstructure:"config"`
}

Config defines configuration for Prometheus receiver.

func (*Config) Unmarshal added in v0.25.0

func (cfg *Config) Unmarshal(componentParser *configparser.Parser) error

Unmarshal a config.Parser into the config struct.

func (*Config) Validate added in v0.24.0

func (cfg *Config) Validate() error

Validate checks the receiver configuration is valid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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