
Add support for collecting arbitrary metrics from a textfile as well as metrics collected from fail2ban. This allows other data to be exported along with the fail2ban metrics (e.g. instance metadata). Update the docker image to allow mounting a folder with a collection of metric files to be exported. Only files ending in `.prom` with be read. Update project README with the new functionality.
21 lines
382 B
Go
21 lines
382 B
Go
package textfile
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func (c *Collector) WriteTextFileMetrics(w http.ResponseWriter, r *http.Request) {
|
|
if !c.enabled {
|
|
return
|
|
}
|
|
|
|
for _, f := range c.fileMap {
|
|
_, err := w.Write(f.fileContents)
|
|
if err != nil {
|
|
c.appendErrorForPath(f.fileName)
|
|
log.Printf("error writing file contents to response writer '%s': %v", f.fileName, err)
|
|
}
|
|
}
|
|
}
|