cortexexporter

package
v0.0.0-...-5621c17 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

README

Cortex Exporter

This Exporter sends metrics data in Prometheus TimeSeries format to Cortex and signs each outgoing HTTP request following the AWS Signature Version 4 signing process. AWS region and service must be provided in the configuration file, and AWS credentials are retrieved from the default credential chain of the AWS SDK for Go.

Note: this exporter intends to import and use the Prometheus remote write exporter from upstream; However, since the Prometheus remote write exporter has not been fully merged upstream, the OpenTelemtry Collector code has been copied to /internal folder of this project, and a replace directive in go.mod redirects imports of go.opentelemtry.io/collector to /internal/opentelemtry-collector. Once upstream code is fully merged and stable, the Collector code and the replace directive in this project can be removed.

Same as the Prometheus remote write exporter, this exporter checks the temporality and the type of each incoming metric and only exports the following combination:

  • Int64 or Double type with any temporality
  • MonotonicInt64, MonotonicDouble, Histogram, or Summary with only Cumulative temporality.

Configuration

The following settings are required:

  • endpoint: protocol:host:port to which the exporter is going to send traces or metrics, using the HTTP/HTTPS protocol.

The following settings can be optionally configured:

  • namespace: prefix attached to each exported metric name.
  • headers: additional headers attached to each HTTP request. If X-Prometheus-Remote-Write-Version is set by user, its value must be 0.1.0
  • insecure (default = false): whether to enable client transport security for the exporter's connection.
  • ca_file: path to the CA cert. For a client this verifies the server certificate. Should only be used if insecure is set to true.
  • cert_file: path to the TLS cert to use for TLS required connections. Should only be used if insecure is set to true.
  • key_file: path to the TLS key to use for TLS required connections. Should only be used if insecure is set to true.
  • timeout (default = 5s): How long to wait until the connection is close.
  • read_buffer_size (default = 0): ReadBufferSize for HTTP client.
  • write_buffer_size (default = 512 * 1024): WriteBufferSize for HTTP client.
  • aws_auth: whether each request should be singed with AWS Sig v4. The following settings must be configured:
    • enabled: whether AWS Sig V4 Signing should be enabled.
    • region: region string used for AWS Sig V4 signing.
    • service: service string used for AWS Sig V4 signing.
    • debug: whether the Sig V4 signature as well as each of the HTTP request and response should be printed.

Example:

exporters:
  prometheusremotewrite:
    endpoint: "http://some.url:9411/api/prom/push"

The full list of settings exposed for this exporter are documented here with detailed sample configurations here.

Here is a link to the overall project design

Testing

This package provide instructions on conducting integration test for the Cortex exporter.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuth

func NewAuth(params AuthSettings, origClient *http.Client) (http.RoundTripper, error)

NewAuth takes a map of strings as parameters and return a http.RoundTripper that perform Sig V4 signing on each request.

func NewFactory

func NewFactory() component.ExporterFactory

NewFactory returns a factory of the Cortex exporter that can be registered to the Collector.

Types

type AuthSettings

type AuthSettings struct {
	Enabled bool `mapstructure:"enabled"`
	// region string for AWS Sig V4
	Region string `mapstructure:"region"`
	// service string for AWS Sig V4
	Service string `mapstructure:"service"`
	// whether AWS Sig v4 debug information should be printed
	Debug bool `mapstructure:"debug"`
}

AuthSettings defines AWS authentication configurations for SigningRoundTripper

type Config

type Config struct {
	// squash ensures fields are correctly decoded in embedded struct.
	configmodels.ExporterSettings  `mapstructure:",squash"`
	exporterhelper.TimeoutSettings `mapstructure:",squash"`
	exporterhelper.QueueSettings   `mapstructure:"sending_queue"`
	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"`

	// AWS Sig V4 configuration options
	AuthSettings AuthSettings `mapstructure:"aws_auth"`

	HTTPClientSettings confighttp.HTTPClientSettings `mapstructure:",squash"`
}

Config defines configuration for Remote Write exporter.

type SigningRoundTripper

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

SigningRoundTripper is a Custom RoundTripper that performs AWS Sig V4

func (*SigningRoundTripper) RoundTrip

func (si *SigningRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip signs each outgoing request

Jump to

Keyboard shortcuts

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