diff --git a/cmd/thanos/query.go b/cmd/thanos/query.go index f0dfafa7a5..fe71f14f17 100644 --- a/cmd/thanos/query.go +++ b/cmd/thanos/query.go @@ -22,6 +22,7 @@ import ( "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" + "github.com/thanos-io/thanos/pkg/rules" kingpin "gopkg.in/alecthomas/kingpin.v2" "github.com/thanos-io/thanos/pkg/component" @@ -258,7 +259,8 @@ func runQuery( dialOpts, unhealthyStoreTimeout, ) - proxy = store.NewProxyStore(logger, reg, stores.Get, stores.GetRulesClients, component.Query, selectorLset, storeResponseTimeout) + proxy = store.NewProxyStore(logger, reg, stores.Get, component.Query, selectorLset, storeResponseTimeout) + rulesProxy = rules.NewProxy(logger, stores.GetRulesClients) queryableCreator = query.NewQueryableCreator(logger, proxy) engine = promql.NewEngine( promql.EngineOpts{ @@ -362,7 +364,17 @@ func runQuery( ins := extpromhttp.NewInstrumentationMiddleware(reg) ui.NewQueryUI(logger, reg, stores, flagsMap).Register(router.WithPrefix(webRoutePrefix), ins) - api := v1.NewAPI(logger, reg, engine, queryableCreator, enableAutodownsampling, enablePartialResponse, queryReplicaLabels, instantDefaultMaxSourceResolution, query.NewRulesRetriever(proxy)) + api := v1.NewAPI( + logger, + reg, + engine, + queryableCreator, + enableAutodownsampling, + enablePartialResponse, + queryReplicaLabels, + instantDefaultMaxSourceResolution, + rules.NewRetriever(rulesProxy), + ) api.Register(router.WithPrefix(path.Join(webRoutePrefix, "/api/v1")), tracer, logger, ins) @@ -390,7 +402,7 @@ func runQuery( return errors.Wrap(err, "setup gRPC server") } - s := grpcserver.New(logger, reg, tracer, comp, grpcProbe, proxy, proxy, + s := grpcserver.New(logger, reg, tracer, comp, grpcProbe, proxy, rulesProxy, grpcserver.WithListen(grpcBindAddr), grpcserver.WithGracePeriod(grpcGracePeriod), grpcserver.WithTLSConfig(tlsCfg), diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 5ff5c55d39..2294dce208 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -39,8 +39,8 @@ import ( "github.com/thanos-io/thanos/pkg/prober" "github.com/thanos-io/thanos/pkg/promclient" "github.com/thanos-io/thanos/pkg/query" - thanosrule "github.com/thanos-io/thanos/pkg/rule" - v1 "github.com/thanos-io/thanos/pkg/rule/api" + v1 "github.com/thanos-io/thanos/pkg/rules/api" + thanosmanager "github.com/thanos-io/thanos/pkg/rules/manager" "github.com/thanos-io/thanos/pkg/runutil" grpcserver "github.com/thanos-io/thanos/pkg/server/grpc" httpserver "github.com/thanos-io/thanos/pkg/server/http" @@ -389,7 +389,7 @@ func runRule( // Run rule evaluation and alert notifications. var ( alertQ = alert.NewQueue(logger, reg, 10000, 100, labelsTSDBToProm(lset), alertExcludeLabels) - ruleMgr = thanosrule.NewManager(dataDir) + ruleMgr = thanosmanager.NewManager(dataDir) ) { notify := func(ctx context.Context, expr string, alerts ...*rules.Alert) { diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index e612dc1332..e6067b971a 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -28,6 +28,7 @@ import ( "github.com/thanos-io/thanos/pkg/prober" "github.com/thanos-io/thanos/pkg/promclient" "github.com/thanos-io/thanos/pkg/reloader" + "github.com/thanos-io/thanos/pkg/rules" "github.com/thanos-io/thanos/pkg/runutil" grpcserver "github.com/thanos-io/thanos/pkg/server/grpc" httpserver "github.com/thanos-io/thanos/pkg/server/http" @@ -267,7 +268,8 @@ func runSidecar( t := exthttp.NewTransport() t.MaxIdleConnsPerHost = connectionPoolSizePerHost t.MaxIdleConns = connectionPoolSize - c := &http.Client{Transport: tracing.HTTPTripperware(logger, t)} + + c := promclient.NewClient(&http.Client{Transport: tracing.HTTPTripperware(logger, t)}, logger, promclient.ThanosUserAgent) promStore, err := store.NewPrometheusStore(logger, c, promURL, component.Sidecar, m.Labels, m.Timestamps) if err != nil { @@ -279,7 +281,7 @@ func runSidecar( return errors.Wrap(err, "setup gRPC server") } - s := grpcserver.New(logger, reg, tracer, comp, grpcProbe, promStore, promStore, + s := grpcserver.New(logger, reg, tracer, comp, grpcProbe, promStore, rules.NewPrometheus(promURL, c), grpcserver.WithListen(grpcBindAddr), grpcserver.WithGracePeriod(grpcGracePeriod), grpcserver.WithTLSConfig(tlsCfg), diff --git a/pkg/promclient/promclient.go b/pkg/promclient/promclient.go index 631d00c430..62e5ec2cf3 100644 --- a/pkg/promclient/promclient.go +++ b/pkg/promclient/promclient.go @@ -25,10 +25,12 @@ import ( "github.com/gogo/status" "github.com/pkg/errors" "github.com/prometheus/common/model" + "github.com/prometheus/common/version" "github.com/prometheus/prometheus/pkg/labels" promlabels "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/promql" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/thanos-io/thanos/pkg/runutil" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/tracing" @@ -46,6 +48,8 @@ var ( http.StatusServiceUnavailable: codes.Unavailable, http.StatusInternalServerError: codes.Internal, } + + ThanosUserAgent = fmt.Sprintf("Thanos/%s", version.Version) ) const ( @@ -609,7 +613,7 @@ func (c *Client) LabelValuesInGRPC(ctx context.Context, base *url.URL, label str // RulesInGRPC returns the rules from Prometheus rules API. It uses gRPC errors. // NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus. -func (c *Client) RulesInGRPC(ctx context.Context, base *url.URL, typeRules string) ([]*storepb.RuleGroup, error) { +func (c *Client) RulesInGRPC(ctx context.Context, base *url.URL, typeRules string) ([]*rulespb.RuleGroup, error) { u := *base u.Path = path.Join(u.Path, "/api/v1/rules") @@ -620,7 +624,7 @@ func (c *Client) RulesInGRPC(ctx context.Context, base *url.URL, typeRules strin } var m struct { - Data *storepb.RuleGroups `json:"data"` + Data *rulespb.RuleGroups `json:"data"` } if err := c.get2xxResultWithGRPCErrors(ctx, "/prom_rules HTTP[client]", &u, &m); err != nil { diff --git a/pkg/query/api/v1.go b/pkg/query/api/v1.go index 6595a9eb3d..99c58180db 100644 --- a/pkg/query/api/v1.go +++ b/pkg/query/api/v1.go @@ -42,8 +42,8 @@ import ( "github.com/prometheus/prometheus/storage" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" "github.com/thanos-io/thanos/pkg/query" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/thanos-io/thanos/pkg/runutil" - "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/tracing" ) @@ -99,7 +99,7 @@ func SetCORS(w http.ResponseWriter) { type ApiFunc func(r *http.Request) (interface{}, []error, *ApiError) type rulesRetriever interface { - RuleGroups(context.Context) ([]*storepb.RuleGroup, storage.Warnings, error) + RuleGroups(context.Context) ([]*rulespb.RuleGroup, storage.Warnings, error) } // API can register a set of endpoints in a router and handle @@ -640,7 +640,7 @@ func (api *API) labelNames(r *http.Request) (interface{}, []error, *ApiError) { func (api *API) rules(r *http.Request) (interface{}, []error, *ApiError) { var ( - res = &storepb.RuleGroups{} + res = &rulespb.RuleGroups{} typeParam = strings.ToLower(r.URL.Query().Get("type")) ) @@ -657,7 +657,7 @@ func (api *API) rules(r *http.Request) (interface{}, []error, *ApiError) { } for _, grp := range groups { - apiRuleGroup := &storepb.RuleGroup{ + apiRuleGroup := &rulespb.RuleGroup{ Name: grp.Name, File: grp.File, Interval: grp.Interval, @@ -667,7 +667,7 @@ func (api *API) rules(r *http.Request) (interface{}, []error, *ApiError) { PartialResponseStrategy: grp.PartialResponseStrategy, } - apiRuleGroup.Rules = make([]*storepb.Rule, 0, len(grp.Rules)) + apiRuleGroup.Rules = make([]*rulespb.Rule, 0, len(grp.Rules)) for _, r := range grp.Rules { switch { diff --git a/pkg/query/storeset.go b/pkg/query/storeset.go index 2509d38dc7..f4d11b1e1c 100644 --- a/pkg/query/storeset.go +++ b/pkg/query/storeset.go @@ -17,6 +17,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/prometheus/pkg/labels" "github.com/thanos-io/thanos/pkg/component" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/thanos-io/thanos/pkg/runutil" "github.com/thanos-io/thanos/pkg/store" "github.com/thanos-io/thanos/pkg/store/storepb" @@ -177,7 +178,7 @@ type StoreSet struct { unhealthyStoreTimeout time.Duration } -// NewStoreSet returns a new set of stores from cluster peers and statically configured ones. +// NewStoreSet returns a new set of store APIs and potentially Rules APIs from given specs. func NewStoreSet( logger log.Logger, reg *prometheus.Registry, @@ -215,14 +216,15 @@ func NewStoreSet( return ss } +// TODO(bwplotka): Consider moving out of this package and renam as it also supports rules API. type storeRef struct { storepb.StoreClient mtx sync.RWMutex cc *grpc.ClientConn addr string - // if rule is not nil, then this store also supports rules API. - rule storepb.RulesClient + // If rule is not nil, then this store also supports rules API. + rule rulespb.RulesClient // Meta (can change during runtime). labelSets []storepb.LabelSet @@ -449,10 +451,10 @@ func (s *StoreSet) getHealthyStores(ctx context.Context, stores map[string]*stor return } - var rule storepb.RulesClient + var rule rulespb.RulesClient if _, ok := ruleAddrSet[addr]; ok { - rule = storepb.NewRulesClient(conn) + rule = rulespb.NewRulesClient(conn) } st = &storeRef{StoreClient: storepb.NewStoreClient(conn), rule: rule, cc: conn, addr: addr, logger: s.logger} @@ -542,11 +544,11 @@ func (s *StoreSet) Get() []store.Client { } // GetRulesClients returns a list of all active rules clients. -func (s *StoreSet) GetRulesClients() []storepb.RulesClient { +func (s *StoreSet) GetRulesClients() []rulespb.RulesClient { s.storesMtx.RLock() defer s.storesMtx.RUnlock() - rules := make([]storepb.RulesClient, 0, len(s.stores)) + rules := make([]rulespb.RulesClient, 0, len(s.stores)) for _, st := range s.stores { if st.HasRulesAPI() { rules = append(rules, st.rule) diff --git a/pkg/rule/api/v1.go b/pkg/rules/api/v1.go similarity index 77% rename from pkg/rule/api/v1.go rename to pkg/rules/api/v1.go index 2eaa1f2ec3..864a33e37b 100644 --- a/pkg/rule/api/v1.go +++ b/pkg/rules/api/v1.go @@ -11,6 +11,7 @@ import ( "github.com/NYTimes/gziphandler" "github.com/prometheus/client_golang/prometheus" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/go-kit/kit/log" opentracing "github.com/opentracing/opentracing-go" @@ -18,7 +19,7 @@ import ( "github.com/prometheus/prometheus/rules" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" qapi "github.com/thanos-io/thanos/pkg/query/api" - thanosrule "github.com/thanos-io/thanos/pkg/rule" + "github.com/thanos-io/thanos/pkg/rules/manager" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/tracing" ) @@ -63,14 +64,14 @@ func (api *API) Register(r *route.Router, tracer opentracing.Tracer, logger log. } type RulesRetriever interface { - RuleGroups() []thanosrule.Group - AlertingRules() []thanosrule.AlertingRule + RuleGroups() []manager.Group + AlertingRules() []manager.AlertingRule } func (api *API) rules(*http.Request) (interface{}, []error, *qapi.ApiError) { - res := &storepb.RuleGroups{} + res := &rulespb.RuleGroups{} for _, grp := range api.ruleRetriever.RuleGroups() { - apiRuleGroup := &storepb.RuleGroup{ + apiRuleGroup := &rulespb.RuleGroup{ Name: grp.Name(), File: grp.OriginalFile(), Interval: grp.Interval().Seconds(), @@ -85,14 +86,14 @@ func (api *API) rules(*http.Request) (interface{}, []error, *qapi.ApiError) { switch rule := r.(type) { case *rules.AlertingRule: - apiRuleGroup.Rules = append(apiRuleGroup.Rules, &storepb.Rule{ - Result: &storepb.Rule_Alert{Alert: &storepb.Alert{ - State: storepb.AlertState(rule.State()), + apiRuleGroup.Rules = append(apiRuleGroup.Rules, &rulespb.Rule{ + Result: &rulespb.Rule_Alert{Alert: &rulespb.Alert{ + State: rulespb.AlertState(rule.State()), Name: rule.Name(), Query: rule.Query().String(), DurationSeconds: rule.Duration().Seconds(), - Labels: &storepb.PromLabels{Labels: storepb.PromLabelsToLabels(rule.Labels())}, - Annotations: &storepb.PromLabels{Labels: storepb.PromLabelsToLabels(rule.Annotations())}, + Labels: &rulespb.PromLabels{Labels: storepb.PromLabelsToLabels(rule.Labels())}, + Annotations: &rulespb.PromLabels{Labels: storepb.PromLabelsToLabels(rule.Annotations())}, Alerts: rulesAlertsToAPIAlerts(grp.PartialResponseStrategy, rule.ActiveAlerts()), Health: string(rule.Health()), LastError: lastError, @@ -100,11 +101,11 @@ func (api *API) rules(*http.Request) (interface{}, []error, *qapi.ApiError) { LastEvaluation: rule.GetEvaluationTimestamp(), }}}) case *rules.RecordingRule: - apiRuleGroup.Rules = append(apiRuleGroup.Rules, &storepb.Rule{ - Result: &storepb.Rule_Recording{Recording: &storepb.RecordingRule{ + apiRuleGroup.Rules = append(apiRuleGroup.Rules, &rulespb.Rule{ + Result: &rulespb.Rule_Recording{Recording: &rulespb.RecordingRule{ Name: rule.Name(), Query: rule.Query().String(), - Labels: &storepb.PromLabels{Labels: storepb.PromLabelsToLabels(rule.Labels())}, + Labels: &rulespb.PromLabels{Labels: storepb.PromLabelsToLabels(rule.Labels())}, Health: string(rule.Health()), LastError: lastError, EvaluationDurationSeconds: rule.GetEvaluationDuration().Seconds(), @@ -122,24 +123,24 @@ func (api *API) rules(*http.Request) (interface{}, []error, *qapi.ApiError) { } func (api *API) alerts(*http.Request) (interface{}, []error, *qapi.ApiError) { - var alerts []*storepb.AlertInstance + var alerts []*rulespb.AlertInstance for _, alertingRule := range api.ruleRetriever.AlertingRules() { alerts = append( alerts, rulesAlertsToAPIAlerts(alertingRule.PartialResponseStrategy, alertingRule.ActiveAlerts())..., ) } - return struct{ Alerts []*storepb.AlertInstance }{Alerts: alerts}, nil, nil + return struct{ Alerts []*rulespb.AlertInstance }{Alerts: alerts}, nil, nil } -func rulesAlertsToAPIAlerts(s storepb.PartialResponseStrategy, rulesAlerts []*rules.Alert) []*storepb.AlertInstance { - apiAlerts := make([]*storepb.AlertInstance, len(rulesAlerts)) +func rulesAlertsToAPIAlerts(s storepb.PartialResponseStrategy, rulesAlerts []*rules.Alert) []*rulespb.AlertInstance { + apiAlerts := make([]*rulespb.AlertInstance, len(rulesAlerts)) for i, ruleAlert := range rulesAlerts { - apiAlerts[i] = &storepb.AlertInstance{ + apiAlerts[i] = &rulespb.AlertInstance{ PartialResponseStrategy: s, - Labels: &storepb.PromLabels{Labels: storepb.PromLabelsToLabels(ruleAlert.Labels)}, - Annotations: &storepb.PromLabels{Labels: storepb.PromLabelsToLabels(ruleAlert.Annotations)}, - State: storepb.AlertState(ruleAlert.State), + Labels: &rulespb.PromLabels{Labels: storepb.PromLabelsToLabels(ruleAlert.Labels)}, + Annotations: &rulespb.PromLabels{Labels: storepb.PromLabelsToLabels(ruleAlert.Annotations)}, + State: rulespb.AlertState(ruleAlert.State), ActiveAt: &ruleAlert.ActiveAt, Value: strconv.FormatFloat(ruleAlert.Value, 'e', -1, 64), } diff --git a/pkg/rule/api/v1_test.go b/pkg/rules/api/v1_test.go similarity index 95% rename from pkg/rule/api/v1_test.go rename to pkg/rules/api/v1_test.go index 759f052474..430bc545d7 100644 --- a/pkg/rule/api/v1_test.go +++ b/pkg/rules/api/v1_test.go @@ -24,7 +24,7 @@ import ( "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage/tsdb" qapi "github.com/thanos-io/thanos/pkg/query/api" - thanosrule "github.com/thanos-io/thanos/pkg/rule" + "github.com/thanos-io/thanos/pkg/rules/manager" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/testutil" "github.com/thanos-io/thanos/pkg/testutil/testpromcompatibility" @@ -66,7 +66,7 @@ type rulesRetrieverMock struct { testing *testing.T } -func (m rulesRetrieverMock) RuleGroups() []thanosrule.Group { +func (m rulesRetrieverMock) RuleGroups() []manager.Group { storage := newStorage(m.testing) engineOpts := promql.EngineOpts{ @@ -97,18 +97,18 @@ func (m rulesRetrieverMock) RuleGroups() []thanosrule.Group { recordingRule := rules.NewRecordingRule("recording-rule-1", recordingExpr, labels.Labels{}) r = append(r, recordingRule) - return []thanosrule.Group{ - thanosrule.Group{ + return []manager.Group{ + manager.Group{ Group: rules.NewGroup("grp", "/path/to/file", time.Second, r, false, opts), PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, }, } } -func (m rulesRetrieverMock) AlertingRules() []thanosrule.AlertingRule { - var ars []thanosrule.AlertingRule +func (m rulesRetrieverMock) AlertingRules() []manager.AlertingRule { + var ars []manager.AlertingRule for _, ar := range alertingRules(m.testing) { - ars = append(ars, thanosrule.AlertingRule{AlertingRule: ar}) + ars = append(ars, manager.AlertingRule{AlertingRule: ar}) } return ars } diff --git a/pkg/rule/rule.go b/pkg/rules/manager/rule.go similarity index 99% rename from pkg/rule/rule.go rename to pkg/rules/manager/rule.go index 8491478c13..87c33c6e37 100644 --- a/pkg/rule/rule.go +++ b/pkg/rules/manager/rule.go @@ -1,7 +1,7 @@ // Copyright (c) The Thanos Authors. // Licensed under the Apache License 2.0. -package thanosrule +package manager import ( "crypto/sha256" diff --git a/pkg/rule/rule_test.go b/pkg/rules/manager/rule_test.go similarity index 99% rename from pkg/rule/rule_test.go rename to pkg/rules/manager/rule_test.go index d238db10d4..b88f87c2e7 100644 --- a/pkg/rule/rule_test.go +++ b/pkg/rules/manager/rule_test.go @@ -1,7 +1,7 @@ // Copyright (c) The Thanos Authors. // Licensed under the Apache License 2.0. -package thanosrule +package manager import ( "context" diff --git a/pkg/rules/prometheus.go b/pkg/rules/prometheus.go new file mode 100644 index 0000000000..34a775a574 --- /dev/null +++ b/pkg/rules/prometheus.go @@ -0,0 +1,44 @@ +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +package rules + +import ( + "net/url" + + "github.com/thanos-io/thanos/pkg/promclient" + "github.com/thanos-io/thanos/pkg/rules/rulespb" +) + +// Prometheus implements rulespb.Rules. +type Prometheus struct { + base *url.URL + client *promclient.Client +} + +// NewPrometheus creates new rules.Prometheus. +func NewPrometheus(base *url.URL, client *promclient.Client) *Prometheus { + return &Prometheus{ + base: base, + client: client, + } +} + +// Rules returns all specified rules from Prometheus. +func (p *Prometheus) Rules(r *rulespb.RulesRequest, s rulespb.Rules_RulesServer) error { + var typeRules string + if r.Type != rulespb.RulesRequest_ALL { + typeRules = r.Type.String() + } + groups, err := p.client.RulesInGRPC(s.Context(), p.base, typeRules) + if err != nil { + return err + } + + for _, g := range groups { + if err := s.Send(&rulespb.RulesResponse{Result: &rulespb.RulesResponse_Group{Group: g}}); err != nil { + return err + } + } + return nil +} diff --git a/pkg/rules/prometheus_test.go b/pkg/rules/prometheus_test.go new file mode 100644 index 0000000000..6c523f9327 --- /dev/null +++ b/pkg/rules/prometheus_test.go @@ -0,0 +1,178 @@ +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +package rules + +import ( + "context" + "fmt" + "net/url" + "os" + "testing" + "time" + + "github.com/fortytw2/leaktest" + "github.com/thanos-io/thanos/pkg/promclient" + "github.com/thanos-io/thanos/pkg/rules/rulespb" + "github.com/thanos-io/thanos/pkg/store/storepb" + "github.com/thanos-io/thanos/pkg/testutil" + "github.com/thanos-io/thanos/pkg/testutil/e2eutil" +) + +func TestPrometheusStore_Rules_e2e(t *testing.T) { + t.Helper() + + defer leaktest.CheckTimeout(t, 10*time.Second)() + + p, err := e2eutil.NewPrometheus() + testutil.Ok(t, err) + defer func() { testutil.Ok(t, p.Stop()) }() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + curr, err := os.Getwd() + testutil.Ok(t, err) + testutil.Ok(t, p.SetConfig(fmt.Sprintf(` +global: + external_labels: + region: eu-west + +rule_files: + - %s/../../examples/alerts/alerts.yaml + - %s/../../examples/alerts/rules.yaml +`, curr, curr))) + testutil.Ok(t, p.Start()) + + u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) + testutil.Ok(t, err) + + promRules := NewPrometheus(u, promclient.NewDefaultClient()) + + someAlert := &rulespb.Rule{Result: &rulespb.Rule_Alert{Alert: &rulespb.Alert{Name: "some"}}} + someRecording := &rulespb.Rule{Result: &rulespb.Rule_Recording{Recording: &rulespb.RecordingRule{Name: "some"}}} + + for _, tcase := range []struct { + expected []*rulespb.RuleGroup + expectedErr error + }{ + { + expected: []*rulespb.RuleGroup{ + { + Name: "thanos-bucket-replicate.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-compact.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-component-absent.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-query.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-receive.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-rule.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-sidecar.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-store.rules", + File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), + Rules: []*rulespb.Rule{someAlert, someAlert, someAlert, someAlert}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-bucket-replicate.rules", + File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), + Rules: []*rulespb.Rule{}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-query.rules", + File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), + Rules: []*rulespb.Rule{someRecording, someRecording, someRecording, someRecording, someRecording}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-receive.rules", File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), + Rules: []*rulespb.Rule{someRecording, someRecording, someRecording, someRecording, someRecording, someRecording}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + { + Name: "thanos-store.rules", + File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), + Rules: []*rulespb.Rule{someRecording, someRecording, someRecording, someRecording}, + Interval: 60, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + }, + }, + // TODO(bwplotka): Potentially add more cases. + }, + } { + t.Run("", func(t *testing.T) { + srv := &rulesServer{ctx: ctx} + err = promRules.Rules(&rulespb.RulesRequest{}, srv) + if tcase.expectedErr != nil { + testutil.NotOk(t, err) + testutil.Equals(t, tcase.expectedErr.Error(), err.Error()) + return + } + + // We don't want to be picky, just check what number and types of rules within group are. + got := srv.groups + for i, g := range got { + for j, r := range g.Rules { + if r.GetAlert() != nil { + got[i].Rules[j] = someAlert + continue + } + if r.GetRecording() != nil { + got[i].Rules[j] = someRecording + continue + } + t.Fatalf("Found rule in group %s that is neither recording not alert.", g.Name) + } + } + + testutil.Ok(t, err) + testutil.Equals(t, []error(nil), srv.warnings) + testutil.Equals(t, tcase.expected, srv.groups) + }) + } +} diff --git a/pkg/rules/proxy.go b/pkg/rules/proxy.go new file mode 100644 index 0000000000..6cd7ecb437 --- /dev/null +++ b/pkg/rules/proxy.go @@ -0,0 +1,153 @@ +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +package rules + +import ( + "context" + "io" + "sort" + + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/pkg/errors" + "github.com/thanos-io/thanos/pkg/rules/rulespb" + "github.com/thanos-io/thanos/pkg/store/storepb" + "golang.org/x/sync/errgroup" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// Proxy implements rulespb.Rules that fanouts requests to given rulespb.Rules and deduplication on the way. +type Proxy struct { + logger log.Logger + rules func() []rulespb.RulesClient +} + +// NewProxy returns new rules.Proxy. +func NewProxy(logger log.Logger, rules func() []rulespb.RulesClient) *Proxy { + return &Proxy{ + logger: logger, + rules: rules, + } +} + +func (s *Proxy) Rules(req *rulespb.RulesRequest, srv rulespb.Rules_RulesServer) error { + var ( + g, gctx = errgroup.WithContext(srv.Context()) + respChan = make(chan *rulespb.RuleGroup, 10) + groups []*rulespb.RuleGroup + ) + + for _, rulesClient := range s.rules() { + rs := &rulesStream{ + client: rulesClient, + request: req, + channel: respChan, + server: srv, + } + g.Go(func() error { return rs.receive(gctx) }) + } + + go func() { + _ = g.Wait() + close(respChan) + }() + + for resp := range respChan { + groups = append(groups, resp) + } + + if err := g.Wait(); err != nil { + level.Error(s.logger).Log("err", err) + return err + } + + groups = dedupGroups(groups) + + for _, g := range groups { + if err := srv.Send(rulespb.NewRuleGroupRulesResponse(g)); err != nil { + return status.Error(codes.Unknown, errors.Wrap(err, "send rules response").Error()) + } + } + + return nil +} + +func dedupGroups(groups []*rulespb.RuleGroup) []*rulespb.RuleGroup { + // sort groups such that they appear next to each other. + sort.Slice(groups, func(i, j int) bool { return groups[i].Name < groups[j].Name }) + + // nothing to do if we have no or a single result, also no deduplication is necessary. + if len(groups) < 2 { + return groups + } + + i := 0 + for _, g := range groups[1:] { + if g.Name == groups[i].Name { + groups[i].Rules = append(groups[i].Rules, g.Rules...) + } else { + i++ + groups[i] = g + } + } + + return groups[:i+1] +} + +type rulesStream struct { + client rulespb.RulesClient + request *rulespb.RulesRequest + channel chan<- *rulespb.RuleGroup + server rulespb.Rules_RulesServer +} + +func (stream *rulesStream) receive(ctx context.Context) error { + rules, err := stream.client.Rules(ctx, stream.request) + if err != nil { + err = errors.Wrapf(err, "fetching rules from rules client %v", stream.client) + + if stream.request.PartialResponseStrategy == storepb.PartialResponseStrategy_ABORT { + return err + } + + if err := stream.server.Send(rulespb.NewWarningRulesResponse(err)); err != nil { + return err + } + } + + for { + rule, err := rules.Recv() + if err == io.EOF { + return nil + } + + if err != nil { + err = errors.Wrapf(err, "receiving rules from rules client %v", stream.client) + + if stream.request.PartialResponseStrategy == storepb.PartialResponseStrategy_ABORT { + return err + } + + if err := stream.server.Send(rulespb.NewWarningRulesResponse(err)); err != nil { + return errors.Wrapf(err, "sending rules error to server %v", stream.server) + } + + continue + } + + if w := rule.GetWarning(); w != "" { + if err := stream.server.Send(rulespb.NewWarningRulesResponse(errors.New(w))); err != nil { + return errors.Wrapf(err, "sending rules warning to server %v", stream.server) + } + continue + } + + select { + case stream.channel <- rule.GetGroup(): + case <-ctx.Done(): + return ctx.Err() + } + } +} diff --git a/pkg/rules/proxy_test.go b/pkg/rules/proxy_test.go new file mode 100644 index 0000000000..44c959c8ed --- /dev/null +++ b/pkg/rules/proxy_test.go @@ -0,0 +1,157 @@ +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +package rules + +import ( + "reflect" + "testing" + + "github.com/thanos-io/thanos/pkg/rules/rulespb" +) + +func TestDedupGroups(t *testing.T) { + for _, tc := range []struct { + name string + groups, want []*rulespb.RuleGroup + }{ + { + name: "no groups", + groups: nil, + want: nil, + }, + { + name: "empty group", + groups: []*rulespb.RuleGroup{ + {Name: "a"}, + }, + want: []*rulespb.RuleGroup{ + {Name: "a"}, + }, + }, + { + name: "multiple empty groups", + groups: []*rulespb.RuleGroup{ + {Name: "a"}, + {Name: "b"}, + }, + want: []*rulespb.RuleGroup{ + {Name: "a"}, + {Name: "b"}, + }, + }, + { + name: "single group", + groups: []*rulespb.RuleGroup{ + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + }, + want: []*rulespb.RuleGroup{ + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + }, + }, + { + name: "separate groups", + groups: []*rulespb.RuleGroup{ + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + { + Name: "b", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b2"}), + }, + }, + }, + want: []*rulespb.RuleGroup{ + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + { + Name: "b", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b2"}), + }, + }, + }, + }, + { + name: "duplicate groups", + groups: []*rulespb.RuleGroup{ + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + { + Name: "b", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b2"}), + }, + }, + { + Name: "c", + }, + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + }, + want: []*rulespb.RuleGroup{ + { + Name: "a", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a2"}), + }, + }, + { + Name: "b", + Rules: []*rulespb.Rule{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b1"}), + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "b2"}), + }, + }, + { + Name: "c", + }, + }, + }, + } { + t.Run(tc.name, func(t *testing.T) { + got := dedupGroups(tc.groups) + if !reflect.DeepEqual(tc.want, got) { + t.Errorf("want groups %v, got %v", tc.want, got) + } + }) + } +} diff --git a/pkg/query/rules.go b/pkg/rules/rules.go similarity index 60% rename from pkg/query/rules.go rename to pkg/rules/rules.go index 555654aa59..b8646fc17e 100644 --- a/pkg/query/rules.go +++ b/pkg/rules/rules.go @@ -1,30 +1,33 @@ // Copyright (c) The Thanos Authors. // Licensed under the Apache License 2.0. -package query +package rules import ( "context" "github.com/pkg/errors" "github.com/prometheus/prometheus/storage" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/thanos-io/thanos/pkg/store/storepb" ) -func NewRulesRetriever(rs storepb.RulesServer) *rulesRetriever { - return &rulesRetriever{ - proxy: rs, - } +// Retriever allows to retrieve rules from gRPC server implementation. +// TODO(bwplotka): Switch to native gRPC transparent client->server adapter once available. +type Retriever struct { + proxy rulespb.RulesServer } -type rulesRetriever struct { - proxy storepb.RulesServer +func NewRetriever(rs rulespb.RulesServer) *Retriever { + return &Retriever{ + proxy: rs, + } } -func (rr *rulesRetriever) RuleGroups(ctx context.Context) ([]*storepb.RuleGroup, storage.Warnings, error) { +func (rr *Retriever) RuleGroups(ctx context.Context) ([]*rulespb.RuleGroup, storage.Warnings, error) { resp := &rulesServer{ctx: ctx} - if err := rr.proxy.Rules(&storepb.RulesRequest{ + if err := rr.proxy.Rules(&rulespb.RulesRequest{ PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, }, resp); err != nil { return nil, nil, errors.Wrap(err, "proxy RuleGroups()") @@ -35,14 +38,14 @@ func (rr *rulesRetriever) RuleGroups(ctx context.Context) ([]*storepb.RuleGroup, type rulesServer struct { // This field just exist to pseudo-implement the unused methods of the interface. - storepb.Rules_RulesServer + rulespb.Rules_RulesServer ctx context.Context warnings []error - groups []*storepb.RuleGroup + groups []*rulespb.RuleGroup } -func (srv *rulesServer) Send(res *storepb.RulesResponse) error { +func (srv *rulesServer) Send(res *rulespb.RulesResponse) error { if res.GetWarning() != "" { srv.warnings = append(srv.warnings, errors.New(res.GetWarning())) return nil diff --git a/pkg/store/storepb/rules_custom.go b/pkg/rules/rulespb/custom.go similarity index 77% rename from pkg/store/storepb/rules_custom.go rename to pkg/rules/rulespb/custom.go index cc16865f7a..a77bc41121 100644 --- a/pkg/store/storepb/rules_custom.go +++ b/pkg/rules/rulespb/custom.go @@ -1,7 +1,7 @@ // Copyright (c) The Thanos Authors. // Licensed under the Apache License 2.0. -package storepb +package rulespb import ( "encoding/json" @@ -11,6 +11,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/prometheus/pkg/labels" + "github.com/thanos-io/thanos/pkg/store/storepb" ) const ( @@ -18,28 +19,26 @@ const ( RuleAlertingType = "alerting" ) -func (x *PartialResponseStrategy) UnmarshalJSON(entry []byte) error { - fieldStr, err := strconv.Unquote(string(entry)) - if err != nil { - return errors.Wrapf(err, "partialResponseStrategy: unquote %v", string(entry)) - } - - if len(fieldStr) == 0 { - // Default. - *x = PartialResponseStrategy_WARN - return nil +func NewRuleGroupRulesResponse(rg *RuleGroup) *RulesResponse { + return &RulesResponse{ + Result: &RulesResponse_Group{ + Group: rg, + }, } +} - strategy, ok := PartialResponseStrategy_value[strings.ToUpper(fieldStr)] - if !ok { - return errors.Errorf("unknown partialResponseStrategy: %v", string(entry)) +func NewWarningRulesResponse(warning error) *RulesResponse { + return &RulesResponse{ + Result: &RulesResponse_Warning{ + Warning: warning.Error(), + }, } - *x = PartialResponseStrategy(strategy) - return nil } -func (x *PartialResponseStrategy) MarshalJSON() ([]byte, error) { - return []byte(strconv.Quote(x.String())), nil +func NewRecordingRule(r *RecordingRule) *Rule { + return &Rule{ + Result: &Rule_Recording{Recording: r}, + } } func (m *Rule) UnmarshalJSON(entry []byte) error { @@ -120,7 +119,7 @@ func (m *PromLabels) UnmarshalJSON(entry []byte) error { if err := lbls.UnmarshalJSON(entry); err != nil { return errors.Wrapf(err, "labels: labels field unmarshal: %v", string(entry)) } - m.Labels = PromLabelsToLabels(lbls) + m.Labels = storepb.PromLabelsToLabels(lbls) sort.Slice(m.Labels, func(i, j int) bool { return m.Labels[i].Name < m.Labels[j].Name }) @@ -128,5 +127,5 @@ func (m *PromLabels) UnmarshalJSON(entry []byte) error { } func (m *PromLabels) MarshalJSON() ([]byte, error) { - return LabelsToPromLabels(m.Labels).MarshalJSON() + return storepb.LabelsToPromLabels(m.Labels).MarshalJSON() } diff --git a/pkg/store/storepb/rules_custom_test.go b/pkg/rules/rulespb/custom_test.go similarity index 91% rename from pkg/store/storepb/rules_custom_test.go rename to pkg/rules/rulespb/custom_test.go index 3ab1ea5c3b..e8471b76b0 100644 --- a/pkg/store/storepb/rules_custom_test.go +++ b/pkg/rules/rulespb/custom_test.go @@ -1,7 +1,7 @@ // Copyright (c) The Thanos Authors. // Licensed under the Apache License 2.0. -package storepb +package rulespb import ( "encoding/json" @@ -10,6 +10,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/prometheus/pkg/labels" + "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/testutil" "github.com/thanos-io/thanos/pkg/testutil/testpromcompatibility" ) @@ -54,8 +55,8 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Interval: 2442, LastEvaluation: now, EvaluationDurationSeconds: 2.1, - DeprecatedPartialResponseStrategy: PartialResponseStrategy_WARN, - PartialResponseStrategy: PartialResponseStrategy_ABORT, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, }, }, }, @@ -70,8 +71,8 @@ func TestJSONUnmarshalMarshal(t *testing.T) { expectedProto: &RuleGroups{ Groups: []*RuleGroup{ { - DeprecatedPartialResponseStrategy: PartialResponseStrategy_WARN, - PartialResponseStrategy: PartialResponseStrategy_WARN, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, }, }, }, @@ -255,7 +256,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Query: "up", Name: "recording1", Labels: &PromLabels{ - Labels: []Label{ + Labels: []storepb.Label{ {Name: "a", Value: "b"}, {Name: "c", Value: "d"}, }, @@ -273,13 +274,13 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Name: "alert1", Query: "up == 0", Labels: &PromLabels{ - Labels: []Label{ + Labels: []storepb.Label{ {Name: "a2", Value: "b2"}, {Name: "c2", Value: "d2"}, }, }, Annotations: &PromLabels{ - Labels: []Label{ + Labels: []storepb.Label{ {Name: "ann1", Value: "ann44"}, {Name: "ann2", Value: "ann33"}, }, @@ -287,19 +288,19 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Alerts: []*AlertInstance{ { Labels: &PromLabels{ - Labels: []Label{ + Labels: []storepb.Label{ {Name: "instance1", Value: "1"}, }, }, Annotations: &PromLabels{ - Labels: []Label{ + Labels: []storepb.Label{ {Name: "annotation1", Value: "2"}, }, }, State: AlertState_INACTIVE, ActiveAt: nil, Value: "1", - PartialResponseStrategy: PartialResponseStrategy_WARN, + PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, }, { Labels: &PromLabels{}, @@ -307,7 +308,7 @@ func TestJSONUnmarshalMarshal(t *testing.T) { State: AlertState_FIRING, ActiveAt: &twoHoursAgo, Value: "2143", - PartialResponseStrategy: PartialResponseStrategy_ABORT, + PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, }, }, DurationSeconds: 60, @@ -324,8 +325,8 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Interval: 2442, LastEvaluation: now, EvaluationDurationSeconds: 2.1, - DeprecatedPartialResponseStrategy: PartialResponseStrategy_WARN, - PartialResponseStrategy: PartialResponseStrategy_ABORT, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, + PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, }, { Name: "group2", @@ -333,8 +334,8 @@ func TestJSONUnmarshalMarshal(t *testing.T) { Interval: 242342442, LastEvaluation: now.Add(40 * time.Hour), EvaluationDurationSeconds: 21244.1, - DeprecatedPartialResponseStrategy: PartialResponseStrategy_ABORT, - PartialResponseStrategy: PartialResponseStrategy_ABORT, + DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, + PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, }, }, }, diff --git a/pkg/store/storepb/rules.pb.go b/pkg/rules/rulespb/rpc.pb.go similarity index 64% rename from pkg/store/storepb/rules.pb.go rename to pkg/rules/rulespb/rpc.pb.go index 4519bea32b..413bacf45c 100644 --- a/pkg/store/storepb/rules.pb.go +++ b/pkg/rules/rulespb/rpc.pb.go @@ -1,20 +1,26 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: rules.proto +// source: rules/rulespb/rpc.proto -package storepb +package rulespb import ( + context "context" encoding_binary "encoding/binary" fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" time "time" + + storepb "github.com/thanos-io/thanos/pkg/store/storepb" ) // Reference imports to suppress errors if they are not otherwise used. @@ -64,7 +70,158 @@ func (x AlertState) String() string { } func (AlertState) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{0} + return fileDescriptor_91b1d28f30eb5efb, []int{0} +} + +type RulesRequest_Type int32 + +const ( + RulesRequest_ALL RulesRequest_Type = 0 + RulesRequest_ALERTING RulesRequest_Type = 1 + RulesRequest_RECORDING RulesRequest_Type = 2 +) + +var RulesRequest_Type_name = map[int32]string{ + 0: "ALL", + 1: "ALERTING", + 2: "RECORDING", +} + +var RulesRequest_Type_value = map[string]int32{ + "ALL": 0, + "ALERTING": 1, + "RECORDING": 2, +} + +func (x RulesRequest_Type) String() string { + return proto.EnumName(RulesRequest_Type_name, int32(x)) +} + +func (RulesRequest_Type) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_91b1d28f30eb5efb, []int{0, 0} +} + +type RulesRequest struct { + Type RulesRequest_Type `protobuf:"varint,1,opt,name=type,proto3,enum=thanos.RulesRequest_Type" json:"type,omitempty"` + PartialResponseStrategy storepb.PartialResponseStrategy `protobuf:"varint,2,opt,name=partial_response_strategy,json=partialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy,omitempty"` +} + +func (m *RulesRequest) Reset() { *m = RulesRequest{} } +func (m *RulesRequest) String() string { return proto.CompactTextString(m) } +func (*RulesRequest) ProtoMessage() {} +func (*RulesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_91b1d28f30eb5efb, []int{0} +} +func (m *RulesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RulesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RulesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RulesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RulesRequest.Merge(m, src) +} +func (m *RulesRequest) XXX_Size() int { + return m.Size() +} +func (m *RulesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RulesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RulesRequest proto.InternalMessageInfo + +type RulesResponse struct { + // Types that are valid to be assigned to Result: + // *RulesResponse_Group + // *RulesResponse_Warning + Result isRulesResponse_Result `protobuf_oneof:"result"` +} + +func (m *RulesResponse) Reset() { *m = RulesResponse{} } +func (m *RulesResponse) String() string { return proto.CompactTextString(m) } +func (*RulesResponse) ProtoMessage() {} +func (*RulesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_91b1d28f30eb5efb, []int{1} +} +func (m *RulesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RulesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RulesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RulesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RulesResponse.Merge(m, src) +} +func (m *RulesResponse) XXX_Size() int { + return m.Size() +} +func (m *RulesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RulesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RulesResponse proto.InternalMessageInfo + +type isRulesResponse_Result interface { + isRulesResponse_Result() + MarshalTo([]byte) (int, error) + Size() int +} + +type RulesResponse_Group struct { + Group *RuleGroup `protobuf:"bytes,1,opt,name=group,proto3,oneof" json:"group,omitempty"` +} +type RulesResponse_Warning struct { + Warning string `protobuf:"bytes,2,opt,name=warning,proto3,oneof" json:"warning,omitempty"` +} + +func (*RulesResponse_Group) isRulesResponse_Result() {} +func (*RulesResponse_Warning) isRulesResponse_Result() {} + +func (m *RulesResponse) GetResult() isRulesResponse_Result { + if m != nil { + return m.Result + } + return nil +} + +func (m *RulesResponse) GetGroup() *RuleGroup { + if x, ok := m.GetResult().(*RulesResponse_Group); ok { + return x.Group + } + return nil +} + +func (m *RulesResponse) GetWarning() string { + if x, ok := m.GetResult().(*RulesResponse_Warning); ok { + return x.Warning + } + return "" +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*RulesResponse) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*RulesResponse_Group)(nil), + (*RulesResponse_Warning)(nil), + } } /// RuleGroups is set of rule groups. @@ -82,7 +239,7 @@ func (m *RuleGroups) Reset() { *m = RuleGroups{} } func (m *RuleGroups) String() string { return proto.CompactTextString(m) } func (*RuleGroups) ProtoMessage() {} func (*RuleGroups) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{0} + return fileDescriptor_91b1d28f30eb5efb, []int{2} } func (m *RuleGroups) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -120,15 +277,15 @@ type RuleGroup struct { EvaluationDurationSeconds float64 `protobuf:"fixed64,5,opt,name=evaluation_duration_seconds,json=evaluationDurationSeconds,proto3" json:"evaluationTime"` LastEvaluation time.Time `protobuf:"bytes,6,opt,name=last_evaluation,json=lastEvaluation,proto3,stdtime" json:"lastEvaluation"` // Thanos specific. - DeprecatedPartialResponseStrategy PartialResponseStrategy `protobuf:"varint,7,opt,name=DeprecatedPartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy"` - PartialResponseStrategy PartialResponseStrategy `protobuf:"varint,8,opt,name=PartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partialResponseStrategy"` + DeprecatedPartialResponseStrategy storepb.PartialResponseStrategy `protobuf:"varint,7,opt,name=DeprecatedPartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy"` + PartialResponseStrategy storepb.PartialResponseStrategy `protobuf:"varint,8,opt,name=PartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partialResponseStrategy"` } func (m *RuleGroup) Reset() { *m = RuleGroup{} } func (m *RuleGroup) String() string { return proto.CompactTextString(m) } func (*RuleGroup) ProtoMessage() {} func (*RuleGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{1} + return fileDescriptor_91b1d28f30eb5efb, []int{3} } func (m *RuleGroup) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -168,7 +325,7 @@ func (m *Rule) Reset() { *m = Rule{} } func (m *Rule) String() string { return proto.CompactTextString(m) } func (*Rule) ProtoMessage() {} func (*Rule) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{2} + return fileDescriptor_91b1d28f30eb5efb, []int{4} } func (m *Rule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -249,14 +406,14 @@ type AlertInstance struct { ActiveAt *time.Time `protobuf:"bytes,4,opt,name=active_at,json=activeAt,proto3,stdtime" json:"activeAt,omitempty"` Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value"` // Thanos specific. Used mainly for alert API purposes. - PartialResponseStrategy PartialResponseStrategy `protobuf:"varint,6,opt,name=PartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partialResponseStrategy"` + PartialResponseStrategy storepb.PartialResponseStrategy `protobuf:"varint,6,opt,name=PartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partialResponseStrategy"` } func (m *AlertInstance) Reset() { *m = AlertInstance{} } func (m *AlertInstance) String() string { return proto.CompactTextString(m) } func (*AlertInstance) ProtoMessage() {} func (*AlertInstance) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{3} + return fileDescriptor_91b1d28f30eb5efb, []int{5} } func (m *AlertInstance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -304,7 +461,7 @@ func (m *Alert) Reset() { *m = Alert{} } func (m *Alert) String() string { return proto.CompactTextString(m) } func (*Alert) ProtoMessage() {} func (*Alert) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{4} + return fileDescriptor_91b1d28f30eb5efb, []int{6} } func (m *Alert) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -347,7 +504,7 @@ func (m *RecordingRule) Reset() { *m = RecordingRule{} } func (m *RecordingRule) String() string { return proto.CompactTextString(m) } func (*RecordingRule) ProtoMessage() {} func (*RecordingRule) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{5} + return fileDescriptor_91b1d28f30eb5efb, []int{7} } func (m *RecordingRule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -377,14 +534,14 @@ func (m *RecordingRule) XXX_DiscardUnknown() { var xxx_messageInfo_RecordingRule proto.InternalMessageInfo type PromLabels struct { - Labels []Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"` + Labels []storepb.Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"` } func (m *PromLabels) Reset() { *m = PromLabels{} } func (m *PromLabels) String() string { return proto.CompactTextString(m) } func (*PromLabels) ProtoMessage() {} func (*PromLabels) Descriptor() ([]byte, []int) { - return fileDescriptor_8e722d3e922f0937, []int{6} + return fileDescriptor_91b1d28f30eb5efb, []int{8} } func (m *PromLabels) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -415,6 +572,9 @@ var xxx_messageInfo_PromLabels proto.InternalMessageInfo func init() { proto.RegisterEnum("thanos.AlertState", AlertState_name, AlertState_value) + proto.RegisterEnum("thanos.RulesRequest_Type", RulesRequest_Type_name, RulesRequest_Type_value) + proto.RegisterType((*RulesRequest)(nil), "thanos.RulesRequest") + proto.RegisterType((*RulesResponse)(nil), "thanos.RulesResponse") proto.RegisterType((*RuleGroups)(nil), "thanos.RuleGroups") proto.RegisterType((*RuleGroup)(nil), "thanos.RuleGroup") proto.RegisterType((*Rule)(nil), "thanos.Rule") @@ -424,67 +584,288 @@ func init() { proto.RegisterType((*PromLabels)(nil), "thanos.PromLabels") } -func init() { proto.RegisterFile("rules.proto", fileDescriptor_8e722d3e922f0937) } - -var fileDescriptor_8e722d3e922f0937 = []byte{ - // 880 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x6f, 0xdb, 0x36, - 0x18, 0xb6, 0x62, 0x4b, 0xb6, 0x5e, 0x25, 0x4d, 0xc6, 0xad, 0x88, 0x9a, 0x6e, 0x96, 0x67, 0xa0, - 0x80, 0xb1, 0x0f, 0x07, 0x70, 0xd0, 0x0e, 0x3d, 0x46, 0x4d, 0xd6, 0x1a, 0x18, 0x82, 0x82, 0x09, - 0x76, 0xd8, 0xc5, 0x60, 0x6c, 0xd6, 0x11, 0x20, 0x8b, 0x1a, 0x49, 0x07, 0xc8, 0x7f, 0xd8, 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0x7b, 0x00, 0x95, 0x6f, 0xa0, 0x75, 0x68, 0x0d, 0x8f, 0xf6, 0x9f, - 0x9d, 0x0c, 0xbf, 0x3f, 0xdc, 0xaa, 0x21, 0x07, 0x9a, 0x2f, 0x0f, 0x8f, 0x0e, 0x86, 0x47, 0xcf, - 0xb7, 0x0c, 0x04, 0x60, 0x7d, 0x3b, 0xc4, 0xd9, 0x78, 0xcd, 0x7f, 0x74, 0xf9, 0x67, 0xbb, 0x76, - 0x79, 0xd5, 0x36, 0xde, 0x5c, 0xb5, 0x8d, 0x3f, 0xae, 0xda, 0xc6, 0xeb, 0xeb, 0x76, 0xed, 0xcd, - 0x75, 0xbb, 0xf6, 0xeb, 0x75, 0xbb, 0xf6, 0x43, 0x53, 0x48, 0xc6, 0x69, 0x7c, 0x7a, 0x6a, 0xa9, - 0x63, 0xed, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x9e, 0x97, 0xda, 0xdc, 0x09, 0x00, 0x00, +func init() { proto.RegisterFile("rules/rulespb/rpc.proto", fileDescriptor_91b1d28f30eb5efb) } + +var fileDescriptor_91b1d28f30eb5efb = []byte{ + // 1026 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x4f, 0xe3, 0x46, + 0x14, 0xb6, 0x49, 0xec, 0xc4, 0x0f, 0x58, 0xe8, 0x74, 0x11, 0x26, 0xdb, 0xc6, 0x34, 0xd2, 0x4a, + 0xb4, 0xdd, 0x4d, 0x2a, 0xd0, 0x52, 0xed, 0xa9, 0x22, 0x90, 0x2e, 0x48, 0x88, 0xae, 0x06, 0xd4, + 0x43, 0x7b, 0x48, 0x87, 0x30, 0x1b, 0x22, 0x39, 0xb6, 0x77, 0x66, 0x42, 0x95, 0xff, 0xd0, 0xc3, + 0xde, 0xfa, 0x3b, 0xfa, 0x2f, 0x38, 0xee, 0xb1, 0x87, 0xca, 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94, 0xfa, 0x3c, 0x75, + 0x8b, 0x46, 0x17, 0x65, 0x61, 0xff, 0x50, 0x69, 0x74, 0x61, 0x68, 0x14, 0x4e, 0x47, 0xd4, 0x82, + 0x79, 0x12, 0x04, 0xa1, 0x50, 0xe9, 0xe4, 0xe9, 0x01, 0x26, 0x19, 0x2f, 0x25, 0xb1, 0x37, 0x0e, + 0xc5, 0xe3, 0x0b, 0xb4, 0x05, 0x16, 0x17, 0x44, 0x50, 0xb7, 0xa0, 0xc2, 0x8c, 0x6e, 0xdc, 0xe0, + 0x58, 0x6a, 0x74, 0x6d, 0x28, 0x10, 0xd6, 0x03, 0x3a, 0x06, 0x87, 0x74, 0x44, 0xef, 0x82, 0xb6, + 0x89, 0x50, 0xc5, 0x71, 0x07, 0x2f, 0x93, 0xd8, 0x43, 0xda, 0x60, 0x47, 0x3c, 0x09, 0xfb, 0x3d, + 0x41, 0xfb, 0x91, 0x18, 0x2a, 0x5e, 0x96, 0x33, 0x39, 0xf2, 0xc0, 0x92, 0xf4, 0xa4, 0xaa, 0x60, + 0x1c, 0xed, 0x55, 0x09, 0xb0, 0x1e, 0xfe, 0x8d, 0x23, 0xf6, 0xfb, 0xe4, 0xc8, 0x5f, 0x45, 0xb0, + 0x54, 0x38, 0xf2, 0x60, 0x99, 0xef, 0x10, 0xac, 0xac, 0x67, 0xcd, 0x4d, 0xec, 0x59, 0x1e, 0x58, + 0xaf, 0x07, 0x94, 0x0d, 0x55, 0xfc, 0xd3, 0x5b, 0x2b, 0x01, 0xd6, 0x03, 0xfa, 0x12, 0x96, 0xff, + 0xd1, 0x52, 0xc6, 0xfa, 0x51, 0xa6, 0xc3, 0x4b, 0x67, 0xb7, 0x5a, 0x48, 0x4e, 0x2c, 0xeb, 0xff, + 0x10, 0xcb, 0xfe, 0x8f, 0xc4, 0x7a, 0x0e, 0xb6, 0x22, 0x3f, 0x77, 0x4b, 0xaa, 0xdf, 0xae, 0xdc, + 0x08, 0x56, 0x46, 0x7f, 0x7d,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xe6, 0x1f, 0x57, 0x55, 0xf3, 0xcd, + 0x75, 0xd5, 0x78, 0x7b, 0x5d, 0x35, 0x7e, 0xbd, 0xae, 0x1a, 0xdf, 0x95, 0xd2, 0xc7, 0xf4, 0xa9, + 0xad, 0xe2, 0xb2, 0xf5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x0e, 0xd2, 0xf3, 0x64, 0x0b, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// RulesClient is the client API for Rules service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type RulesClient interface { + /// Rules has info for all rules. + /// Returned rules are expected to include external labels. + Rules(ctx context.Context, in *RulesRequest, opts ...grpc.CallOption) (Rules_RulesClient, error) +} + +type rulesClient struct { + cc *grpc.ClientConn +} + +func NewRulesClient(cc *grpc.ClientConn) RulesClient { + return &rulesClient{cc} +} + +func (c *rulesClient) Rules(ctx context.Context, in *RulesRequest, opts ...grpc.CallOption) (Rules_RulesClient, error) { + stream, err := c.cc.NewStream(ctx, &_Rules_serviceDesc.Streams[0], "/thanos.Rules/Rules", opts...) + if err != nil { + return nil, err + } + x := &rulesRulesClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Rules_RulesClient interface { + Recv() (*RulesResponse, error) + grpc.ClientStream } +type rulesRulesClient struct { + grpc.ClientStream +} + +func (x *rulesRulesClient) Recv() (*RulesResponse, error) { + m := new(RulesResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// RulesServer is the server API for Rules service. +type RulesServer interface { + /// Rules has info for all rules. + /// Returned rules are expected to include external labels. + Rules(*RulesRequest, Rules_RulesServer) error +} + +// UnimplementedRulesServer can be embedded to have forward compatible implementations. +type UnimplementedRulesServer struct { +} + +func (*UnimplementedRulesServer) Rules(req *RulesRequest, srv Rules_RulesServer) error { + return status.Errorf(codes.Unimplemented, "method Rules not implemented") +} + +func RegisterRulesServer(s *grpc.Server, srv RulesServer) { + s.RegisterService(&_Rules_serviceDesc, srv) +} + +func _Rules_Rules_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(RulesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(RulesServer).Rules(m, &rulesRulesServer{stream}) +} + +type Rules_RulesServer interface { + Send(*RulesResponse) error + grpc.ServerStream +} + +type rulesRulesServer struct { + grpc.ServerStream +} + +func (x *rulesRulesServer) Send(m *RulesResponse) error { + return x.ServerStream.SendMsg(m) +} + +var _Rules_serviceDesc = grpc.ServiceDesc{ + ServiceName: "thanos.Rules", + HandlerType: (*RulesServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Rules", + Handler: _Rules_Rules_Handler, + ServerStreams: true, + }, + }, + Metadata: "rules/rulespb/rpc.proto", +} + +func (m *RulesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RulesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RulesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PartialResponseStrategy != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) + i-- + dAtA[i] = 0x10 + } + if m.Type != 0 { + i = encodeVarintRpc(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RulesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RulesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RulesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Result != nil { + { + size := m.Result.Size() + i -= size + if _, err := m.Result.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *RulesResponse_Group) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RulesResponse_Group) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Group != nil { + { + size, err := m.Group.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *RulesResponse_Warning) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RulesResponse_Warning) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Warning) + copy(dAtA[i:], m.Warning) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Warning))) + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil +} func (m *RuleGroups) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -513,7 +894,7 @@ func (m *RuleGroups) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -543,21 +924,21 @@ func (m *RuleGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.PartialResponseStrategy != 0 { - i = encodeVarintRules(dAtA, i, uint64(m.PartialResponseStrategy)) + i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) i-- dAtA[i] = 0x40 } if m.DeprecatedPartialResponseStrategy != 0 { - i = encodeVarintRules(dAtA, i, uint64(m.DeprecatedPartialResponseStrategy)) + i = encodeVarintRpc(dAtA, i, uint64(m.DeprecatedPartialResponseStrategy)) i-- dAtA[i] = 0x38 } - n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastEvaluation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation):]) - if err1 != nil { - return 0, err1 + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastEvaluation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation):]) + if err2 != nil { + return 0, err2 } - i -= n1 - i = encodeVarintRules(dAtA, i, uint64(n1)) + i -= n2 + i = encodeVarintRpc(dAtA, i, uint64(n2)) i-- dAtA[i] = 0x32 if m.EvaluationDurationSeconds != 0 { @@ -580,7 +961,7 @@ func (m *RuleGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -589,14 +970,14 @@ func (m *RuleGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.File) > 0 { i -= len(m.File) copy(dAtA[i:], m.File) - i = encodeVarintRules(dAtA, i, uint64(len(m.File))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.File))) i-- dAtA[i] = 0x12 } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) - i = encodeVarintRules(dAtA, i, uint64(len(m.Name))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0xa } @@ -649,7 +1030,7 @@ func (m *Rule_Recording) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -670,7 +1051,7 @@ func (m *Rule_Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -698,29 +1079,29 @@ func (m *AlertInstance) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.PartialResponseStrategy != 0 { - i = encodeVarintRules(dAtA, i, uint64(m.PartialResponseStrategy)) + i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) i-- dAtA[i] = 0x30 } if len(m.Value) > 0 { i -= len(m.Value) copy(dAtA[i:], m.Value) - i = encodeVarintRules(dAtA, i, uint64(len(m.Value))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Value))) i-- dAtA[i] = 0x2a } if m.ActiveAt != nil { - n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.ActiveAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.ActiveAt):]) - if err4 != nil { - return 0, err4 + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.ActiveAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.ActiveAt):]) + if err5 != nil { + return 0, err5 } - i -= n4 - i = encodeVarintRules(dAtA, i, uint64(n4)) + i -= n5 + i = encodeVarintRpc(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x22 } if m.State != 0 { - i = encodeVarintRules(dAtA, i, uint64(m.State)) + i = encodeVarintRpc(dAtA, i, uint64(m.State)) i-- dAtA[i] = 0x18 } @@ -731,7 +1112,7 @@ func (m *AlertInstance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -743,7 +1124,7 @@ func (m *AlertInstance) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -771,12 +1152,12 @@ func (m *Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n7, err7 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastEvaluation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation):]) - if err7 != nil { - return 0, err7 + n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastEvaluation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation):]) + if err8 != nil { + return 0, err8 } - i -= n7 - i = encodeVarintRules(dAtA, i, uint64(n7)) + i -= n8 + i = encodeVarintRpc(dAtA, i, uint64(n8)) i-- dAtA[i] = 0x5a if m.EvaluationDurationSeconds != 0 { @@ -788,14 +1169,14 @@ func (m *Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.LastError) > 0 { i -= len(m.LastError) copy(dAtA[i:], m.LastError) - i = encodeVarintRules(dAtA, i, uint64(len(m.LastError))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.LastError))) i-- dAtA[i] = 0x4a } if len(m.Health) > 0 { i -= len(m.Health) copy(dAtA[i:], m.Health) - i = encodeVarintRules(dAtA, i, uint64(len(m.Health))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Health))) i-- dAtA[i] = 0x42 } @@ -807,7 +1188,7 @@ func (m *Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x3a @@ -820,7 +1201,7 @@ func (m *Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x32 @@ -832,7 +1213,7 @@ func (m *Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a @@ -846,19 +1227,19 @@ func (m *Alert) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Query) > 0 { i -= len(m.Query) copy(dAtA[i:], m.Query) - i = encodeVarintRules(dAtA, i, uint64(len(m.Query))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Query))) i-- dAtA[i] = 0x1a } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) - i = encodeVarintRules(dAtA, i, uint64(len(m.Name))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0x12 } if m.State != 0 { - i = encodeVarintRules(dAtA, i, uint64(m.State)) + i = encodeVarintRpc(dAtA, i, uint64(m.State)) i-- dAtA[i] = 0x8 } @@ -885,12 +1266,12 @@ func (m *RecordingRule) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n10, err10 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastEvaluation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation):]) - if err10 != nil { - return 0, err10 + n11, err11 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastEvaluation, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation):]) + if err11 != nil { + return 0, err11 } - i -= n10 - i = encodeVarintRules(dAtA, i, uint64(n10)) + i -= n11 + i = encodeVarintRpc(dAtA, i, uint64(n11)) i-- dAtA[i] = 0x3a if m.EvaluationDurationSeconds != 0 { @@ -902,14 +1283,14 @@ func (m *RecordingRule) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.LastError) > 0 { i -= len(m.LastError) copy(dAtA[i:], m.LastError) - i = encodeVarintRules(dAtA, i, uint64(len(m.LastError))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.LastError))) i-- dAtA[i] = 0x2a } if len(m.Health) > 0 { i -= len(m.Health) copy(dAtA[i:], m.Health) - i = encodeVarintRules(dAtA, i, uint64(len(m.Health))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Health))) i-- dAtA[i] = 0x22 } @@ -920,7 +1301,7 @@ func (m *RecordingRule) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -928,14 +1309,14 @@ func (m *RecordingRule) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Query) > 0 { i -= len(m.Query) copy(dAtA[i:], m.Query) - i = encodeVarintRules(dAtA, i, uint64(len(m.Query))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Query))) i-- dAtA[i] = 0x12 } if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) - i = encodeVarintRules(dAtA, i, uint64(len(m.Name))) + i = encodeVarintRpc(dAtA, i, uint64(len(m.Name))) i-- dAtA[i] = 0xa } @@ -970,7 +1351,7 @@ func (m *PromLabels) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintRules(dAtA, i, uint64(size)) + i = encodeVarintRpc(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -979,8 +1360,8 @@ func (m *PromLabels) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintRules(dAtA []byte, offset int, v uint64) int { - offset -= sovRules(v) +func encodeVarintRpc(dAtA []byte, offset int, v uint64) int { + offset -= sovRpc(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -990,6 +1371,55 @@ func encodeVarintRules(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *RulesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovRpc(uint64(m.Type)) + } + if m.PartialResponseStrategy != 0 { + n += 1 + sovRpc(uint64(m.PartialResponseStrategy)) + } + return n +} + +func (m *RulesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Result != nil { + n += m.Result.Size() + } + return n +} + +func (m *RulesResponse_Group) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Group != nil { + l = m.Group.Size() + n += 1 + l + sovRpc(uint64(l)) + } + return n +} +func (m *RulesResponse_Warning) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Warning) + n += 1 + l + sovRpc(uint64(l)) + return n +} func (m *RuleGroups) Size() (n int) { if m == nil { return 0 @@ -999,7 +1429,7 @@ func (m *RuleGroups) Size() (n int) { if len(m.Groups) > 0 { for _, e := range m.Groups { l = e.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } } return n @@ -1013,16 +1443,16 @@ func (m *RuleGroup) Size() (n int) { _ = l l = len(m.Name) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.File) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if len(m.Rules) > 0 { for _, e := range m.Rules { l = e.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } } if m.Interval != 0 { @@ -1032,12 +1462,12 @@ func (m *RuleGroup) Size() (n int) { n += 9 } l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation) - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) if m.DeprecatedPartialResponseStrategy != 0 { - n += 1 + sovRules(uint64(m.DeprecatedPartialResponseStrategy)) + n += 1 + sovRpc(uint64(m.DeprecatedPartialResponseStrategy)) } if m.PartialResponseStrategy != 0 { - n += 1 + sovRules(uint64(m.PartialResponseStrategy)) + n += 1 + sovRpc(uint64(m.PartialResponseStrategy)) } return n } @@ -1062,7 +1492,7 @@ func (m *Rule_Recording) Size() (n int) { _ = l if m.Recording != nil { l = m.Recording.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } return n } @@ -1074,7 +1504,7 @@ func (m *Rule_Alert) Size() (n int) { _ = l if m.Alert != nil { l = m.Alert.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } return n } @@ -1086,25 +1516,25 @@ func (m *AlertInstance) Size() (n int) { _ = l if m.Labels != nil { l = m.Labels.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.Annotations != nil { l = m.Annotations.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.State != 0 { - n += 1 + sovRules(uint64(m.State)) + n += 1 + sovRpc(uint64(m.State)) } if m.ActiveAt != nil { l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.ActiveAt) - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.Value) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.PartialResponseStrategy != 0 { - n += 1 + sovRules(uint64(m.PartialResponseStrategy)) + n += 1 + sovRpc(uint64(m.PartialResponseStrategy)) } return n } @@ -1116,46 +1546,46 @@ func (m *Alert) Size() (n int) { var l int _ = l if m.State != 0 { - n += 1 + sovRules(uint64(m.State)) + n += 1 + sovRpc(uint64(m.State)) } l = len(m.Name) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.Query) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.DurationSeconds != 0 { n += 9 } if m.Labels != nil { l = m.Labels.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.Annotations != nil { l = m.Annotations.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if len(m.Alerts) > 0 { for _, e := range m.Alerts { l = e.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } } l = len(m.Health) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.LastError) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.EvaluationDurationSeconds != 0 { n += 9 } l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation) - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) return n } @@ -1167,29 +1597,29 @@ func (m *RecordingRule) Size() (n int) { _ = l l = len(m.Name) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.Query) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.Labels != nil { l = m.Labels.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.Health) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } l = len(m.LastError) if l > 0 { - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } if m.EvaluationDurationSeconds != 0 { n += 9 } l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastEvaluation) - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) return n } @@ -1202,17 +1632,228 @@ func (m *PromLabels) Size() (n int) { if len(m.Labels) > 0 { for _, e := range m.Labels { l = e.Size() - n += 1 + l + sovRules(uint64(l)) + n += 1 + l + sovRpc(uint64(l)) } } return n } -func sovRules(x uint64) (n int) { +func sovRpc(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozRules(x uint64) (n int) { - return sovRules(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozRpc(x uint64) (n int) { + return sovRpc(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RulesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RulesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RulesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= RulesRequest_Type(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PartialResponseStrategy", wireType) + } + m.PartialResponseStrategy = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PartialResponseStrategy |= storepb.PartialResponseStrategy(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipRpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RulesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RulesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RulesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &RuleGroup{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Result = &RulesResponse_Group{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Warning", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthRpc + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = &RulesResponse_Warning{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthRpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } func (m *RuleGroups) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -1222,7 +1863,7 @@ func (m *RuleGroups) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1250,7 +1891,7 @@ func (m *RuleGroups) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1263,11 +1904,11 @@ func (m *RuleGroups) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1279,15 +1920,15 @@ func (m *RuleGroups) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1309,7 +1950,7 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1337,7 +1978,7 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1351,11 +1992,11 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1369,7 +2010,7 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1383,11 +2024,11 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1401,7 +2042,7 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1414,11 +2055,11 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1457,7 +2098,7 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1470,11 +2111,11 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1490,14 +2131,14 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { m.DeprecatedPartialResponseStrategy = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.DeprecatedPartialResponseStrategy |= PartialResponseStrategy(b&0x7F) << shift + m.DeprecatedPartialResponseStrategy |= storepb.PartialResponseStrategy(b&0x7F) << shift if b < 0x80 { break } @@ -1509,29 +2150,29 @@ func (m *RuleGroup) Unmarshal(dAtA []byte) error { m.PartialResponseStrategy = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.PartialResponseStrategy |= PartialResponseStrategy(b&0x7F) << shift + m.PartialResponseStrategy |= storepb.PartialResponseStrategy(b&0x7F) << shift if b < 0x80 { break } } default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1553,7 +2194,7 @@ func (m *Rule) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1581,7 +2222,7 @@ func (m *Rule) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1594,11 +2235,11 @@ func (m *Rule) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1616,7 +2257,7 @@ func (m *Rule) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1629,11 +2270,11 @@ func (m *Rule) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1646,15 +2287,15 @@ func (m *Rule) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1676,7 +2317,7 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1704,7 +2345,7 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1717,11 +2358,11 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1740,7 +2381,7 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1753,11 +2394,11 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1776,7 +2417,7 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { m.State = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1795,7 +2436,7 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1808,11 +2449,11 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1831,7 +2472,7 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1845,11 +2486,11 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1863,29 +2504,29 @@ func (m *AlertInstance) Unmarshal(dAtA []byte) error { m.PartialResponseStrategy = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.PartialResponseStrategy |= PartialResponseStrategy(b&0x7F) << shift + m.PartialResponseStrategy |= storepb.PartialResponseStrategy(b&0x7F) << shift if b < 0x80 { break } } default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1907,7 +2548,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1935,7 +2576,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { m.State = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1954,7 +2595,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1968,11 +2609,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -1986,7 +2627,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2000,11 +2641,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2029,7 +2670,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2042,11 +2683,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2065,7 +2706,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2078,11 +2719,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2101,7 +2742,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2114,11 +2755,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2135,7 +2776,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2149,11 +2790,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2167,7 +2808,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2181,11 +2822,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2210,7 +2851,7 @@ func (m *Alert) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2223,11 +2864,11 @@ func (m *Alert) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2238,15 +2879,15 @@ func (m *Alert) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2268,7 +2909,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2296,7 +2937,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2310,11 +2951,11 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2328,7 +2969,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2342,11 +2983,11 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2360,7 +3001,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2373,11 +3014,11 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2396,7 +3037,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2410,11 +3051,11 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2428,7 +3069,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2442,11 +3083,11 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2471,7 +3112,7 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2484,11 +3125,11 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF @@ -2499,15 +3140,15 @@ func (m *RecordingRule) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2529,7 +3170,7 @@ func (m *PromLabels) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2557,7 +3198,7 @@ func (m *PromLabels) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowRules + return ErrIntOverflowRpc } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2570,31 +3211,31 @@ func (m *PromLabels) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if postIndex > l { return io.ErrUnexpectedEOF } - m.Labels = append(m.Labels, Label{}) + m.Labels = append(m.Labels, storepb.Label{}) if err := m.Labels[len(m.Labels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipRules(dAtA[iNdEx:]) + skippy, err := skipRpc(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRules + return ErrInvalidLengthRpc } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2608,7 +3249,7 @@ func (m *PromLabels) Unmarshal(dAtA []byte) error { } return nil } -func skipRules(dAtA []byte) (n int, err error) { +func skipRpc(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -2616,7 +3257,7 @@ func skipRules(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowRules + return 0, ErrIntOverflowRpc } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -2633,7 +3274,7 @@ func skipRules(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowRules + return 0, ErrIntOverflowRpc } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -2649,7 +3290,7 @@ func skipRules(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowRules + return 0, ErrIntOverflowRpc } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -2662,14 +3303,14 @@ func skipRules(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthRules + return 0, ErrInvalidLengthRpc } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupRules + return 0, ErrUnexpectedEndOfGroupRpc } depth-- case 5: @@ -2678,7 +3319,7 @@ func skipRules(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthRules + return 0, ErrInvalidLengthRpc } if depth == 0 { return iNdEx, nil @@ -2688,7 +3329,7 @@ func skipRules(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthRules = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowRules = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupRules = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthRpc = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRpc = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRpc = fmt.Errorf("proto: unexpected end of group") ) diff --git a/pkg/rules/rulespb/rpc.proto b/pkg/rules/rulespb/rpc.proto new file mode 100644 index 0000000000..4a28a01441 --- /dev/null +++ b/pkg/rules/rulespb/rpc.proto @@ -0,0 +1,139 @@ +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +syntax = "proto3"; +package thanos; + +import "store/storepb/types.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "rulespb"; + +option (gogoproto.sizer_all) = true; +option (gogoproto.marshaler_all) = true; +option (gogoproto.unmarshaler_all) = true; +option (gogoproto.goproto_getters_all) = false; + +// Do not generate XXX fields to reduce memory footprint and opening a door +// for zero-copy casts to/from prometheus data types. +option (gogoproto.goproto_unkeyed_all) = false; +option (gogoproto.goproto_unrecognized_all) = false; +option (gogoproto.goproto_sizecache_all) = false; + +/// Rules represents API that is responsible for gathering rules and their statuses. +service Rules { + /// Rules has info for all rules. + /// Returned rules are expected to include external labels. + rpc Rules(RulesRequest) returns (stream RulesResponse); +} + +message RulesRequest { + enum Type { + ALL = 0; + ALERTING = 1; + RECORDING = 2; + } + Type type = 1; + PartialResponseStrategy partial_response_strategy = 2; +} + +message RulesResponse { + oneof result { + // It is up to server implementation to decide how many of those to put here. + RuleGroup group = 1; + + /// warning is considered an information piece in place of series for warning purposes. + /// It is used to warn rule API users about suspicious cases or partial response (if enabled). + string warning = 2; + } +} + + +/// RuleGroups is set of rule groups. +/// This and below APIs are meant to be used for unmarshaling and marshsaling rules from/to Prometheus API. +/// That's why json tag has to be customized and matching https://github.com/prometheus/prometheus/blob/c530b4b456cc5f9ec249f771dff187eb7715dc9b/web/api/v1/api.go#L955 +/// NOTE: See rules_custom_test.go for compatibility tests. +/// +/// For rule parsing from YAML configuration other struct is used: https://github.com/prometheus/prometheus/blob/20b1f596f6fb16107ef0c244d240b0ad6da36829/pkg/rulefmt/rulefmt.go#L105 +/// TODO(bwplotka): Replace Thanos Rule JSON API Rules structs with this. +message RuleGroups { + repeated RuleGroup groups = 1 [(gogoproto.jsontag) = "groups" ]; +} + +/// RuleGroup has info for rules which are part of a group. +message RuleGroup { + string name = 1 [(gogoproto.jsontag) = "name" ]; + string file = 2 [(gogoproto.jsontag) = "file" ]; + repeated Rule rules = 3 [(gogoproto.jsontag) = "rules" ]; + double interval = 4 [(gogoproto.jsontag) = "interval" ]; + double evaluation_duration_seconds = 5 [(gogoproto.jsontag) = "evaluationTime" ]; // TODO: Is it really second? + google.protobuf.Timestamp last_evaluation = 6 [(gogoproto.jsontag) = "lastEvaluation", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + + // Thanos specific. + PartialResponseStrategy DeprecatedPartialResponseStrategy = 7 [(gogoproto.jsontag) = "partial_response_strategy"]; + PartialResponseStrategy PartialResponseStrategy = 8 [(gogoproto.jsontag) = "partialResponseStrategy" ]; +} + +message Rule { + oneof result { + RecordingRule recording = 1; + Alert alert= 2; + } +} + +/// AlertState represents state of the alert. Has to match 1:1 Prometheus AlertState: +// +// StateInactive is the state of an alert that is neither firing nor pending. +//StateInactive AlertState = iota +// StatePending is the state of an alert that has been active for less than +// the configured threshold duration. +//StatePending +// StateFiring is the state of an alert that has been active for longer than +// the configured threshold duration. +//StateFiring +enum AlertState { + INACTIVE = 0; + PENDING = 1; + FIRING = 2; +} + +message AlertInstance { + PromLabels labels = 1 [(gogoproto.jsontag) = "labels" ]; + PromLabels annotations = 2 [(gogoproto.jsontag) = "annotations" ]; + AlertState state = 3 [(gogoproto.jsontag) = "state" ]; + google.protobuf.Timestamp active_at = 4 [(gogoproto.jsontag) = "activeAt,omitempty", (gogoproto.stdtime) = true]; + string value = 5 [(gogoproto.jsontag) = "value" ]; + + // Thanos specific. Used mainly for alert API purposes. + PartialResponseStrategy PartialResponseStrategy = 6 [(gogoproto.jsontag) = "partialResponseStrategy" ]; +} + +message Alert { + /// state returns the maximum state of alert instances for this rule. + AlertState state = 1 [(gogoproto.jsontag) = "state" ]; + string name = 2 [(gogoproto.jsontag) = "name" ]; + string query = 3 [(gogoproto.jsontag) = "query" ]; + double duration_seconds = 4 [(gogoproto.jsontag) = "duration" ]; + PromLabels labels = 5 [(gogoproto.jsontag) = "labels" ]; + PromLabels annotations = 6 [(gogoproto.jsontag) = "annotations" ]; + repeated AlertInstance alerts = 7 [(gogoproto.jsontag) = "alerts" ]; + string health = 8 [(gogoproto.jsontag) = "health" ]; + string last_error = 9 [(gogoproto.jsontag) = "lastError,omitempty" ]; + double evaluation_duration_seconds = 10 [(gogoproto.jsontag) = "evaluationTime" ]; + google.protobuf.Timestamp last_evaluation = 11 [(gogoproto.jsontag) = "lastEvaluation", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; +} + +message RecordingRule { + string name = 1 [(gogoproto.jsontag) = "name" ]; + string query = 2 [(gogoproto.jsontag) = "query" ]; + PromLabels labels = 3 [(gogoproto.jsontag) = "labels" ]; + string health = 4 [(gogoproto.jsontag) = "health" ]; + string last_error = 5 [(gogoproto.jsontag) = "lastError,omitempty" ]; + double evaluation_duration_seconds = 6 [(gogoproto.jsontag) = "evaluationTime" ]; + google.protobuf.Timestamp last_evaluation = 7 [(gogoproto.jsontag) = "lastEvaluation", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; +} + +message PromLabels { + repeated Label labels = 1 [(gogoproto.nullable) = false]; +} diff --git a/pkg/server/grpc/grpc.go b/pkg/server/grpc/grpc.go index bc7fd6c176..2f7078976e 100644 --- a/pkg/server/grpc/grpc.go +++ b/pkg/server/grpc/grpc.go @@ -19,6 +19,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/prober" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/tracing" "google.golang.org/grpc" @@ -41,7 +42,7 @@ type Server struct { // New creates a new gRPC Store API. // If rulesSrv is not nil, it also registers Rules API to the returned server. -func New(logger log.Logger, reg prometheus.Registerer, tracer opentracing.Tracer, comp component.Component, probe *prober.GRPCProbe, storeSrv storepb.StoreServer, rulesSrv storepb.RulesServer, opts ...Option) *Server { +func New(logger log.Logger, reg prometheus.Registerer, tracer opentracing.Tracer, comp component.Component, probe *prober.GRPCProbe, storeSrv storepb.StoreServer, rulesSrv rulespb.RulesServer, opts ...Option) *Server { logger = log.With(logger, "service", "gRPC/server", "component", comp.String()) options := options{} for _, o := range opts { @@ -84,7 +85,7 @@ func New(logger log.Logger, reg prometheus.Registerer, tracer opentracing.Tracer s := grpc.NewServer(grpcOpts...) if rulesSrv != nil { - storepb.RegisterRulesServer(s, rulesSrv) + rulespb.RegisterRulesServer(s, rulesSrv) storepb.RegisterStoreServer(s, storeSrv) level.Info(logger).Log("msg", "registering as gRPC StoreAPI and RulesAPI") } else { diff --git a/pkg/store/prometheus.go b/pkg/store/prometheus.go index 8bd6914afc..0ca595f164 100644 --- a/pkg/store/prometheus.go +++ b/pkg/store/prometheus.go @@ -24,13 +24,11 @@ import ( "github.com/golang/snappy" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" - "github.com/prometheus/common/version" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/storage/remote" "github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/exthttp" "github.com/thanos-io/thanos/pkg/promclient" "github.com/thanos-io/thanos/pkg/runutil" "github.com/thanos-io/thanos/pkg/store/storepb" @@ -39,8 +37,6 @@ import ( "google.golang.org/grpc/status" ) -var userAgent = fmt.Sprintf("Thanos/%s", version.Version) - // PrometheusStore implements the store node API on top of the Prometheus remote read API. type PrometheusStore struct { logger log.Logger @@ -61,7 +57,7 @@ const initialBufSize = 32 * 1024 // 32KB seems like a good minimum starting size // It attaches the provided external labels to all results. func NewPrometheusStore( logger log.Logger, - client *http.Client, + client *promclient.Client, baseURL *url.URL, component component.StoreAPI, externalLabels func() labels.Labels, @@ -70,15 +66,10 @@ func NewPrometheusStore( if logger == nil { logger = log.NewNopLogger() } - if client == nil { - client = &http.Client{ - Transport: tracing.HTTPTripperware(logger, exthttp.NewTransport()), - } - } p := &PrometheusStore{ logger: logger, base: baseURL, - client: promclient.NewClient(client, logger, userAgent), + client: client, component: component, externalLabels: externalLabels, timestamps: timestamps, @@ -432,7 +423,7 @@ func (p *PrometheusStore) startPromRemoteRead(ctx context.Context, q *prompb.Que } preq.Header.Add("Content-Encoding", "snappy") preq.Header.Set("Content-Type", "application/x-stream-protobuf") - preq.Header.Set("User-Agent", userAgent) + preq.Header.Set("User-Agent", promclient.ThanosUserAgent) spanReqDo, ctx := tracing.StartSpan(ctx, "query_prometheus_request", opentracing.Tag{Key: "prometheus.query", Value: string(qjson)}) preq = preq.WithContext(ctx) presp, err := p.client.Do(preq) @@ -555,22 +546,3 @@ func (p *PrometheusStore) LabelValues(ctx context.Context, r *storepb.LabelValue sort.Strings(vals) return &storepb.LabelValuesResponse{Values: vals}, nil } - -// Rules returns all specified rules from Prometheus. -func (p *PrometheusStore) Rules(r *storepb.RulesRequest, s storepb.Rules_RulesServer) error { - var typeRules string - if r.Type != storepb.RulesRequest_ALL { - typeRules = r.Type.String() - } - groups, err := p.client.RulesInGRPC(s.Context(), p.base, typeRules) - if err != nil { - return err - } - - for _, g := range groups { - if err := s.Send(&storepb.RulesResponse{Result: &storepb.RulesResponse_Group{Group: g}}); err != nil { - return err - } - } - return nil -} diff --git a/pkg/store/prometheus_test.go b/pkg/store/prometheus_test.go index 0c0d33d311..0b50ed2e76 100644 --- a/pkg/store/prometheus_test.go +++ b/pkg/store/prometheus_test.go @@ -8,7 +8,6 @@ import ( "fmt" "math" "net/url" - "os" "testing" "time" @@ -19,11 +18,11 @@ import ( "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/tsdb" "github.com/prometheus/prometheus/tsdb/chunkenc" - "github.com/thanos-io/thanos/pkg/testutil/e2eutil" - "github.com/thanos-io/thanos/pkg/component" + "github.com/thanos-io/thanos/pkg/promclient" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/testutil" + "github.com/thanos-io/thanos/pkg/testutil/e2eutil" ) func TestPrometheusStore_Series_e2e(t *testing.T) { @@ -64,7 +63,7 @@ func testPrometheusStoreSeriesE2e(t *testing.T, prefix string) { testutil.Ok(t, err) limitMinT := int64(0) - proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, func() (int64, int64) { return limitMinT, -1 }) // Maxt does not matter. testutil.Ok(t, err) @@ -199,7 +198,7 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - promStore, err := NewPrometheusStore(nil, nil, u, component.Sidecar, + promStore, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, func() (int64, int64) { return math.MinInt64/1000 + 62135596801, math.MaxInt64/1000 - 62135596801 }) testutil.Ok(t, err) @@ -353,167 +352,6 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { } } -func TestPrometheusStore_Rules_e2e(t *testing.T) { - t.Helper() - - defer leaktest.CheckTimeout(t, 10*time.Second)() - - p, err := e2eutil.NewPrometheus() - testutil.Ok(t, err) - defer func() { testutil.Ok(t, p.Stop()) }() - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - curr, err := os.Getwd() - testutil.Ok(t, err) - testutil.Ok(t, p.SetConfig(fmt.Sprintf(` -global: - external_labels: - region: eu-west - -rule_files: - - %s/../../examples/alerts/alerts.yaml - - %s/../../examples/alerts/rules.yaml -`, curr, curr))) - testutil.Ok(t, p.Start()) - - u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) - testutil.Ok(t, err) - - promStore, err := NewPrometheusStore(nil, nil, u, component.Sidecar, - func() labels.Labels { return labels.FromStrings("region", "eu-west") }, - func() (int64, int64) { return math.MinInt64/1000 + 62135596801, math.MaxInt64/1000 - 62135596801 }) - testutil.Ok(t, err) - - someAlert := &storepb.Rule{Result: &storepb.Rule_Alert{Alert: &storepb.Alert{Name: "some"}}} - someRecording := &storepb.Rule{Result: &storepb.Rule_Recording{Recording: &storepb.RecordingRule{Name: "some"}}} - for _, tcase := range []struct { - req *storepb.RulesRequest - expected []storepb.RuleGroup - expectedErr error - }{ - { - req: &storepb.RulesRequest{}, - expected: []storepb.RuleGroup{ - { - Name: "thanos-bucket-replicate.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-compact.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-component-absent.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-query.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-receive.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-rule.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-sidecar.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-store.rules", - File: fmt.Sprintf("%s/../../examples/alerts/alerts.yaml", curr), - Rules: []*storepb.Rule{someAlert, someAlert, someAlert, someAlert}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-bucket-replicate.rules", - File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), - Rules: []*storepb.Rule{}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-query.rules", - File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), - Rules: []*storepb.Rule{someRecording, someRecording, someRecording, someRecording, someRecording}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-receive.rules", File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), - Rules: []*storepb.Rule{someRecording, someRecording, someRecording, someRecording, someRecording, someRecording}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - { - Name: "thanos-store.rules", - File: fmt.Sprintf("%s/../../examples/alerts/rules.yaml", curr), - Rules: []*storepb.Rule{someRecording, someRecording, someRecording, someRecording}, - Interval: 60, - DeprecatedPartialResponseStrategy: storepb.PartialResponseStrategy_WARN, PartialResponseStrategy: storepb.PartialResponseStrategy_WARN, - }, - }, - }, - } { - t.Run("", func(t *testing.T) { - srv := newRulesServer(ctx) - err = promStore.Rules(tcase.req, srv) - if tcase.expectedErr != nil { - testutil.NotOk(t, err) - testutil.Equals(t, tcase.expectedErr.Error(), err.Error()) - return - } - - // We don't want to be picky, just check what number and types of rules within group are. - got := srv.Groups - for i, g := range got { - for j, r := range g.Rules { - if r.GetAlert() != nil { - got[i].Rules[j] = someAlert - continue - } - if r.GetRecording() != nil { - got[i].Rules[j] = someRecording - continue - } - t.Fatalf("Found rule in group %s that is neither recording not alert.", g.Name) - } - } - - testutil.Ok(t, err) - testutil.Equals(t, []string(nil), srv.Warnings) - testutil.Equals(t, tcase.expected, srv.Groups) - }) - } -} - func TestPrometheusStore_LabelNames_e2e(t *testing.T) { defer leaktest.CheckTimeout(t, 10*time.Second)() @@ -538,7 +376,7 @@ func TestPrometheusStore_LabelNames_e2e(t *testing.T) { u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, getExternalLabels, nil) + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, getExternalLabels, nil) testutil.Ok(t, err) resp, err := proxy.LabelNames(ctx, &storepb.LabelNamesRequest{}) @@ -571,7 +409,7 @@ func TestPrometheusStore_LabelValues_e2e(t *testing.T) { u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, getExternalLabels, nil) + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, getExternalLabels, nil) testutil.Ok(t, err) resp, err := proxy.LabelValues(ctx, &storepb.LabelValuesRequest{ @@ -605,7 +443,7 @@ func TestPrometheusStore_ExternalLabelValues_e2e(t *testing.T) { u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, getExternalLabels, nil) + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, getExternalLabels, nil) testutil.Ok(t, err) resp, err := proxy.LabelValues(ctx, &storepb.LabelValuesRequest{ @@ -649,7 +487,7 @@ func TestPrometheusStore_Series_MatchExternalLabel_e2e(t *testing.T) { u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, func() (int64, int64) { return 0, math.MaxInt64 }) testutil.Ok(t, err) @@ -694,7 +532,7 @@ func TestPrometheusStore_Info(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - proxy, err := NewPrometheusStore(nil, nil, nil, component.Sidecar, + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), nil, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, func() (int64, int64) { return 123, 456 }) testutil.Ok(t, err) @@ -772,7 +610,7 @@ func TestPrometheusStore_Series_SplitSamplesIntoChunksWithMaxSizeOfUint16_e2e(t u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, + proxy, err := NewPrometheusStore(nil, promclient.NewDefaultClient(), u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, func() (int64, int64) { return 0, math.MaxInt64 }) testutil.Ok(t, err) diff --git a/pkg/store/proxy.go b/pkg/store/proxy.go index febd7c1a5a..a8a77c3804 100644 --- a/pkg/store/proxy.go +++ b/pkg/store/proxy.go @@ -50,7 +50,6 @@ type Client interface { type ProxyStore struct { logger log.Logger stores func() []Client - rules func() []storepb.RulesClient component component.StoreAPI selectorLabels labels.Labels @@ -58,126 +57,6 @@ type ProxyStore struct { metrics *proxyStoreMetrics } -func (s *ProxyStore) Rules(req *storepb.RulesRequest, srv storepb.Rules_RulesServer) error { - var ( - g, gctx = errgroup.WithContext(srv.Context()) - respChan = make(chan *storepb.RuleGroup, 10) - groups []*storepb.RuleGroup - ) - - for _, rulesClient := range s.rules() { - rs := &rulesStream{ - client: rulesClient, - request: req, - channel: respChan, - server: srv, - } - g.Go(func() error { return rs.receive(gctx) }) - } - - go func() { - _ = g.Wait() - close(respChan) - }() - - for resp := range respChan { - groups = append(groups, resp) - } - - if err := g.Wait(); err != nil { - level.Error(s.logger).Log("err", err) - return err - } - - groups = dedupGroups(groups) - - for _, g := range groups { - if err := srv.Send(storepb.NewRuleGroupRulesResponse(g)); err != nil { - return status.Error(codes.Unknown, errors.Wrap(err, "send rules response").Error()) - } - } - - return nil -} - -func dedupGroups(groups []*storepb.RuleGroup) []*storepb.RuleGroup { - // sort groups such that they appear next to each other. - sort.Slice(groups, func(i, j int) bool { return groups[i].Name < groups[j].Name }) - - // nothing to do if we have no or a single result, also no deduplication is necessary. - if len(groups) < 2 { - return groups - } - - i := 0 - for _, g := range groups[1:] { - if g.Name == groups[i].Name { - groups[i].Rules = append(groups[i].Rules, g.Rules...) - } else { - i++ - groups[i] = g - } - } - - return groups[:i+1] -} - -type rulesStream struct { - client storepb.RulesClient - request *storepb.RulesRequest - channel chan<- *storepb.RuleGroup - server storepb.Rules_RulesServer -} - -func (stream *rulesStream) receive(ctx context.Context) error { - rules, err := stream.client.Rules(ctx, stream.request) - if err != nil { - err = errors.Wrapf(err, "fetching rules from rules client %v", stream.client) - - if stream.request.PartialResponseStrategy == storepb.PartialResponseStrategy_ABORT { - return err - } - - if err := stream.server.Send(storepb.NewWarningRulesResponse(err)); err != nil { - return err - } - } - - for { - rule, err := rules.Recv() - if err == io.EOF { - return nil - } - - if err != nil { - err = errors.Wrapf(err, "receiving rules from rules client %v", stream.client) - - if stream.request.PartialResponseStrategy == storepb.PartialResponseStrategy_ABORT { - return err - } - - if err := stream.server.Send(storepb.NewWarningRulesResponse(err)); err != nil { - return errors.Wrapf(err, "sending rules error to server %v", stream.server) - } - - continue - } - - if w := rule.GetWarning(); w != "" { - if err := stream.server.Send(storepb.NewWarningRulesResponse(errors.New(w))); err != nil { - return errors.Wrapf(err, "sending rules warning to server %v", stream.server) - } - continue - } - - select { - case stream.channel <- rule.GetGroup(): - case <-ctx.Done(): - return ctx.Err() - } - } -} - type proxyStoreMetrics struct { emptyStreamResponses prometheus.Counter } @@ -204,7 +83,6 @@ func NewProxyStore( logger log.Logger, reg prometheus.Registerer, stores func() []Client, - rules func() []storepb.RulesClient, component component.StoreAPI, selectorLabels labels.Labels, responseTimeout time.Duration, @@ -217,7 +95,6 @@ func NewProxyStore( s := &ProxyStore{ logger: logger, stores: stores, - rules: rules, component: component, selectorLabels: selectorLabels, responseTimeout: responseTimeout, diff --git a/pkg/store/proxy_test.go b/pkg/store/proxy_test.go index a76f2089e1..815cf3472d 100644 --- a/pkg/store/proxy_test.go +++ b/pkg/store/proxy_test.go @@ -9,7 +9,6 @@ import ( "io" "math" "os" - "reflect" "sort" "testing" "time" @@ -61,7 +60,6 @@ func TestProxyStore_Info(t *testing.T) { q := NewProxyStore(nil, nil, func() []Client { return nil }, - nil, component.Query, nil, 0*time.Second, ) @@ -422,7 +420,6 @@ func TestProxyStore_Series(t *testing.T) { q := NewProxyStore(nil, nil, func() []Client { return tc.storeAPIs }, - nil, component.Query, tc.selectorLabels, 0*time.Second, @@ -889,7 +886,6 @@ func TestProxyStore_SeriesSlowStores(t *testing.T) { q := NewProxyStore(nil, nil, func() []Client { return tc.storeAPIs }, - nil, component.Query, tc.selectorLabels, 4*time.Second, @@ -939,7 +935,6 @@ func TestProxyStore_Series_RequestParamsProxied(t *testing.T) { q := NewProxyStore(nil, nil, func() []Client { return cls }, - nil, component.Query, nil, 0*time.Second, @@ -1000,7 +995,6 @@ func TestProxyStore_Series_RegressionFillResponseChannel(t *testing.T) { q := NewProxyStore(nil, nil, func() []Client { return cls }, - nil, component.Query, labels.FromStrings("fed", "a"), 0*time.Second, @@ -1040,7 +1034,6 @@ func TestProxyStore_LabelValues(t *testing.T) { q := NewProxyStore(nil, nil, func() []Client { return cls }, - nil, component.Query, nil, 0*time.Second, @@ -1145,7 +1138,6 @@ func TestProxyStore_LabelNames(t *testing.T) { nil, nil, func() []Client { return tc.storeAPIs }, - nil, component.Query, nil, 0*time.Second, @@ -1345,42 +1337,6 @@ func (s *storeSeriesServer) Context() context.Context { return s.ctx } -// rulesServer is test gRPC storeAPI series server. -type rulesServer struct { - // This field just exist to pseudo-implement the unused methods of the interface. - storepb.Rules_RulesServer - - ctx context.Context - - Groups []storepb.RuleGroup - Warnings []string - - Size int64 -} - -func newRulesServer(ctx context.Context) *rulesServer { - return &rulesServer{ctx: ctx} -} - -func (s *rulesServer) Send(r *storepb.RulesResponse) error { - s.Size += int64(r.Size()) - - if r.GetWarning() != "" { - s.Warnings = append(s.Warnings, r.GetWarning()) - return nil - } - - if r.GetGroup() == nil { - return errors.New("no grup") - } - s.Groups = append(s.Groups, *r.GetGroup()) - return nil -} - -func (s *rulesServer) Context() context.Context { - return s.ctx -} - // mockedStoreAPI is test gRPC store API client. type mockedStoreAPI struct { RespSeries []*storepb.SeriesResponse @@ -1396,7 +1352,7 @@ type mockedStoreAPI struct { LastLabelNamesReq *storepb.LabelNamesRequest } -func (s *mockedStoreAPI) Info(ctx context.Context, req *storepb.InfoRequest, _ ...grpc.CallOption) (*storepb.InfoResponse, error) { +func (s *mockedStoreAPI) Info(context.Context, *storepb.InfoRequest, ...grpc.CallOption) (*storepb.InfoResponse, error) { return nil, status.Error(codes.Unimplemented, "not implemented") } @@ -1406,13 +1362,13 @@ func (s *mockedStoreAPI) Series(ctx context.Context, req *storepb.SeriesRequest, return &StoreSeriesClient{ctx: ctx, respSet: s.RespSeries, respDur: s.RespDuration, slowSeriesIndex: s.SlowSeriesIndex}, s.RespError } -func (s *mockedStoreAPI) LabelNames(ctx context.Context, req *storepb.LabelNamesRequest, _ ...grpc.CallOption) (*storepb.LabelNamesResponse, error) { +func (s *mockedStoreAPI) LabelNames(_ context.Context, req *storepb.LabelNamesRequest, _ ...grpc.CallOption) (*storepb.LabelNamesResponse, error) { s.LastLabelNamesReq = req return s.RespLabelNames, s.RespError } -func (s *mockedStoreAPI) LabelValues(ctx context.Context, req *storepb.LabelValuesRequest, _ ...grpc.CallOption) (*storepb.LabelValuesResponse, error) { +func (s *mockedStoreAPI) LabelValues(_ context.Context, req *storepb.LabelValuesRequest, _ ...grpc.CallOption) (*storepb.LabelValuesResponse, error) { s.LastLabelValuesReq = req return s.RespLabelValues, s.RespError @@ -1487,149 +1443,3 @@ func TestMergeLabels(t *testing.T) { testutil.Equals(t, expected, resLabels) } - -func TestDedupGroups(t *testing.T) { - for _, tc := range []struct { - name string - groups, want []*storepb.RuleGroup - }{ - { - name: "no groups", - groups: nil, - want: nil, - }, - { - name: "empty group", - groups: []*storepb.RuleGroup{ - {Name: "a"}, - }, - want: []*storepb.RuleGroup{ - {Name: "a"}, - }, - }, - { - name: "multiple empty groups", - groups: []*storepb.RuleGroup{ - {Name: "a"}, - {Name: "b"}, - }, - want: []*storepb.RuleGroup{ - {Name: "a"}, - {Name: "b"}, - }, - }, - { - name: "single group", - groups: []*storepb.RuleGroup{ - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - }, - want: []*storepb.RuleGroup{ - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - }, - }, - { - name: "separate groups", - groups: []*storepb.RuleGroup{ - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - { - Name: "b", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b2"}), - }, - }, - }, - want: []*storepb.RuleGroup{ - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - { - Name: "b", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b2"}), - }, - }, - }, - }, - { - name: "duplicate groups", - groups: []*storepb.RuleGroup{ - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - { - Name: "b", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b2"}), - }, - }, - { - Name: "c", - }, - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - }, - want: []*storepb.RuleGroup{ - { - Name: "a", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "a2"}), - }, - }, - { - Name: "b", - Rules: []*storepb.Rule{ - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b1"}), - storepb.NewRecordingRule(&storepb.RecordingRule{Name: "b2"}), - }, - }, - { - Name: "c", - }, - }, - }, - } { - t.Run(tc.name, func(t *testing.T) { - got := dedupGroups(tc.groups) - if !reflect.DeepEqual(tc.want, got) { - t.Errorf("want groups %v, got %v", tc.want, got) - } - }) - } -} diff --git a/pkg/store/storepb/custom.go b/pkg/store/storepb/custom.go index 9bd0f4ab03..e996927b02 100644 --- a/pkg/store/storepb/custom.go +++ b/pkg/store/storepb/custom.go @@ -4,8 +4,10 @@ package storepb import ( + "strconv" "strings" + "github.com/pkg/errors" "github.com/prometheus/prometheus/pkg/labels" ) @@ -33,28 +35,6 @@ func NewSeriesResponse(series *Series) *SeriesResponse { } } -func NewRuleGroupRulesResponse(rg *RuleGroup) *RulesResponse { - return &RulesResponse{ - Result: &RulesResponse_Group{ - Group: rg, - }, - } -} - -func NewWarningRulesResponse(warning error) *RulesResponse { - return &RulesResponse{ - Result: &RulesResponse_Warning{ - Warning: warning.Error(), - }, - } -} - -func NewRecordingRule(r *RecordingRule) *Rule { - return &Rule{ - Result: &Rule_Recording{Recording: r}, - } -} - // CompareLabels compares two sets of labels. func CompareLabels(a, b []Label) int { l := len(a) @@ -219,3 +199,27 @@ func LabelSetsToString(lsets []LabelSet) string { } return strings.Join(s, "") } + +func (x *PartialResponseStrategy) UnmarshalJSON(entry []byte) error { + fieldStr, err := strconv.Unquote(string(entry)) + if err != nil { + return errors.Wrapf(err, "partialResponseStrategy: unquote %v", string(entry)) + } + + if len(fieldStr) == 0 { + // Default. + *x = PartialResponseStrategy_WARN + return nil + } + + strategy, ok := PartialResponseStrategy_value[strings.ToUpper(fieldStr)] + if !ok { + return errors.Errorf("unknown partialResponseStrategy: %v", string(entry)) + } + *x = PartialResponseStrategy(strategy) + return nil +} + +func (x *PartialResponseStrategy) MarshalJSON() ([]byte, error) { + return []byte(strconv.Quote(x.String())), nil +} diff --git a/pkg/store/storepb/rpc.pb.go b/pkg/store/storepb/rpc.pb.go index 0a99b10293..d62052ca3b 100644 --- a/pkg/store/storepb/rpc.pb.go +++ b/pkg/store/storepb/rpc.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: rpc.proto +// source: store/storepb/rpc.proto package storepb @@ -63,7 +63,7 @@ func (x StoreType) String() string { } func (StoreType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{0} + return fileDescriptor_a938d55a388af629, []int{0} } type Aggr int32 @@ -100,35 +100,7 @@ func (x Aggr) String() string { } func (Aggr) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{1} -} - -type RulesRequest_Type int32 - -const ( - RulesRequest_ALL RulesRequest_Type = 0 - RulesRequest_ALERTING RulesRequest_Type = 1 - RulesRequest_RECORDING RulesRequest_Type = 2 -) - -var RulesRequest_Type_name = map[int32]string{ - 0: "ALL", - 1: "ALERTING", - 2: "RECORDING", -} - -var RulesRequest_Type_value = map[string]int32{ - "ALL": 0, - "ALERTING": 1, - "RECORDING": 2, -} - -func (x RulesRequest_Type) String() string { - return proto.EnumName(RulesRequest_Type_name, int32(x)) -} - -func (RulesRequest_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{11, 0} + return fileDescriptor_a938d55a388af629, []int{1} } type WriteResponse struct { @@ -138,7 +110,7 @@ func (m *WriteResponse) Reset() { *m = WriteResponse{} } func (m *WriteResponse) String() string { return proto.CompactTextString(m) } func (*WriteResponse) ProtoMessage() {} func (*WriteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{0} + return fileDescriptor_a938d55a388af629, []int{0} } func (m *WriteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -177,7 +149,7 @@ func (m *WriteRequest) Reset() { *m = WriteRequest{} } func (m *WriteRequest) String() string { return proto.CompactTextString(m) } func (*WriteRequest) ProtoMessage() {} func (*WriteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{1} + return fileDescriptor_a938d55a388af629, []int{1} } func (m *WriteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -213,7 +185,7 @@ func (m *InfoRequest) Reset() { *m = InfoRequest{} } func (m *InfoRequest) String() string { return proto.CompactTextString(m) } func (*InfoRequest) ProtoMessage() {} func (*InfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{2} + return fileDescriptor_a938d55a388af629, []int{2} } func (m *InfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -256,7 +228,7 @@ func (m *InfoResponse) Reset() { *m = InfoResponse{} } func (m *InfoResponse) String() string { return proto.CompactTextString(m) } func (*InfoResponse) ProtoMessage() {} func (*InfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{3} + return fileDescriptor_a938d55a388af629, []int{3} } func (m *InfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -293,7 +265,7 @@ func (m *LabelSet) Reset() { *m = LabelSet{} } func (m *LabelSet) String() string { return proto.CompactTextString(m) } func (*LabelSet) ProtoMessage() {} func (*LabelSet) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{4} + return fileDescriptor_a938d55a388af629, []int{4} } func (m *LabelSet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -340,7 +312,7 @@ func (m *SeriesRequest) Reset() { *m = SeriesRequest{} } func (m *SeriesRequest) String() string { return proto.CompactTextString(m) } func (*SeriesRequest) ProtoMessage() {} func (*SeriesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{5} + return fileDescriptor_a938d55a388af629, []int{5} } func (m *SeriesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -380,7 +352,7 @@ func (m *SeriesResponse) Reset() { *m = SeriesResponse{} } func (m *SeriesResponse) String() string { return proto.CompactTextString(m) } func (*SeriesResponse) ProtoMessage() {} func (*SeriesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{6} + return fileDescriptor_a938d55a388af629, []int{6} } func (m *SeriesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -464,7 +436,7 @@ func (m *LabelNamesRequest) Reset() { *m = LabelNamesRequest{} } func (m *LabelNamesRequest) String() string { return proto.CompactTextString(m) } func (*LabelNamesRequest) ProtoMessage() {} func (*LabelNamesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{7} + return fileDescriptor_a938d55a388af629, []int{7} } func (m *LabelNamesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -502,7 +474,7 @@ func (m *LabelNamesResponse) Reset() { *m = LabelNamesResponse{} } func (m *LabelNamesResponse) String() string { return proto.CompactTextString(m) } func (*LabelNamesResponse) ProtoMessage() {} func (*LabelNamesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{8} + return fileDescriptor_a938d55a388af629, []int{8} } func (m *LabelNamesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -542,7 +514,7 @@ func (m *LabelValuesRequest) Reset() { *m = LabelValuesRequest{} } func (m *LabelValuesRequest) String() string { return proto.CompactTextString(m) } func (*LabelValuesRequest) ProtoMessage() {} func (*LabelValuesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{9} + return fileDescriptor_a938d55a388af629, []int{9} } func (m *LabelValuesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -580,7 +552,7 @@ func (m *LabelValuesResponse) Reset() { *m = LabelValuesResponse{} } func (m *LabelValuesResponse) String() string { return proto.CompactTextString(m) } func (*LabelValuesResponse) ProtoMessage() {} func (*LabelValuesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{10} + return fileDescriptor_a938d55a388af629, []int{10} } func (m *LabelValuesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -609,133 +581,9 @@ func (m *LabelValuesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_LabelValuesResponse proto.InternalMessageInfo -type RulesRequest struct { - Type RulesRequest_Type `protobuf:"varint,1,opt,name=type,proto3,enum=thanos.RulesRequest_Type" json:"type,omitempty"` - PartialResponseStrategy PartialResponseStrategy `protobuf:"varint,2,opt,name=partial_response_strategy,json=partialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partial_response_strategy,omitempty"` -} - -func (m *RulesRequest) Reset() { *m = RulesRequest{} } -func (m *RulesRequest) String() string { return proto.CompactTextString(m) } -func (*RulesRequest) ProtoMessage() {} -func (*RulesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{11} -} -func (m *RulesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RulesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RulesRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RulesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_RulesRequest.Merge(m, src) -} -func (m *RulesRequest) XXX_Size() int { - return m.Size() -} -func (m *RulesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_RulesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_RulesRequest proto.InternalMessageInfo - -type RulesResponse struct { - // Types that are valid to be assigned to Result: - // *RulesResponse_Group - // *RulesResponse_Warning - Result isRulesResponse_Result `protobuf_oneof:"result"` -} - -func (m *RulesResponse) Reset() { *m = RulesResponse{} } -func (m *RulesResponse) String() string { return proto.CompactTextString(m) } -func (*RulesResponse) ProtoMessage() {} -func (*RulesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_77a6da22d6a3feb1, []int{12} -} -func (m *RulesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RulesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RulesResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RulesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RulesResponse.Merge(m, src) -} -func (m *RulesResponse) XXX_Size() int { - return m.Size() -} -func (m *RulesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RulesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_RulesResponse proto.InternalMessageInfo - -type isRulesResponse_Result interface { - isRulesResponse_Result() - MarshalTo([]byte) (int, error) - Size() int -} - -type RulesResponse_Group struct { - Group *RuleGroup `protobuf:"bytes,1,opt,name=group,proto3,oneof" json:"group,omitempty"` -} -type RulesResponse_Warning struct { - Warning string `protobuf:"bytes,2,opt,name=warning,proto3,oneof" json:"warning,omitempty"` -} - -func (*RulesResponse_Group) isRulesResponse_Result() {} -func (*RulesResponse_Warning) isRulesResponse_Result() {} - -func (m *RulesResponse) GetResult() isRulesResponse_Result { - if m != nil { - return m.Result - } - return nil -} - -func (m *RulesResponse) GetGroup() *RuleGroup { - if x, ok := m.GetResult().(*RulesResponse_Group); ok { - return x.Group - } - return nil -} - -func (m *RulesResponse) GetWarning() string { - if x, ok := m.GetResult().(*RulesResponse_Warning); ok { - return x.Warning - } - return "" -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*RulesResponse) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*RulesResponse_Group)(nil), - (*RulesResponse_Warning)(nil), - } -} - func init() { proto.RegisterEnum("thanos.StoreType", StoreType_name, StoreType_value) proto.RegisterEnum("thanos.Aggr", Aggr_name, Aggr_value) - proto.RegisterEnum("thanos.RulesRequest_Type", RulesRequest_Type_name, RulesRequest_Type_value) proto.RegisterType((*WriteResponse)(nil), "thanos.WriteResponse") proto.RegisterType((*WriteRequest)(nil), "thanos.WriteRequest") proto.RegisterType((*InfoRequest)(nil), "thanos.InfoRequest") @@ -747,79 +595,69 @@ func init() { proto.RegisterType((*LabelNamesResponse)(nil), "thanos.LabelNamesResponse") proto.RegisterType((*LabelValuesRequest)(nil), "thanos.LabelValuesRequest") proto.RegisterType((*LabelValuesResponse)(nil), "thanos.LabelValuesResponse") - proto.RegisterType((*RulesRequest)(nil), "thanos.RulesRequest") - proto.RegisterType((*RulesResponse)(nil), "thanos.RulesResponse") -} - -func init() { proto.RegisterFile("rpc.proto", fileDescriptor_77a6da22d6a3feb1) } - -var fileDescriptor_77a6da22d6a3feb1 = []byte{ - // 1036 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0xe3, 0x44, - 0x14, 0xf7, 0xc4, 0xf9, 0xfb, 0xd2, 0x04, 0x77, 0x9a, 0x16, 0x37, 0x48, 0x69, 0x65, 0x09, 0x29, - 0x2c, 0x4b, 0xba, 0x64, 0xc5, 0x22, 0xd0, 0x4a, 0x28, 0x4d, 0xb3, 0xdb, 0x88, 0x36, 0x85, 0x49, - 0xbb, 0xe5, 0xcf, 0xa1, 0xeb, 0xb4, 0x83, 0x6b, 0x6d, 0x62, 0x1b, 0xcf, 0x84, 0xb6, 0x17, 0x0e, - 0x7c, 0x02, 0xae, 0x7c, 0x07, 0xbe, 0x05, 0x97, 0x1e, 0xf7, 0x08, 0x17, 0x04, 0xed, 0x17, 0x41, - 0x33, 0x1e, 0x27, 0x76, 0x29, 0x15, 0xa8, 0xe2, 0x36, 0xef, 0xfd, 0x9e, 0xdf, 0x9f, 0xdf, 0xbc, - 0xf7, 0x3c, 0x50, 0x0a, 0x83, 0xe3, 0x56, 0x10, 0xfa, 0xdc, 0xc7, 0x79, 0x7e, 0x6a, 0x7b, 0x3e, - 0xab, 0x97, 0xf9, 0x45, 0x40, 0x59, 0xa4, 0xac, 0x97, 0xc3, 0xe9, 0x78, 0x26, 0xd4, 0x1c, 0xdf, - 0xf1, 0xe5, 0x71, 0x43, 0x9c, 0x94, 0xf6, 0xb1, 0xe3, 0xf2, 0xd3, 0xe9, 0xa8, 0x75, 0xec, 0x4f, - 0x36, 0x82, 0xd0, 0x9f, 0x50, 0x7e, 0x4a, 0xa7, 0xec, 0xe6, 0x31, 0x18, 0x6d, 0x24, 0xfc, 0x5a, - 0x6f, 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, 0x29, 0x57, 0xa9, 0x95, 0xc6, 0x4a, 0x66, - 0xd6, 0x87, 0x50, 0x8c, 0xc1, 0xff, 0x54, 0x96, 0xf5, 0x93, 0x0e, 0x95, 0x88, 0xf2, 0xf8, 0x96, - 0x92, 0x85, 0xa2, 0x7f, 0x2e, 0x34, 0x93, 0x2e, 0xf4, 0x89, 0x80, 0xf8, 0xf1, 0x29, 0x0d, 0x99, - 0xa9, 0xcb, 0xb0, 0xb5, 0x54, 0xd8, 0xdd, 0x08, 0x54, 0xd1, 0x67, 0xb6, 0xb8, 0x0d, 0xcb, 0xc2, - 0x65, 0x48, 0x99, 0x3f, 0x9e, 0x72, 0xd7, 0xf7, 0x8e, 0xce, 0x5c, 0xef, 0xc4, 0x3f, 0x93, 0x64, - 0xe9, 0x64, 0x69, 0x62, 0x9f, 0x93, 0x19, 0x76, 0x28, 0x21, 0xfc, 0x10, 0xc0, 0x76, 0x9c, 0x90, - 0x3a, 0x36, 0xa7, 0x11, 0x47, 0xd5, 0xf6, 0x42, 0x1c, 0xad, 0xe3, 0x38, 0x21, 0x49, 0xe0, 0xf8, - 0x63, 0x58, 0x0d, 0xec, 0x90, 0xbb, 0xf6, 0x58, 0x44, 0x91, 0x37, 0x7f, 0x74, 0xe2, 0x32, 0x7b, - 0x34, 0xa6, 0x27, 0x66, 0x7e, 0x1d, 0x35, 0x8b, 0xe4, 0x4d, 0x65, 0x10, 0x77, 0xc6, 0x96, 0x82, - 0xf1, 0xd7, 0xb7, 0x7c, 0xcb, 0x78, 0x68, 0x73, 0xea, 0x5c, 0x98, 0x05, 0x79, 0x9d, 0x6b, 0x71, - 0xe0, 0xcf, 0xd2, 0x3e, 0x86, 0xca, 0xec, 0x6f, 0xce, 0x63, 0x00, 0xaf, 0x41, 0x99, 0xbd, 0x72, - 0x83, 0xa3, 0xe3, 0xd3, 0xa9, 0xf7, 0x8a, 0x99, 0x45, 0x99, 0x0a, 0x08, 0x55, 0x57, 0x6a, 0xac, - 0x97, 0x50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0xa6, 0x3a, - 0xfa, 0xf0, 0x11, 0xc2, 0x5d, 0x80, 0xf9, 0x54, 0xe2, 0xd5, 0xd4, 0xda, 0x4f, 0xee, 0x95, 0x7a, - 0xfd, 0x36, 0x48, 0xc5, 0x7f, 0x06, 0xe5, 0x44, 0x33, 0xe3, 0xb4, 0x69, 0x6a, 0x4c, 0xeb, 0x6f, - 0xdd, 0x8a, 0x45, 0x7e, 0xda, 0x03, 0xa8, 0xca, 0x37, 0x87, 0x98, 0xbf, 0x88, 0x8c, 0xa7, 0x50, - 0x26, 0x74, 0xe2, 0x73, 0x2a, 0xf5, 0x78, 0x56, 0x7e, 0xf2, 0x69, 0x52, 0x5f, 0xbe, 0xa1, 0x55, - 0x2f, 0x18, 0xad, 0xfd, 0x09, 0xe4, 0x64, 0x3b, 0xe1, 0x27, 0xf1, 0xa1, 0x76, 0xdb, 0x30, 0xcc, - 0x1d, 0xa4, 0x9a, 0xef, 0x11, 0xda, 0x7c, 0xfb, 0xf2, 0xcf, 0x86, 0x76, 0x79, 0xd5, 0x40, 0xaf, - 0xaf, 0x1a, 0xe8, 0x8f, 0xab, 0x06, 0xfa, 0xf1, 0xba, 0xa1, 0xbd, 0xbe, 0x6e, 0x68, 0xbf, 0x5e, - 0x37, 0xb4, 0xaf, 0x0a, 0xf2, 0xcf, 0x1f, 0x8c, 0x46, 0x79, 0xf9, 0x86, 0x7a, 0xfc, 0x57, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x51, 0xa1, 0x1b, 0x77, 0xbd, 0x09, 0x00, 0x00, +} + +func init() { proto.RegisterFile("store/storepb/rpc.proto", fileDescriptor_a938d55a388af629) } + +var fileDescriptor_a938d55a388af629 = []byte{ + // 911 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcd, 0x6e, 0x23, 0x45, + 0x10, 0x9e, 0xf1, 0xd8, 0x63, 0xbb, 0x9c, 0x98, 0xd9, 0x8e, 0x93, 0x9d, 0x0c, 0x92, 0x63, 0x8d, + 0x84, 0x64, 0x2d, 0x28, 0x01, 0x23, 0x40, 0xa0, 0xbd, 0x24, 0x5e, 0xaf, 0xd6, 0x62, 0xe3, 0x40, + 0x3b, 0xde, 0xf0, 0x73, 0x30, 0x93, 0xa4, 0x99, 0x8c, 0x76, 0xfe, 0x98, 0x6e, 0x93, 0xe4, 0xc2, + 0x81, 0x27, 0xe0, 0xca, 0x3b, 0xf0, 0x16, 0x5c, 0x72, 0xdc, 0x23, 0x5c, 0x10, 0x24, 0x2f, 0x82, + 0xfa, 0x67, 0x1c, 0xcf, 0x12, 0x22, 0xad, 0x7c, 0xb1, 0xa6, 0xbe, 0xaf, 0xba, 0xab, 0xea, 0xeb, + 0xaa, 0x6e, 0xc3, 0x43, 0xca, 0x92, 0x8c, 0xec, 0x88, 0xdf, 0xf4, 0x78, 0x27, 0x4b, 0x4f, 0xb6, + 0xd3, 0x2c, 0x61, 0x09, 0x32, 0xd9, 0x99, 0x17, 0x27, 0xd4, 0xd9, 0x2c, 0x3a, 0xb0, 0xcb, 0x94, + 0x50, 0xe9, 0xe2, 0xb4, 0xfc, 0xc4, 0x4f, 0xc4, 0xe7, 0x0e, 0xff, 0x52, 0x28, 0x4a, 0xb3, 0x24, + 0x2a, 0x7a, 0xba, 0x6f, 0xc1, 0xea, 0x51, 0x16, 0x30, 0x82, 0x09, 0x4d, 0x93, 0x98, 0x12, 0xf7, + 0x27, 0x58, 0x51, 0xc0, 0x0f, 0x33, 0x42, 0x19, 0x7a, 0x0c, 0xc0, 0x82, 0x88, 0x50, 0x92, 0x05, + 0x84, 0xda, 0x7a, 0xc7, 0xe8, 0x36, 0x7a, 0x1b, 0x7c, 0x71, 0x44, 0xd8, 0x19, 0x99, 0xd1, 0xed, + 0xc3, 0x20, 0x22, 0x63, 0xc1, 0xee, 0x95, 0xaf, 0xfe, 0xda, 0xd2, 0xf0, 0x82, 0x3f, 0xda, 0x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70, 0xaf, 0x62, 0xfa, + 0x12, 0x8a, 0x95, 0x96, 0x53, 0xcc, 0x7d, 0x0a, 0x68, 0x31, 0x5b, 0x25, 0x4a, 0x0b, 0x2a, 0x31, + 0x07, 0x44, 0xbb, 0xd7, 0xb1, 0x34, 0x90, 0x03, 0x35, 0x55, 0x2f, 0xb5, 0x4b, 0x82, 0x98, 0xdb, + 0xee, 0xef, 0xba, 0xda, 0xe8, 0x85, 0x17, 0xce, 0x6e, 0xeb, 0x6e, 0x41, 0x45, 0x4c, 0x85, 0xa8, + 0xb1, 0x8e, 0xa5, 0x71, 0xbf, 0x1a, 0xa5, 0x25, 0xd4, 0x30, 0x96, 0x54, 0x63, 0x08, 0x6b, 0x85, + 0x22, 0x94, 0x1c, 0x1b, 0x60, 0xfe, 0x28, 0x10, 0xa5, 0x87, 0xb2, 0xee, 0x13, 0xe4, 0x11, 0x86, + 0xfa, 0xfc, 0x36, 0x42, 0x0d, 0xa8, 0x4e, 0x46, 0x9f, 0x8f, 0x0e, 0x8e, 0x46, 0x96, 0x86, 0xea, + 0x50, 0xf9, 0x72, 0x32, 0xc0, 0x5f, 0x5b, 0x3a, 0xaa, 0x41, 0x19, 0x4f, 0x9e, 0x0f, 0xac, 0x12, + 0xf7, 0x18, 0x0f, 0x9f, 0x0c, 0xfa, 0xbb, 0xd8, 0x32, 0xb8, 0xc7, 0xf8, 0xf0, 0x00, 0x0f, 0xac, + 0x32, 0xc7, 0xf1, 0xa0, 0x3f, 0x18, 0xbe, 0x18, 0x58, 0x95, 0x47, 0x7b, 0x50, 0xe6, 0xb3, 0x88, + 0xaa, 0x60, 0xe0, 0xdd, 0x23, 0xb9, 0x55, 0xff, 0x60, 0x32, 0x3a, 0xb4, 0x74, 0x8e, 0x8d, 0x27, + 0xfb, 0x56, 0x89, 0x7f, 0xec, 0x0f, 0x47, 0x96, 0x21, 0x3e, 0x76, 0xbf, 0x92, 0x7b, 0x08, 0xaf, + 0x01, 0xb6, 0x2a, 0xbd, 0x9f, 0x4b, 0x50, 0x11, 0x89, 0xa1, 0x0f, 0xa0, 0xcc, 0xef, 0x6e, 0xb4, + 0x96, 0xcb, 0xb5, 0x70, 0xb3, 0x3b, 0xad, 0x22, 0xa8, 0x84, 0xf8, 0x14, 0x4c, 0x39, 0x16, 0x68, + 0xbd, 0x38, 0x26, 0xf9, 0xb2, 0x8d, 0xd7, 0x61, 0xb9, 0xf0, 0x7d, 0x1d, 0xf5, 0x01, 0x6e, 0x1b, + 0x0d, 0x6d, 0x16, 0x6e, 0xb2, 0xc5, 0x51, 0x71, 0x9c, 0xbb, 0x28, 0x15, 0xff, 0x29, 0x34, 0x16, + 0xce, 0x07, 0x15, 0x5d, 0x0b, 0x9d, 0xe7, 0xbc, 0x7d, 0x27, 0x27, 0xf7, 0xe9, 0x8d, 0xa0, 0x29, + 0x9e, 0x51, 0xde, 0x52, 0x52, 0x8c, 0xc7, 0xd0, 0xc0, 0x24, 0x4a, 0x18, 0x11, 0x38, 0x9a, 0x97, + 0xbf, 0xf8, 0xda, 0x3a, 0xeb, 0xaf, 0xa1, 0xea, 0x51, 0xd6, 0xf6, 0xde, 0xb9, 0xfa, 0xa7, 0xad, + 0x5d, 0x5d, 0xb7, 0xf5, 0x57, 0xd7, 0x6d, 0xfd, 0xef, 0xeb, 0xb6, 0xfe, 0xcb, 0x4d, 0x5b, 0x7b, + 0x75, 0xd3, 0xd6, 0xfe, 0xb8, 0x69, 0x6b, 0xdf, 0x54, 0xd5, 0x9f, 0x80, 0x63, 0x53, 0xbc, 0xea, + 0x1f, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xd6, 0xcc, 0x8a, 0xe4, 0x3d, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1057,7 +895,7 @@ var _Store_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "rpc.proto", + Metadata: "store/storepb/rpc.proto", } // WriteableStoreClient is the client API for WriteableStore service. @@ -1131,110 +969,7 @@ var _WriteableStore_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "rpc.proto", -} - -// RulesClient is the client API for Rules service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type RulesClient interface { - /// Rules has info for all rules. - /// Returned rules are expected to include external labels. - Rules(ctx context.Context, in *RulesRequest, opts ...grpc.CallOption) (Rules_RulesClient, error) -} - -type rulesClient struct { - cc *grpc.ClientConn -} - -func NewRulesClient(cc *grpc.ClientConn) RulesClient { - return &rulesClient{cc} -} - -func (c *rulesClient) Rules(ctx context.Context, in *RulesRequest, opts ...grpc.CallOption) (Rules_RulesClient, error) { - stream, err := c.cc.NewStream(ctx, &_Rules_serviceDesc.Streams[0], "/thanos.Rules/Rules", opts...) - if err != nil { - return nil, err - } - x := &rulesRulesClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Rules_RulesClient interface { - Recv() (*RulesResponse, error) - grpc.ClientStream -} - -type rulesRulesClient struct { - grpc.ClientStream -} - -func (x *rulesRulesClient) Recv() (*RulesResponse, error) { - m := new(RulesResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// RulesServer is the server API for Rules service. -type RulesServer interface { - /// Rules has info for all rules. - /// Returned rules are expected to include external labels. - Rules(*RulesRequest, Rules_RulesServer) error -} - -// UnimplementedRulesServer can be embedded to have forward compatible implementations. -type UnimplementedRulesServer struct { -} - -func (*UnimplementedRulesServer) Rules(req *RulesRequest, srv Rules_RulesServer) error { - return status.Errorf(codes.Unimplemented, "method Rules not implemented") -} - -func RegisterRulesServer(s *grpc.Server, srv RulesServer) { - s.RegisterService(&_Rules_serviceDesc, srv) -} - -func _Rules_Rules_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(RulesRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RulesServer).Rules(m, &rulesRulesServer{stream}) -} - -type Rules_RulesServer interface { - Send(*RulesResponse) error - grpc.ServerStream -} - -type rulesRulesServer struct { - grpc.ServerStream -} - -func (x *rulesRulesServer) Send(m *RulesResponse) error { - return x.ServerStream.SendMsg(m) -} - -var _Rules_serviceDesc = grpc.ServiceDesc{ - ServiceName: "thanos.Rules", - HandlerType: (*RulesServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "Rules", - Handler: _Rules_Rules_Handler, - ServerStreams: true, - }, - }, - Metadata: "rpc.proto", + Metadata: "store/storepb/rpc.proto", } func (m *WriteResponse) Marshal() (dAtA []byte, err error) { @@ -1762,106 +1497,6 @@ func (m *LabelValuesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *RulesRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RulesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RulesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.PartialResponseStrategy != 0 { - i = encodeVarintRpc(dAtA, i, uint64(m.PartialResponseStrategy)) - i-- - dAtA[i] = 0x10 - } - if m.Type != 0 { - i = encodeVarintRpc(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *RulesResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RulesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RulesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Result != nil { - { - size := m.Result.Size() - i -= size - if _, err := m.Result.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *RulesResponse_Group) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RulesResponse_Group) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Group != nil { - { - size, err := m.Group.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRpc(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *RulesResponse_Warning) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RulesResponse_Warning) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= len(m.Warning) - copy(dAtA[i:], m.Warning) - i = encodeVarintRpc(dAtA, i, uint64(len(m.Warning))) - i-- - dAtA[i] = 0x12 - return len(dAtA) - i, nil -} func encodeVarintRpc(dAtA []byte, offset int, v uint64) int { offset -= sovRpc(v) base := offset @@ -2108,56 +1743,6 @@ func (m *LabelValuesResponse) Size() (n int) { return n } -func (m *RulesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovRpc(uint64(m.Type)) - } - if m.PartialResponseStrategy != 0 { - n += 1 + sovRpc(uint64(m.PartialResponseStrategy)) - } - return n -} - -func (m *RulesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Result != nil { - n += m.Result.Size() - } - return n -} - -func (m *RulesResponse_Group) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Group != nil { - l = m.Group.Size() - n += 1 + l + sovRpc(uint64(l)) - } - return n -} -func (m *RulesResponse_Warning) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Warning) - n += 1 + l + sovRpc(uint64(l)) - return n -} - func sovRpc(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3515,217 +3100,6 @@ func (m *LabelValuesResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *RulesRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRpc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RulesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RulesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRpc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= RulesRequest_Type(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PartialResponseStrategy", wireType) - } - m.PartialResponseStrategy = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRpc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PartialResponseStrategy |= PartialResponseStrategy(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipRpc(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRpc - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRpc - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RulesResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRpc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RulesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RulesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Group", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRpc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRpc - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRpc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RuleGroup{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Result = &RulesResponse_Group{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Warning", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRpc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRpc - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRpc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Result = &RulesResponse_Warning{string(dAtA[iNdEx:postIndex])} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRpc(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthRpc - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthRpc - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipRpc(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/pkg/store/storepb/rpc.proto b/pkg/store/storepb/rpc.proto index 30ec66106d..2bb210a193 100644 --- a/pkg/store/storepb/rpc.proto +++ b/pkg/store/storepb/rpc.proto @@ -4,10 +4,9 @@ syntax = "proto3"; package thanos; -import "types.proto"; -import "rules.proto"; +import "store/storepb/types.proto"; import "gogoproto/gogo.proto"; -import "github.com/prometheus/prometheus/prompb/types.proto"; +import "prompb/types.proto"; option go_package = "storepb"; @@ -22,7 +21,7 @@ option (gogoproto.goproto_unkeyed_all) = false; option (gogoproto.goproto_unrecognized_all) = false; option (gogoproto.goproto_sizecache_all) = false; -/// Store reprents API against instance that stores XOR encoded values with label set metadata (e.g Prometheus metrics). +/// Store represents API against instance that stores XOR encoded values with label set metadata (e.g Prometheus metrics). service Store { /// Info returns meta information about a store e.g labels that makes that store unique as well as time range that is /// available. @@ -146,31 +145,3 @@ message LabelValuesResponse { repeated string values = 1; repeated string warnings = 2; } - -/// Rules represents API that is responsible for gathering rules and their statuses. -service Rules { - /// Rules has info for all rules. - /// Returned rules are expected to include external labels. - rpc Rules(RulesRequest) returns (stream RulesResponse); -} - -message RulesRequest { - enum Type { - ALL = 0; - ALERTING = 1; - RECORDING = 2; - } - Type type = 1; - PartialResponseStrategy partial_response_strategy = 2; -} - -message RulesResponse { - oneof result { - // It is up to server implementation to decide how many of those to put here. - RuleGroup group = 1; - - /// warning is considered an information piece in place of series for warning purposes. - /// It is used to warn rule API users about suspicious cases or partial response (if enabled). - string warning = 2; - } -} diff --git a/pkg/store/storepb/rules.proto b/pkg/store/storepb/rules.proto deleted file mode 100644 index b3000062a0..0000000000 --- a/pkg/store/storepb/rules.proto +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) The Thanos Authors. -// Licensed under the Apache License 2.0. - -syntax = "proto3"; -package thanos; - -import "types.proto"; -import "gogoproto/gogo.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "storepb"; - -option (gogoproto.sizer_all) = true; -option (gogoproto.marshaler_all) = true; -option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_getters_all) = false; - -// Do not generate XXX fields to reduce memory footprint and opening a door -// for zero-copy casts to/from prometheus data types. -option (gogoproto.goproto_unkeyed_all) = false; -option (gogoproto.goproto_unrecognized_all) = false; -option (gogoproto.goproto_sizecache_all) = false; - -/// RuleGroups is set of rule groups. -/// This and below APIs are meant to be used for unmarshaling and marshsaling rules from/to Prometheus API. -/// That's why json tag has to be customized and matching https://github.com/prometheus/prometheus/blob/c530b4b456cc5f9ec249f771dff187eb7715dc9b/web/api/v1/api.go#L955 -/// NOTE: See rules_custom_test.go for compatibility tests. -/// -/// For rule parsing from YAML configuration other struct is used: https://github.com/prometheus/prometheus/blob/20b1f596f6fb16107ef0c244d240b0ad6da36829/pkg/rulefmt/rulefmt.go#L105 -/// TODO(bwplotka): Replace Thanos Rule JSON API Rules structs with this. -message RuleGroups { - repeated RuleGroup groups = 1 [(gogoproto.jsontag) = "groups" ]; -} - -/// RuleGroup has info for rules which are part of a group. -message RuleGroup { - string name = 1 [(gogoproto.jsontag) = "name" ]; - string file = 2 [(gogoproto.jsontag) = "file" ]; - repeated Rule rules = 3 [(gogoproto.jsontag) = "rules" ]; - double interval = 4 [(gogoproto.jsontag) = "interval" ]; - double evaluation_duration_seconds = 5 [(gogoproto.jsontag) = "evaluationTime" ]; // TODO: Is it really second? - google.protobuf.Timestamp last_evaluation = 6 [(gogoproto.jsontag) = "lastEvaluation", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - - // Thanos specific. - PartialResponseStrategy DeprecatedPartialResponseStrategy = 7 [(gogoproto.jsontag) = "partial_response_strategy"]; - PartialResponseStrategy PartialResponseStrategy = 8 [(gogoproto.jsontag) = "partialResponseStrategy" ]; -} - -message Rule { - oneof result { - RecordingRule recording = 1; - Alert alert= 2; - } -} - -/// AlertState represents state of the alert. Has to match 1:1 Prometheus AlertState: -// -// StateInactive is the state of an alert that is neither firing nor pending. -//StateInactive AlertState = iota -// StatePending is the state of an alert that has been active for less than -// the configured threshold duration. -//StatePending -// StateFiring is the state of an alert that has been active for longer than -// the configured threshold duration. -//StateFiring -enum AlertState { - INACTIVE = 0; - PENDING = 1; - FIRING = 2; -} - -message AlertInstance { - PromLabels labels = 1 [(gogoproto.jsontag) = "labels" ]; - PromLabels annotations = 2 [(gogoproto.jsontag) = "annotations" ]; - AlertState state = 3 [(gogoproto.jsontag) = "state" ]; - google.protobuf.Timestamp active_at = 4 [(gogoproto.jsontag) = "activeAt,omitempty", (gogoproto.stdtime) = true]; - string value = 5 [(gogoproto.jsontag) = "value" ]; - - // Thanos specific. Used mainly for alert API purposes. - PartialResponseStrategy PartialResponseStrategy = 6 [(gogoproto.jsontag) = "partialResponseStrategy" ]; -} - -message Alert { - /// state returns the maximum state of alert instances for this rule. - AlertState state = 1 [(gogoproto.jsontag) = "state" ]; - string name = 2 [(gogoproto.jsontag) = "name" ]; - string query = 3 [(gogoproto.jsontag) = "query" ]; - double duration_seconds = 4 [(gogoproto.jsontag) = "duration" ]; - PromLabels labels = 5 [(gogoproto.jsontag) = "labels" ]; - PromLabels annotations = 6 [(gogoproto.jsontag) = "annotations" ]; - repeated AlertInstance alerts = 7 [(gogoproto.jsontag) = "alerts" ]; - string health = 8 [(gogoproto.jsontag) = "health" ]; - string last_error = 9 [(gogoproto.jsontag) = "lastError,omitempty" ]; - double evaluation_duration_seconds = 10 [(gogoproto.jsontag) = "evaluationTime" ]; - google.protobuf.Timestamp last_evaluation = 11 [(gogoproto.jsontag) = "lastEvaluation", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; -} - -message RecordingRule { - string name = 1 [(gogoproto.jsontag) = "name" ]; - string query = 2 [(gogoproto.jsontag) = "query" ]; - PromLabels labels = 3 [(gogoproto.jsontag) = "labels" ]; - string health = 4 [(gogoproto.jsontag) = "health" ]; - string last_error = 5 [(gogoproto.jsontag) = "lastError,omitempty" ]; - double evaluation_duration_seconds = 6 [(gogoproto.jsontag) = "evaluationTime" ]; - google.protobuf.Timestamp last_evaluation = 7 [(gogoproto.jsontag) = "lastEvaluation", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; -} - -message PromLabels{ - repeated Label labels = 1 [(gogoproto.nullable) = false]; -} \ No newline at end of file diff --git a/pkg/store/storepb/types.pb.go b/pkg/store/storepb/types.pb.go index 37e9fa812d..aecd10191f 100644 --- a/pkg/store/storepb/types.pb.go +++ b/pkg/store/storepb/types.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: types.proto +// source: store/storepb/types.proto package storepb @@ -55,7 +55,7 @@ func (x PartialResponseStrategy) String() string { } func (PartialResponseStrategy) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{0} + return fileDescriptor_121fba57de02d8e0, []int{0} } type Chunk_Encoding int32 @@ -77,7 +77,7 @@ func (x Chunk_Encoding) String() string { } func (Chunk_Encoding) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{1, 0} + return fileDescriptor_121fba57de02d8e0, []int{1, 0} } type LabelMatcher_Type int32 @@ -108,7 +108,7 @@ func (x LabelMatcher_Type) String() string { } func (LabelMatcher_Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{4, 0} + return fileDescriptor_121fba57de02d8e0, []int{4, 0} } type Label struct { @@ -120,7 +120,7 @@ func (m *Label) Reset() { *m = Label{} } func (m *Label) String() string { return proto.CompactTextString(m) } func (*Label) ProtoMessage() {} func (*Label) Descriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{0} + return fileDescriptor_121fba57de02d8e0, []int{0} } func (m *Label) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -158,7 +158,7 @@ func (m *Chunk) Reset() { *m = Chunk{} } func (m *Chunk) String() string { return proto.CompactTextString(m) } func (*Chunk) ProtoMessage() {} func (*Chunk) Descriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{1} + return fileDescriptor_121fba57de02d8e0, []int{1} } func (m *Chunk) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -196,7 +196,7 @@ func (m *Series) Reset() { *m = Series{} } func (m *Series) String() string { return proto.CompactTextString(m) } func (*Series) ProtoMessage() {} func (*Series) Descriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{2} + return fileDescriptor_121fba57de02d8e0, []int{2} } func (m *Series) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -240,7 +240,7 @@ func (m *AggrChunk) Reset() { *m = AggrChunk{} } func (m *AggrChunk) String() string { return proto.CompactTextString(m) } func (*AggrChunk) ProtoMessage() {} func (*AggrChunk) Descriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{3} + return fileDescriptor_121fba57de02d8e0, []int{3} } func (m *AggrChunk) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +280,7 @@ func (m *LabelMatcher) Reset() { *m = LabelMatcher{} } func (m *LabelMatcher) String() string { return proto.CompactTextString(m) } func (*LabelMatcher) ProtoMessage() {} func (*LabelMatcher) Descriptor() ([]byte, []int) { - return fileDescriptor_d938547f84707355, []int{4} + return fileDescriptor_121fba57de02d8e0, []int{4} } func (m *LabelMatcher) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -320,41 +320,41 @@ func init() { proto.RegisterType((*LabelMatcher)(nil), "thanos.LabelMatcher") } -func init() { proto.RegisterFile("types.proto", fileDescriptor_d938547f84707355) } - -var fileDescriptor_d938547f84707355 = []byte{ - // 485 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xc7, 0xfd, 0x3f, 0xc9, 0xb4, 0xbf, 0x9f, 0xcc, 0x52, 0xc1, 0x96, 0x83, 0x1b, 0x19, 0x21, - 0xa2, 0x22, 0x5c, 0x51, 0x9e, 0x20, 0x41, 0xb9, 0x41, 0x4b, 0xb7, 0x91, 0x40, 0x08, 0x09, 0x6d, - 0xd2, 0xc5, 0xb1, 0x88, 0xd7, 0x91, 0x77, 0x03, 0xc9, 0x5b, 0x80, 0x78, 0xa9, 0x1c, 0x7b, 0xe4, - 0x84, 0x20, 0x79, 0x11, 0xb4, 0xe3, 0x18, 0x5a, 0xc9, 0xb7, 0xf1, 0x7c, 0x3f, 0x33, 0xdf, 0xd1, - 0xce, 0x18, 0xf6, 0xf4, 0x6a, 0x2e, 0x54, 0x32, 0x2f, 0x0b, 0x5d, 0x90, 0x40, 0x4f, 0xb9, 0x2c, - 0xd4, 0x83, 0x83, 0xb4, 0x48, 0x0b, 0x4c, 0x9d, 0x98, 0xa8, 0x52, 0xe3, 0x67, 0xe0, 0xbf, 0xe4, - 0x63, 0x31, 0x23, 0x04, 0x3c, 0xc9, 0x73, 0x41, 0xed, 0xae, 0xdd, 0xeb, 0x30, 0x8c, 0xc9, 0x01, - 0xf8, 0x9f, 0xf9, 0x6c, 0x21, 0xa8, 0x83, 0xc9, 0xea, 0x23, 0x7e, 0x0f, 0xfe, 0x8b, 0xe9, 0x42, - 0x7e, 0x22, 0xc7, 0xe0, 0x19, 0x23, 0x2c, 0xf9, 0xff, 0xf4, 0x5e, 0x52, 0x19, 0x25, 0x28, 0x26, - 0x43, 0x39, 0x29, 0xae, 0x32, 0x99, 0x32, 0x64, 0x4c, 0xfb, 0x2b, 0xae, 0x39, 0x76, 0xda, 0x67, - 0x18, 0xc7, 0x77, 0xa1, 0x5d, 0x53, 0xa4, 0x05, 0xee, 0xdb, 0x73, 0x16, 0x5a, 0xf1, 0x47, 0x08, - 0x2e, 0x45, 0x99, 0x09, 0x45, 0x9e, 0x40, 0x30, 0x33, 0xa3, 0x29, 0x6a, 0x77, 0xdd, 0xde, 0xde, - 0xe9, 0x7f, 0xb5, 0x01, 0x0e, 0x3c, 0xf0, 0xd6, 0x3f, 0x8f, 0x2c, 0xb6, 0x43, 0xc8, 0x09, 0x04, - 0x13, 0xe3, 0xab, 0xa8, 0x83, 0xf0, 0x9d, 0x1a, 0xee, 0xa7, 0x69, 0x89, 0x13, 0xd5, 0x05, 0x15, - 0x16, 0x7f, 0x77, 0xa0, 0xf3, 0x57, 0x23, 0x87, 0xd0, 0xce, 0x33, 0xf9, 0x41, 0x67, 0xbb, 0x17, - 0x70, 0x59, 0x2b, 0xcf, 0xe4, 0x28, 0xcb, 0x05, 0x4a, 0x7c, 0x59, 0x49, 0xce, 0x4e, 0xe2, 0x4b, - 0x94, 0x8e, 0xc0, 0x2d, 0xf9, 0x17, 0xea, 0x76, 0xed, 0x9b, 0xe3, 0x61, 0x47, 0x66, 0x14, 0xf2, - 0x10, 0xfc, 0x49, 0xb1, 0x90, 0x9a, 0x7a, 0x4d, 0x48, 0xa5, 0x99, 0x2e, 0x6a, 0x91, 0x53, 0xbf, - 0xb1, 0x8b, 0x5a, 0xe4, 0x06, 0xc8, 0x33, 0x49, 0x83, 0x46, 0x20, 0xcf, 0x24, 0x02, 0x7c, 0x49, - 0x5b, 0xcd, 0x00, 0x5f, 0x92, 0xc7, 0xd0, 0x42, 0x2f, 0x51, 0xd2, 0x76, 0x13, 0x54, 0xab, 0xf1, - 0x37, 0x1b, 0xf6, 0xf1, 0x79, 0x5f, 0x71, 0x3d, 0x99, 0x8a, 0x92, 0x3c, 0xbd, 0xb5, 0xe3, 0xc3, - 0x5b, 0x2b, 0xd8, 0x31, 0xc9, 0x68, 0x35, 0x17, 0xff, 0xd6, 0x8c, 0x57, 0xe4, 0x34, 0x5d, 0x91, - 0x7b, 0xf3, 0x8a, 0x7a, 0xe0, 0x99, 0x3a, 0x12, 0x80, 0x33, 0xbc, 0x08, 0x2d, 0x73, 0x00, 0x67, - 0xc3, 0x8b, 0xd0, 0x36, 0x09, 0x36, 0x0c, 0x1d, 0x4c, 0xb0, 0x61, 0xe8, 0x1e, 0x27, 0x70, 0xff, - 0x35, 0x2f, 0x75, 0xc6, 0x67, 0x4c, 0xa8, 0x79, 0x21, 0x95, 0xb8, 0xd4, 0x25, 0xd7, 0x22, 0x5d, - 0x91, 0x36, 0x78, 0x6f, 0xfa, 0xec, 0x2c, 0xb4, 0x48, 0x07, 0xfc, 0xfe, 0xe0, 0x9c, 0x8d, 0x42, - 0x7b, 0xf0, 0x68, 0xfd, 0x3b, 0xb2, 0xd6, 0x9b, 0xc8, 0xbe, 0xde, 0x44, 0xf6, 0xaf, 0x4d, 0x64, - 0x7f, 0xdd, 0x46, 0xd6, 0xf5, 0x36, 0xb2, 0x7e, 0x6c, 0x23, 0xeb, 0x5d, 0x4b, 0xe9, 0xa2, 0x14, - 0xf3, 0xf1, 0x38, 0xc0, 0x1f, 0xe0, 0xf9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x04, 0xf7, 0xda, - 0x10, 0x2d, 0x03, 0x00, 0x00, +func init() { proto.RegisterFile("store/storepb/types.proto", fileDescriptor_121fba57de02d8e0) } + +var fileDescriptor_121fba57de02d8e0 = []byte{ + // 490 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xfd, 0x3f, 0xc9, 0x50, 0x90, 0x59, 0x2a, 0xd8, 0x70, 0x70, 0x23, 0x23, 0x44, 0x54, + 0x84, 0x23, 0xca, 0x13, 0x24, 0x28, 0x37, 0x68, 0xe9, 0x36, 0x12, 0x08, 0x21, 0xa1, 0x4d, 0xba, + 0x38, 0x16, 0xf1, 0x3a, 0xf2, 0x6e, 0x20, 0x79, 0x0b, 0x10, 0x2f, 0x95, 0x63, 0x8f, 0x9c, 0x10, + 0x24, 0x2f, 0x82, 0x76, 0x9c, 0x40, 0x2b, 0xf9, 0x62, 0xad, 0xe7, 0xfb, 0xcd, 0x7c, 0xa3, 0x9d, + 0x59, 0x68, 0x2b, 0x5d, 0x94, 0xa2, 0x87, 0xdf, 0xf9, 0xb8, 0xa7, 0x57, 0x73, 0xa1, 0x92, 0x79, + 0x59, 0xe8, 0x82, 0x04, 0x7a, 0xca, 0x65, 0xa1, 0x1e, 0x1e, 0xa6, 0x45, 0x5a, 0x60, 0xa8, 0x67, + 0x4e, 0x95, 0x1a, 0x3f, 0x07, 0xff, 0x15, 0x1f, 0x8b, 0x19, 0x21, 0xe0, 0x49, 0x9e, 0x0b, 0x6a, + 0x77, 0xec, 0x6e, 0x8b, 0xe1, 0x99, 0x1c, 0x82, 0xff, 0x85, 0xcf, 0x16, 0x82, 0x3a, 0x18, 0xac, + 0x7e, 0xe2, 0x0f, 0xe0, 0xbf, 0x9c, 0x2e, 0xe4, 0x67, 0x72, 0x0c, 0x9e, 0x31, 0xc2, 0x94, 0x3b, + 0x27, 0xf7, 0x93, 0xca, 0x28, 0x41, 0x31, 0x19, 0xca, 0x49, 0x71, 0x99, 0xc9, 0x94, 0x21, 0x63, + 0xca, 0x5f, 0x72, 0xcd, 0xb1, 0xd2, 0x01, 0xc3, 0x73, 0x7c, 0x0f, 0x9a, 0x7b, 0x8a, 0x34, 0xc0, + 0x7d, 0x77, 0xc6, 0x42, 0x2b, 0xfe, 0x04, 0xc1, 0x85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, + 0xe0, 0x0c, 0xcf, 0x43, 0xcb, 0x2c, 0xc0, 0xe9, 0xf0, 0x3c, 0xb4, 0x4d, 0x80, 0x0d, 0x43, 0x07, + 0x03, 0x6c, 0x18, 0xba, 0xc7, 0x09, 0x3c, 0x78, 0xc3, 0x4b, 0x9d, 0xf1, 0x19, 0x13, 0x6a, 0x5e, + 0x48, 0x25, 0x2e, 0x74, 0xc9, 0xb5, 0x48, 0x57, 0xa4, 0x09, 0xde, 0xdb, 0x3e, 0x3b, 0x0d, 0x2d, + 0xd2, 0x02, 0xbf, 0x3f, 0x38, 0x63, 0xa3, 0xd0, 0x1e, 0x3c, 0x5e, 0xff, 0x89, 0xac, 0xf5, 0x26, + 0xb2, 0xaf, 0x36, 0x91, 0xfd, 0x7b, 0x13, 0xd9, 0xdf, 0xb6, 0x91, 0x75, 0xb5, 0x8d, 0xac, 0x9f, + 0xdb, 0xc8, 0x7a, 0xdf, 0xd8, 0xbd, 0x91, 0x71, 0x80, 0x0f, 0xe0, 0xc5, 0xdf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xb1, 0xe1, 0xde, 0x65, 0x3b, 0x03, 0x00, 0x00, } func (m *Label) Marshal() (dAtA []byte, err error) { diff --git a/pkg/ui/rule.go b/pkg/ui/rule.go index 22ab0f3ba6..8333edb467 100644 --- a/pkg/ui/rule.go +++ b/pkg/ui/rule.go @@ -17,7 +17,7 @@ import ( "github.com/prometheus/common/route" "github.com/prometheus/prometheus/rules" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" - thanosrule "github.com/thanos-io/thanos/pkg/rule" + "github.com/thanos-io/thanos/pkg/rules/manager" ) type Rule struct { @@ -25,12 +25,12 @@ type Rule struct { flagsMap map[string]string - ruleManager *thanosrule.Manager + ruleManager *manager.Manager queryURL string reg prometheus.Registerer } -func NewRuleUI(logger log.Logger, reg prometheus.Registerer, ruleManager *thanosrule.Manager, queryURL string, flagsMap map[string]string) *Rule { +func NewRuleUI(logger log.Logger, reg prometheus.Registerer, ruleManager *manager.Manager, queryURL string, flagsMap map[string]string) *Rule { return &Rule{ BaseUI: NewBaseUI(logger, "rule_menu.html", ruleTmplFuncs(queryURL)), flagsMap: flagsMap, @@ -116,7 +116,7 @@ func ruleTmplFuncs(queryURL string) template.FuncMap { } func (ru *Rule) alerts(w http.ResponseWriter, r *http.Request) { - var groups []thanosrule.Group + var groups []manager.Group for _, group := range ru.ruleManager.RuleGroups() { if group.HasAlertingRules() { groups = append(groups, group) @@ -167,7 +167,7 @@ func (ru *Rule) Register(r *route.Router, ins extpromhttp.InstrumentationMiddlew // AlertStatus bundles alerting rules and the mapping of alert states to row classes. type AlertStatus struct { - Groups []thanosrule.Group + Groups []manager.Group AlertStateToRowClass map[rules.AlertState]string Counts AlertByStateCount } @@ -178,7 +178,7 @@ type AlertByStateCount struct { Firing int32 } -func alertCounts(groups []thanosrule.Group) AlertByStateCount { +func alertCounts(groups []manager.Group) AlertByStateCount { result := AlertByStateCount{} for _, group := range groups { for _, alert := range group.AlertingRules() { diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 1311ee8d76..093e53c2ef 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -22,22 +22,28 @@ echo "installing gogofast" GO111MODULE=on go install "github.com/gogo/protobuf/protoc-gen-gogofast" GOGOPROTO_ROOT="$(GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)" -GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf" +PROMETHEUS_ROOT="$(GO111MODULE=on go list -f '{{ .Dir }}' -m github.com/prometheus/prometheus)" -DIRS="pkg/store/storepb" +GOGOPROTO_PATH="${GOGOPROTO_ROOT}:${GOGOPROTO_ROOT}/protobuf" +PROMETHEUS_PATH="${PROMETHEUS_ROOT}:${PROMETHEUS_ROOT}/prompb" +DIRS="store/storepb/ rules/rulespb" echo "generating code" -for dir in ${DIRS}; do - pushd ${dir} - ${PROTOC_BIN} --gogofast_out=plugins=grpc:. \ - -I=. \ - -I="${GOGOPROTO_PATH}" \ - -I="../../../vendor" \ - *.proto - - sed -i.bak -E 's/import _ \"gogoproto\"//g' *.pb.go - sed -i.bak -E 's/_ \"google\/protobuf\"//g' *.pb.go - rm -f *.bak - ${GOIMPORTS_BIN} -w *.pb.go - popd -done +pushd "pkg" + for dir in ${DIRS}; do + ${PROTOC_BIN} --gogofast_out=plugins=grpc:. \ + -I=. \ + -I="${GOGOPROTO_PATH}" \ + -I="${PROMETHEUS_ROOT}" \ + ${dir}/*.proto + + pushd ${dir} + sed -i.bak -E 's/import _ \"gogoproto\"//g' *.pb.go + sed -i.bak -E 's/_ \"google\/protobuf\"//g' *.pb.go + sed -i.bak -E 's/\"prompb\"/\"github.com\/prometheus\/prometheus\/prompb\"/g' *.pb.go + sed -i.bak -E 's/\"store\/storepb\"/\"github.com\/thanos-io\/thanos\/pkg\/store\/storepb\"/g' *.pb.go + rm -f *.bak + ${GOIMPORTS_BIN} -w *.pb.go + popd + done +popd \ No newline at end of file diff --git a/test/e2e/query_test.go b/test/e2e/query_test.go index f3dc60e1af..99d34a995a 100644 --- a/test/e2e/query_test.go +++ b/test/e2e/query_test.go @@ -13,12 +13,11 @@ import ( "testing" "time" - "github.com/thanos-io/thanos/pkg/store/storepb" - "github.com/cortexproject/cortex/integration/e2e" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/thanos-io/thanos/pkg/promclient" + "github.com/thanos-io/thanos/pkg/rules/rulespb" "github.com/thanos-io/thanos/pkg/runutil" "github.com/thanos-io/thanos/pkg/testutil" "github.com/thanos-io/thanos/test/e2e/e2ethanos" @@ -243,7 +242,7 @@ func ruleAndAssert(t *testing.T, ctx context.Context, addr string, typ string, e t.Helper() fmt.Println("ruleAndAssert: Waiting for", expectedLen, "results for rules type", typ) - var result []*storepb.RuleGroup + var result []*rulespb.RuleGroup testutil.Ok(t, runutil.Retry(time.Second, ctx.Done(), func() error { res, err := promclient.NewDefaultClient().RulesInGRPC(ctx, urlParse(t, "http://"+addr), typ) if err != nil {