Skip to content

Commit 1d3614b

Browse files
authored
Remove unused /validate_expr endpoint. (#2152)
* Remove unused /validate_expr endpoint. Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com> * Updated CHANGELOG.md. Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
1 parent ea08e33 commit 1d3614b

File tree

3 files changed

+1
-43
lines changed

3 files changed

+1
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* `--querier.query-store-after` has been added in it's place.
1111
* [CHANGE] Experimental Memberlist KV store can now be used in single-binary Cortex. Attempts to use it previously would fail with panic. This change also breaks existing binary protocol used to exchange gossip messages, so this version will not be able to understand gossiped Ring when used in combination with the previous version of Cortex. Easiest way to upgrade is to shutdown old Cortex installation, and restart it with new version. Incremental rollout works too, but with reduced functionality until all components run the same version. #2016
1212
* [CHANGE] Renamed the cache configuration setting `defaul_validity` to `default_validity`. #2140
13+
* [CHANGE] Removed unused /validate_expr endpoint. #2152
1314
* [FEATURE] Added a read-only local alertmanager config store using files named corresponding to their tenant id. #2125
1415
* [FEATURE] Added user sub rings to distribute users to a subset of ingesters. #1947
1516
* `--experimental.distributor.user-subring-size`

pkg/cortex/modules.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ func (t *Cortex) initQuerier(cfg *Config) (err error) {
262262
subrouter := t.server.HTTP.PathPrefix("/api/prom").Subrouter()
263263
subrouter.PathPrefix("/api/v1").Handler(t.httpAuthMiddleware.Wrap(promRouter))
264264
subrouter.Path("/read").Handler(t.httpAuthMiddleware.Wrap(querier.RemoteReadHandler(queryable)))
265-
subrouter.Path("/validate_expr").Handler(t.httpAuthMiddleware.Wrap(http.HandlerFunc(t.distributor.ValidateExprHandler)))
266265
subrouter.Path("/chunks").Handler(t.httpAuthMiddleware.Wrap(querier.ChunksHandler(queryable)))
267266
subrouter.Path("/user_stats").Handler(middleware.AuthenticateUser.Wrap(http.HandlerFunc(t.distributor.UserStatsHandler)))
268267

pkg/distributor/http_server.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package distributor
22

33
import (
4-
"fmt"
54
"net/http"
65

76
"github.com/go-kit/kit/log/level"
8-
"github.com/prometheus/prometheus/promql"
97
"github.com/weaveworks/common/httpgrpc"
108

119
"github.com/cortexproject/cortex/pkg/ingester/client"
@@ -66,43 +64,3 @@ func (d *Distributor) UserStatsHandler(w http.ResponseWriter, r *http.Request) {
6664

6765
util.WriteJSONResponse(w, stats)
6866
}
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

Comments
 (0)