Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[query] Log query errors with query params #2225

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/query/api/v1/handler/prometheus/native/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (h *PromReadHandler) ServeHTTPWithEngine(
w http.ResponseWriter,
r *http.Request,
engine executor.Engine,
opts *executor.QueryOptions,
queryOpts *executor.QueryOptions,
fetchOpts *storage.FetchOptions,
) ([]*ts.Series, models.RequestParams, *RespError) {
ctx := context.WithValue(r.Context(), handler.HeaderKey, r.Header)
Expand All @@ -197,21 +197,25 @@ func (h *PromReadHandler) ServeHTTPWithEngine(
}

if params.Debug {
logger.Info("Request params", zap.Any("params", params))
logger.Info("request params", zap.Any("params", params))
}

if err := h.validateRequest(&params); err != nil {
h.promReadMetrics.fetchErrorsClient.Inc(1)
return nil, emptyReqParams, &RespError{Err: err, Code: http.StatusBadRequest}
}

result, err := read(ctx, engine, opts, fetchOpts, h.tagOpts,
result, err := read(ctx, engine, queryOpts, fetchOpts, h.tagOpts,
w, params, h.instrumentOpts)
if err != nil {
sp := xopentracing.SpanFromContextOrNoop(ctx)
sp.LogFields(opentracinglog.Error(err))
opentracingext.Error.Set(sp, true)
logger.Error("unable to fetch data", zap.Error(err))
logger.Error("range query error",
zap.Error(err),
zap.Any("params", params),
zap.Any("queryOpts", queryOpts),
zap.Any("fetchOpts", fetchOpts))
h.promReadMetrics.fetchErrorsServer.Inc(1)
return nil, emptyReqParams, &RespError{
Err: err,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ func (h *PromReadInstantHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
result, err := read(ctx, h.engine, queryOpts, fetchOpts,
h.tagOpts, w, params, h.instrumentOpts)
if err != nil {
logger.Error("unable to fetch data", zap.Error(err))
logger.Error("instant query error",
zap.Error(err),
zap.Any("params", params),
zap.Any("queryOpts", queryOpts),
zap.Any("fetchOpts", queryOpts))
xhttp.Error(w, err, http.StatusInternalServerError)
return
}
Expand Down
6 changes: 5 additions & 1 deletion src/query/api/v1/handler/prometheus/remote/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ func (h *PromReadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
readResult, err := h.read(ctx, w, req, timeout, fetchOpts)
if err != nil {
h.promReadMetrics.fetchErrorsServer.Inc(1)
logger.Error("unable to fetch data", zap.Error(err))
logger.Error("remote read query error",
zap.Error(err),
zap.Any("req", req),
zap.Duration("timeout", timeout),
zap.Any("fetchOpts", fetchOpts))
xhttp.Error(w, err, http.StatusInternalServerError)
return
}
Expand Down
9 changes: 6 additions & 3 deletions src/query/api/v1/handler/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ func (h *SearchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
logger := logging.WithContext(r.Context(), h.instrumentOpts)

query, parseBodyErr := h.parseBody(r)
opts, parseURLParamsErr := h.parseURLParams(r)
fetchOpts, parseURLParamsErr := h.parseURLParams(r)
if err := firstParseError(parseBodyErr, parseURLParamsErr); err != nil {
logger.Error("unable to parse request", zap.Error(err.Inner()))
xhttp.Error(w, err.Inner(), err.Code())
return
}

results, err := h.search(r.Context(), query, opts)
results, err := h.search(r.Context(), query, fetchOpts)
if err != nil {
logger.Error("unable to fetch data", zap.Error(err))
logger.Error("search query error",
zap.Error(err),
zap.Any("query", query),
zap.Any("fetchOpts", fetchOpts))
xhttp.Error(w, err, http.StatusBadRequest)
return
}
Expand Down