Fix build errors in rest of prometheus

Signed-off-by: Tobias Guggenmos <tguggenm@redhat.com>
This commit is contained in:
Tobias Guggenmos 2020-02-03 19:06:39 +01:00
parent 273ea9093a
commit 20b1f596f6
6 changed files with 20 additions and 15 deletions

View file

@ -24,7 +24,7 @@ import (
yaml "gopkg.in/yaml.v3" yaml "gopkg.in/yaml.v3"
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/template" "github.com/prometheus/prometheus/template"
) )
@ -156,7 +156,7 @@ func (r *RuleNode) Validate() (nodes []WrappedError) {
err: errors.Errorf("field 'expr' must be set in rule"), err: errors.Errorf("field 'expr' must be set in rule"),
node: &r.Expr, node: &r.Expr,
}) })
} else if _, err := promql.ParseExpr(r.Expr.Value); err != nil { } else if _, err := parser.ParseExpr(r.Expr.Value); err != nil {
nodes = append(nodes, WrappedError{ nodes = append(nodes, WrappedError{
err: errors.Wrapf(err, "could not parse expression"), err: errors.Wrapf(err, "could not parse expression"),
node: &r.Expr, node: &r.Expr,

View file

@ -34,6 +34,7 @@ import (
"github.com/prometheus/prometheus/pkg/rulefmt" "github.com/prometheus/prometheus/pkg/rulefmt"
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/template" "github.com/prometheus/prometheus/template"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
) )
@ -112,7 +113,7 @@ type AlertingRule struct {
// The name of the alert. // The name of the alert.
name string name string
// The vector expression from which to generate alerts. // The vector expression from which to generate alerts.
vector promql.Expr vector parser.Expr
// The duration for which a labelset needs to persist in the expression // The duration for which a labelset needs to persist in the expression
// output vector before an alert transitions from Pending to Firing state. // output vector before an alert transitions from Pending to Firing state.
holdDuration time.Duration holdDuration time.Duration
@ -144,7 +145,7 @@ type AlertingRule struct {
// NewAlertingRule constructs a new AlertingRule. // NewAlertingRule constructs a new AlertingRule.
func NewAlertingRule( func NewAlertingRule(
name string, vec promql.Expr, hold time.Duration, name string, vec parser.Expr, hold time.Duration,
labels, annotations, externalLabels labels.Labels, labels, annotations, externalLabels labels.Labels,
restored bool, logger log.Logger, restored bool, logger log.Logger,
) *AlertingRule { ) *AlertingRule {
@ -201,7 +202,7 @@ func (r *AlertingRule) Health() RuleHealth {
} }
// Query returns the query expression of the alerting rule. // Query returns the query expression of the alerting rule.
func (r *AlertingRule) Query() promql.Expr { func (r *AlertingRule) Query() parser.Expr {
return r.vector return r.vector
} }

View file

@ -34,6 +34,7 @@ import (
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/pkg/value" "github.com/prometheus/prometheus/pkg/value"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage"
) )
@ -993,7 +994,7 @@ func (m *Manager) LoadGroups(
rules := make([]Rule, 0, len(rg.Rules)) rules := make([]Rule, 0, len(rg.Rules))
for _, r := range rg.Rules { for _, r := range rg.Rules {
expr, err := promql.ParseExpr(r.Expr.Value) expr, err := parser.ParseExpr(r.Expr.Value)
if err != nil { if err != nil {
return nil, []error{errors.Wrap(err, fn)} return nil, []error{errors.Wrap(err, fn)}
} }

View file

@ -26,13 +26,14 @@ import (
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/rulefmt" "github.com/prometheus/prometheus/pkg/rulefmt"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
) )
// A RecordingRule records its vector expression into new timeseries. // A RecordingRule records its vector expression into new timeseries.
type RecordingRule struct { type RecordingRule struct {
name string name string
vector promql.Expr vector parser.Expr
labels labels.Labels labels labels.Labels
// Protects the below. // Protects the below.
mtx sync.Mutex mtx sync.Mutex
@ -47,7 +48,7 @@ type RecordingRule struct {
} }
// NewRecordingRule returns a new recording rule. // NewRecordingRule returns a new recording rule.
func NewRecordingRule(name string, vector promql.Expr, lset labels.Labels) *RecordingRule { func NewRecordingRule(name string, vector parser.Expr, lset labels.Labels) *RecordingRule {
return &RecordingRule{ return &RecordingRule{
name: name, name: name,
vector: vector, vector: vector,
@ -62,7 +63,7 @@ func (rule *RecordingRule) Name() string {
} }
// Query returns the rule query expression. // Query returns the rule query expression.
func (rule *RecordingRule) Query() promql.Expr { func (rule *RecordingRule) Query() parser.Expr {
return rule.vector return rule.vector
} }

View file

@ -44,6 +44,7 @@ import (
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/rules" "github.com/prometheus/prometheus/rules"
"github.com/prometheus/prometheus/scrape" "github.com/prometheus/prometheus/scrape"
"github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage"
@ -300,8 +301,8 @@ func (api *API) Register(r *route.Router) {
} }
type queryData struct { type queryData struct {
ResultType promql.ValueType `json:"resultType"` ResultType parser.ValueType `json:"resultType"`
Result promql.Value `json:"result"` Result parser.Value `json:"result"`
Stats *stats.QueryStats `json:"stats,omitempty"` Stats *stats.QueryStats `json:"stats,omitempty"`
} }
@ -534,7 +535,7 @@ func (api *API) series(r *http.Request) apiFuncResult {
var matcherSets [][]*labels.Matcher var matcherSets [][]*labels.Matcher
for _, s := range r.Form["match[]"] { for _, s := range r.Form["match[]"] {
matchers, err := promql.ParseMetricSelector(s) matchers, err := parser.ParseMetricSelector(s)
if err != nil { if err != nil {
return apiFuncResult{nil, &apiError{errorBadData, err}, nil, nil} return apiFuncResult{nil, &apiError{errorBadData, err}, nil, nil}
} }
@ -695,7 +696,7 @@ func (api *API) targetMetadata(r *http.Request) apiFuncResult {
var err error var err error
if matchTarget != "" { if matchTarget != "" {
matchers, err = promql.ParseMetricSelector(matchTarget) matchers, err = parser.ParseMetricSelector(matchTarget)
if err != nil { if err != nil {
return apiFuncResult{nil, &apiError{errorBadData, err}, nil, nil} return apiFuncResult{nil, &apiError{errorBadData, err}, nil, nil}
} }
@ -1282,7 +1283,7 @@ func (api *API) deleteSeries(r *http.Request) apiFuncResult {
} }
for _, s := range r.Form["match[]"] { for _, s := range r.Form["match[]"] {
matchers, err := promql.ParseMetricSelector(s) matchers, err := parser.ParseMetricSelector(s)
if err != nil { if err != nil {
return apiFuncResult{nil, &apiError{errorBadData, err}, nil, nil} return apiFuncResult{nil, &apiError{errorBadData, err}, nil, nil}
} }

View file

@ -29,6 +29,7 @@ import (
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/pkg/value" "github.com/prometheus/prometheus/pkg/value"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage"
) )
@ -54,7 +55,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
var matcherSets [][]*labels.Matcher var matcherSets [][]*labels.Matcher
for _, s := range req.Form["match[]"] { for _, s := range req.Form["match[]"] {
matchers, err := promql.ParseMetricSelector(s) matchers, err := parser.ParseMetricSelector(s)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return