Skip to content

Commit

Permalink
Add ability to set bind address via command-line flag (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatirdan committed Mar 1, 2021
1 parent b033474 commit 2870493
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/loader_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package config
func LoadConfigFromFlags(config *Config, flags *StartupFlags) error {
config.Listen = ListenConfig{
Port: flags.ListenPort,
Address: "0.0.0.0",
Address: flags.ListenAddress,
MetricsEndpoint: flags.MetricsEndpoint,
}
config.Namespaces = []NamespaceConfig{
Expand Down
1 change: 1 addition & 0 deletions config/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type StartupFlags struct {
Parser string
Format string
Namespace string
ListenAddress string
ListenPort int
EnableExperimentalFeatures bool
MetricsEndpoint string
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func main() {
nsGatherers := make(prometheus.Gatherers, 0)

flag.IntVar(&opts.ListenPort, "listen-port", 4040, "HTTP port to listen on")
flag.StringVar(&opts.ListenAddress, "listen-address", "0.0.0.0", "IP-address to bind")
flag.StringVar(&opts.Parser, "parser", "text", "NGINX access log format parser. One of: [text, json]")
flag.StringVar(&opts.Format, "format", `$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"`, "NGINX access log format")
flag.StringVar(&opts.Namespace, "namespace", "nginx", "namespace to use for metric names")
Expand Down

0 comments on commit 2870493

Please sign in to comment.