Documentation
¶
Index ¶
Constants ¶
const ( // Maximum number of samples to pack into a batch sent to GCM. BatchSizeMax = 200 // Prefix for GCM metric. MetricTypePrefix = "prometheus.googleapis.com" )
const ( CompressionNone = "none" CompressionGZIP = "gzip" )
Supported gRPC compression formats.
const ( KeyProjectID = "project_id" KeyLocation = "location" KeyCluster = "cluster" KeyNamespace = "namespace" KeyJob = "job" KeyInstance = "instance" )
The target label keys used for the Prometheus monitored resource.
const ( ClientName = "prometheus-engine-export" Version = "0.2.2" )
ClientName and Version are used to identify to User Agent. TODO(maxamin): automate versioning.
Variables ¶
This section is empty.
Functions ¶
func WithMetadataFunc ¶ added in v0.0.1
func WithMetadataFunc(ctx context.Context, mf MetadataFunc) context.Context
WithMetadataFunc stores mf in the context.
Types ¶
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter converts Prometheus samples into Cloud Monitoring samples and exports them.
func New ¶
func New(logger log.Logger, reg prometheus.Registerer, opts ExporterOpts) (*Exporter, error)
New returns a new Cloud Monitoring Exporter.
func NopExporter ¶ added in v0.2.2
func NopExporter() *Exporter
NopExporter returns an inactive exporter.
func (*Exporter) ApplyConfig ¶
ApplyConfig updates the exporter state to the given configuration. Must be called at least once before Export() can be used.
func (*Exporter) Export ¶
func (e *Exporter) Export(metadata MetadataFunc, batch []record.RefSample)
Export enqueues the samples to be written to Cloud Monitoring.
type ExporterOpts ¶
type ExporterOpts struct {
// Whether to disable exporting of metrics.
Disable bool
// GCM API endpoint to send metric data to.
Endpoint string
// Compression format to use for gRPC requests.
Compression string
// Credentials file for authentication with the GCM API.
CredentialsFile string
// Disable authentication (for debugging purposes).
DisableAuth bool
// A user agent string added as a suffix to the regular user agent.
UserAgent string
// Default monitored resource fields set on exported data.
ProjectID string
Location string
Cluster string
// A list of metric matchers. Only Prometheus time series satisfying at
// least one of the matchers are exported.
// This option matches the semantics of the Prometheus federation match[]
// parameter.
Matchers Matchers
// Maximum batch size to use when sending data to the GCM API. The default
// maximum will be used if set to 0.
BatchSize uint
// Prefix under which metrics are written to GCM.
MetricTypePrefix string
// A lease on a time range for which the exporter send sample data.
// It is checked for on each batch provided to the Export method.
// If unset, data is always sent.
Lease Lease
}
ExporterOpts holds options for an exporter.
type Lease ¶ added in v0.2.2
type Lease interface {
// Range informs whether the caller currently holds the lease and for what time range.
// The range is inclusive.
Range() (start, end time.Time, ok bool)
// Run background processing until context is cancelled.
Run(context.Context)
// OnLeaderChange sets a callback that is invoked when the lease leader changes.
// Must be called before Run.
OnLeaderChange(func())
}
Lease determines a currently owned time range.
type Matchers ¶ added in v0.0.4
Matchers holds a list of metric selectors that can be set as a flag.
func (*Matchers) IsCumulative ¶ added in v0.0.4
type MetadataFunc ¶ added in v0.0.1
type MetadataFunc func(metric string) (MetricMetadata, bool)
MetadataFunc gets metadata for a specific metric name.
func MetadataFuncFromContext ¶ added in v0.0.1
func MetadataFuncFromContext(ctx context.Context) (MetadataFunc, bool)
MetadataFuncFromContext extracts a MetataFunc from ctx.
type MetricMetadata ¶ added in v0.0.1
type MetricMetadata struct {
Metric string
Type textparse.MetricType
Help string
Unit string
}
MetricMetadata is a copy of MetricMetadata in Prometheus's scrape package. It is copied to break a dependency cycle.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage provides a stateful wrapper around an Exporter that implements Prometheus's storage interface (Appendable).
For performance reasons Exporter is optimized to be tightly integrate with Prometheus's storage. This makes it rely on external state (series ID to label mapping). For use cases where a full Prometheus storage engine is not present (e.g. rule evaluation service), Storage acts as a simple drop-in replacement that directly manages the state required by Exporter.
func NewStorage ¶
NewStorage returns a new Prometheus storage that's exporting data via the exporter.
func (*Storage) ApplyConfig ¶ added in v0.1.0
ApplyConfig applies the new configuration to the storage.