Documentation ¶
Overview ¶
Package lib provides utility functions to read/write/transform metrics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TranslateHistogram ¶
func TranslateHistogram(config *BucketConfig, mf *dto.MetricFamily)
TranslateHistogram translates the HDR Histogram into a Log10 linear histogram
Types ¶
type BucketConfig ¶
type BucketConfig struct { Bins int Startns int // optional Endns int Exclude string Include string Unit string }
BucketConfig defines the config parameters for each histogram bucket * Bins: the number of linear buckets for each log10 bucket * Startns: The lower range in nanoseconds. * Endns: Optional upper range * Exclude: Regex of histogram names to exclude * Include: Regex of histogram names to include, regardless of the exclude settings * Unit: Time unit to use for the log10 buckets
func (*BucketConfig) UnitDiv ¶
func (b *BucketConfig) UnitDiv() float64
UnitDiv converts time units into nano secods
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector queries the database to collect custom metrics
func NewCollector ¶
NewCollector creates a new collector for retrieving sql activity from the internal CRDB tables
func (*Collector) GetCustomMetrics ¶
GetCustomMetrics retrieves all the custom metrics
func (*Collector) GetStatement ¶
GetStatement retrieves the statement associated to the given in
type Config ¶
type Config struct { Bucket BucketConfig Port int TLS TLSConfig `yaml:"tls,omitempty"` URL string Custom Custom `yaml:"custom,omitempty"` }
Config has the configuration for the metrics-exporter * Bucket: Log10 Bucket Configuration * Port: Port that the export is listening to * Tls: optional Tls configuration * Url: CockroachDB Prometheus endpoint
func ReadConfig ¶
ReadConfig reads yaml configuration from a file
func (*Config) GetTLSClientContext ¶
func (c *Config) GetTLSClientContext() (*TLSClientContext, error)
GetTLSClientContext builds the Client TLS context
func (*Config) GetTLSServerContext ¶
GetTLSServerContext builds the Server TLS context
type Custom ¶
type Custom struct { URL string DisableGetStatement bool Limit int SkipActivity bool SkipEfficiency bool Frequency int Endpoint string }
Custom provides the configuration to retrieve custom metrics
type MetricsReader ¶
type MetricsReader struct { Config *Config //SecureCtx *TlsClientContext Transport *http.Transport }
MetricsReader reads the metrics from a CockroachDB endpoint (/_status/var)
func CreateMetricsReader ¶
func CreateMetricsReader(c *Config, t *http.Transport) *MetricsReader
CreateMetricsReader instantiates a new Reader
func (*MetricsReader) ReadMetrics ¶
func (r *MetricsReader) ReadMetrics(ctx context.Context) (map[string]*dto.MetricFamily, error)
ReadMetrics reads the metrics from the endpoint and returns a map of dto.MetricFamily
type MetricsWriter ¶
MetricsWriter write metrics, after transforming them based on the configuration supplied.
func CreateMetricsWriter ¶
func CreateMetricsWriter(config *Config) *MetricsWriter
CreateMetricsWriter instantiates a MetricsWriter
func (*MetricsWriter) WriteMetrics ¶
func (w *MetricsWriter) WriteMetrics( ctx context.Context, metricFamilies map[string]*dto.MetricFamily, out io.Writer, )
WriteMetrics writes the metrics, converting HDR Histogram into Log10 linear histograms.
type TLSClientContext ¶
type TLSClientContext struct { CertPool *x509.CertPool Certificate tls.Certificate }
TLSClientContext is the context for TLS connections.