|
1 | 1 | package distributor
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "fmt" |
5 | 4 | "net/http"
|
6 | 5 |
|
7 | 6 | "github.com/go-kit/kit/log/level"
|
8 |
| - "github.com/prometheus/prometheus/promql" |
9 | 7 | "github.com/weaveworks/common/httpgrpc"
|
10 | 8 |
|
11 | 9 | "github.com/cortexproject/cortex/pkg/ingester/client"
|
@@ -66,43 +64,3 @@ func (d *Distributor) UserStatsHandler(w http.ResponseWriter, r *http.Request) {
|
66 | 64 |
|
67 | 65 | util.WriteJSONResponse(w, stats)
|
68 | 66 | }
|
69 |
| - |
70 |
| -// ValidateExprHandler validates a PromQL expression. |
71 |
| -func (d *Distributor) ValidateExprHandler(w http.ResponseWriter, r *http.Request) { |
72 |
| - _, err := promql.ParseExpr(r.FormValue("expr")) |
73 |
| - |
74 |
| - // We mimick the response format of Prometheus's official API here for |
75 |
| - // consistency, but unfortunately its private types (string consts etc.) |
76 |
| - // aren't reusable. |
77 |
| - if err == nil { |
78 |
| - util.WriteJSONResponse(w, map[string]string{ |
79 |
| - "status": "success", |
80 |
| - }) |
81 |
| - return |
82 |
| - } |
83 |
| - |
84 |
| - parseErr, ok := err.(*promql.ParseErr) |
85 |
| - if !ok { |
86 |
| - // This should always be a promql.ParseErr. |
87 |
| - http.Error(w, fmt.Sprintf("unexpected error returned from PromQL parser: %v", err), http.StatusInternalServerError) |
88 |
| - return |
89 |
| - } |
90 |
| - |
91 |
| - // If the parsing input was a single line, parseErr.Line is 0 |
92 |
| - // and the generated error string omits the line entirely. But we |
93 |
| - // want to report line numbers consistently, no matter how many |
94 |
| - // lines there are (starting at 1). |
95 |
| - if parseErr.Line == 0 { |
96 |
| - parseErr.Line = 1 |
97 |
| - } |
98 |
| - w.WriteHeader(http.StatusBadRequest) |
99 |
| - util.WriteJSONResponse(w, map[string]interface{}{ |
100 |
| - "status": "error", |
101 |
| - "errorType": "bad_data", |
102 |
| - "error": err.Error(), |
103 |
| - "location": map[string]int{ |
104 |
| - "line": parseErr.Line, |
105 |
| - "pos": parseErr.Pos, |
106 |
| - }, |
107 |
| - }) |
108 |
| -} |
0 commit comments