|
|
|
@ -242,10 +242,12 @@ func parse(args []string) error {
|
|
|
|
|
if err := parsePrometheusURL(); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err := parseInfluxdbURL(); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
if err := validateAlertmanagerURL(); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cfg.remote.InfluxdbPassword = os.Getenv("INFLUXDB_PW") |
|
|
|
|
|
|
|
|
@ -266,7 +268,7 @@ func parsePrometheusURL() error {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ok := govalidator.IsURL(cfg.prometheusURL); !ok { |
|
|
|
|
return fmt.Errorf("Invalid Prometheus URL: %s", cfg.prometheusURL) |
|
|
|
|
return fmt.Errorf("invalid Prometheus URL: %s", cfg.prometheusURL) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
promURL, err := url.Parse(cfg.prometheusURL) |
|
|
|
@ -289,7 +291,7 @@ func parseInfluxdbURL() error {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ok := govalidator.IsURL(cfg.influxdbURL); !ok { |
|
|
|
|
return fmt.Errorf("Invalid InfluxDB URL: %s", cfg.influxdbURL) |
|
|
|
|
return fmt.Errorf("invalid InfluxDB URL: %s", cfg.influxdbURL) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
url, err := url.Parse(cfg.influxdbURL) |
|
|
|
@ -301,6 +303,23 @@ func parseInfluxdbURL() error {
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func validateAlertmanagerURL() error { |
|
|
|
|
if cfg.notifier.AlertmanagerURL == "" { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
if ok := govalidator.IsURL(cfg.notifier.AlertmanagerURL); !ok { |
|
|
|
|
return fmt.Errorf("invalid Alertmanager URL: %s", cfg.notifier.AlertmanagerURL) |
|
|
|
|
} |
|
|
|
|
url, err := url.Parse(cfg.notifier.AlertmanagerURL) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
if url.Scheme == "" { |
|
|
|
|
return fmt.Errorf("missing scheme in Alertmanager URL: %s", cfg.notifier.AlertmanagerURL) |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var helpTmpl = ` |
|
|
|
|
usage: prometheus [<args>] |
|
|
|
|
{{ range $cat, $flags := . }}{{ if ne $cat "." }} == {{ $cat | upper }} =={{ end }} |
|
|
|
|