mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-21 07:56:26 +01:00
2a3a62dc41
vmalert: support configuration file for notifiers * vmalert notifiers now can be configured via file see https://docs.victoriametrics.com/vmalert.html#notifier-configuration-file * add support of Consul service discovery for notifiers config see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1947 * add UI section for currently loaded/discovered notifiers * deprecate `-rule.configCheckInterval` in favour of `-configCheckInterval` * add ability to suppress logs for duplicated targets for notifiers discovery * change behaviour of `vmalert_alerts_send_errors_total` - it now accounts for failed alerts, not HTTP calls.
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package utils
|
|
|
|
import "github.com/VictoriaMetrics/metrics"
|
|
|
|
type namedMetric struct {
|
|
Name string
|
|
}
|
|
|
|
// Unregister removes the metric by name from default registry
|
|
func (nm namedMetric) Unregister() {
|
|
metrics.UnregisterMetric(nm.Name)
|
|
}
|
|
|
|
// Gauge is a metrics.Gauge with Name
|
|
type Gauge struct {
|
|
namedMetric
|
|
*metrics.Gauge
|
|
}
|
|
|
|
// GetOrCreateGauge creates a new Gauge with the given name
|
|
func GetOrCreateGauge(name string, f func() float64) *Gauge {
|
|
return &Gauge{
|
|
namedMetric: namedMetric{Name: name},
|
|
Gauge: metrics.GetOrCreateGauge(name, f),
|
|
}
|
|
}
|
|
|
|
// Counter is a metrics.Counter with Name
|
|
type Counter struct {
|
|
namedMetric
|
|
*metrics.Counter
|
|
}
|
|
|
|
// GetOrCreateCounter creates a new Counter with the given name
|
|
func GetOrCreateCounter(name string) *Counter {
|
|
return &Counter{
|
|
namedMetric: namedMetric{Name: name},
|
|
Counter: metrics.GetOrCreateCounter(name),
|
|
}
|
|
}
|
|
|
|
// Summary is a metrics.Summary with Name
|
|
type Summary struct {
|
|
namedMetric
|
|
*metrics.Summary
|
|
}
|
|
|
|
// GetOrCreateSummary creates a new Summary with the given name
|
|
func GetOrCreateSummary(name string) *Summary {
|
|
return &Summary{
|
|
namedMetric: namedMetric{Name: name},
|
|
Summary: metrics.GetOrCreateSummary(name),
|
|
}
|
|
}
|