diff --git a/cmd/thanos/downsample.go b/cmd/thanos/downsample.go index 294a693447..e53cd7680b 100644 --- a/cmd/thanos/downsample.go +++ b/cmd/thanos/downsample.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "github.com/improbable-eng/thanos/pkg/component" "os" "path" "path/filepath" @@ -35,7 +36,7 @@ func registerDownsample(m map[string]setupFunc, app *kingpin.Application, name s objStoreConfig := regCommonObjStoreFlags(cmd, "", true) m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error { - return runDownsample(g, logger, reg, *dataDir, objStoreConfig, name) + return runDownsample(g, logger, reg, *dataDir, objStoreConfig) } } @@ -45,14 +46,13 @@ func runDownsample( reg *prometheus.Registry, dataDir string, objStoreConfig *pathOrContent, - component string, ) error { confContentYaml, err := objStoreConfig.Content() if err != nil { return err } - bkt, err := client.NewBucket(logger, confContentYaml, reg, component) + bkt, err := client.NewBucket(logger, confContentYaml, reg, component.Downsample.String()) if err != nil { return err } diff --git a/cmd/thanos/query.go b/cmd/thanos/query.go index 95da5419be..b740d6d973 100644 --- a/cmd/thanos/query.go +++ b/cmd/thanos/query.go @@ -12,15 +12,15 @@ import ( "path" "time" - "github.com/improbable-eng/thanos/pkg/extprom" - "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/grpc-ecosystem/go-grpc-middleware" "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/improbable-eng/thanos/pkg/cluster" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/discovery/cache" "github.com/improbable-eng/thanos/pkg/discovery/dns" + "github.com/improbable-eng/thanos/pkg/extprom" "github.com/improbable-eng/thanos/pkg/query" "github.com/improbable-eng/thanos/pkg/query/api" "github.com/improbable-eng/thanos/pkg/runutil" @@ -306,7 +306,7 @@ func runQuery( ) proxy = store.NewProxyStore(logger, func(context.Context) ([]store.Client, error) { return stores.Get(), nil - }, selectorLset) + }, component.Query, selectorLset) queryableCreator = query.NewQueryableCreator(logger, proxy, replicaLabel) engine = promql.NewEngine( promql.EngineOpts{ @@ -446,7 +446,7 @@ func runQuery( if err != nil { return errors.Wrapf(err, "listen gRPC on address") } - logger := log.With(logger, "component", "query") + logger := log.With(logger, "component", component.Query.String()) opts, err := defaultGRPCServerOpts(logger, reg, tracer, srvCert, srvKey, srvClientCA) if err != nil { diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 87eecee92c..3b9a983c8e 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -23,6 +23,7 @@ import ( "github.com/improbable-eng/thanos/pkg/alert" "github.com/improbable-eng/thanos/pkg/block/metadata" "github.com/improbable-eng/thanos/pkg/cluster" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/discovery/cache" "github.com/improbable-eng/thanos/pkg/discovery/dns" "github.com/improbable-eng/thanos/pkg/extprom" @@ -159,7 +160,6 @@ func registerRule(m map[string]setupFunc, app *kingpin.Application, name string) peer, objStoreConfig, tsdbOpts, - name, alertQueryURL, *alertExcludeLabels, *queries, @@ -193,7 +193,6 @@ func runRule( peer cluster.Peer, objStoreConfig *pathOrContent, tsdbOpts *tsdb.Options, - component string, alertQueryURL *url.URL, alertExcludeLabels []string, queryAddrs []string, @@ -520,9 +519,9 @@ func runRule( if err != nil { return errors.Wrap(err, "listen API address") } - logger := log.With(logger, "component", "store") + logger := log.With(logger, "component", component.Rule.String()) - store := store.NewTSDBStore(logger, reg, db, lset) + store := store.NewTSDBStore(logger, reg, db, component.Rule, lset) opts, err := defaultGRPCServerOpts(logger, reg, tracer, cert, key, clientCA) if err != nil { @@ -593,7 +592,7 @@ func runRule( if uploads { // The background shipper continuously scans the data directory and uploads // new blocks to Google Cloud Storage or an S3-compatible storage service. - bkt, err := client.NewBucket(logger, confContentYaml, reg, component) + bkt, err := client.NewBucket(logger, confContentYaml, reg, component.Rule.String()) if err != nil { return err } diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index 4f85f3c039..e9fd52535b 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -13,6 +13,7 @@ import ( "github.com/go-kit/kit/log/level" "github.com/improbable-eng/thanos/pkg/block/metadata" "github.com/improbable-eng/thanos/pkg/cluster" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/objstore/client" "github.com/improbable-eng/thanos/pkg/promclient" "github.com/improbable-eng/thanos/pkg/reloader" @@ -77,7 +78,6 @@ func registerSidecar(m map[string]setupFunc, app *kingpin.Application, name stri objStoreConfig, peer, rl, - name, ) } } @@ -97,7 +97,6 @@ func runSidecar( objStoreConfig *pathOrContent, peer cluster.Peer, reloader *reloader.Reloader, - component string, ) error { var m = &promMetadata{ promURL: promURL, @@ -196,12 +195,12 @@ func runSidecar( if err != nil { return errors.Wrap(err, "listen API address") } - logger := log.With(logger, "component", "sidecar") + logger := log.With(logger, "component", component.Sidecar.String()) var client http.Client promStore, err := store.NewPrometheusStore( - logger, &client, promURL, m.Labels, m.Timestamps) + logger, &client, promURL, component.Sidecar, m.Labels, m.Timestamps) if err != nil { return errors.Wrap(err, "create Prometheus store") } @@ -236,7 +235,7 @@ func runSidecar( if uploads { // The background shipper continuously scans the data directory and uploads // new blocks to Google Cloud Storage or an S3-compatible storage service. - bkt, err := client.NewBucket(logger, confContentYaml, reg, component) + bkt, err := client.NewBucket(logger, confContentYaml, reg, component.Sidecar.String()) if err != nil { return err } diff --git a/pkg/compact/downsample/downsample_test.go b/pkg/compact/downsample/downsample_test.go index bb2c38b17a..f55cfc7e61 100644 --- a/pkg/compact/downsample/downsample_test.go +++ b/pkg/compact/downsample/downsample_test.go @@ -1,26 +1,22 @@ package downsample import ( - "github.com/prometheus/tsdb" "io/ioutil" "math" "os" "path/filepath" "testing" - - "github.com/improbable-eng/thanos/pkg/block/metadata" - - "github.com/prometheus/prometheus/pkg/value" - - "github.com/prometheus/tsdb/chunks" - "time" "github.com/fortytw2/leaktest" "github.com/go-kit/kit/log" "github.com/improbable-eng/thanos/pkg/block" + "github.com/improbable-eng/thanos/pkg/block/metadata" "github.com/improbable-eng/thanos/pkg/testutil" + "github.com/prometheus/prometheus/pkg/value" + "github.com/prometheus/tsdb" "github.com/prometheus/tsdb/chunkenc" + "github.com/prometheus/tsdb/chunks" "github.com/prometheus/tsdb/index" "github.com/prometheus/tsdb/labels" ) diff --git a/pkg/component/component.go b/pkg/component/component.go new file mode 100644 index 0000000000..368de1f60c --- /dev/null +++ b/pkg/component/component.go @@ -0,0 +1,87 @@ +package component + +import ( + "strings" + + "github.com/improbable-eng/thanos/pkg/store/storepb" +) + +// StoreAPI is a component that implements Thanos' gRPC StoreAPI. +type StoreAPI interface { + implementsStoreAPI() + String() string + ToProto() storepb.StoreType +} + +// Source is a Thanos component that produce blocks of metrics. +type Source interface { + producesBlocks() + String() string +} + +// SourceStoreAPI is a component that implements Thanos' gRPC StoreAPI +// and produce blocks of metrics. +type SourceStoreAPI interface { + implementsStoreAPI() + producesBlocks() + String() string + ToProto() storepb.StoreType +} + +type component struct { + name string +} + +func (c component) String() string { return c.name } + +type storeAPI struct { + component +} + +func (storeAPI) implementsStoreAPI() {} + +func (s sourceStoreAPI) ToProto() storepb.StoreType { + return storepb.StoreType(storepb.StoreType_value[strings.ToUpper(s.String())]) +} + +func (s storeAPI) ToProto() storepb.StoreType { + return storepb.StoreType(storepb.StoreType_value[strings.ToUpper(s.String())]) +} + +type source struct { + component +} + +func (source) producesBlocks() {} + +type sourceStoreAPI struct { + component + source + storeAPI +} + +// FromProto converts from a gRPC StoreType to StoreAPI. +func FromProto(storeType storepb.StoreType) StoreAPI { + switch storeType { + case storepb.StoreType_QUERY: + return Query + case storepb.StoreType_RULE: + return Rule + case storepb.StoreType_SIDECAR: + return Sidecar + case storepb.StoreType_STORE: + return Store + default: + return nil + } +} + +var ( + Bucket = source{component: component{name: "bucket"}} + Compact = source{component: component{name: "compact"}} + Downsample = source{component: component{name: "downsample"}} + Query = sourceStoreAPI{component: component{name: "query"}} + Rule = sourceStoreAPI{component: component{name: "rule"}} + Sidecar = sourceStoreAPI{component: component{name: "sidecar"}} + Store = sourceStoreAPI{component: component{name: "store"}} +) diff --git a/pkg/query/storeset.go b/pkg/query/storeset.go index 1a63c22e08..bb9c7698df 100644 --- a/pkg/query/storeset.go +++ b/pkg/query/storeset.go @@ -9,6 +9,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/runutil" "github.com/improbable-eng/thanos/pkg/store" "github.com/improbable-eng/thanos/pkg/store/storepb" @@ -26,7 +27,7 @@ const ( type StoreSpec interface { // Addr returns StoreAPI Address for the store spec. It is used as ID for store. Addr() string - // Metadata returns current labels and min, max ranges for store. + // Metadata returns current labels, store type and min, max ranges for store. // It can change for every call for this method. // If metadata call fails we assume that store is no longer accessible and we should not use it. // NOTE: It is implementation responsibility to retry until context timeout, but a caller responsibility to manage @@ -38,9 +39,10 @@ type StoreStatus struct { Name string LastCheck time.Time LastError error + Labels []storepb.Label + StoreType component.StoreAPI MinTime int64 MaxTime int64 - Labels []storepb.Label } type grpcStoreSpec struct { @@ -159,9 +161,10 @@ type storeRef struct { addr string // Meta (can change during runtime). - labels []storepb.Label - minTime int64 - maxTime int64 + labels []storepb.Label + storeType component.StoreAPI + minTime int64 + maxTime int64 logger log.Logger } @@ -305,6 +308,7 @@ func (s *StoreSet) getHealthyStores(ctx context.Context) map[string]*storeRef { level.Warn(s.logger).Log("msg", "update of store node failed", "err", errors.Wrap(err, "initial store client info fetch"), "address", addr) return } + store.storeType = component.FromProto(resp.StoreType) store.Update(resp.Labels, resp.MinTime, resp.MaxTime) } @@ -340,9 +344,10 @@ func (s *StoreSet) updateStoreStatus(store *storeRef, err error) { now := time.Now() s.storeStatuses[store.addr] = &StoreStatus{ Name: store.addr, - Labels: store.labels, LastError: err, LastCheck: now, + Labels: store.labels, + StoreType: store.storeType, MinTime: store.minTime, MaxTime: store.maxTime, } diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index e006f5c70c..e0740c7b66 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -21,6 +21,7 @@ import ( "github.com/improbable-eng/thanos/pkg/block" "github.com/improbable-eng/thanos/pkg/block/metadata" "github.com/improbable-eng/thanos/pkg/compact/downsample" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/objstore" "github.com/improbable-eng/thanos/pkg/pool" "github.com/improbable-eng/thanos/pkg/runutil" @@ -423,8 +424,9 @@ func (s *BucketStore) Info(context.Context, *storepb.InfoRequest) (*storepb.Info mint, maxt := s.TimeRange() // Store nodes hold global data and thus have no labels. return &storepb.InfoResponse{ - MinTime: mint, - MaxTime: maxt, + StoreType: component.Store.ToProto(), + MinTime: mint, + MaxTime: maxt, }, nil } diff --git a/pkg/store/bucket_test.go b/pkg/store/bucket_test.go index f2880dd9b4..7cc57da4cf 100644 --- a/pkg/store/bucket_test.go +++ b/pkg/store/bucket_test.go @@ -1,12 +1,16 @@ package store import ( + "context" + "io/ioutil" + "math" "testing" "time" "github.com/fortytw2/leaktest" "github.com/improbable-eng/thanos/pkg/block/metadata" "github.com/improbable-eng/thanos/pkg/compact/downsample" + "github.com/improbable-eng/thanos/pkg/store/storepb" "github.com/improbable-eng/thanos/pkg/testutil" "github.com/oklog/ulid" "github.com/prometheus/tsdb/labels" @@ -269,3 +273,23 @@ func TestPartitionRanges(t *testing.T) { testutil.Equals(t, c.expected, res) } } + +func TestBucketStore_Info(t *testing.T) { + defer leaktest.CheckTimeout(t, 10*time.Second)() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + dir, err := ioutil.TempDir("", "prometheus-test") + testutil.Ok(t, err) + + bucketStore, err := NewBucketStore(nil, nil, nil, dir, 2e5, 2e5, false, 20) + testutil.Ok(t, err) + + resp, err := bucketStore.Info(ctx, &storepb.InfoRequest{}) + testutil.Ok(t, err) + + testutil.Equals(t, storepb.StoreType_STORE, resp.StoreType) + testutil.Equals(t, int64(math.MaxInt64), resp.MinTime) + testutil.Equals(t, int64(math.MinInt64), resp.MaxTime) +} diff --git a/pkg/store/prometheus.go b/pkg/store/prometheus.go index 9296636b70..e8fd677f53 100644 --- a/pkg/store/prometheus.go +++ b/pkg/store/prometheus.go @@ -17,6 +17,7 @@ import ( "github.com/go-kit/kit/log/level" "github.com/gogo/protobuf/proto" "github.com/golang/snappy" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/runutil" "github.com/improbable-eng/thanos/pkg/store/prompb" "github.com/improbable-eng/thanos/pkg/store/storepb" @@ -34,6 +35,7 @@ type PrometheusStore struct { base *url.URL client *http.Client buffers sync.Pool + component component.StoreAPI externalLabels func() labels.Labels timestamps func() (mint int64, maxt int64) } @@ -45,6 +47,7 @@ func NewPrometheusStore( logger log.Logger, client *http.Client, baseURL *url.URL, + component component.StoreAPI, externalLabels func() labels.Labels, timestamps func() (mint int64, maxt int64), ) (*PrometheusStore, error) { @@ -60,6 +63,7 @@ func NewPrometheusStore( logger: logger, base: baseURL, client: client, + component: component, externalLabels: externalLabels, timestamps: timestamps, } @@ -74,9 +78,10 @@ func (p *PrometheusStore) Info(ctx context.Context, r *storepb.InfoRequest) (*st mint, maxt := p.timestamps() res := &storepb.InfoResponse{ - MinTime: mint, - MaxTime: maxt, - Labels: make([]storepb.Label, 0, len(lset)), + Labels: make([]storepb.Label, 0, len(lset)), + StoreType: p.component.ToProto(), + MinTime: mint, + MaxTime: maxt, } for _, l := range lset { res.Labels = append(res.Labels, storepb.Label{ diff --git a/pkg/store/prometheus_test.go b/pkg/store/prometheus_test.go index c4218a1e14..44693411a7 100644 --- a/pkg/store/prometheus_test.go +++ b/pkg/store/prometheus_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/fortytw2/leaktest" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/store/storepb" "github.com/improbable-eng/thanos/pkg/testutil" "github.com/prometheus/prometheus/pkg/timestamp" @@ -53,7 +54,7 @@ func testPrometheusStoreSeriesE2e(t *testing.T, prefix string) { u, err := url.Parse(fmt.Sprintf("http://%s", p.Addr())) testutil.Ok(t, err) - proxy, err := NewPrometheusStore(nil, nil, u, + proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, nil) @@ -134,7 +135,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, getExternalLabels, nil) + proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, getExternalLabels, nil) testutil.Ok(t, err) resp, err := proxy.LabelValues(ctx, &storepb.LabelValuesRequest{ @@ -168,7 +169,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, getExternalLabels, nil) + proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, getExternalLabels, nil) testutil.Ok(t, err) resp, err := proxy.LabelValues(ctx, &storepb.LabelValuesRequest{ @@ -212,7 +213,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, + proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, nil) @@ -258,7 +259,7 @@ func TestPrometheusStore_Info(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - proxy, err := NewPrometheusStore(nil, nil, nil, + proxy, err := NewPrometheusStore(nil, nil, nil, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, @@ -271,6 +272,7 @@ func TestPrometheusStore_Info(t *testing.T) { testutil.Ok(t, err) testutil.Equals(t, []storepb.Label{{Name: "region", Value: "eu-west"}}, resp.Labels) + testutil.Equals(t, storepb.StoreType_SIDECAR, resp.StoreType) testutil.Equals(t, int64(123), resp.MinTime) testutil.Equals(t, int64(456), resp.MaxTime) } @@ -303,7 +305,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, + proxy, err := NewPrometheusStore(nil, nil, u, component.Sidecar, func() labels.Labels { return labels.FromStrings("region", "eu-west") }, nil) diff --git a/pkg/store/proxy.go b/pkg/store/proxy.go index 4eab4580de..4b697f14b8 100644 --- a/pkg/store/proxy.go +++ b/pkg/store/proxy.go @@ -2,15 +2,15 @@ package store import ( "context" + "fmt" "io" "math" "strings" "sync" - "fmt" - "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/store/storepb" "github.com/improbable-eng/thanos/pkg/strutil" "github.com/pkg/errors" @@ -38,6 +38,7 @@ type Client interface { type ProxyStore struct { logger log.Logger stores func(context.Context) ([]Client, error) + component component.StoreAPI selectorLabels labels.Labels } @@ -46,6 +47,7 @@ type ProxyStore struct { func NewProxyStore( logger log.Logger, stores func(context.Context) ([]Client, error), + component component.StoreAPI, selectorLabels labels.Labels, ) *ProxyStore { if logger == nil { @@ -54,6 +56,7 @@ func NewProxyStore( s := &ProxyStore{ logger: logger, stores: stores, + component: component, selectorLabels: selectorLabels, } return s @@ -62,9 +65,10 @@ func NewProxyStore( // Info returns store information about the external labels this store have. func (s *ProxyStore) Info(ctx context.Context, r *storepb.InfoRequest) (*storepb.InfoResponse, error) { res := &storepb.InfoResponse{ - MinTime: 0, - MaxTime: math.MaxInt64, - Labels: make([]storepb.Label, 0, len(s.selectorLabels)), + Labels: make([]storepb.Label, 0, len(s.selectorLabels)), + StoreType: s.component.ToProto(), + MinTime: 0, + MaxTime: math.MaxInt64, } for _, l := range s.selectorLabels { res.Labels = append(res.Labels, storepb.Label{ diff --git a/pkg/store/proxy_test.go b/pkg/store/proxy_test.go index 5d5fb1a5d7..d159b88740 100644 --- a/pkg/store/proxy_test.go +++ b/pkg/store/proxy_test.go @@ -3,11 +3,13 @@ package store import ( "context" "io" + "math" "testing" "time" "github.com/fortytw2/leaktest" "github.com/gogo/protobuf/proto" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/store/storepb" "github.com/improbable-eng/thanos/pkg/testutil" "github.com/pkg/errors" @@ -45,6 +47,7 @@ func TestProxyStore_Series_StoresFetchFail(t *testing.T) { q := NewProxyStore(nil, func(_ context.Context) ([]Client, error) { return nil, errors.New("Fail") }, + component.Query, nil, ) @@ -56,6 +59,26 @@ func TestProxyStore_Series_StoresFetchFail(t *testing.T) { }, s)) } +func TestProxyStore_Info(t *testing.T) { + defer leaktest.CheckTimeout(t, 10*time.Second)() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + q := NewProxyStore(nil, + func(context.Context) ([]Client, error) { return nil, nil }, + component.Query, + nil, + ) + + resp, err := q.Info(ctx, &storepb.InfoRequest{}) + testutil.Ok(t, err) + testutil.Equals(t, []storepb.Label{}, resp.Labels) + testutil.Equals(t, storepb.StoreType_QUERY, resp.StoreType) + testutil.Equals(t, int64(0), resp.MinTime) + testutil.Equals(t, int64(math.MaxInt64), resp.MaxTime) +} + func TestProxyStore_Series(t *testing.T) { defer leaktest.CheckTimeout(t, 10*time.Second)() @@ -397,6 +420,7 @@ func TestProxyStore_Series(t *testing.T) { if ok := t.Run(tc.title, func(t *testing.T) { q := NewProxyStore(nil, func(_ context.Context) ([]Client, error) { return tc.storeAPIs, nil }, // what if err? + component.Query, tc.selectorLabels, ) @@ -437,6 +461,7 @@ func TestProxyStore_Series_RequestParamsProxied(t *testing.T) { } q := NewProxyStore(nil, func(context.Context) ([]Client, error) { return cls, nil }, + component.Query, nil, ) @@ -494,6 +519,7 @@ func TestProxyStore_Series_RegressionFillResponseChannel(t *testing.T) { q := NewProxyStore(nil, func(context.Context) ([]Client, error) { return cls, nil }, + component.Query, tlabels.FromStrings("fed", "a"), ) @@ -530,6 +556,7 @@ func TestProxyStore_LabelValues(t *testing.T) { } q := NewProxyStore(nil, func(context.Context) ([]Client, error) { return cls, nil }, + component.Query, nil, ) diff --git a/pkg/store/storepb/rpc.pb.go b/pkg/store/storepb/rpc.pb.go index 432d2ec998..78dec4b95f 100644 --- a/pkg/store/storepb/rpc.pb.go +++ b/pkg/store/storepb/rpc.pb.go @@ -24,6 +24,38 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package +type StoreType int32 + +const ( + StoreType_UNKNOWN StoreType = 0 + StoreType_QUERY StoreType = 1 + StoreType_RULE StoreType = 2 + StoreType_SIDECAR StoreType = 3 + StoreType_STORE StoreType = 4 +) + +var StoreType_name = map[int32]string{ + 0: "UNKNOWN", + 1: "QUERY", + 2: "RULE", + 3: "SIDECAR", + 4: "STORE", +} +var StoreType_value = map[string]int32{ + "UNKNOWN": 0, + "QUERY": 1, + "RULE": 2, + "SIDECAR": 3, + "STORE": 4, +} + +func (x StoreType) String() string { + return proto.EnumName(StoreType_name, int32(x)) +} +func (StoreType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_rpc_e304c8713328de35, []int{0} +} + type Aggr int32 const ( @@ -56,7 +88,7 @@ func (x Aggr) String() string { return proto.EnumName(Aggr_name, int32(x)) } func (Aggr) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_rpc_6ccafde20b200300, []int{0} + return fileDescriptor_rpc_e304c8713328de35, []int{1} } type InfoRequest struct { @@ -69,7 +101,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_rpc_6ccafde20b200300, []int{0} + return fileDescriptor_rpc_e304c8713328de35, []int{0} } func (m *InfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -99,19 +131,20 @@ func (m *InfoRequest) XXX_DiscardUnknown() { var xxx_messageInfo_InfoRequest proto.InternalMessageInfo type InfoResponse struct { - Labels []Label `protobuf:"bytes,1,rep,name=labels" json:"labels"` - MinTime int64 `protobuf:"varint,2,opt,name=min_time,json=minTime,proto3" json:"min_time,omitempty"` - MaxTime int64 `protobuf:"varint,3,opt,name=max_time,json=maxTime,proto3" json:"max_time,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Labels []Label `protobuf:"bytes,1,rep,name=labels" json:"labels"` + MinTime int64 `protobuf:"varint,2,opt,name=min_time,json=minTime,proto3" json:"min_time,omitempty"` + MaxTime int64 `protobuf:"varint,3,opt,name=max_time,json=maxTime,proto3" json:"max_time,omitempty"` + StoreType StoreType `protobuf:"varint,4,opt,name=storeType,proto3,enum=thanos.StoreType" json:"storeType,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } 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_rpc_6ccafde20b200300, []int{1} + return fileDescriptor_rpc_e304c8713328de35, []int{1} } func (m *InfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -156,7 +189,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_rpc_6ccafde20b200300, []int{2} + return fileDescriptor_rpc_e304c8713328de35, []int{2} } func (m *SeriesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -199,7 +232,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_rpc_6ccafde20b200300, []int{3} + return fileDescriptor_rpc_e304c8713328de35, []int{3} } func (m *SeriesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -346,7 +379,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_rpc_6ccafde20b200300, []int{4} + return fileDescriptor_rpc_e304c8713328de35, []int{4} } func (m *LabelNamesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -387,7 +420,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_rpc_6ccafde20b200300, []int{5} + return fileDescriptor_rpc_e304c8713328de35, []int{5} } func (m *LabelNamesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -428,7 +461,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_rpc_6ccafde20b200300, []int{6} + return fileDescriptor_rpc_e304c8713328de35, []int{6} } func (m *LabelValuesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -469,7 +502,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_rpc_6ccafde20b200300, []int{7} + return fileDescriptor_rpc_e304c8713328de35, []int{7} } func (m *LabelValuesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -507,6 +540,7 @@ func init() { proto.RegisterType((*LabelNamesResponse)(nil), "thanos.LabelNamesResponse") proto.RegisterType((*LabelValuesRequest)(nil), "thanos.LabelValuesRequest") proto.RegisterType((*LabelValuesResponse)(nil), "thanos.LabelValuesResponse") + proto.RegisterEnum("thanos.StoreType", StoreType_name, StoreType_value) proto.RegisterEnum("thanos.Aggr", Aggr_name, Aggr_value) } @@ -779,6 +813,11 @@ func (m *InfoResponse) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintRpc(dAtA, i, uint64(m.MaxTime)) } + if m.StoreType != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintRpc(dAtA, i, uint64(m.StoreType)) + } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -1113,6 +1152,9 @@ func (m *InfoResponse) Size() (n int) { if m.MaxTime != 0 { n += 1 + sovRpc(uint64(m.MaxTime)) } + if m.StoreType != 0 { + n += 1 + sovRpc(uint64(m.StoreType)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1413,6 +1455,25 @@ func (m *InfoResponse) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StoreType", wireType) + } + m.StoreType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StoreType |= (StoreType(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipRpc(dAtA[iNdEx:]) @@ -2262,46 +2323,51 @@ var ( ErrIntOverflowRpc = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("rpc.proto", fileDescriptor_rpc_6ccafde20b200300) } +func init() { proto.RegisterFile("rpc.proto", fileDescriptor_rpc_e304c8713328de35) } -var fileDescriptor_rpc_6ccafde20b200300 = []byte{ - // 602 bytes of a gzipped FileDescriptorProto +var fileDescriptor_rpc_e304c8713328de35 = []byte{ + // 675 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0x8e, 0xed, 0xd8, 0x49, 0xc6, 0x6d, 0x65, 0xb6, 0x69, 0x71, 0x8c, 0x14, 0x22, 0x9f, 0x22, - 0x40, 0x05, 0x82, 0x84, 0x04, 0xb7, 0xa6, 0x50, 0xb5, 0x12,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3, - 0x07, 0x92, 0x54, 0x9e, 0x67, 0xb5, 0x68, 0x00, 0x1b, 0x5c, 0x32, 0xa7, 0x2c, 0x8d, 0xc6, 0x45, - 0x98, 0x26, 0xe7, 0xb7, 0x61, 0x72, 0x99, 0xde, 0xba, 0x75, 0xa1, 0xbf, 0x1e, 0x93, 0x3b, 0x3c, - 0xe3, 0xce, 0x04, 0x85, 0x9e, 0x01, 0x90, 0x20, 0xc8, 0x69, 0x40, 0x0a, 0xca, 0x5c, 0xb3, 0x67, - 0xf4, 0xd7, 0x06, 0x2b, 0x65, 0xb7, 0xed, 0x20, 0xc8, 0xf1, 0x02, 0x8f, 0xde, 0x42, 0x27, 0x23, - 0x79, 0x11, 0x92, 0x88, 0x77, 0x11, 0x83, 0x3d, 0xbf, 0x0c, 0x19, 0x19, 0x45, 0xf4, 0xd2, 0xb5, - 0x7a, 0x5a, 0xbf, 0x89, 0x1f, 0xaa, 0x82, 0x72, 0xf0, 0xef, 0x14, 0xed, 0x7f, 0x81, 0xb5, 0x72, - 0x38, 0x6a, 0x25, 0x7d, 0xb0, 0x98, 0x40, 0xc4, 0x6c, 0xec, 0xc1, 0x5a, 0xd9, 0x57, 0xd6, 0xed, - 0xd5, 0xb0, 0xe2, 0x91, 0x07, 0x8d, 0x5b, 0x92, 0x27, 0x61, 0x12, 0x88, 0x59, 0xb5, 0xf6, 0x6a, - 0xb8, 0x04, 0x86, 0x4d, 0xb0, 0x72, 0xca, 0xc6, 0x51, 0xe1, 0x1f, 0xc1, 0x03, 0x31, 0x9f, 0x43, - 0x12, 0xcf, 0x57, 0xb0, 0xd4, 0xb2, 0xb6, 0xdc, 0xf2, 0x2e, 0xa0, 0x45, 0x41, 0x65, 0xbb, 0x0d, - 0x66, 0xc2, 0x01, 0x71, 0x48, 0x2d, 0x2c, 0x13, 0xe4, 0x41, 0x53, 0x39, 0x62, 0xae, 0x2e, 0x88, - 0x59, 0xee, 0x5f, 0x29, 0x9d, 0x8f, 0x24, 0x1a, 0x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f0, 0x43, 0xfb, 0x83, 0xa1, 0xb2, 0x72, 0x3c, 0xab, 0x8b, 0x8d, + 0x7c, 0xeb, 0x9b, 0x0c, 0x79, 0xae, 0x05, 0xbd, 0x00, 0x95, 0x3d, 0x02, 0x68, 0x33, 0x35, 0xca, + 0xd2, 0x13, 0x61, 0x55, 0xb2, 0xa0, 0xb8, 0xfb, 0x6b, 0xd0, 0x12, 0x37, 0xa1, 0xad, 0xac, 0xbb, + 0xd2, 0xcf, 0xb6, 0xff, 0x85, 0x93, 0x0f, 0x9f, 0x4b, 0x68, 0x1f, 0x60, 0xb1, 0x7d, 0x54, 0xcd, + 0xfc, 0x82, 0xcb, 0x16, 0xb3, 0xac, 0x87, 0x28, 0xd1, 0xff, 0x10, 0x4a, 0x4b, 0x2b, 0x41, 0xd9, + 0xd4, 0x8c, 0x1f, 0xac, 0xc7, 0x0f, 0x72, 0x49, 0x9d, 0x4e, 0xf5, 0xee, 0x4f, 0x2d, 0x77, 0x77, + 0x5f, 0x93, 0x7e, 0xde, 0xd7, 0xa4, 0xdf, 0xf7, 0x35, 0xe9, 0x53, 0x81, 0x3f, 0x3c, 0xe1, 0x64, + 0xa2, 0xf1, 0x17, 0xf3, 0xe5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x17, 0xfe, 0xbd, 0x57, 0x69, + 0x05, 0x00, 0x00, } diff --git a/pkg/store/storepb/rpc.proto b/pkg/store/storepb/rpc.proto index cc95738895..899ddf2aef 100644 --- a/pkg/store/storepb/rpc.proto +++ b/pkg/store/storepb/rpc.proto @@ -35,10 +35,19 @@ service Store { message InfoRequest { } +enum StoreType { + UNKNOWN = 0; + QUERY = 1; + RULE = 2; + SIDECAR = 3; + STORE = 4; +} + message InfoResponse { repeated Label labels = 1 [(gogoproto.nullable) = false]; int64 min_time = 2; int64 max_time = 3; + StoreType storeType = 4; } message SeriesRequest { diff --git a/pkg/store/tsdb.go b/pkg/store/tsdb.go index 109922e648..1a5b5f820b 100644 --- a/pkg/store/tsdb.go +++ b/pkg/store/tsdb.go @@ -6,6 +6,7 @@ import ( "sort" "github.com/go-kit/kit/log" + "github.com/improbable-eng/thanos/pkg/component" "github.com/improbable-eng/thanos/pkg/runutil" "github.com/improbable-eng/thanos/pkg/store/storepb" "github.com/pkg/errors" @@ -21,29 +22,32 @@ import ( // It attaches the provided external labels to all results. It only responds with raw data // and does not support downsampling. type TSDBStore struct { - logger log.Logger - db *tsdb.DB - labels labels.Labels + logger log.Logger + db *tsdb.DB + component component.SourceStoreAPI + labels labels.Labels } // NewTSDBStore creates a new TSDBStore. -func NewTSDBStore(logger log.Logger, reg prometheus.Registerer, db *tsdb.DB, externalLabels labels.Labels) *TSDBStore { +func NewTSDBStore(logger log.Logger, reg prometheus.Registerer, db *tsdb.DB, component component.SourceStoreAPI, externalLabels labels.Labels) *TSDBStore { if logger == nil { logger = log.NewNopLogger() } return &TSDBStore{ - logger: logger, - db: db, - labels: externalLabels, + logger: logger, + db: db, + component: component, + labels: externalLabels, } } // Info returns store information about the Prometheus instance. func (s *TSDBStore) Info(ctx context.Context, r *storepb.InfoRequest) (*storepb.InfoResponse, error) { res := &storepb.InfoResponse{ - MinTime: 0, - MaxTime: math.MaxInt64, - Labels: make([]storepb.Label, 0, len(s.labels)), + Labels: make([]storepb.Label, 0, len(s.labels)), + StoreType: s.component.ToProto(), + MinTime: 0, + MaxTime: math.MaxInt64, } if blocks := s.db.Blocks(); len(blocks) > 0 { res.MinTime = blocks[0].Meta().MinTime diff --git a/pkg/store/tsdb_test.go b/pkg/store/tsdb_test.go new file mode 100644 index 0000000000..4334bedaea --- /dev/null +++ b/pkg/store/tsdb_test.go @@ -0,0 +1,35 @@ +package store + +import ( + "context" + "math" + "testing" + "time" + + "github.com/fortytw2/leaktest" + "github.com/improbable-eng/thanos/pkg/component" + "github.com/improbable-eng/thanos/pkg/store/storepb" + "github.com/improbable-eng/thanos/pkg/testutil" + "github.com/prometheus/tsdb/labels" +) + +func TestTSDBStore_Info(t *testing.T) { + defer leaktest.CheckTimeout(t, 10*time.Second)() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + db, err := testutil.NewTSDB() + defer func() { testutil.Ok(t, db.Close()) }() + testutil.Ok(t, err) + + tsdbStore := NewTSDBStore(nil, nil, db, component.Rule, labels.FromStrings("region", "eu-west")) + + resp, err := tsdbStore.Info(ctx, &storepb.InfoRequest{}) + testutil.Ok(t, err) + + testutil.Equals(t, []storepb.Label{{Name: "region", Value: "eu-west"}}, resp.Labels) + testutil.Equals(t, storepb.StoreType_RULE, resp.StoreType) + testutil.Equals(t, int64(0), resp.MinTime) + testutil.Equals(t, int64(math.MaxInt64), resp.MaxTime) +} diff --git a/pkg/ui/bindata.go b/pkg/ui/bindata.go index e0465a33ec..2431d48040 100644 --- a/pkg/ui/bindata.go +++ b/pkg/ui/bindata.go @@ -122,7 +122,7 @@ func pkgUiTemplates_baseHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/_base.html", size: 1065, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/_base.html", size: 1065, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -142,7 +142,7 @@ func pkgUiTemplatesAlertsHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/alerts.html", size: 2534, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/alerts.html", size: 2534, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -162,7 +162,7 @@ func pkgUiTemplatesFlagsHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/flags.html", size: 433, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/flags.html", size: 433, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -182,7 +182,7 @@ func pkgUiTemplatesGraphHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/graph.html", size: 2061, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/graph.html", size: 2061, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -202,7 +202,7 @@ func pkgUiTemplatesQuery_menuHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/query_menu.html", size: 1479, mode: os.FileMode(420), modTime: time.Unix(1545065695, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/query_menu.html", size: 1479, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -222,7 +222,7 @@ func pkgUiTemplatesRule_menuHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/rule_menu.html", size: 1021, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/rule_menu.html", size: 1021, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -242,7 +242,7 @@ func pkgUiTemplatesRulesHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/rules.html", size: 1095, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/rules.html", size: 1095, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -262,12 +262,12 @@ func pkgUiTemplatesStatusHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/status.html", size: 1286, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/status.html", size: 1286, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _pkgUiTemplatesStoresHtml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x55\x4f\x6b\x1b\x3f\x10\xbd\xfb\x53\x0c\xe2\x77\xb5\x17\x72\xf9\x41\xd9\x75\x29\x25\xd0\x43\x12\x0a\x29\xb9\x16\x59\x1a\x7b\x45\x64\x69\xd1\xcc\xa6\x36\x42\xdf\xbd\x68\xd7\x1b\xdb\xf1\xda\xb1\x7b\x11\x68\xfe\xe8\xbd\x19\x3d\x8d\x62\xd4\xb8\x34\x0e\x41\xd4\x28\xb5\x48\x69\x52\x5a\xe3\x5e\x81\xb7\x0d\x56\x82\x71\xc3\x85\x22\x12\x10\xd0\x56\x82\x78\x6b\x91\x6a\x44\x16\x50\x07\x5c\x56\x22\x46\x68\x24\xd7\x3f\x03\x2e\xcd\x06\x52\x2a\x88\x25\x1b\x95\x73\x8a\xd0\x5a\xa4\x99\x22\xfa\xfa\x56\xc5\x08\x8b\xd6\x58\xfd\x82\x81\x8c\x77\x90\x92\x98\x4f\x62\x44\xa7\x53\x9a\x4c\xf6\x24\x94\x77\x8c\x8e\x3b\x1e\xda\xbc\x81\xb2\x92\xa8\xea\xcc\xd2\x38\x0c\xd3\xa5\x6d\x8d\x16\xf3\x09\x00\x40\x59\xdf\xcd\x9f\xd9\x07\xa4\xb2\xa8\xef\x76\x36\x96\x0b\x8b\x43\x5e\xbf\xe9\xd6\xe9\xc2\x07\x8d\x01\x87\xe4\x3e\x38\x17\x7d\xb8\x0f\xfb\xcd\x2e\x60\x7e\xef\x74\xe3\x8d\xe3\xb2\xe0\xfa\xd4\xfb\xcc\x92\x5b\x1a\xf7\x7d\x73\xce\xb7\x4e\xa1\x86\x07\xb9\x40\x7b\x26\xea\xd1\x38\xf8\x65\xd6\x78\xc6\x2b\x37\x17\xbc\x0f\x92\x18\x7e\xa0\xb4\x5c\xc3\xf7\x1a\xd5\xeb\x85\xb0\x47\x24\x92\xab\x0f\x07\x95\xc5\x61\xc9\xd9\xf7\xa1\x21\x0b\xaf\xb7\xfb\x7d\x8c\x41\xba\x15\xc2\x7f\x94\xdb\x0e\x5f\x2a\x98\xa5\x74\xa9\x7d\x7a\x1e\x63\x1f\x3c\x7b\x92\x6b\x4c\xa9\x2c\x58\x9f\x04\x0d\xd7\x95\xc5\x83\xe2\xd8\xdd\xc3\x9a\x25\x38\xcf\x3b\xdc\x59\xae\xe7\x3e\x04\x1f\x0e\xc0\xdf\x8f\xa3\x46\xba\xe1\x40\x69\x31\x30\x74\xeb\x94\x5a\xa5\x90\x08\x3a\x90\xdf\xc6\x69\xa3\x24\xfb\x00\x59\xe3\xd3\xb6\x69\x30\x28\x49\x63\xe8\x6d\x73\x0a\x52\x64\x94\x31\xa2\x68\x09\x6f\x61\xa5\x73\x3f\xc3\xed\xa4\xb4\xff\xe3\x6e\xa1\xd5\x3d\xb4\xe3\xd8\x91\x8b\x38\x36\xbc\xdf\xb6\xcd\xf2\xcd\xb7\xfd\xde\xff\x2c\xe7\xcf\xca\xec\xb3\xba\x75\xda\x04\xb3\x96\x61\x2b\xb2\x1c\x3a\xcb\x4e\x0e\x79\x82\xec\x0c\x2f\xd2\xb6\x98\x92\x18\x2b\xe2\xfa\x02\x62\x5c\xfa\xb0\x96\x9c\xdf\x0c\xb1\x5c\x37\x03\xe7\x47\xe3\xb2\xed\x8c\x02\x2f\xe4\xc9\xcd\xe5\x3c\x32\x4e\xe1\xa1\x32\xbb\x87\x98\x12\xc8\x95\xbf\xa2\xc9\x30\xe8\xfb\x0a\x6d\x9f\xb4\xf8\x73\x25\x8d\x48\xa7\x47\xbc\x16\xee\x9f\x25\x75\x3c\x5a\x4e\x5e\xc6\xd8\xb0\x00\xe5\x6d\x86\xab\xc4\xff\x23\xbc\x9f\x3c\x74\x9c\x09\x02\xae\x0c\x71\x1e\xe6\xb7\xe0\x1f\xf1\x2d\x8b\x83\xd1\x56\x16\xdd\x17\x31\x9f\x94\x85\x36\x6f\xfb\x8f\xe9\x6f\x00\x00\x00\xff\xff\xdf\xa9\x37\xf4\x1d\x07\x00\x00") +var _pkgUiTemplatesStoresHtml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x55\x41\x6b\xe3\x3c\x10\xbd\xe7\x57\x0c\xe2\x3b\x7e\x89\xa1\x97\x85\xc5\xc9\xb2\x2c\x85\x3d\xb4\x65\xa1\xdd\x5e\x17\xc5\x9a\xc4\xa2\x8a\x64\x34\xe3\x36\x41\xe8\xbf\x2f\x72\xec\xc4\x6e\x9c\x34\xdd\x8b\xb1\x66\x9e\x34\x6f\x66\x9e\x46\x21\x28\x5c\x69\x8b\x20\x4a\x94\x4a\xc4\x38\xc9\x8d\xb6\x2f\xc0\xbb\x0a\xe7\x82\x71\xcb\x59\x41\x24\xc0\xa3\x99\x0b\xe2\x9d\x41\x2a\x11\x59\x40\xe9\x71\x35\x17\x21\x40\x25\xb9\xfc\xe5\x71\xa5\xb7\x10\x63\x46\x2c\x59\x17\x69\x4f\xe6\x6b\x83\x34\x2b\x88\xbe\xbd\xce\x43\x80\x65\xad\x8d\x7a\x46\x4f\xda\x59\x88\x51\x2c\x26\x21\xa0\x55\x31\x4e\x26\x47\x12\x85\xb3\x8c\x96\x1b\x1e\x4a\xbf\x42\x61\x24\xd1\xbc\x31\x4b\x6d\xd1\x4f\x57\xa6\xd6\x4a\x2c\x26\x00\x00\x21\x78\x69\xd7\x08\xff\x11\x3b\x8f\x4f\xbb\x0a\xff\x6f\xff\x09\xbe\xce\x61\x16\x63\x0b\xd3\xab\x1e\xa6\xb5\xe6\xe5\xcd\x22\x84\xa3\x79\xf6\xc8\x5e\xdb\x75\x8c\x79\x56\xde\x74\xe7\xa3\xa1\x3e\xfe\xb7\x7d\xb1\xee\xcd\x42\xc2\x0f\x60\x4d\x1a\x0d\x8a\xe5\xd2\x60\x47\x7b\xbf\x68\xbe\xd3\xa5\xf3\x0a\x3d\x76\xdc\xf7\xe0\x54\xf3\xfe\xda\x1f\x17\x2d\x60\x71\x6b\x55\xe5\xb4\xe5\x3c\xe3\xf2\xd4\xfb\xc8\x92\x6b\x1a\xf7\x7d\xb7\xd6\xd5\xb6\x40\x05\x77\x72\x89\xe6\x0c\xea\x5e\x5b\x78\xd2\x1b\x3c\xe3\x95\xdb\x0b\xde\x3b\x49\x0c\x3f\x51\x1a\x2e\xe1\x47\x89\xc5\xcb\x05\xd8\x3d\x12\xc9\xf5\xbb\x83\xf2\xac\x9f\x72\xf2\xbd\x2b\xc8\xd2\xa9\xdd\x71\x3d\x6c\x78\xea\x71\xdb\xee\xb6\xfa\x67\x8a\xa8\x0e\x8d\x9e\x3d\xc8\x0d\xa6\x16\xb3\x3a\x01\x75\x4d\x4b\x0a\x46\x31\x74\x43\x27\x23\xeb\xb8\x8d\x39\x4b\x59\xdd\x7a\xef\x7c\x2f\xf8\xe1\x38\xaa\xa4\xed\x0e\x94\x06\x3d\x43\xf3\x9d\x52\x5d\x14\x48\x04\x4d\x90\x3f\xda\x2a\x5d\x48\x76\x1e\xd2\x45\x9b\xd6\x55\x85\xbe\x90\x34\x16\xbd\xae\x4e\x83\x64\x29\xca\x18\xd1\x9e\x6c\xaf\x62\xa5\x52\x55\xfd\xe7\x49\x29\xf7\x66\x3f\x43\xeb\x70\x4d\x8e\xd8\x91\x46\x0c\x0d\x87\x9e\x9b\x24\xe2\x63\xcf\x67\x7b\x51\x7f\x94\xe6\x7e\x57\xf3\x9d\x56\x5e\x6f\xa4\xdf\x89\x24\x87\xc6\xd2\xca\x21\x8d\xb1\xd6\xf0\x2c\x4d\x8d\x31\x8a\xb1\x24\xae\x4f\x20\x84\x95\xf3\x1b\xc9\xe9\xe6\x10\xcb\x4d\xd5\x71\xbe\xd7\x36\xd9\xce\x28\xf0\xc2\x3e\xb9\xbd\xbc\x8f\xb4\x2d\xb0\xaf\xcc\xe6\x3a\xc6\x08\x72\xed\xae\x28\x32\x0c\xc7\xe4\x45\x6d\x9f\x94\xf8\x63\x25\x8d\x48\x67\x1f\xf1\xda\x70\xff\x2c\xa9\xe1\x80\x39\xb9\x19\x63\xc3\x02\x0a\x67\x52\xb8\xb9\xf8\x32\xc2\xfb\xc1\x41\xfb\xc2\x78\x5c\x6b\xe2\x34\xd2\x3f\x13\x7f\xc0\x37\xcf\x7a\x03\x2e\xcf\x9a\x87\x62\xe4\xe9\x69\xbc\xcb\xfe\xa0\xec\x3d\x8d\xfd\xea\xbf\x49\x6f\xb5\x5d\x8b\xc5\x18\xcb\x3c\x53\xfa\x75\xf8\x62\xb5\xa6\x6e\xf9\x37\x00\x00\xff\xff\x71\x7e\x93\x06\x0c\x08\x00\x00") func pkgUiTemplatesStoresHtmlBytes() ([]byte, error) { return bindataRead( @@ -282,7 +282,7 @@ func pkgUiTemplatesStoresHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/templates/stores.html", size: 1821, mode: os.FileMode(420), modTime: time.Unix(1545065695, 0)} + info := bindataFileInfo{name: "pkg/ui/templates/stores.html", size: 2060, mode: os.FileMode(420), modTime: time.Unix(1548437743, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -302,7 +302,7 @@ func pkgUiStaticCssAlertsCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/css/alerts.css", size: 383, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/css/alerts.css", size: 383, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -322,7 +322,7 @@ func pkgUiStaticCssGraphCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/css/graph.css", size: 3363, mode: os.FileMode(420), modTime: time.Unix(1546275027, 0)} + info := bindataFileInfo{name: "pkg/ui/static/css/graph.css", size: 3363, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -342,7 +342,7 @@ func pkgUiStaticCssPrometheusCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/css/prometheus.css", size: 322, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/css/prometheus.css", size: 322, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -362,7 +362,7 @@ func pkgUiStaticCssRulesCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/css/rules.css", size: 190, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/css/rules.css", size: 190, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -382,7 +382,7 @@ func pkgUiStaticImgAjaxLoaderGif() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/img/ajax-loader.gif", size: 847, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/img/ajax-loader.gif", size: 847, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -402,7 +402,7 @@ func pkgUiStaticImgFaviconIco() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/img/favicon.ico", size: 15886, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/img/favicon.ico", size: 15886, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -422,7 +422,7 @@ func pkgUiStaticJsAlertsJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/js/alerts.js", size: 1152, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/js/alerts.js", size: 1152, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -442,7 +442,7 @@ func pkgUiStaticJsGraphJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/js/graph.js", size: 32282, mode: os.FileMode(420), modTime: time.Unix(1546274409, 0)} + info := bindataFileInfo{name: "pkg/ui/static/js/graph.js", size: 32282, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -462,7 +462,7 @@ func pkgUiStaticJsGraph_templateHandlebar() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/js/graph_template.handlebar", size: 7611, mode: os.FileMode(420), modTime: time.Unix(1546274409, 0)} + info := bindataFileInfo{name: "pkg/ui/static/js/graph_template.handlebar", size: 7611, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -482,7 +482,7 @@ func pkgUiStaticVendorBootstrap331CssBootstrapThemeMinCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/css/bootstrap-theme.min.css", size: 19835, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/css/bootstrap-theme.min.css", size: 19835, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -502,7 +502,7 @@ func pkgUiStaticVendorBootstrap331CssBootstrapMinCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css", size: 113498, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/css/bootstrap.min.css", size: 113498, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -522,7 +522,7 @@ func pkgUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularEot() (*asset, return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.eot", size: 20335, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.eot", size: 20335, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -542,7 +542,7 @@ func pkgUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularSvg() (*asset, return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.svg", size: 62926, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.svg", size: 62926, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -562,7 +562,7 @@ func pkgUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularTtf() (*asset, return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.ttf", size: 41280, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.ttf", size: 41280, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -582,7 +582,7 @@ func pkgUiStaticVendorBootstrap331FontsGlyphiconsHalflingsRegularWoff() (*asset, return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.woff", size: 23320, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/fonts/glyphicons-halflings-regular.woff", size: 23320, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -602,7 +602,7 @@ func pkgUiStaticVendorBootstrap331JsBootstrapMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js", size: 35601, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/js/bootstrap.min.js", size: 35601, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -622,7 +622,7 @@ func pkgUiStaticVendorBootstrap331JsNpmJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/js/npm.js", size: 484, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap-3.3.1/js/npm.js", size: 484, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -642,7 +642,7 @@ func pkgUiStaticVendorBootstrap3TypeaheadBootstrap3TypeaheadMinJs() (*asset, err return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js", size: 7856, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/bootstrap3-typeahead/bootstrap3-typeahead.min.js", size: 7856, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -662,7 +662,7 @@ func pkgUiStaticVendorEonasdanBootstrapDatetimepickerBootstrapDatetimepickerMinC return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css", size: 7771, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.css", size: 7771, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -682,7 +682,7 @@ func pkgUiStaticVendorEonasdanBootstrapDatetimepickerBootstrapDatetimepickerMinJ return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.js", size: 48881, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/eonasdan-bootstrap-datetimepicker/bootstrap-datetimepicker.min.js", size: 48881, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -702,7 +702,7 @@ func pkgUiStaticVendorFuzzyFuzzyJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/fuzzy/fuzzy.js", size: 5669, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/fuzzy/fuzzy.js", size: 5669, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -722,7 +722,7 @@ func pkgUiStaticVendorJsJqueryHotkeysJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/js/jquery.hotkeys.js", size: 4490, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/js/jquery.hotkeys.js", size: 4490, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -742,7 +742,7 @@ func pkgUiStaticVendorJsJqueryMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/js/jquery.min.js", size: 86671, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/js/jquery.min.js", size: 86671, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -762,7 +762,7 @@ func pkgUiStaticVendorJsJquerySelectionJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/js/jquery.selection.js", size: 12881, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/js/jquery.selection.js", size: 12881, mode: os.FileMode(420), modTime: time.Unix(1548355675, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -782,7 +782,7 @@ func pkgUiStaticVendorMomentMomentTimezoneWithDataMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/moment/moment-timezone-with-data.min.js", size: 184190, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/moment/moment-timezone-with-data.min.js", size: 184190, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -802,7 +802,7 @@ func pkgUiStaticVendorMomentMomentMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/moment/moment.min.js", size: 61281, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/moment/moment.min.js", size: 61281, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -822,7 +822,7 @@ func pkgUiStaticVendorMustacheMustacheMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/mustache/mustache.min.js", size: 9528, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/mustache/mustache.min.js", size: 9528, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -842,7 +842,7 @@ func pkgUiStaticVendorRickshawRickshawMinCss() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/rickshaw.min.css", size: 6102, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/rickshaw.min.css", size: 6102, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -862,7 +862,7 @@ func pkgUiStaticVendorRickshawRickshawMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/rickshaw.min.js", size: 76322, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/rickshaw.min.js", size: 76322, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -882,7 +882,7 @@ func pkgUiStaticVendorRickshawVendorD3LayoutMinJs() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/vendor/d3.layout.min.js", size: 17514, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/vendor/d3.layout.min.js", size: 17514, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -902,7 +902,7 @@ func pkgUiStaticVendorRickshawVendorD3V3Js() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/vendor/d3.v3.js", size: 144718, mode: os.FileMode(420), modTime: time.Unix(1535122210, 0)} + info := bindataFileInfo{name: "pkg/ui/static/vendor/rickshaw/vendor/d3.v3.js", size: 144718, mode: os.FileMode(420), modTime: time.Unix(1548355676, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/pkg/ui/query.go b/pkg/ui/query.go index da79eecbbf..969f07e596 100644 --- a/pkg/ui/query.go +++ b/pkg/ui/query.go @@ -3,14 +3,14 @@ package ui import ( "html/template" "net/http" + "os" "path" + "strings" "time" - "github.com/improbable-eng/thanos/pkg/query" - - "os" - "github.com/go-kit/kit/log" + "github.com/improbable-eng/thanos/pkg/component" + "github.com/improbable-eng/thanos/pkg/query" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/common/route" @@ -62,6 +62,7 @@ func queryTmplFuncs() template.FuncMap { "formatTimestamp": func(timestamp int64) string { return time.Unix(timestamp/1000, 0).Format(time.RFC3339) }, + "title": strings.Title, } } @@ -117,11 +118,14 @@ func (q *Query) status(w http.ResponseWriter, r *http.Request) { func (q *Query) stores(w http.ResponseWriter, r *http.Request) { prefix := GetWebPrefix(q.logger, q.flagsMap, r) - q.executeTemplate(w, "stores.html", prefix, q.storeSet.GetStoreStatus()) + statuses := make(map[component.StoreAPI][]query.StoreStatus) + for _, status := range q.storeSet.GetStoreStatus() { + statuses[status.StoreType] = append(statuses[status.StoreType], status) + } + q.executeTemplate(w, "stores.html", prefix, statuses) } func (q *Query) flags(w http.ResponseWriter, r *http.Request) { prefix := GetWebPrefix(q.logger, q.flagsMap, r) - q.executeTemplate(w, "flags.html", prefix, q.flagsMap) } diff --git a/pkg/ui/templates/stores.html b/pkg/ui/templates/stores.html index 43bef03485..7750a1d1a0 100644 --- a/pkg/ui/templates/stores.html +++ b/pkg/ui/templates/stores.html @@ -4,7 +4,12 @@ {{define "content"}}
{{$store.Name}} |
@@ -57,5 +62,9 @@ Stores{{end}} |