Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support config-file #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions php-fpm_exporter.yaml
Original file line number Diff line number Diff line change
@@ -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