diff --git a/cmd/root.go b/cmd/root.go index cbafe938..66aeed75 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -82,6 +82,24 @@ func initConfig() { if err := viper.ReadInConfig(); err == nil { fmt.Println("Using config file:", viper.ConfigFileUsed()) } + + // use config file + if len(viper.GetString("web.listen-address")) > 0 { + listeningAddress = viper.GetString("web.listen-address") + } + + if len(viper.GetString("web.telemetry-path")) > 0 { + metricsEndpoint = viper.GetString("web.telemetry-path") + } + + if len(viper.GetStringSlice("phpfpm.scrape-uri")) > 0 { + scrapeURIs = viper.GetStringSlice("phpfpm.scrape-uri") + } + + if viper.GetString("phpfpm.fix-process-count") == "true" { + fixProcessCount = viper.GetBool("phpfpm.fix-process-count") + } + log.Println(viper.Get("web.listen-address")) } // initLogger configures the log level diff --git a/php-fpm_exporter.yaml b/php-fpm_exporter.yaml new file mode 100644 index 00000000..858c75dd --- /dev/null +++ b/php-fpm_exporter.yaml @@ -0,0 +1,7 @@ +web: + listen-address: ":9523" + telemetry-path: "/metrics" +php-fpm: + scrape-uri: + - "tcp://127.0.0.1:9000/status" + fix-process-count: false