promremote

package
v0.1.74 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package promremote writes timeseries to a Prometheus remote-write endpoint.

It is a thin wrapper around the upstream Prometheus remote-write client (github.com/prometheus/prometheus/storage/remote.NewWriteClient) that preserves the historical TSList/TimeSeries surface used elsewhere in dmt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps an upstream Prometheus remote.WriteClient.

func NewClient

func NewClient(rawURL, token string) *Client

NewClient creates a remote-write client backed by the default upstream Prometheus client. Returns nil when url or token is empty, matching the previous behaviour relied on by callers.

func (*Client) WriteProto

func (c *Client) WriteProto(
	ctx context.Context,
	promWR *prompb.WriteRequest,
) (WriteResult, WriteError)

WriteProto sends an already-built prompb.WriteRequest to the configured endpoint.

func (*Client) WriteTimeSeries

func (c *Client) WriteTimeSeries(
	ctx context.Context,
	seriesList TSList,
	_ WriteOptions,
) (WriteResult, WriteError)

WriteTimeSeries serialises seriesList to the Prometheus remote-write v1 protobuf, snappy-encodes it, and POSTs it to the configured endpoint.

type Datapoint

type Datapoint struct {
	Timestamp time.Time
	Value     float64
}

Datapoint is a single value reported at a given time.

type Label

type Label struct {
	Name  string
	Value string
}

Label is a metric label.

type TSList

type TSList []TimeSeries

TSList is a slice of TimeSeries.

type TimeSeries

type TimeSeries struct {
	Labels    []Label
	Datapoint Datapoint
}

TimeSeries is a labelled datapoint.

func ConvertMetric

func ConvertMetric(metric prometheus.Metric, name string) TimeSeries

type WriteError

type WriteError interface {
	error
	StatusCode() int
}

WriteError is an error that can also report an HTTP status code when the failure was caused by the response.

type WriteOptions

type WriteOptions struct {
	Headers map[string]string
}

WriteOptions specifies additional write options. Reserved for future use; the upstream client manages its headers (Content-Type/Encoding, User-Agent, X-Prometheus-Remote-Write-Version, Authorization) internally.

type WriteResult

type WriteResult struct {
	StatusCode int
}

WriteResult returns the successful HTTP status code.

Jump to

Keyboard shortcuts

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