mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
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:
parent
1c6d2194c4
commit
6141a8bd7c
|
@ -21,6 +21,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gogo/protobuf/proto"
|
"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)
|
io.Copy(ioutil.Discard, httpResp.Body)
|
||||||
httpResp.Body.Close()
|
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)
|
compressed, err = ioutil.ReadAll(httpResp.Body)
|
||||||
if err != nil {
|
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)
|
uncompressed, err := snappy.Decode(nil, compressed)
|
||||||
|
|
|
@ -15,6 +15,7 @@ package remote
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/prometheus/pkg/labels"
|
"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)
|
res, err := q.client.Read(q.ctx, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, fmt.Errorf("remote_read: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return FromQueryResult(res), nil, nil
|
return FromQueryResult(res), nil, nil
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -513,6 +513,10 @@ Prometheus.Graph.prototype.submitQuery = function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("warnings" in json && json.warnings.length > 0) {
|
||||||
|
self.showWarning(json.warnings.join('<br>'));
|
||||||
|
}
|
||||||
|
|
||||||
queryHistory.handleHistory(self);
|
queryHistory.handleHistory(self);
|
||||||
success(json.data, textStatus);
|
success(json.data, textStatus);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue