prometheus

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Overview

Package prometheus defines configuration and functions for emitting metrics to Prometheus.

It supports a special format for metric names to add metric-specific labels:

metricName[label1,label2:value2,...]

Global labels for all metrics can be set in the configuration. If a label is specified without a value, the label key is used as the value.

The package translates between rcrowley/go-metrics types and Prometheus types as neeeded:

  • metrics.Counter metrics are reported as untyped metrics because they may increase or decrease
  • metrics.Histogram metrics are reported as Prometheus summaries using a configurable (per emitter) set of quantiles. The max and min values are also reported. Use Prometheus functions to compute the mean.
  • metrics.Meter metrics are reported as Prometheus counters. Use Prometheus functions to compute rates.
  • metrics.Timers values are reported as Prometheus summaries in fractional seconds using a configurable (per emitter) set of quantiles. The max and min values are also reported. Use Prometheus functions to compute the mean and rates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(r metrics.Registry, config Config) http.Handler

NewHandler returns a new http.Handler that returns the metrics in the registry.

Types

type Collector

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

Collector is a prometheus.Collector that emits the metrics from a metrics.Registry.

func NewCollector

func NewCollector(r metrics.Registry, opts ...CollectorOption) *Collector

func (*Collector) Collect

func (c *Collector) Collect(ch chan<- prometheus.Metric)

func (*Collector) Describe

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

type CollectorOption

type CollectorOption func(*Collector)

func WithHistogramQuantiles

func WithHistogramQuantiles(qs []float64) CollectorOption

WithHistogramQuantiles sets the quantiles reported in summaries of histogram metrics. By default, use 0.5 and 0.95, the median and the 95th percentile.

func WithLabels

func WithLabels(labels map[string]string) CollectorOption

WithLabels sets static labels to attach to all metrics.

func WithTimerQuantiles

func WithTimerQuantiles(qs []float64) CollectorOption

WithTimerQuantiles sets the quantiles reported in summaries of timer metrics. By default, use 0.5 and 0.95, the median and the 95th percentile.

type Config

type Config struct {
	Labels             map[string]string `yaml:"labels" json:"labels"`
	HistogramQuantiles []float64         `yaml:"histogram_quantiles" json:"histogram_quantiles"`
	TimerQuantiles     []float64         `yaml:"timer_quantiles" json:"timer_quantiles"`
}

Jump to

Keyboard shortcuts

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