writer

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRemoteWriteVersion = "0.1.0"

Variables

View Source
var (
	ErrNilContext         = errors.New("nil context passed")
	ErrNoGatherersDefined = errors.New("no gatherers were defined")
)

Functions

This section is empty.

Types

type Compression added in v0.1.1

type Compression int

Compression is the compression algorithm used on the marshalled data before sending

const (
	// None tells the engine not to compress at all
	None Compression = iota
	// Snappy uses the snappy compression algorithm described at https://github.com/google/snappy
	Snappy
	// Gzip uses the standard Gzip compression algorithm with default compression level
	Gzip
)

func (Compression) Compress added in v0.1.1

func (e Compression) Compress(data []byte) ([]byte, error)

Compress attempts to compress the data with the given algorithm. If the Compression instance is valid, only gzip returns an error

func (Compression) String added in v0.1.1

func (e Compression) String() string

String returns the name of the compression algorithm

func (Compression) UpdateRequest added in v0.1.1

func (e Compression) UpdateRequest(req *http.Request)

UpdateRequest adds the appropriate Content-Encoding header to the given request

type Format added in v0.1.1

type Format int

Format represents the format to which metrics will be marshalled before sending to Prometheus

const (
	// Protobuf serializes to the protobuf description from the Prometheus github repository
	Protobuf Format = iota + 1
	// JSON serializes to standard JSON according to the Prometheus objects' JSON tags
	JSON
)

func (Format) Marshal added in v0.1.1

func (f Format) Marshal(wr prompb.WriteRequest) ([]byte, error)

Marshal will attempt to convert the prompb.WriteRequest into a byte slice

func (Format) String added in v0.1.1

func (f Format) String() string

String returns the name of the Format

func (Format) UpdateRequest added in v0.1.1

func (f Format) UpdateRequest(req *http.Request)

UpdateRequest adds the approprate Content-Type header to the given request

type RemoteMetricsWriter

type RemoteMetricsWriter interface {
	WriteMetrics(context.Context) (int, error)
}

RemoteMetricsWriter knows how to marshal a set of metrics and send them to a remote prometheus endpoint

func NewRemoteMetricsWriter

func NewRemoteMetricsWriter(targetURL string, options RemoteMetricsWriterOptions, gatherers ...prometheus.Gatherer) (RemoteMetricsWriter, error)

NewRemoteMetricsWriter attempts to create and return a new RemoteMetricsWriter, and will do so unless targetURL is the empty string (or only whitespace). If no gatherers are specified, prometheus.DefaultGatherer is used.

type RemoteMetricsWriterOptions

type RemoteMetricsWriterOptions struct {
	HTTPClient         *http.Client
	Format             Format
	Compression        Compression
	RemoteWriteVersion string
}

RemoteMetricsWriterOptions are the optional settings for a RemoteMetricsWriter.

If HTTPClient is not set, http.DefaultClient is used
If Format is not set, it defaults to Protobuf
If Compression is not set, it defaults to None
If RemoteWriteVersion is not set, it defaults to DefaultRemoteWriteVersion (0.1.0, currently). This should never change

Jump to

Keyboard shortcuts

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