Documentation ¶
Overview ¶
Package metric is the package to report the metrics to Prometheus
Index ¶
- func AddConstLabels(labels prometheus.Labels, constLabels prometheus.Labels) prometheus.Labels
- func Counter(key string) *prometheus.CounterVec
- func Gauge(key string) *prometheus.GaugeVec
- func GetName(fields ...string) string
- func NewCounter(namespace, subsystem, name, metric string, help string, labels []string, ...) *prometheus.CounterVec
- func NewGauge(namespace, subsystem, name, metric string, help string, labels []string, ...) *prometheus.GaugeVec
- func RemoveInvalidChars(name string) string
- func ValidLabelName(label string) bool
- func ValidMetricChar(ch byte) bool
- func ValidMetricName(name string) bool
- type MetricsType
- type PrometheusPushSink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConstLabels ¶
func AddConstLabels(labels prometheus.Labels, constLabels prometheus.Labels) prometheus.Labels
AddConstLabels append user defined labels in the configuration file to the predefined label set.
func Counter ¶
func Counter(key string) *prometheus.CounterVec
Counter get the counter metric by key
func NewCounter ¶
func NewCounter(namespace, subsystem, name, metric string, help string, labels []string, constLabels prometheus.Labels) *prometheus.CounterVec
NewCounter create the counter metric
func NewGauge ¶
func NewGauge(namespace, subsystem, name, metric string, help string, labels []string, constLabels prometheus.Labels) *prometheus.GaugeVec
NewGauge create the gauge metric
func RemoveInvalidChars ¶
RemoveInvalidChars remove invalid chars
func ValidLabelName ¶
ValidLabelName check if the label name is valid
func ValidMetricChar ¶
ValidMetricChar check if the char is valid for metric name
func ValidMetricName ¶
ValidMetricName check if the metric name is valid
Types ¶
type MetricsType ¶
type MetricsType interface { *prometheus.CounterVec | *prometheus.GaugeVec | *prometheus.HistogramVec | *prometheus.SummaryVec }
MetricsType is the generic type of metrics
type PrometheusPushSink ¶
type PrometheusPushSink struct {
// contains filtered or unexported fields
}
func NewPrometheusPushSink ¶
func NewPrometheusPushSink(namespace, address string, pushInterval time.Duration, done chan bool) *PrometheusPushSink
func (*PrometheusPushSink) Collect ¶
func (p *PrometheusPushSink) Collect(c chan<- prometheus.Metric)
Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.
func (*PrometheusPushSink) Describe ¶
func (p *PrometheusPushSink) Describe(c chan<- *prometheus.Desc)
Describe sends a Collector.Describe value from the descriptor created around PrometheusSink.Name Note that we cannot describe all the metrics (gauges, counters, summaries) in the sink as metrics can be added at any point during the lifecycle of the sink, which does not respect the idempotency aspect of the Collector.Describe() interface