mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-04 20:06:12 +02:00
Fix path handling in File-SD watcher to allow directory monitoring on Windows
Previously, `d.paths` were normalized to backslashes on Windows, even when if
the config file used Unix style. The end result meant always watching `./`, so
changes for this config were always ignored:
scrape_configs:
- job_name: 'envmsc1'
file_sd_configs:
- files:
- 'targets/envmsc1.d/*.yml'
- 'targets/envmsc1.d/*.yaml'
Additionally, unlike the other platforms, no warning was emitted on startup
about not being able to install the watch if the directory didn't exist. Now it
is logged.
Signed-off-by: Matt Harbison <mharbison@atto.com>
This commit is contained in:
parent
391ecaec9a
commit
02277bbe0d
@ -226,8 +226,8 @@ func (d *Discovery) watchFiles() {
|
||||
panic("no watcher configured")
|
||||
}
|
||||
for _, p := range d.paths {
|
||||
if idx := strings.LastIndex(p, "/"); idx > -1 {
|
||||
p = p[:idx]
|
||||
if dir, _ := filepath.Split(p); dir != "" {
|
||||
p = dir
|
||||
} else {
|
||||
p = "./"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user