mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-25 20:54:41 -08:00
Refactor file discovery init function (#8891)
* Refactor file discovery init function Combine to one init function like other discovery. Signed-off-by: songjiayang <songjiayang1@gmail.com>
This commit is contained in:
parent
6cbed8c569
commit
b781b5cac5
|
@ -102,8 +102,7 @@ var (
|
|||
|
||||
func init() {
|
||||
discovery.RegisterConfig(&SDConfig{})
|
||||
prometheus.MustRegister(rpcFailuresCount)
|
||||
prometheus.MustRegister(rpcDuration)
|
||||
prometheus.MustRegister(rpcFailuresCount, rpcDuration)
|
||||
}
|
||||
|
||||
// SDConfig is the configuration for Consul service discovery.
|
||||
|
|
|
@ -68,8 +68,7 @@ var (
|
|||
|
||||
func init() {
|
||||
discovery.RegisterConfig(&SDConfig{})
|
||||
prometheus.MustRegister(dnsSDLookupFailuresCount)
|
||||
prometheus.MustRegister(dnsSDLookupsCount)
|
||||
prometheus.MustRegister(dnsSDLookupFailuresCount, dnsSDLookupsCount)
|
||||
}
|
||||
|
||||
// SDConfig is the configuration for DNS based service discovery.
|
||||
|
|
|
@ -39,6 +39,19 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
fileSDScanDuration = prometheus.NewSummary(
|
||||
prometheus.SummaryOpts{
|
||||
Name: "prometheus_sd_file_scan_duration_seconds",
|
||||
Help: "The duration of the File-SD scan in seconds.",
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
})
|
||||
fileSDReadErrorsCount = prometheus.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "prometheus_sd_file_read_errors_total",
|
||||
Help: "The number of File-SD read errors.",
|
||||
})
|
||||
fileSDTimeStamp = NewTimestampCollector()
|
||||
|
||||
patFileSDName = regexp.MustCompile(`^[^*]*(\*[^/]*)?\.(json|yml|yaml|JSON|YML|YAML)$`)
|
||||
|
||||
// DefaultSDConfig is the default file SD configuration.
|
||||
|
@ -49,6 +62,7 @@ var (
|
|||
|
||||
func init() {
|
||||
discovery.RegisterConfig(&SDConfig{})
|
||||
prometheus.MustRegister(fileSDScanDuration, fileSDReadErrorsCount, fileSDTimeStamp)
|
||||
}
|
||||
|
||||
// SDConfig is the configuration for file based discovery.
|
||||
|
@ -153,27 +167,6 @@ func NewTimestampCollector() *TimestampCollector {
|
|||
}
|
||||
}
|
||||
|
||||
var (
|
||||
fileSDScanDuration = prometheus.NewSummary(
|
||||
prometheus.SummaryOpts{
|
||||
Name: "prometheus_sd_file_scan_duration_seconds",
|
||||
Help: "The duration of the File-SD scan in seconds.",
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
})
|
||||
fileSDReadErrorsCount = prometheus.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "prometheus_sd_file_read_errors_total",
|
||||
Help: "The number of File-SD read errors.",
|
||||
})
|
||||
fileSDTimeStamp = NewTimestampCollector()
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(fileSDScanDuration)
|
||||
prometheus.MustRegister(fileSDReadErrorsCount)
|
||||
prometheus.MustRegister(fileSDTimeStamp)
|
||||
}
|
||||
|
||||
// Discovery provides service discovery functionality based
|
||||
// on files that contain target groups in JSON or YAML format. Refreshing
|
||||
// happens using file watches and periodic refreshes.
|
||||
|
|
Loading…
Reference in a new issue