Show warnings in UI if query have returned some warnings (#5964)

* Show warnings in UI if query have returned some warnings
+ improve warning (error) text if query to remote was finished with error
* Add prefixes for remote_read errors

Signed-off-by: Stan Putrya <root.vagner@gmail.com>
This commit is contained in:
Stanislav Putrya 2019-08-28 15:25:28 +02:00 committed by Brian Brazil
parent 1c6d2194c4
commit 6141a8bd7c
4 changed files with 14 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import (
"io"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/gogo/protobuf/proto"
@ -155,13 +156,14 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query) (*prompb.QueryRe
io.Copy(ioutil.Discard, httpResp.Body)
httpResp.Body.Close()
}()
if httpResp.StatusCode/100 != 2 {
return nil, errors.Errorf("server returned HTTP status %s", httpResp.Status)
}
compressed, err = ioutil.ReadAll(httpResp.Body)
if err != nil {
return nil, errors.Wrap(err, "error reading response")
return nil, errors.Wrap(err, fmt.Sprintf("error reading response. HTTP status code: %s", httpResp.Status))
}
if httpResp.StatusCode/100 != 2 {
return nil, errors.Errorf("remote server %s returned HTTP status %s: %s", c.url.String(), httpResp.Status, strings.TrimSpace(string(compressed)))
}
uncompressed, err := snappy.Decode(nil, compressed)

View File

@ -15,6 +15,7 @@ package remote
import (
"context"
"fmt"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/pkg/labels"
@ -70,7 +71,7 @@ func (q *querier) Select(p *storage.SelectParams, matchers ...*labels.Matcher) (
res, err := q.client.Read(q.ctx, query)
if err != nil {
return nil, nil, err
return nil, nil, fmt.Errorf("remote_read: %v", err)
}
return FromQueryResult(res), nil, nil

File diff suppressed because one or more lines are too long

View File

@ -513,6 +513,10 @@ Prometheus.Graph.prototype.submitQuery = function() {
return;
}
if ("warnings" in json && json.warnings.length > 0) {
self.showWarning(json.warnings.join('<br>'));
}
queryHistory.handleHistory(self);
success(json.data, textStatus);
},