Skip to content
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 cortex vendor #610

Merged
merged 2 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions cmd/loki/loki-local-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ ingester:
lifecycler:
address: 127.0.0.1
ring:
store: inmemory
kvstore:
store: inmemory
replication_factor: 1
chunk_idle_period: 15m

Expand All @@ -31,5 +32,5 @@ storage_config:
limits_config:
enforce_metric_name: false

querier:
chunk_store_config:
max_look_back_period: 0
10 changes: 6 additions & 4 deletions pkg/ingester/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/weaveworks/common/user"

"github.com/cortexproject/cortex/pkg/chunk"
Expand Down Expand Up @@ -58,8 +59,8 @@ const (
// position, not wallclock time.
flushBackoff = 1 * time.Second

nameLabel = model.LabelName("__name__")
logsValue = model.LabelValue("logs")
nameLabel = "__name__"
logsValue = "logs"
)

// Flush triggers a flush of all the chunks and closes the flush queues.
Expand Down Expand Up @@ -254,8 +255,9 @@ func (i *Ingester) flushChunks(ctx context.Context, fp model.Fingerprint, labelP
return err
}

metric := client.FromLabelAdaptersToMetric(labelPairs)
metric[nameLabel] = logsValue
labelsBuilder := labels.NewBuilder(client.FromLabelAdaptersToLabels(labelPairs))
labelsBuilder.Set(nameLabel, logsValue)
metric := labelsBuilder.Labels()

wireChunks := make([]chunk.Chunk, 0, len(cs))
for _, c := range cs {
Expand Down
17 changes: 11 additions & 6 deletions pkg/ingester/flush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
"golang.org/x/net/context"
Expand Down Expand Up @@ -67,13 +68,13 @@ func newTestStore(t require.TestingT, cfg Config) (*testStore, *Ingester) {

// nolint
func defaultIngesterTestConfig() Config {
consul := ring.NewInMemoryKVClient()
consul := ring.NewInMemoryKVClient(ring.ProtoCodec{Factory: ring.ProtoDescFactory})
cfg := Config{}
flagext.DefaultValues(&cfg)
cfg.FlushCheckPeriod = 99999 * time.Hour
cfg.MaxChunkIdle = 99999 * time.Hour
cfg.ConcurrentFlushes = 1
cfg.LifecyclerConfig.RingConfig.Mock = consul
cfg.LifecyclerConfig.RingConfig.KVStore.Mock = consul
cfg.LifecyclerConfig.NumTokens = 1
cfg.LifecyclerConfig.ListenPort = func(i int) *int { return &i }(0)
cfg.LifecyclerConfig.Addr = "localhost"
Expand All @@ -91,9 +92,9 @@ func (s *testStore) Put(ctx context.Context, chunks []chunk.Chunk) error {
return err
}
for _, chunk := range chunks {
for k, v := range chunk.Metric {
if v == "" {
return fmt.Errorf("Chunk has blank label %q", k)
for _, label := range chunk.Metric {
if label.Value == "" {
return fmt.Errorf("Chunk has blank label %q", label.Name)
}
}
}
Expand Down Expand Up @@ -157,7 +158,11 @@ func (s *testStore) checkData(t *testing.T, userIDs []string, testData map[strin
streams := []*logproto.Stream{}
for _, chunk := range chunks {
lokiChunk := chunk.Data.(*chunkenc.Facade).LokiChunk()
delete(chunk.Metric, nameLabel)
if chunk.Metric.Has("__name__") {
labelsBuilder := labels.NewBuilder(chunk.Metric)
labelsBuilder.Del("__name__")
chunk.Metric = labelsBuilder.Labels()
}
labels := chunk.Metric.String()
streams = append(streams, buildStreamsFromChunk(t, labels, lokiChunk))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func New(cfg Config, store ChunkStore) (*Ingester, error) {
}

var err error
i.lifecycler, err = ring.NewLifecycler(cfg.LifecyclerConfig, i)
i.lifecycler, err = ring.NewLifecycler(cfg.LifecyclerConfig, i, "ingester")
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (t *Loki) initServer() (err error) {
}

func (t *Loki) initRing() (err error) {
t.ring, err = ring.New(t.cfg.Ingester.LifecyclerConfig.RingConfig)
t.ring, err = ring.New(t.cfg.Ingester.LifecyclerConfig.RingConfig, "ingester")
if err != nil {
return
}
Expand Down
11 changes: 0 additions & 11 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package querier
import (
"context"
"flag"
"time"

"github.com/cortexproject/cortex/pkg/chunk"
cortex_client "github.com/cortexproject/cortex/pkg/ingester/client"
Expand All @@ -19,13 +18,10 @@ import (

// Config for a querier.
type Config struct {
// Limits query start time to be greater than now() - MaxLookBackPeriod, if set.
MaxLookBackPeriod time.Duration `yaml:"max_look_back_period"`
}

// RegisterFlags register flags.
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.DurationVar(&cfg.MaxLookBackPeriod, "querier.max_look_back_period", 0, "Limit how long back data can be queried")
}

// Querier handlers queries.
Expand Down Expand Up @@ -96,13 +92,6 @@ func (q *Querier) forAllIngesters(f func(logproto.QuerierClient) (interface{}, e

// Query does the heavy lifting for an actual query.
func (q *Querier) Query(ctx context.Context, req *logproto.QueryRequest) (*logproto.QueryResponse, error) {
if q.cfg.MaxLookBackPeriod != 0 {
oldestStartTime := time.Now().Add(-q.cfg.MaxLookBackPeriod)
if oldestStartTime.After(req.Start) {
req.Start = oldestStartTime
}
}

ingesterIterators, err := q.queryIngesters(ctx, req)
if err != nil {
return nil, err
Expand Down
8 changes: 6 additions & 2 deletions pkg/querier/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func filterSeriesByMatchers(chks map[model.Fingerprint][][]chunkenc.LazyChunk, m
outer:
for fp, chunks := range chks {
for _, matcher := range matchers {
if !matcher.Matches(string(chunks[0][0].Chunk.Metric[model.LabelName(matcher.Name)])) {
if !matcher.Matches(chunks[0][0].Chunk.Metric.Get(matcher.Name)) {
delete(chks, fp)
continue outer
}
Expand Down Expand Up @@ -184,7 +184,11 @@ func partitionBySeriesChunks(chunks [][]chunk.Chunk, fetchers []*chunk.Fetcher)
for _, c := range chks {
fp := c.Fingerprint
chunksByFp[fp] = append(chunksByFp[fp], chunkenc.LazyChunk{Chunk: c, Fetcher: fetchers[i]})
delete(c.Metric, "__name__")
if c.Metric.Has("__name__") {
labelsBuilder := labels.NewBuilder(c.Metric)
labelsBuilder.Del("__name__")
c.Metric = labelsBuilder.Labels()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: loki
version: 0.8.2
version: 0.8.3
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
5 changes: 3 additions & 2 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ config:
chunk_block_size: 262144
lifecycler:
ring:
store: inmemory
kvstore:
store: inmemory
replication_factor: 1

## Different ring configs can be used. E.g. Consul
Expand Down Expand Up @@ -56,7 +57,7 @@ config:
directory: /data/loki/index
filesystem:
directory: /data/loki/chunks
querier:
chunk_store_config:
max_look_back_period: 0

deploymentStrategy: RollingUpdate
Expand Down
15 changes: 8 additions & 7 deletions production/ksonnet/loki/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@

lifecycler: {
ring: {
store: 'consul',
heartbeat_timeout: '1m',
replication_factor: 3,

consul: {
host: 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
prefix: '',
httpclienttimeout: '20s',
consistentreads: true,
kvstore: {
store: 'consul',
consul: {
host: 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
prefix: '',
httpclienttimeout: '20s',
consistentreads: true,
},
},
},

Expand Down
11 changes: 11 additions & 0 deletions vendor/github.com/cortexproject/cortex/pkg/chunk/bucket_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading