Documentation ¶
Overview ¶
Package collector manages a metric collection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector interface { fmt.Stringer // AddCounter adds a counter to the list of metrics to return. AddCounter(name string, help string) error // AddGauge adds a gauge to the list of metrics to return. AddGauge(name string, help string) error // Collect retrieves the values for all the metrics defined. Collect(ctx context.Context, conn database.Connection) error // GetFrequency returns how often the collector is called, in seconds. GetFrequency() int // GetLastModified retrieve the last time the job was modified. GetLastModified() time.Time // Unregister all the prometheus collectors. Unregister() // WithFrequency sets the frequency WithFrequency(frequency int) Collector // WithMaxResults sets the maximum number of results to collect each time Collect is called. WithMaxResults(max int) Collector }
A Collector retrieves all the metric values for all the gauges and counters configured.
func FromCollection ¶
func FromCollection(coll *store.Collection, registerer prometheus.Registerer) (Collector, error)
FromCollection creates a collector from a collection configuration stored in the database.
func New ¶
New creates a collector with the given name. The labels define the various attributes of the metrics being captured. The query is the SQL query being executed to retrieve the metric values. The query must have an argument to specify the limit on the number results to be returned. The columns must contain the labels specified. The format of the query: (SELECT label1,label2, ..., metric1,metric2,... FROM ... WHERE ... LIMIT $1)
type MetricKind ¶
type MetricKind int
MetricKind specify the type of the metric: counter or gauge.
const ( // Undefined is for metrics not currently supported. Undefined MetricKind = iota // Counter is a cumulative metric that represents a single monotonically increasing value. Counter // Gauge is a metric that represents a single numerical value that can arbitrarily go up and down. Gauge )