diff --git a/.circleci/config.yml b/.circleci/config.yml
index 6a0d1dc4f3183012a7032cbd706c22cc30699207..78e0d5b6c7d29dcf8dfd6223902f13b5c9147a44 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -41,7 +41,7 @@ workflows:
 # https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
 defaults: &defaults
   docker:
-    - image: grafana/loki-build-image:0.1.0
+    - image: grafana/loki-build-image:0.2.0
   working_directory: /go/src/github.com/grafana/loki
 
 jobs:
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..20358201e63be0dc523aca9282af3ab6536bd459
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,74 @@
+# This file contains all available configuration options
+# with their default values.
+
+# options for analysis running
+run:
+  # default concurrency is a available CPU number
+  concurrency: 2
+
+  # timeout for analysis, e.g. 30s, 5m, default is 1m
+  deadline: 5m
+
+  # exit code when at least one issue was found, default is 1
+  issues-exit-code: 1
+
+  # include test files or not, default is true
+  tests: true
+
+  # list of build tags, all linters use it. Default is empty list.
+  build-tags:
+
+  # which dirs to skip: they won't be analyzed;
+  # can use regexp here: generated.*, regexp is applied on full path;
+  # default value is empty list, but next dirs are always skipped independently
+  # from this option's value:
+  #   	vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
+  skip-dirs:
+
+  # which files to skip: they will be analyzed, but issues from them
+  # won't be reported. Default value is empty list, but there is
+  # no need to include all autogenerated files, we confidently recognize
+  # autogenerated files. If it's not please let us know.
+  skip-files:
+    - ".*\\.y$"
+    - ".*yaccpar$"
+
+# output configuration options
+output:
+  # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
+  format: colored-line-number
+
+  # print lines of code with issue, default is true
+  print-issued-lines: true
+
+  # print linter name in the end of issue text, default is true
+  print-linter-name: true
+
+linters:
+  enable:
+    - deadcode
+    - errcheck
+    - goconst
+    - gofmt
+    - goimports
+    - golint
+    - gosimple
+    - ineffassign
+    - megacheck
+    - misspell
+    - structcheck
+    - unconvert
+    - unparam
+    - varcheck
+    - govet
+    - unused # new from here.
+    - interfacer
+    - typecheck
+    - dupl
+    - gocyclo
+    - nakedret
+
+issues:
+  exclude-use-default: false
+  exclude:
+    - Error return value of .*log\.Logger\)\.Log\x60 is not checked 
\ No newline at end of file
diff --git a/.gometalinter.json b/.gometalinter.json
deleted file mode 100644
index ed3fda665df43f4579efa5405ede82b4814194b6..0000000000000000000000000000000000000000
--- a/.gometalinter.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-  "Vendor": true,
-  "Deadline": "5m",
-  "Concurrency": 2,
-  "Linters": {
-    "gofmt": {"Command": "gofmt -l -s -w"},
-    "goimports": {"Command": "goimports -l -w"}
-  },
-  "Exclude": [
-    "\\.pb\\.go",
-    "method Seek.*should have signature",
-    "error return value not checked \\(level\\.",
-    "\"err\" shadows declaration"
-  ],
-
-  "Enable": [
-    "deadcode",
-    "errcheck",
-    "goconst",
-    "gofmt",
-    "goimports",
-    "golint",
-    "gosimple",
-    "gotypex",
-    "ineffassign",
-    "megacheck",
-    "misspell",
-    "structcheck",
-    "unconvert",
-    "unparam",
-    "varcheck",
-    "vet",
-    "vetshadow"
-  ]
-}
diff --git a/Makefile b/Makefile
index 7c91bf63bfb04f0f401173bdff0b270a52849a9a..110a6c62f601c14980b3e3110ea1642aa07101e0 100644
--- a/Makefile
+++ b/Makefile
@@ -171,7 +171,7 @@ $(EXES): loki-build-image/$(UPTODATE)
 	goyacc -p $(basename $(notdir $<)) -o $@ $<
 
 lint: loki-build-image/$(UPTODATE)
-	gometalinter ./...
+	golangci-lint run
 
 check-generated-files: loki-build-image/$(UPTODATE) yacc protos
 	@git diff-files || (echo "changed files; failing check" && exit 1)
diff --git a/loki-build-image/Dockerfile b/loki-build-image/Dockerfile
index 9d52f1f1b602ed1fdb4aae54fab9535cb81b45a4..005b806710a87f50aaba86113d6d0be1d9c5b805 100644
--- a/loki-build-image/Dockerfile
+++ b/loki-build-image/Dockerfile
@@ -18,11 +18,9 @@ RUN go get \
 		github.com/go-delve/delve/cmd/dlv \
 		golang.org/x/tools/cmd/goyacc && \
 		rm -rf /go/pkg /go/src
-ENV GOMETALINTER_VER="2.0.11"
-RUN curl -L -o /tmp/gometalinter-$GOMETALINTER_VER.tgz https://github.com/alecthomas/gometalinter/releases/download/v$GOMETALINTER_VER/gometalinter-$GOMETALINTER_VER-linux-amd64.tar.gz && \
-		tar -xz -C /tmp -f /tmp/gometalinter-$GOMETALINTER_VER.tgz && \
-		mv /tmp/gometalinter-$GOMETALINTER_VER-linux-amd64/* /usr/bin && \
-		rm /tmp/gometalinter-$GOMETALINTER_VER.tgz
+ENV GOLANGCI_LINT_VER="1.16.0"
+RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VER} && \
+	golangci-lint --version
 COPY build.sh /
 ENV GOCACHE=/go/cache
 ENTRYPOINT ["/build.sh"]
diff --git a/pkg/chunkenc/gzip.go b/pkg/chunkenc/gzip.go
index 8476dbbc491ad7bff3e2c1bc175096b722dc1a0b..04fbb081e2597ab478074a8ef2fce17982c40ad5 100644
--- a/pkg/chunkenc/gzip.go
+++ b/pkg/chunkenc/gzip.go
@@ -454,10 +454,6 @@ type listIterator struct {
 	cur entry
 }
 
-func (li *listIterator) Seek(int64) bool {
-	return false
-}
-
 func (li *listIterator) Next() bool {
 	if len(li.entries) > 0 {
 		li.cur = li.entries[0]
@@ -500,10 +496,6 @@ func newBufferedIterator(s *bufio.Reader) *bufferedIterator {
 	}
 }
 
-func (si *bufferedIterator) Seek(int64) bool {
-	return false
-}
-
 func (si *bufferedIterator) Next() bool {
 	ts, err := binary.ReadVarint(si.s)
 	if err != nil {
diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go
index d3e0689a13da4039a62954bcf7efa8aba31f732b..a768c98bb0d220a8c9c6b432948e36ac58a41a2b 100644
--- a/pkg/distributor/distributor.go
+++ b/pkg/distributor/distributor.go
@@ -248,8 +248,8 @@ func (d *Distributor) sendSamplesErr(ctx context.Context, ingester ring.Ingester
 
 func tokenFor(userID, labels string) uint32 {
 	h := fnv.New32()
-	h.Write([]byte(userID))
-	h.Write([]byte(labels))
+	_, _ = h.Write([]byte(userID))
+	_, _ = h.Write([]byte(labels))
 	return h.Sum32()
 }
 
diff --git a/pkg/ingester/chunk_test.go b/pkg/ingester/chunk_test.go
index 83d3588c1c128218a4a41cade1fbbcbd937d8e70..4feb7fffe778a52df8c53615ceed406d69f34dc4 100644
--- a/pkg/ingester/chunk_test.go
+++ b/pkg/ingester/chunk_test.go
@@ -63,7 +63,7 @@ func TestIterator(t *testing.T) {
 				iter, err := chunk.Iterator(time.Unix(int64(from), 0), time.Unix(int64(from+len), 0), logproto.FORWARD)
 				require.NoError(t, err)
 				testIteratorForward(t, iter, int64(from), int64(from+len))
-				iter.Close()
+				_ = iter.Close()
 			}
 
 			for i := 0; i < entries; i++ {
@@ -72,7 +72,7 @@ func TestIterator(t *testing.T) {
 				iter, err := chunk.Iterator(time.Unix(int64(from), 0), time.Unix(int64(from+len), 0), logproto.BACKWARD)
 				require.NoError(t, err)
 				testIteratorBackward(t, iter, int64(from), int64(from+len))
-				iter.Close()
+				_ = iter.Close()
 			}
 		})
 	}
diff --git a/pkg/ingester/client/client.go b/pkg/ingester/client/client.go
index 97446c0098077d2e9ba8ef7e8d283c35de6929be..9c08be7fbdf219be602fbcd48e0de5da5a378275 100644
--- a/pkg/ingester/client/client.go
+++ b/pkg/ingester/client/client.go
@@ -8,7 +8,7 @@ import (
 	cortex_client "github.com/cortexproject/cortex/pkg/ingester/client"
 	"github.com/grafana/loki/pkg/logproto"
 	"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
-	"github.com/mwitkow/go-grpc-middleware"
+	grpc_middleware "github.com/mwitkow/go-grpc-middleware"
 	opentracing "github.com/opentracing/opentracing-go"
 	"github.com/weaveworks/common/middleware"
 	"google.golang.org/grpc"
diff --git a/pkg/ingester/flush_test.go b/pkg/ingester/flush_test.go
index 3f15fa3a516bb5aca04990bb01406be56a80369d..9cfa8fbd5ff6def983a2410f712250275b36ffe4 100644
--- a/pkg/ingester/flush_test.go
+++ b/pkg/ingester/flush_test.go
@@ -68,10 +68,6 @@ func newTestStore(t require.TestingT, cfg Config) (*testStore, *Ingester) {
 	return store, ing
 }
 
-func newDefaultTestStore(t require.TestingT) (*testStore, *Ingester) {
-	return newTestStore(t, defaultIngesterTestConfig())
-}
-
 func defaultIngesterTestConfig() Config {
 	consul := ring.NewInMemoryKVClient()
 	cfg := Config{}
@@ -108,7 +104,7 @@ func (s *testStore) Put(ctx context.Context, chunks []chunk.Chunk) error {
 
 func (s *testStore) Stop() {}
 
-func pushTestSamples(t *testing.T, ing *Ingester) ([]string, map[string][]*logproto.Stream) {
+func pushTestSamples(t *testing.T, ing logproto.PusherServer) ([]string, map[string][]*logproto.Stream) {
 	userIDs := []string{"1", "2", "3"}
 
 	// Create test samples.
diff --git a/pkg/ingester/stream_test.go b/pkg/ingester/stream_test.go
index 5eb8eb78229d666fe9f7ab25bbd9b6d687baed60..a61b100b16c5b55b481b15ce0a62a863eed93868 100644
--- a/pkg/ingester/stream_test.go
+++ b/pkg/ingester/stream_test.go
@@ -44,7 +44,7 @@ func TestStreamIterator(t *testing.T) {
 				require.NotNil(t, iter)
 				require.NoError(t, err)
 				testIteratorForward(t, iter, int64(from), int64(from+len))
-				iter.Close()
+				_ = iter.Close()
 			}
 
 			for i := 0; i < 100; i++ {
@@ -54,7 +54,7 @@ func TestStreamIterator(t *testing.T) {
 				require.NotNil(t, iter)
 				require.NoError(t, err)
 				testIteratorBackward(t, iter, int64(from), int64(from+len))
-				iter.Close()
+				_ = iter.Close()
 			}
 		})
 	}
diff --git a/pkg/iter/iterator_test.go b/pkg/iter/iterator_test.go
index 000284689624af4a800fc9f12fc385c46112f500..d428af6b88f96421829a67d95e0acb0c9dc671c9 100644
--- a/pkg/iter/iterator_test.go
+++ b/pkg/iter/iterator_test.go
@@ -23,7 +23,7 @@ func TestIterator(t *testing.T) {
 	}{
 		// Test basic identity.
 		{
-			iterator:  mkStreamIterator(testSize, identity, defaultLabels),
+			iterator:  mkStreamIterator(identity, defaultLabels),
 			generator: identity,
 			length:    testSize,
 			labels:    defaultLabels,
@@ -31,7 +31,7 @@ func TestIterator(t *testing.T) {
 
 		// Test basic identity (backwards).
 		{
-			iterator:  mkStreamIterator(testSize, inverse(identity), defaultLabels),
+			iterator:  mkStreamIterator(inverse(identity), defaultLabels),
 			generator: inverse(identity),
 			length:    testSize,
 			labels:    defaultLabels,
@@ -40,9 +40,9 @@ func TestIterator(t *testing.T) {
 		// Test dedupe of overlapping iterators with the heap iterator.
 		{
 			iterator: NewHeapIterator([]EntryIterator{
-				mkStreamIterator(testSize, offset(0, identity), defaultLabels),
-				mkStreamIterator(testSize, offset(testSize/2, identity), defaultLabels),
-				mkStreamIterator(testSize, offset(testSize, identity), defaultLabels),
+				mkStreamIterator(offset(0, identity), defaultLabels),
+				mkStreamIterator(offset(testSize/2, identity), defaultLabels),
+				mkStreamIterator(offset(testSize, identity), defaultLabels),
 			}, logproto.FORWARD),
 			generator: identity,
 			length:    2 * testSize,
@@ -52,9 +52,9 @@ func TestIterator(t *testing.T) {
 		// Test dedupe of overlapping iterators with the heap iterator (backward).
 		{
 			iterator: NewHeapIterator([]EntryIterator{
-				mkStreamIterator(testSize, inverse(offset(0, identity)), defaultLabels),
-				mkStreamIterator(testSize, inverse(offset(-testSize/2, identity)), defaultLabels),
-				mkStreamIterator(testSize, inverse(offset(-testSize, identity)), defaultLabels),
+				mkStreamIterator(inverse(offset(0, identity)), defaultLabels),
+				mkStreamIterator(inverse(offset(-testSize/2, identity)), defaultLabels),
+				mkStreamIterator(inverse(offset(-testSize, identity)), defaultLabels),
 			}, logproto.BACKWARD),
 			generator: inverse(identity),
 			length:    2 * testSize,
@@ -64,9 +64,9 @@ func TestIterator(t *testing.T) {
 		// Test dedupe of entries with the same timestamp but different entries.
 		{
 			iterator: NewHeapIterator([]EntryIterator{
-				mkStreamIterator(testSize, offset(0, constant(0)), defaultLabels),
-				mkStreamIterator(testSize, offset(0, constant(0)), defaultLabels),
-				mkStreamIterator(testSize, offset(testSize, constant(0)), defaultLabels),
+				mkStreamIterator(offset(0, constant(0)), defaultLabels),
+				mkStreamIterator(offset(0, constant(0)), defaultLabels),
+				mkStreamIterator(offset(testSize, constant(0)), defaultLabels),
 			}, logproto.FORWARD),
 			generator: constant(0),
 			length:    2 * testSize,
@@ -75,7 +75,7 @@ func TestIterator(t *testing.T) {
 
 		// Test basic identity with non-default labels.
 		{
-			iterator:  mkStreamIterator(testSize, identity, "{foobar: \"bazbar\"}"),
+			iterator:  mkStreamIterator(identity, "{foobar: \"bazbar\"}"),
 			generator: identity,
 			length:    testSize,
 			labels:    "{foobar: \"bazbar\"}",
@@ -105,8 +105,8 @@ func TestIteratorMultipleLabels(t *testing.T) {
 		// Test merging with differing labels but same timestamps and values.
 		{
 			iterator: NewHeapIterator([]EntryIterator{
-				mkStreamIterator(testSize, identity, "{foobar: \"baz1\"}"),
-				mkStreamIterator(testSize, identity, "{foobar: \"baz2\"}"),
+				mkStreamIterator(identity, "{foobar: \"baz1\"}"),
+				mkStreamIterator(identity, "{foobar: \"baz2\"}"),
 			}, logproto.FORWARD),
 			generator: func(i int64) logproto.Entry {
 				return identity(i / 2)
@@ -123,8 +123,8 @@ func TestIteratorMultipleLabels(t *testing.T) {
 		// Test merging with differing labels but all the same timestamps and different values.
 		{
 			iterator: NewHeapIterator([]EntryIterator{
-				mkStreamIterator(testSize, constant(0), "{foobar: \"baz1\"}"),
-				mkStreamIterator(testSize, constant(0), "{foobar: \"baz2\"}"),
+				mkStreamIterator(constant(0), "{foobar: \"baz1\"}"),
+				mkStreamIterator(constant(0), "{foobar: \"baz2\"}"),
 			}, logproto.FORWARD),
 			generator: func(i int64) logproto.Entry {
 				return constant(0)(i % testSize)
@@ -154,9 +154,9 @@ func TestIteratorMultipleLabels(t *testing.T) {
 
 type generator func(i int64) logproto.Entry
 
-func mkStreamIterator(numEntries int64, f generator, labels string) EntryIterator {
+func mkStreamIterator(f generator, labels string) EntryIterator {
 	entries := []logproto.Entry{}
-	for i := int64(0); i < numEntries; i++ {
+	for i := int64(0); i < testSize; i++ {
 		entries = append(entries, f(i))
 	}
 	return newStreamIterator(&logproto.Stream{
@@ -178,6 +178,7 @@ func offset(j int64, g generator) generator {
 	}
 }
 
+// nolint
 func constant(t int64) generator {
 	return func(i int64) logproto.Entry {
 		return logproto.Entry{
diff --git a/pkg/logproto/logproto.pb.go b/pkg/logproto/logproto.pb.go
index 8dd17f50b7bcfbc3950c635b8b350bcf208d4b8a..c7598067f04940ac6ce0ffb6fe60c84fc4973828 100644
--- a/pkg/logproto/logproto.pb.go
+++ b/pkg/logproto/logproto.pb.go
@@ -3,28 +3,22 @@
 
 package logproto
 
-import proto "github.com/gogo/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import _ "github.com/gogo/protobuf/gogoproto"
-import _ "github.com/gogo/protobuf/types"
-
-import time "time"
-
-import strconv "strconv"
-
-import strings "strings"
-import reflect "reflect"
-
 import (
-	context "golang.org/x/net/context"
+	context "context"
+	fmt "fmt"
+	_ "github.com/gogo/protobuf/gogoproto"
+	proto "github.com/gogo/protobuf/proto"
+	_ "github.com/gogo/protobuf/types"
+	github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
 	grpc "google.golang.org/grpc"
+	io "io"
+	math "math"
+	reflect "reflect"
+	strconv "strconv"
+	strings "strings"
+	time "time"
 )
 
-import github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
-
-import io "io"
-
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
 var _ = fmt.Errorf
@@ -48,23 +42,24 @@ var Direction_name = map[int32]string{
 	0: "FORWARD",
 	1: "BACKWARD",
 }
+
 var Direction_value = map[string]int32{
 	"FORWARD":  0,
 	"BACKWARD": 1,
 }
 
 func (Direction) EnumDescriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{0}
+	return fileDescriptor_7a8976f235a02f79, []int{0}
 }
 
 type PushRequest struct {
-	Streams []*Stream `protobuf:"bytes,1,rep,name=streams" json:"streams"`
+	Streams []*Stream `protobuf:"bytes,1,rep,name=streams,proto3" json:"streams"`
 }
 
 func (m *PushRequest) Reset()      { *m = PushRequest{} }
 func (*PushRequest) ProtoMessage() {}
 func (*PushRequest) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{0}
+	return fileDescriptor_7a8976f235a02f79, []int{0}
 }
 func (m *PushRequest) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -81,8 +76,8 @@ func (m *PushRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
 		return b[:n], nil
 	}
 }
-func (dst *PushRequest) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_PushRequest.Merge(dst, src)
+func (m *PushRequest) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_PushRequest.Merge(m, src)
 }
 func (m *PushRequest) XXX_Size() int {
 	return m.Size()
@@ -106,7 +101,7 @@ type PushResponse struct {
 func (m *PushResponse) Reset()      { *m = PushResponse{} }
 func (*PushResponse) ProtoMessage() {}
 func (*PushResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{1}
+	return fileDescriptor_7a8976f235a02f79, []int{1}
 }
 func (m *PushResponse) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -123,8 +118,8 @@ func (m *PushResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
 		return b[:n], nil
 	}
 }
-func (dst *PushResponse) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_PushResponse.Merge(dst, src)
+func (m *PushResponse) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_PushResponse.Merge(m, src)
 }
 func (m *PushResponse) XXX_Size() int {
 	return m.Size()
@@ -138,8 +133,8 @@ var xxx_messageInfo_PushResponse proto.InternalMessageInfo
 type QueryRequest struct {
 	Query     string    `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
 	Limit     uint32    `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
-	Start     time.Time `protobuf:"bytes,3,opt,name=start,stdtime" json:"start"`
-	End       time.Time `protobuf:"bytes,4,opt,name=end,stdtime" json:"end"`
+	Start     time.Time `protobuf:"bytes,3,opt,name=start,proto3,stdtime" json:"start"`
+	End       time.Time `protobuf:"bytes,4,opt,name=end,proto3,stdtime" json:"end"`
 	Direction Direction `protobuf:"varint,5,opt,name=direction,proto3,enum=logproto.Direction" json:"direction,omitempty"`
 	Regex     string    `protobuf:"bytes,6,opt,name=regex,proto3" json:"regex,omitempty"`
 }
@@ -147,7 +142,7 @@ type QueryRequest struct {
 func (m *QueryRequest) Reset()      { *m = QueryRequest{} }
 func (*QueryRequest) ProtoMessage() {}
 func (*QueryRequest) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{2}
+	return fileDescriptor_7a8976f235a02f79, []int{2}
 }
 func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -164,8 +159,8 @@ func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
 		return b[:n], nil
 	}
 }
-func (dst *QueryRequest) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_QueryRequest.Merge(dst, src)
+func (m *QueryRequest) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_QueryRequest.Merge(m, src)
 }
 func (m *QueryRequest) XXX_Size() int {
 	return m.Size()
@@ -219,13 +214,13 @@ func (m *QueryRequest) GetRegex() string {
 }
 
 type QueryResponse struct {
-	Streams []*Stream `protobuf:"bytes,1,rep,name=streams" json:"streams,omitempty"`
+	Streams []*Stream `protobuf:"bytes,1,rep,name=streams,proto3" json:"streams,omitempty"`
 }
 
 func (m *QueryResponse) Reset()      { *m = QueryResponse{} }
 func (*QueryResponse) ProtoMessage() {}
 func (*QueryResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{3}
+	return fileDescriptor_7a8976f235a02f79, []int{3}
 }
 func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -242,8 +237,8 @@ func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error
 		return b[:n], nil
 	}
 }
-func (dst *QueryResponse) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_QueryResponse.Merge(dst, src)
+func (m *QueryResponse) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_QueryResponse.Merge(m, src)
 }
 func (m *QueryResponse) XXX_Size() int {
 	return m.Size()
@@ -269,7 +264,7 @@ type LabelRequest struct {
 func (m *LabelRequest) Reset()      { *m = LabelRequest{} }
 func (*LabelRequest) ProtoMessage() {}
 func (*LabelRequest) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{4}
+	return fileDescriptor_7a8976f235a02f79, []int{4}
 }
 func (m *LabelRequest) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -286,8 +281,8 @@ func (m *LabelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
 		return b[:n], nil
 	}
 }
-func (dst *LabelRequest) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_LabelRequest.Merge(dst, src)
+func (m *LabelRequest) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_LabelRequest.Merge(m, src)
 }
 func (m *LabelRequest) XXX_Size() int {
 	return m.Size()
@@ -313,13 +308,13 @@ func (m *LabelRequest) GetValues() bool {
 }
 
 type LabelResponse struct {
-	Values []string `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
+	Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
 }
 
 func (m *LabelResponse) Reset()      { *m = LabelResponse{} }
 func (*LabelResponse) ProtoMessage() {}
 func (*LabelResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{5}
+	return fileDescriptor_7a8976f235a02f79, []int{5}
 }
 func (m *LabelResponse) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -336,8 +331,8 @@ func (m *LabelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error
 		return b[:n], nil
 	}
 }
-func (dst *LabelResponse) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_LabelResponse.Merge(dst, src)
+func (m *LabelResponse) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_LabelResponse.Merge(m, src)
 }
 func (m *LabelResponse) XXX_Size() int {
 	return m.Size()
@@ -357,13 +352,13 @@ func (m *LabelResponse) GetValues() []string {
 
 type Stream struct {
 	Labels  string  `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"`
-	Entries []Entry `protobuf:"bytes,2,rep,name=entries" json:"entries"`
+	Entries []Entry `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries"`
 }
 
 func (m *Stream) Reset()      { *m = Stream{} }
 func (*Stream) ProtoMessage() {}
 func (*Stream) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{6}
+	return fileDescriptor_7a8976f235a02f79, []int{6}
 }
 func (m *Stream) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -380,8 +375,8 @@ func (m *Stream) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
 		return b[:n], nil
 	}
 }
-func (dst *Stream) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_Stream.Merge(dst, src)
+func (m *Stream) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_Stream.Merge(m, src)
 }
 func (m *Stream) XXX_Size() int {
 	return m.Size()
@@ -407,14 +402,14 @@ func (m *Stream) GetEntries() []Entry {
 }
 
 type Entry struct {
-	Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,stdtime" json:"ts"`
+	Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"ts"`
 	Line      string    `protobuf:"bytes,2,opt,name=line,proto3" json:"line"`
 }
 
 func (m *Entry) Reset()      { *m = Entry{} }
 func (*Entry) ProtoMessage() {}
 func (*Entry) Descriptor() ([]byte, []int) {
-	return fileDescriptor_logproto_ab9c6ba375ad5e80, []int{7}
+	return fileDescriptor_7a8976f235a02f79, []int{7}
 }
 func (m *Entry) XXX_Unmarshal(b []byte) error {
 	return m.Unmarshal(b)
@@ -431,8 +426,8 @@ func (m *Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
 		return b[:n], nil
 	}
 }
-func (dst *Entry) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_Entry.Merge(dst, src)
+func (m *Entry) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_Entry.Merge(m, src)
 }
 func (m *Entry) XXX_Size() int {
 	return m.Size()
@@ -458,6 +453,7 @@ func (m *Entry) GetLine() string {
 }
 
 func init() {
+	proto.RegisterEnum("logproto.Direction", Direction_name, Direction_value)
 	proto.RegisterType((*PushRequest)(nil), "logproto.PushRequest")
 	proto.RegisterType((*PushResponse)(nil), "logproto.PushResponse")
 	proto.RegisterType((*QueryRequest)(nil), "logproto.QueryRequest")
@@ -466,8 +462,52 @@ func init() {
 	proto.RegisterType((*LabelResponse)(nil), "logproto.LabelResponse")
 	proto.RegisterType((*Stream)(nil), "logproto.Stream")
 	proto.RegisterType((*Entry)(nil), "logproto.Entry")
-	proto.RegisterEnum("logproto.Direction", Direction_name, Direction_value)
 }
+
+func init() { proto.RegisterFile("logproto.proto", fileDescriptor_7a8976f235a02f79) }
+
+var fileDescriptor_7a8976f235a02f79 = []byte{
+	// 601 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4f, 0x6f, 0xd3, 0x4e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0xd0, 0x45, 0x46,
+	0xd0, 0x24, 0x23, 0xe8, 0x6b, 0x46, 0xd0, 0xb7, 0x8c, 0x28, 0x57, 0x19, 0x41, 0xe7, 0x73, 0xa2,
+	0x4c, 0xe6, 0x44, 0xb9, 0x9c, 0x13, 0x65, 0xac, 0xca, 0x64, 0xf7, 0x7e, 0x04, 0x00, 0x00, 0xff,
+	0xff, 0x47, 0x69, 0x1e, 0x88, 0x68, 0x04, 0x00, 0x00,
+}
+
 func (x Direction) String() string {
 	s, ok := Direction_name[int32(x)]
 	if ok {
@@ -1088,17 +1128,17 @@ func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) {
 	dAtA[i] = 0x1a
 	i++
 	i = encodeVarintLogproto(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Start)))
-	n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Start, dAtA[i:])
-	if err != nil {
-		return 0, err
+	n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Start, dAtA[i:])
+	if err1 != nil {
+		return 0, err1
 	}
 	i += n1
 	dAtA[i] = 0x22
 	i++
 	i = encodeVarintLogproto(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.End)))
-	n2, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.End, dAtA[i:])
-	if err != nil {
-		return 0, err
+	n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.End, dAtA[i:])
+	if err2 != nil {
+		return 0, err2
 	}
 	i += n2
 	if m.Direction != 0 {
@@ -1266,9 +1306,9 @@ func (m *Entry) MarshalTo(dAtA []byte) (int, error) {
 	dAtA[i] = 0xa
 	i++
 	i = encodeVarintLogproto(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp)))
-	n3, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
-	if err != nil {
-		return 0, err
+	n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i:])
+	if err3 != nil {
+		return 0, err3
 	}
 	i += n3
 	if len(m.Line) > 0 {
@@ -1437,8 +1477,13 @@ func (this *PushRequest) String() string {
 	if this == nil {
 		return "nil"
 	}
+	repeatedStringForStreams := "[]*Stream{"
+	for _, f := range this.Streams {
+		repeatedStringForStreams += strings.Replace(f.String(), "Stream", "Stream", 1) + ","
+	}
+	repeatedStringForStreams += "}"
 	s := strings.Join([]string{`&PushRequest{`,
-		`Streams:` + strings.Replace(fmt.Sprintf("%v", this.Streams), "Stream", "Stream", 1) + `,`,
+		`Streams:` + repeatedStringForStreams + `,`,
 		`}`,
 	}, "")
 	return s
@@ -1459,8 +1504,8 @@ func (this *QueryRequest) String() string {
 	s := strings.Join([]string{`&QueryRequest{`,
 		`Query:` + fmt.Sprintf("%v", this.Query) + `,`,
 		`Limit:` + fmt.Sprintf("%v", this.Limit) + `,`,
-		`Start:` + strings.Replace(strings.Replace(this.Start.String(), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
-		`End:` + strings.Replace(strings.Replace(this.End.String(), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
+		`Start:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Start), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
+		`End:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.End), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
 		`Direction:` + fmt.Sprintf("%v", this.Direction) + `,`,
 		`Regex:` + fmt.Sprintf("%v", this.Regex) + `,`,
 		`}`,
@@ -1471,8 +1516,13 @@ func (this *QueryResponse) String() string {
 	if this == nil {
 		return "nil"
 	}
+	repeatedStringForStreams := "[]*Stream{"
+	for _, f := range this.Streams {
+		repeatedStringForStreams += strings.Replace(f.String(), "Stream", "Stream", 1) + ","
+	}
+	repeatedStringForStreams += "}"
 	s := strings.Join([]string{`&QueryResponse{`,
-		`Streams:` + strings.Replace(fmt.Sprintf("%v", this.Streams), "Stream", "Stream", 1) + `,`,
+		`Streams:` + repeatedStringForStreams + `,`,
 		`}`,
 	}, "")
 	return s
@@ -1502,9 +1552,14 @@ func (this *Stream) String() string {
 	if this == nil {
 		return "nil"
 	}
+	repeatedStringForEntries := "[]Entry{"
+	for _, f := range this.Entries {
+		repeatedStringForEntries += strings.Replace(strings.Replace(f.String(), "Entry", "Entry", 1), `&`, ``, 1) + ","
+	}
+	repeatedStringForEntries += "}"
 	s := strings.Join([]string{`&Stream{`,
 		`Labels:` + fmt.Sprintf("%v", this.Labels) + `,`,
-		`Entries:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Entries), "Entry", "Entry", 1), `&`, ``, 1) + `,`,
+		`Entries:` + repeatedStringForEntries + `,`,
 		`}`,
 	}, "")
 	return s
@@ -1514,7 +1569,7 @@ func (this *Entry) String() string {
 		return "nil"
 	}
 	s := strings.Join([]string{`&Entry{`,
-		`Timestamp:` + strings.Replace(strings.Replace(this.Timestamp.String(), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
+		`Timestamp:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Timestamp), "Timestamp", "types.Timestamp", 1), `&`, ``, 1) + `,`,
 		`Line:` + fmt.Sprintf("%v", this.Line) + `,`,
 		`}`,
 	}, "")
@@ -1543,7 +1598,7 @@ func (m *PushRequest) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -1571,7 +1626,7 @@ func (m *PushRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				msglen |= (int(b) & 0x7F) << shift
+				msglen |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1580,6 +1635,9 @@ func (m *PushRequest) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + msglen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1597,6 +1655,9 @@ func (m *PushRequest) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1624,7 +1685,7 @@ func (m *PushResponse) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -1647,6 +1708,9 @@ func (m *PushResponse) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1674,7 +1738,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -1702,7 +1766,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				stringLen |= (uint64(b) & 0x7F) << shift
+				stringLen |= uint64(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1712,6 +1776,9 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + intStringLen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1731,7 +1798,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				m.Limit |= (uint32(b) & 0x7F) << shift
+				m.Limit |= uint32(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1750,7 +1817,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				msglen |= (int(b) & 0x7F) << shift
+				msglen |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1759,6 +1826,9 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + msglen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1780,7 +1850,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				msglen |= (int(b) & 0x7F) << shift
+				msglen |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1789,6 +1859,9 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + msglen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1810,7 +1883,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				m.Direction |= (Direction(b) & 0x7F) << shift
+				m.Direction |= Direction(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1829,7 +1902,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				stringLen |= (uint64(b) & 0x7F) << shift
+				stringLen |= uint64(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1839,6 +1912,9 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + intStringLen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1853,6 +1929,9 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1880,7 +1959,7 @@ func (m *QueryResponse) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -1908,7 +1987,7 @@ func (m *QueryResponse) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				msglen |= (int(b) & 0x7F) << shift
+				msglen |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1917,6 +1996,9 @@ func (m *QueryResponse) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + msglen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1934,6 +2016,9 @@ func (m *QueryResponse) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -1961,7 +2046,7 @@ func (m *LabelRequest) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -1989,7 +2074,7 @@ func (m *LabelRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				stringLen |= (uint64(b) & 0x7F) << shift
+				stringLen |= uint64(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -1999,6 +2084,9 @@ func (m *LabelRequest) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + intStringLen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2018,7 +2106,7 @@ func (m *LabelRequest) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				v |= (int(b) & 0x7F) << shift
+				v |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -2033,6 +2121,9 @@ func (m *LabelRequest) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2060,7 +2151,7 @@ func (m *LabelResponse) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -2088,7 +2179,7 @@ func (m *LabelResponse) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				stringLen |= (uint64(b) & 0x7F) << shift
+				stringLen |= uint64(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -2098,6 +2189,9 @@ func (m *LabelResponse) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + intStringLen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2112,6 +2206,9 @@ func (m *LabelResponse) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2139,7 +2236,7 @@ func (m *Stream) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -2167,7 +2264,7 @@ func (m *Stream) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				stringLen |= (uint64(b) & 0x7F) << shift
+				stringLen |= uint64(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -2177,6 +2274,9 @@ func (m *Stream) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + intStringLen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2196,7 +2296,7 @@ func (m *Stream) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				msglen |= (int(b) & 0x7F) << shift
+				msglen |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -2205,6 +2305,9 @@ func (m *Stream) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + msglen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2222,6 +2325,9 @@ func (m *Stream) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2249,7 +2355,7 @@ func (m *Entry) Unmarshal(dAtA []byte) error {
 			}
 			b := dAtA[iNdEx]
 			iNdEx++
-			wire |= (uint64(b) & 0x7F) << shift
+			wire |= uint64(b&0x7F) << shift
 			if b < 0x80 {
 				break
 			}
@@ -2277,7 +2383,7 @@ func (m *Entry) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				msglen |= (int(b) & 0x7F) << shift
+				msglen |= int(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -2286,6 +2392,9 @@ func (m *Entry) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + msglen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2307,7 +2416,7 @@ func (m *Entry) Unmarshal(dAtA []byte) error {
 				}
 				b := dAtA[iNdEx]
 				iNdEx++
-				stringLen |= (uint64(b) & 0x7F) << shift
+				stringLen |= uint64(b&0x7F) << shift
 				if b < 0x80 {
 					break
 				}
@@ -2317,6 +2426,9 @@ func (m *Entry) Unmarshal(dAtA []byte) error {
 				return ErrInvalidLengthLogproto
 			}
 			postIndex := iNdEx + intStringLen
+			if postIndex < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if postIndex > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2331,6 +2443,9 @@ func (m *Entry) Unmarshal(dAtA []byte) error {
 			if skippy < 0 {
 				return ErrInvalidLengthLogproto
 			}
+			if (iNdEx + skippy) < 0 {
+				return ErrInvalidLengthLogproto
+			}
 			if (iNdEx + skippy) > l {
 				return io.ErrUnexpectedEOF
 			}
@@ -2397,10 +2512,13 @@ func skipLogproto(dAtA []byte) (n int, err error) {
 					break
 				}
 			}
-			iNdEx += length
 			if length < 0 {
 				return 0, ErrInvalidLengthLogproto
 			}
+			iNdEx += length
+			if iNdEx < 0 {
+				return 0, ErrInvalidLengthLogproto
+			}
 			return iNdEx, nil
 		case 3:
 			for {
@@ -2429,6 +2547,9 @@ func skipLogproto(dAtA []byte) (n int, err error) {
 					return 0, err
 				}
 				iNdEx = start + next
+				if iNdEx < 0 {
+					return 0, ErrInvalidLengthLogproto
+				}
 			}
 			return iNdEx, nil
 		case 4:
@@ -2447,47 +2568,3 @@ var (
 	ErrInvalidLengthLogproto = fmt.Errorf("proto: negative length found during unmarshaling")
 	ErrIntOverflowLogproto   = fmt.Errorf("proto: integer overflow")
 )
-
-func init() { proto.RegisterFile("logproto.proto", fileDescriptor_logproto_ab9c6ba375ad5e80) }
-
-var fileDescriptor_logproto_ab9c6ba375ad5e80 = []byte{
-	// 601 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4f, 0x6f, 0xd3, 0x4e,
-	0x10, 0xf5, 0xb6, 0x89, 0x13, 0x4f, 0xd2, 0xb4, 0xda, 0xdf, 0x8f, 0x62, 0x45, 0x68, 0x1d, 0xf9,
-	0x00, 0x51, 0x25, 0x5c, 0x08, 0x88, 0x4a, 0x85, 0x4b, 0x4d, 0xa9, 0x90, 0x40, 0x02, 0x16, 0x24,
-	0xce, 0x4e, 0xbb, 0xb8, 0x96, 0xfc, 0xa7, 0xb5, 0xd7, 0x88, 0xde, 0x90, 0xf8, 0x02, 0xfd, 0x18,
-	0x7c, 0x94, 0x1e, 0x73, 0xec, 0x29, 0x10, 0xe7, 0x82, 0x72, 0xea, 0x8d, 0x2b, 0xda, 0xb5, 0x1d,
-	0x1b, 0x90, 0x40, 0x5c, 0x9c, 0x79, 0xbb, 0xef, 0xcd, 0xec, 0x9b, 0x99, 0x40, 0xcf, 0x8f, 0xdc,
-	0x93, 0x38, 0xe2, 0x91, 0x25, 0xbf, 0xb8, 0x5d, 0xe2, 0xbe, 0xe1, 0x46, 0x91,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xb6, 0xbd, 0xf7, 0xf8, 0x99, 0x44, 0x68, 0xb4, 0x07, 0xaa, 0x58,
-	0x57, 0x16, 0xe3, 0x1d, 0x68, 0x88, 0x08, 0x5f, 0xab, 0x5c, 0xd5, 0xfe, 0x10, 0xfd, 0xcd, 0x5f,
-	0x8f, 0x8b, 0xfd, 0x56, 0x46, 0x9f, 0x10, 0xb4, 0xc4, 0xa0, 0x3d, 0x16, 0xe3, 0x47, 0xd0, 0x94,
-	0x33, 0xc7, 0x35, 0x7a, 0x7d, 0xfb, 0xfb, 0xd7, 0x7f, 0x3b, 0x2f, 0xf3, 0xdc, 0x41, 0x62, 0xdd,
-	0xe5, 0xe0, 0xea, 0xea, 0xfa, 0x16, 0xd4, 0xd5, 0x3f, 0x4d, 0xd8, 0x54, 0xec, 0xfb, 0x93, 0x19,
-	0x51, 0x2e, 0x67, 0x44, 0xb9, 0x9a, 0x11, 0xf4, 0x31, 0x23, 0xe8, 0x73, 0x46, 0xd0, 0x45, 0x46,
-	0xd0, 0x24, 0x23, 0xe8, 0x6b, 0x46, 0xd0, 0xb7, 0x8c, 0x28, 0x57, 0x19, 0x41, 0xe7, 0x73, 0xa2,
-	0x4c, 0xe6, 0x44, 0xb9, 0x9c, 0x13, 0x65, 0xac, 0xca, 0x64, 0xf7, 0x7e, 0x04, 0x00, 0x00, 0xff,
-	0xff, 0x47, 0x69, 0x1e, 0x88, 0x68, 0x04, 0x00, 0x00,
-}
diff --git a/pkg/promtail/promtail_test.go b/pkg/promtail/promtail_test.go
index b261db624074dde7cabda9d319833d9a8a0a9838..109eb7c01c094dccb854cd4c71a8866c598765e7 100644
--- a/pkg/promtail/promtail_test.go
+++ b/pkg/promtail/promtail_test.go
@@ -1,7 +1,6 @@
 package promtail
 
 import (
-	"errors"
 	"fmt"
 	"io"
 	"io/ioutil"
@@ -17,6 +16,7 @@ import (
 	"github.com/cortexproject/cortex/pkg/util/flagext"
 	"github.com/go-kit/kit/log"
 	"github.com/go-kit/kit/log/level"
+	"github.com/pkg/errors"
 	"github.com/prometheus/common/model"
 	sd_config "github.com/prometheus/prometheus/discovery/config"
 	"github.com/prometheus/prometheus/discovery/targetgroup"
@@ -49,7 +49,8 @@ func TestPromtail(t *testing.T) {
 		t.Error(err)
 		return
 	}
-	defer os.RemoveAll(dirName)
+
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	testDir := dirName + "/logs"
 	err = os.MkdirAll(testDir, 0750)
@@ -64,9 +65,14 @@ func TestPromtail(t *testing.T) {
 		t:           t,
 	}
 	http.Handle("/api/prom/push", handler)
+	defer func() {
+		if err != nil {
+			t.Fatal(err)
+		}
+	}()
 	go func() {
-		if err := http.ListenAndServe("127.0.0.1:3100", nil); err != nil {
-			t.Fatal("Failed to start web server to receive logs", err)
+		if err = http.ListenAndServe("127.0.0.1:3100", nil); err != nil {
+			err = errors.Wrap(err, "Failed to start web server to receive logs")
 		}
 	}()
 
@@ -79,9 +85,9 @@ func TestPromtail(t *testing.T) {
 	}
 
 	go func() {
-		err := p.Run()
+		err = p.Run()
 		if err != nil {
-			t.Fatal("Failed to start promtail", err)
+			err = errors.Wrap(err, "Failed to start promtail")
 		}
 	}()
 
@@ -374,7 +380,7 @@ func (h *testServerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		file := ""
 		for _, label := range labels {
 			if label.Name == "__filename__" {
-				file = string(label.Value)
+				file = label.Value
 				continue
 			}
 		}
diff --git a/pkg/promtail/targets/filetarget_test.go b/pkg/promtail/targets/filetarget_test.go
index 3f141e7f45e6f141b1b3a7e662a36b8c17db2d6c..e6139b6597529ee9833dcaa2d8f07eb5d585cc36 100644
--- a/pkg/promtail/targets/filetarget_test.go
+++ b/pkg/promtail/targets/filetarget_test.go
@@ -32,7 +32,7 @@ func TestLongPositionsSyncDelayStillSavesCorrectPosition(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.RemoveAll(dirName)
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	// Set the sync period to a really long value, to guarantee the sync timer never runs, this way we know
 	// everything saved was done through channel notifications when target.stop() was called.
@@ -125,7 +125,7 @@ func TestWatchEntireDirectory(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.RemoveAll(dirName)
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	// Set the sync period to a really long value, to guarantee the sync timer never runs, this way we know
 	// everything saved was done through channel notifications when target.stop() was called.
@@ -214,7 +214,7 @@ func TestFileRolls(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.RemoveAll(dirName)
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	// Set the sync period to a really long value, to guarantee the sync timer never runs, this way we know
 	// everything saved was done through channel notifications when target.stop() was called.
@@ -312,7 +312,7 @@ func TestResumesWhereLeftOff(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.RemoveAll(dirName)
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	// Set the sync period to a really long value, to guarantee the sync timer never runs, this way we know
 	// everything saved was done through channel notifications when target.stop() was called.
@@ -421,7 +421,7 @@ func TestGlobWithMultipleFiles(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.RemoveAll(dirName)
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	// Set the sync period to a really long value, to guarantee the sync timer never runs, this way we know
 	// everything saved was done through channel notifications when target.stop() was called.
@@ -524,7 +524,7 @@ func TestFileTargetSync(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	defer os.RemoveAll(dirName)
+	defer func() { _ = os.RemoveAll(dirName) }()
 
 	// Set the sync period to a really long value, to guarantee the sync timer never runs, this way we know
 	// everything saved was done through channel notifications when target.stop() was called.
diff --git a/pkg/querier/store.go b/pkg/querier/store.go
index eaba978c8e3b1e5cb521f322b5b9dc599e15b2f0..5680778618ab18e359d0684f16d84a5de4060b4a 100644
--- a/pkg/querier/store.go
+++ b/pkg/querier/store.go
@@ -53,13 +53,11 @@ func (q Querier) queryStore(ctx context.Context, req *logproto.QueryRequest) ([]
 
 func filterChunksByTime(from, through model.Time, chunks []chunk.Chunk) []chunk.Chunk {
 	filtered := make([]chunk.Chunk, 0, len(chunks))
-	keys := make([]string, 0, len(chunks))
 	for _, chunk := range chunks {
 		if chunk.Through < from || through < chunk.From {
 			continue
 		}
 		filtered = append(filtered, chunk)
-		keys = append(keys, chunk.ExternalKey())
 	}
 	return filtered
 }
@@ -189,7 +187,7 @@ func partitionBySeriesChunks(chunks [][]chunk.Chunk, fetchers []*chunk.Fetcher)
 // partitionOverlappingChunks splits the list of chunks into different non-overlapping lists.
 func partitionOverlappingChunks(chunks []chunkenc.LazyChunk) [][]chunkenc.LazyChunk {
 	sort.Slice(chunks, func(i, j int) bool {
-		return chunks[i].Chunk.From < chunks[i].Chunk.From
+		return chunks[i].Chunk.From < chunks[j].Chunk.From
 	})
 
 	css := [][]chunkenc.LazyChunk{}