Documentation ¶
Index ¶
- Variables
- func AddMetrics(url string, job string)
- func GetHandler(getMetricsFn func(), timer *Timer) http.Handler
- func GetLabelNames(labelStruct interface{}) []string
- func GetLabelValues(labelStruct interface{}) []string
- func GetMetricText() string
- func PushMetrics(url string, job string)
- func Serve(getMetricsFn func(), port uint16, timer *Timer) error
- type Target
- type TargetGroup
- type Timer
Constants ¶
This section is empty.
Variables ¶
var Gatherer *prometheus.Gatherer = &prometheus.DefaultGatherer
Gatherer points to the current gatherer
Functions ¶
func AddMetrics ¶
AddMetrics pushes all metrics in the default registry to the target URL without overriding previously pushed metrics for this job
The URL should contain no path for the official pushgateway
func GetHandler ¶
GetHandler returns "/metrics" handler. Use this if you want to set up more handlers If the timer is nil, `getMetricsFn` will be called on each request
func GetLabelNames ¶
func GetLabelNames(labelStruct interface{}) []string
GetLabelNames creates a sorted list of label names out of struct fields to use in Prometheus metric The label can be specified by a `label` tag, e.g.: ```go
type ProcessLabels struct { ProcessName string `label:"process_name"` ProcessStatus string `label:"process_status"` }
``` If no `label` tag is specified, a field name converted to snake_case will be used instead
func GetLabelValues ¶
func GetLabelValues(labelStruct interface{}) []string
GetLabelValues creates a sorted list of label values out of struct field values to use in Prometheus metric See GetLabelNames function for the context If a field type is not string it will be converted to string automatically, see https://golang.org/pkg/reflect/#Value.String
func GetMetricText ¶
func GetMetricText() string
GetMetricText returns collected metrics. Usefull for tests.
func PushMetrics ¶
PushMetrics pushes all metrics in the default registry to the target URL
The URL should contain no path for the official pushgateway
Types ¶
type Target ¶
type Target[L comparable] struct { Target string // address, e.g. "host.org:12340" Labels L }
Target is a prometheus scrape target.
Labels must be a comparable struct, see `GetLabelNames` function description.
type TargetGroup ¶
type TargetGroup[L comparable] struct { Targets []string `json:"targets"` Labels L `json:"labels"` }
TargetGroup is a group of scrape targets sharing the same labels.
Each group normally represent the deployment one cluster on one server.
func GroupTargets ¶
func GroupTargets[L comparable](targetList []Target[L]) []TargetGroup[L]
GroupTargets groups targets by distinct label values
The resulting target groups and the target addresses inside each group are ordered by their string representations to ensure stable ordering.
type Timer ¶
type Timer = chan bool
Timer defines how often metrics will be updated. Should return true if there are more ticks left or false if we must shutdown
func CreateTimerFromCron ¶
CreateTimerFromCron creates a timer from a cron exptession, e.g "* * * * *"
func CreateTimerFromTicker ¶
CreateTimerFromTicker creates a timer from Ticker
Directories ¶
Path | Synopsis |
---|---|
Package promext contains custom metric types and pure utility functions
|
Package promext contains custom metric types and pure utility functions |
Package promreg provides a front to Prometheus metric registry to help with creation of metrics in components as well as querying.
|
Package promreg provides a front to Prometheus metric registry to help with creation of metrics in components as well as querying. |