prometheusremotewriteexporter

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

README

Prometheus Remote Write Exporter

Prometheus Remote Write Exporter sends OpenTelemetry metrics to Prometheus remote write compatible backends such as Cortex and Thanos. By default, this exporter requires TLS and offers queued retry capabilities.

Supported pipeline types: metrics

⚠ Non-cumulative monotonic, histogram, and summary OTLP metrics are dropped by this exporter.

A design doc is available to document in detail how this exporter works.

Getting Started

The following settings are required:

  • endpoint (no default): The remote write URL to send remote write samples.

By default, TLS is enabled:

  • insecure (default = false): whether to enable client transport security for the exporter's connection.

As a result, the following parameters are also required:

  • cert_file (no default): path to the TLS cert to use for TLS required connections. Should only be used if insecure is set to false.
  • key_file (no default): path to the TLS key to use for TLS required connections. Should only be used if insecure is set to false.

The following settings can be optionally configured:

  • external_labels: list of labels to be attached to each metric data point
  • headers: additional headers attached to each HTTP request.
    • Note the following headers cannot be changed: Content-Encoding, Content-Type, X-Prometheus-Remote-Write-Version, and User-Agent.
  • namespace: prefix attached to each exported metric name.
  • remote_write_queue: fine tuning for queueing and sending of the outgoing remote writes.
    • queue_size: number of OTLP metrics that can be queued.
    • num_consumers: minimum number of workers to use to fan out the outgoing requests.

Example:

exporters:
  prometheusremotewrite:
    endpoint: "https://my-cortex:7900/api/v1/push"

Advanced Configuration

Several helper files are leveraged to provide additional capabilities automatically:

Documentation

Overview

Package prometheusremotewriteexporter sends metrics data to Prometheus Remote Write (PRW) endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() component.ExporterFactory

NewFactory creates a new Prometheus Remote Write exporter.

Types

type ByLabelName

type ByLabelName []prompb.Label

ByLabelName enables the usage of sort.Sort() with a slice of labels

func (ByLabelName) Len

func (a ByLabelName) Len() int

func (ByLabelName) Less

func (a ByLabelName) Less(i, j int) bool

func (ByLabelName) Swap

func (a ByLabelName) Swap(i, j int)

type Config

type Config struct {
	config.ExporterSettings        `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
	exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
	exporterhelper.RetrySettings   `mapstructure:"retry_on_failure"`

	// prefix attached to each exported metric name
	// See: https://prometheus.io/docs/practices/naming/#metric-names
	Namespace string `mapstructure:"namespace"`

	// QueueConfig allows users to fine tune the queues
	// that handle outgoing requests.
	RemoteWriteQueue RemoteWriteQueue `mapstructure:"remote_write_queue"`

	// ExternalLabels defines a map of label keys and values that are allowed to start with reserved prefix "__"
	ExternalLabels map[string]string `mapstructure:"external_labels"`

	HTTPClientSettings confighttp.HTTPClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.

	// ResourceToTelemetrySettings is the option for converting resource attributes to telemetry attributes.
	// "Enabled" - A boolean field to enable/disable this option. Default is `false`.
	// If enabled, all the resource attributes will be converted to metric labels by default.
	exporterhelper.ResourceToTelemetrySettings `mapstructure:"resource_to_telemetry_conversion"`
}

Config defines configuration for Remote Write exporter.

func (*Config) Validate added in v0.25.0

func (cfg *Config) Validate() error

Validate checks if the exporter configuration is valid

type PRWExporter added in v0.28.0

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

PRWExporter converts OTLP metrics to Prometheus remote write TimeSeries and sends them to a remote endpoint.

func NewPRWExporter added in v0.28.0

func NewPRWExporter(cfg *Config, buildInfo component.BuildInfo) (*PRWExporter, error)

NewPRWExporter initializes a new PRWExporter instance and sets fields accordingly.

func (*PRWExporter) PushMetrics added in v0.28.0

func (prwe *PRWExporter) PushMetrics(ctx context.Context, md pdata.Metrics) error

PushMetrics converts metrics to Prometheus remote write TimeSeries and send to remote endpoint. It maintain a map of TimeSeries, validates and handles each individual metric, adding the converted TimeSeries to the map, and finally exports the map.

func (*PRWExporter) Shutdown added in v0.28.0

func (prwe *PRWExporter) Shutdown(context.Context) error

Shutdown stops the exporter from accepting incoming calls(and return error), and wait for current export operations to finish before returning

func (*PRWExporter) Start added in v0.28.0

func (prwe *PRWExporter) Start(_ context.Context, host component.Host) (err error)

Start creates the prometheus client

type RemoteWriteQueue added in v0.27.0

type RemoteWriteQueue struct {
	// QueueSize is the maximum number of OTLP metric batches allowed
	// in the queue at a given time.
	QueueSize int `mapstructure:"queue_size"`

	// NumWorkers configures the number of workers used by
	// the collector to fan out remote write requests.
	NumConsumers int `mapstructure:"num_consumers"`
}

RemoteWriteQueue allows to configure the remote write queue.

Jump to

Keyboard shortcuts

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