You've already forked prometheus-fail2ban-exporter
feat: support for textfile metrics (#13)
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.
This commit is contained in:
@ -12,10 +12,12 @@ const (
|
||||
)
|
||||
|
||||
type AppSettings struct {
|
||||
VersionMode bool
|
||||
MetricsPort int
|
||||
Fail2BanDbPath string
|
||||
Fail2BanSocketPath string
|
||||
VersionMode bool
|
||||
MetricsPort int
|
||||
Fail2BanDbPath string
|
||||
Fail2BanSocketPath string
|
||||
FileCollectorPath string
|
||||
FileCollectorEnabled bool
|
||||
}
|
||||
|
||||
func Parse() *AppSettings {
|
||||
@ -24,6 +26,8 @@ func Parse() *AppSettings {
|
||||
flag.IntVar(&appSettings.MetricsPort, "port", 9191, "port to use for the metrics server")
|
||||
flag.StringVar(&appSettings.Fail2BanDbPath, "db", "", "path to the fail2ban sqlite database (deprecated)")
|
||||
flag.StringVar(&appSettings.Fail2BanSocketPath, "socket", "", "path to the fail2ban server socket")
|
||||
flag.BoolVar(&appSettings.FileCollectorEnabled, "collector.textfile", false, "enable the textfile collector")
|
||||
flag.StringVar(&appSettings.FileCollectorPath, "collector.textfile.directory", "", "directory to read text files with metrics from")
|
||||
|
||||
flag.Parse()
|
||||
appSettings.validateFlags()
|
||||
@ -42,6 +46,10 @@ func (settings *AppSettings) validateFlags() {
|
||||
minServerPort, maxServerPort, settings.MetricsPort)
|
||||
flagsValid = false
|
||||
}
|
||||
if settings.FileCollectorEnabled && settings.FileCollectorPath == "" {
|
||||
fmt.Printf("file collector directory path must not be empty if collector enabled\n")
|
||||
flagsValid = false
|
||||
}
|
||||
}
|
||||
if !flagsValid {
|
||||
flag.Usage()
|
||||
|
Reference in New Issue
Block a user