mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-13 17:14:05 -08:00
file sd: create and increment an inotify error counter when file-SD i… (#11066)
* file sd: create and increment an inotify error counter when file-SD is unable to watch files. Additionally, order metrics alphabetically. Signed-off-by: Michael Fuller <mfuller@digitalocean.com> * file.go: consistent naming and help for prometheus_sd_file_watcher_errors_total Signed-off-by: Michael Fuller <mfuller@digitalocean.com> Signed-off-by: Michael Fuller <mfuller@digitalocean.com> Co-authored-by: Michael Fuller <mfuller@digitalocean.com>
This commit is contained in:
parent
6b53aeb012
commit
15ba7a0d2d
|
@ -39,18 +39,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
fileSDReadErrorsCount = prometheus.NewCounter(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Name: "prometheus_sd_file_read_errors_total",
|
||||||
|
Help: "The number of File-SD read errors.",
|
||||||
|
})
|
||||||
fileSDScanDuration = prometheus.NewSummary(
|
fileSDScanDuration = prometheus.NewSummary(
|
||||||
prometheus.SummaryOpts{
|
prometheus.SummaryOpts{
|
||||||
Name: "prometheus_sd_file_scan_duration_seconds",
|
Name: "prometheus_sd_file_scan_duration_seconds",
|
||||||
Help: "The duration of the File-SD scan in 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},
|
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()
|
fileSDTimeStamp = NewTimestampCollector()
|
||||||
|
fileWatcherErrorsCount = prometheus.NewCounter(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Name: "prometheus_sd_file_watcher_errors_total",
|
||||||
|
Help: "The number of File-SD errors caused by filesystem watch failures.",
|
||||||
|
})
|
||||||
|
|
||||||
patFileSDName = regexp.MustCompile(`^[^*]*(\*[^/]*)?\.(json|yml|yaml|JSON|YML|YAML)$`)
|
patFileSDName = regexp.MustCompile(`^[^*]*(\*[^/]*)?\.(json|yml|yaml|JSON|YML|YAML)$`)
|
||||||
|
|
||||||
|
@ -62,7 +67,7 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
discovery.RegisterConfig(&SDConfig{})
|
discovery.RegisterConfig(&SDConfig{})
|
||||||
prometheus.MustRegister(fileSDScanDuration, fileSDReadErrorsCount, fileSDTimeStamp)
|
prometheus.MustRegister(fileSDReadErrorsCount, fileSDScanDuration, fileSDTimeStamp, fileWatcherErrorsCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SDConfig is the configuration for file based discovery.
|
// SDConfig is the configuration for file based discovery.
|
||||||
|
@ -237,6 +242,7 @@ func (d *Discovery) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Error(d.logger).Log("msg", "Error adding file watcher", "err", err)
|
level.Error(d.logger).Log("msg", "Error adding file watcher", "err", err)
|
||||||
|
fileWatcherErrorsCount.Inc()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
d.watcher = watcher
|
d.watcher = watcher
|
||||||
|
|
Loading…
Reference in a new issue