Prometheus Remote Write Exporter

This exporter sends data in Prometheus TimeSeries format to Cortex or any Prometheus remote write compatible backend. By default, this exporter requires TLS and offers queued retry capabilities.

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

Here is a link to the overall project design

Supported pipeline types: metrics

Getting Started

The following settings are required:

  • endpoint (no default): protocol:host:port to which the exporter is going to send data.

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.


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

Advanced Configuration

Several helper files are leveraged to provide additional capabilities automatically:



    Package prometheusremotewriteexporter implements an exporter that sends Prometheus remote write requests.



    This section is empty.


    This section is empty.


    func NewFactory

    func NewFactory() component.ExporterFactory

      NewFactory creates a new Prometheus Remote Write exporter.


      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:"-"`
        	exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
        	exporterhelper.QueueSettings   `mapstructure:"sending_queue"`
        	exporterhelper.RetrySettings   `mapstructure:"retry_on_failure"`
        	// prefix attached to each exported metric name
        	// See:
        	Namespace string `mapstructure:"namespace"`
        	// 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.

          Config defines configuration for Remote Write exporter.

          func (*Config) Validate

          func (cfg *Config) Validate() error

            Validate checks if the exporter configuration is valid

            type PrwExporter

            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

              func NewPrwExporter(namespace string, endpoint string, client *http.Client, externalLabels map[string]string) (*PrwExporter, error)

                NewPrwExporter initializes a new PrwExporter instance and sets fields accordingly. client parameter cannot be nil.

                func (*PrwExporter) PushMetrics

                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

                  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