-
Notifications
You must be signed in to change notification settings - Fork 837
Update prometheus #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update prometheus #802
Changes from 6 commits
c035775
dc566ed
d6ae235
062f038
c44c7f0
9e41258
b1ab760
782ae13
b89f1aa
b84528e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,40 +2,56 @@ package querier | |
|
|
||
| import ( | ||
| "context" | ||
| "flag" | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/go-kit/kit/log/level" | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| "github.com/prometheus/common/model" | ||
| "github.com/prometheus/prometheus/pkg/labels" | ||
| "github.com/prometheus/prometheus/promql" | ||
| "github.com/prometheus/prometheus/storage" | ||
|
|
||
| "github.com/weaveworks/cortex/pkg/ingester/client" | ||
| "github.com/weaveworks/cortex/pkg/prom1/storage/metric" | ||
|
|
||
| "github.com/weaveworks/cortex/pkg/util" | ||
| ) | ||
|
|
||
| // Config contains the configuration require to create a querier | ||
| type Config struct { | ||
| MaxConcurrent int | ||
| Timeout time.Duration | ||
| } | ||
|
|
||
| // RegisterFlags adds the flags required to config this to the given FlagSet | ||
| func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
| flag.IntVar(&cfg.MaxConcurrent, "querier.max-concurrent", 20, "The maximum number of concurrent queries.") | ||
| flag.DurationVar(&cfg.Timeout, "querier.timeout", 2*time.Minute, "The timeout for a query.") | ||
| } | ||
|
|
||
| // ChunkStore is the interface we need to get chunks | ||
| type ChunkStore interface { | ||
| Get(ctx context.Context, from, through model.Time, matchers ...*labels.Matcher) (model.Matrix, error) | ||
| } | ||
|
|
||
| // NewEngine creates a new promql.Engine for cortex. | ||
| func NewEngine(distributor Querier, chunkStore ChunkStore) *promql.Engine { | ||
| queryable := NewQueryable(distributor, chunkStore, false) | ||
| return promql.NewEngine(queryable, nil) | ||
| func NewEngine(distributor Querier, chunkStore ChunkStore, reg prometheus.Registerer, maxConcurrent int, timeout time.Duration) (*promql.Engine, storage.Queryable) { | ||
|
||
| queryable := NewQueryable(distributor, chunkStore) | ||
| engine := promql.NewEngine(util.Logger, reg, maxConcurrent, timeout) | ||
| return engine, queryable | ||
| } | ||
|
|
||
| // NewQueryable creates a new Queryable for cortex. | ||
| func NewQueryable(distributor Querier, chunkStore ChunkStore, mo bool) MergeQueryable { | ||
| func NewQueryable(distributor Querier, chunkStore ChunkStore) MergeQueryable { | ||
| return MergeQueryable{ | ||
| queriers: []Querier{ | ||
| distributor, | ||
| &chunkQuerier{ | ||
| store: chunkStore, | ||
| }, | ||
| }, | ||
| metadataOnly: mo, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -108,18 +124,16 @@ func mergeMatrices(matrices chan model.Matrix, errors chan error, n int) (model. | |
| // A MergeQueryable is a storage.Queryable that produces a storage.Querier which merges | ||
| // results from multiple underlying Queriers. | ||
| type MergeQueryable struct { | ||
| queriers []Querier | ||
| metadataOnly bool | ||
| queriers []Querier | ||
| } | ||
|
|
||
| // Querier implements storage.Queryable. | ||
| func (q MergeQueryable) Querier(ctx context.Context, mint, maxt int64) (storage.Querier, error) { | ||
| return mergeQuerier{ | ||
| ctx: ctx, | ||
| queriers: q.queriers, | ||
| mint: mint, | ||
| maxt: maxt, | ||
| metadataOnly: q.metadataOnly, | ||
| ctx: ctx, | ||
| queriers: q.queriers, | ||
| mint: mint, | ||
| maxt: maxt, | ||
| }, nil | ||
| } | ||
|
|
||
|
|
@@ -188,16 +202,12 @@ type mergeQuerier struct { | |
| queriers []Querier | ||
| mint int64 | ||
| maxt int64 | ||
| // Whether this querier should only load series metadata in Select(). | ||
| // Necessary for remote storage implementations of the storage.Querier | ||
| // interface because both metadata and bulk data loading happens via | ||
| // the Select() method. | ||
| metadataOnly bool | ||
| } | ||
|
|
||
| func (mq mergeQuerier) Select(matchers ...*labels.Matcher) (storage.SeriesSet, error) { | ||
| func (mq mergeQuerier) Select(sp *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) { | ||
| // TODO: Update underlying selectors to return errors directly. | ||
| if mq.metadataOnly { | ||
| // Kludge: Prometheus passes nil SelectParams if it is doing a 'series' operation, which needs only metadata | ||
| if sp == nil { | ||
| return mq.selectMetadata(matchers...), nil | ||
| } | ||
| return mq.selectSamples(matchers...), nil | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we want to have comments for newly added constraints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good spot