From cb66e325d80c3b9605c7726d96c4686d2ed6b9ae Mon Sep 17 00:00:00 2001 From: Sayan Chowdhury Date: Sat, 24 Aug 2019 23:12:21 +0530 Subject: [PATCH] Show the warnings during label query (#5924) This patch loops through the warnings while querying the label and spits the output to stderr Fixes #5885 Signed-off-by: Sayan Chowdhury --- cmd/promtool/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go index 0958c4c96..84faf5d56 100644 --- a/cmd/promtool/main.go +++ b/cmd/promtool/main.go @@ -501,10 +501,13 @@ func QueryLabels(url *url.URL, name string, p printer) int { // Run query against client. api := v1.NewAPI(c) ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) - // TODO: Show warnings (second return value) somehow? See https://github.com/prometheus/prometheus/issues/5885 - val, _, err := api.LabelValues(ctx, name) + val, warn, err := api.LabelValues(ctx, name) cancel() + for _, v := range warn { + fmt.Fprintln(os.Stderr, "query warning:", v) + } + if err != nil { fmt.Fprintln(os.Stderr, "query error:", err) return 1