From e8296a644d4b05c7f5907abd0b49d7f557289a87 Mon Sep 17 00:00:00 2001 From: Hector Date: Tue, 12 Oct 2021 21:28:19 +0100 Subject: [PATCH] support metric files with uppercase extension --- README.md | 6 +++--- src/textfile/file.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7cd339a..6667d7b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ $ fail2ban-prometheus-exporter -h path to the fail2ban server socket -version show version info and exit - -collector.textfile + -collector.textfile enable the textfile collector -collector.textfile.directory string directory to read text files with metrics from @@ -256,7 +256,7 @@ To enable textfile metrics: Metrics collected from these files will be exposed directly alongside the other metrics without any additional processing. This means that it is the responsibility of the file creator to ensure the format is correct. -By exporting textfile metrics, an extra metric is also exported with an error count for each file: +By exporting textfile metrics an extra metric is also exported with an error count for each file: ``` # HELP textfile_error Checks for errors while reading text files @@ -264,4 +264,4 @@ By exporting textfile metrics, an extra metric is also exported with an error co textfile_error{path="file.prom"} 0 ``` -**NOTE:** Only files ending with `.prom` will be considered. +**NOTE:** Any file not ending with `.prom` will be ignored. diff --git a/src/textfile/file.go b/src/textfile/file.go index 0388e3f..7ed5de7 100644 --- a/src/textfile/file.go +++ b/src/textfile/file.go @@ -27,7 +27,7 @@ func (c *Collector) collectFileContents() { for _, file := range files { fileName := file.Name() - if !strings.HasSuffix(fileName, ".prom") { + if !strings.HasSuffix(strings.ToLower(fileName), ".prom") { continue } c.fileMap[fileName] = &fileData{