package
0.0.0-20151026012706-449ccefff16c
Repository: https://github.com/dnesting/client_golang.git
Documentation: pkg.go.dev

# README

Overview

This is the Prometheus telemetric instrumentation client Go client library. It enable authors to define process-space metrics for their servers and expose them through a web service interface for extraction, aggregation, and a whole slew of other post processing techniques.

Installing

$ go get github.com/prometheus/client_golang/prometheus

Example

package main

import (
	"net/http"

	"github.com/prometheus/client_golang/prometheus"
)

var (
	indexed = prometheus.NewCounter(prometheus.CounterOpts{
		Namespace: "my_company",
		Subsystem: "indexer",
		Name:      "documents_indexed",
		Help:      "The number of documents indexed.",
	})
	size = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "my_company",
		Subsystem: "storage",
		Name:      "documents_total_size_bytes",
		Help:      "The total size of all documents in the storage.",
	})
)

func main() {
	http.Handle("/metrics", prometheus.Handler())

	indexed.Inc()
	size.Set(5)

	http.ListenAndServe(":8080", nil)
}

func init() {
	prometheus.MustRegister(indexed)
	prometheus.MustRegister(size)
}

Documentation

GoDoc

# Functions

BuildFQName joins the given three name components by "_".
EnableCollectChecks enables (or disables) additional consistency checks during metrics collection.
ExponentialBuckets creates 'count' buckets, where the lowest bucket has an upper bound of 'start' and each following bucket's upper bound is 'factor' times the previous bucket's upper bound.
Handler returns the HTTP handler for the global Prometheus registry.
InstrumentHandler wraps the given HTTP handler for instrumentation.
InstrumentHandlerFunc wraps the given function for instrumentation.
InstrumentHandlerFuncWithOpts works like InstrumentHandlerFunc but provides more flexibility (at the cost of a more complex call syntax).
InstrumentHandlerWithOpts works like InstrumentHandler but provides more flexibility (at the cost of a more complex call syntax).
LinearBuckets creates 'count' buckets, each 'width' wide, where the lowest bucket has an upper bound of 'start'.
MustNewConstHistogram is a version of NewConstHistogram that panics where NewConstMetric would have returned an error.
MustNewConstMetric is a version of NewConstMetric that panics where NewConstMetric would have returned an error.
MustNewConstSummary is a version of NewConstSummary that panics where NewConstMetric would have returned an error.
MustRegister works like Register but panics where Register would have returned an error.
MustRegisterOrGet works like Register but panics where RegisterOrGet would have returned an error.
NewConstHistogram returns a metric representing a Prometheus histogram with fixed values for the count, sum, and bucket counts.
NewConstMetric returns a metric with one fixed value that cannot be changed.
NewConstSummary returns a metric representing a Prometheus summary with fixed values for the count, sum, and quantiles.
NewCounter creates a new Counter based on the provided CounterOpts.
NewCounterFunc creates a new CounterFunc based on the provided CounterOpts.
NewCounterVec creates a new CounterVec based on the provided CounterOpts and partitioned by the given label names.
NewDesc allocates and initializes a new Desc.
NewExpvarCollector returns a newly allocated ExpvarCollector that still has to be registered with the Prometheus registry.
NewGauge creates a new Gauge based on the provided GaugeOpts.
NewGaugeFunc creates a new GaugeFunc based on the provided GaugeOpts.
NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and partitioned by the given label names.
NewGoCollector returns a collector which exports metrics about the current go process.
NewHistogram creates a new Histogram based on the provided HistogramOpts.
NewHistogramVec creates a new HistogramVec based on the provided HistogramOpts and partitioned by the given label names.
NewInvalidDesc returns an invalid descriptor, i.e.
NewInvalidMetric returns a metric whose Write method always returns the provided error.
NewProcessCollector returns a collector which exports the current state of process metrics including cpu, memory and file descriptor usage as well as the process start time for the given process id under the given namespace.
NewProcessCollectorPIDFn returns a collector which exports the current state of process metrics including cpu, memory and file descriptor usage as well as the process start time under the given namespace.
NewSummary creates a new Summary based on the provided SummaryOpts.
NewSummaryVec creates a new SummaryVec based on the provided SummaryOpts and partitioned by the given label names.
NewUntyped creates a new Untyped metric from the provided UntypedOpts.
NewUntypedFunc creates a new UntypedFunc based on the provided UntypedOpts.
NewUntypedVec creates a new UntypedVec based on the provided UntypedOpts and partitioned by the given label names.
PanicOnCollectError sets the behavior whether a panic is caused upon an error while metrics are collected and served to the HTTP endpoint.
Push triggers a metric collection by the default registry and pushes all collected metrics to the Pushgateway specified by addr.
PushAdd works like Push, but only previously pushed metrics with the same name (and the same job and instance) will be replaced.
PushAddCollectors works like PushAdd, but it does not collect from the default registry.
PushCollectors works like Push, but it does not collect from the default registry.
Register registers a new Collector to be included in metrics collection.
RegisterOrGet works like Register but does not return an error if a Collector is registered that equals a previously registered Collector.
SetMetricFamilyInjectionHook sets a function that is called whenever metrics are collected.
UninstrumentedHandler works in the same way as Handler, but the returned HTTP handler is not instrumented.
Unregister unregisters the Collector that equals the Collector passed in as an argument.

# Constants

APIVersion is the version of the format of the exported data.
Possible values for the ValueType enum.
DefAgeBuckets is the default number of buckets used to calculate the age of observations.
DefBufCap is the standard buffer size for collecting Summary observations.
DefMaxAge is the default duration for which observations stay relevant.
DelimitedTelemetryContentType is the content type set on telemetry data responses in delimited protobuf format.
Possible values for the ValueType enum.
ProtoCompactTextTelemetryContentType is the content type set on telemetry data responses in protobuf compact text format.
ProtoTextTelemetryContentType is the content type set on telemetry data responses in protobuf text format.
TextTelemetryContentType is the content type set on telemetry data responses in text format.
Possible values for the ValueType enum.

# Variables

DefBuckets are the default Histogram buckets.
DefObjectives are the default Summary quantile values.

# Structs

CounterVec is a Collector that bundles a set of Counters that all share the same Desc, but have different values for their variable labels.
Desc is the descriptor used by every Prometheus Metric.
ExpvarCollector collects metrics from the expvar interface.
GaugeVec is a Collector that bundles a set of Gauges that all share the same Desc, but have different values for their variable labels.
HistogramOpts bundles the options for creating a Histogram metric.
HistogramVec is a Collector that bundles a set of Histograms that all share the same Desc, but have different values for their variable labels.
MetricVec is a Collector to bundle metrics of the same name that differ in their label values.
Opts bundles the options for creating most Metric types.
SelfCollector implements Collector for a single Metric so that that the Metric collects itself.
SummaryOpts bundles the options for creating a Summary metric.
SummaryVec is a Collector that bundles a set of Summaries that all share the same Desc, but have different values for their variable labels.
UntypedVec is a Collector that bundles a set of Untyped metrics that all share the same Desc, but have different values for their variable labels.

# Interfaces

Collector is the interface implemented by anything that can be used by Prometheus to collect metrics.
Counter is a Metric that represents a single numerical value that only ever goes up.
CounterFunc is a Counter whose value is determined at collect time by calling a provided function.
Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down.
GaugeFunc is a Gauge whose value is determined at collect time by calling a provided function.
A Histogram counts individual observations from an event or sample stream in configurable buckets.
A Metric models a single sample value with its meta data being exported to Prometheus.
A Summary captures individual observations from an event or sample stream and summarizes them in a manner similar to traditional summary statistics: 1.
Untyped is a Metric that represents a single numerical value that can arbitrarily go up and down.
UntypedFunc is an Untyped whose value is determined at collect time by calling a provided function.

# Type aliases

CounterOpts is an alias for Opts.
GaugeOpts is an alias for Opts.
LabelPairSorter implements sort.Interface.
Labels represents a collection of label name -> value mappings.
UntypedOpts is an alias for Opts.
ValueType is an enumeration of metric types that represent a simple value.