diff --git a/cmd/logcli/main.go b/cmd/logcli/main.go index be6023ebdb7ef3af3a64f3477bc705ea4a4d1d9d..28d65eeaf68c73e68e90335f3439c69f7a75517b 100644 --- a/cmd/logcli/main.go +++ b/cmd/logcli/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" kingpin "gopkg.in/alecthomas/kingpin.v2" @@ -8,7 +9,7 @@ import ( var ( app = kingpin.New("logcli", "A command-line for loki.") - addr = app.Flag("addr", "Server address.").Default("https://log-us.grafana.net").Envar("GRAFANA_ADDR").String() + addr = app.Flag("addr", "Server address.").Default("").Envar("GRAFANA_ADDR").String() username = app.Flag("username", "Username for HTTP basic auth.").Default("").Envar("GRAFANA_USERNAME").String() password = app.Flag("password", "Password for HTTP basic auth.").Default("").Envar("GRAFANA_PASSWORD").String() @@ -27,6 +28,10 @@ var ( func main() { switch kingpin.MustParse(app.Parse(os.Args[1:])) { case queryCmd.FullCommand(): + if *addr == "" { + fmt.Println("Server address cannot be empty") + os.Exit(1) + } doQuery() case labelsCmd.FullCommand(): doLabels() diff --git a/docs/logcli.md b/docs/logcli.md index 7d27ed81007e54413e0153f77c9cc9485734ff2d..d122e9c2d0ea170bf5c45ce5b7f9aa7751978563 100644 --- a/docs/logcli.md +++ b/docs/logcli.md @@ -31,8 +31,7 @@ A command-line for loki. Flags: --help Show context-sensitive help (also try --help-long and --help-man). - --addr="https://log-us.grafana.net" - Server address. + --addr="" Server address, need to specify. --username="" Username for HTTP basic auth. --password="" Password for HTTP basic auth. @@ -53,8 +52,7 @@ Run a LogQL query. Flags: --help Show context-sensitive help (also try --help-long and --help-man). - --addr="https://log-us.grafana.net" - Server address. + --addr="" Server address, need to specify. --username="" Username for HTTP basic auth. --password="" Password for HTTP basic auth. --limit=30 Limit on number of entries to print.