diff --git a/.golangci.yml b/.golangci.yml index c58d807253a61..a96a6ef453a09 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,6 +40,10 @@ output: # print linter name in the end of issue text, default is true print-linter-name: true +linters-settings: + goimports: + local-prefixes: github.com/grafana/loki/pkg + linters: enable: - deadcode diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d3ebf0dc5d3bc..b2390dde565fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ Please follow the [Loki Helm Chart](./production/helm/README.md). ### Dependency management -We uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages. +We use [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages. This requires a working Go environment with version 1.13 or greater and git installed. To add or update a new dependency, use the `go get` command: @@ -48,3 +48,23 @@ git commit ``` You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request. + +## Coding Standards + +### go imports +imports should follow `std libs`, `externals libs` and `local packages` format + +Example +``` +import ( + "fmt" + "math" + + "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/pkg/labels" + + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql" +) +``` + diff --git a/cmd/chunks-inspect/main.go b/cmd/chunks-inspect/main.go index f88193e2b4edb..3a004b4998b86 100644 --- a/cmd/chunks-inspect/main.go +++ b/cmd/chunks-inspect/main.go @@ -80,7 +80,7 @@ func printFile(filename string, blockDetails, printLines, storeBlocks bool) { } if len(lokiChunk.blocks) > 0 { fmt.Println("Minimum time (from first block):", time.Unix(0, lokiChunk.blocks[0].minT).In(timezone).Format(format)) - fmt.Println("Maximum time (from last block):", time.Unix(0, lokiChunk.blocks[len(lokiChunk.blocks) - 1].maxT).In(timezone).Format(format)) + fmt.Println("Maximum time (from last block):", time.Unix(0, lokiChunk.blocks[len(lokiChunk.blocks)-1].maxT).In(timezone).Format(format)) } if blockDetails { diff --git a/cmd/docker-driver/config.go b/cmd/docker-driver/config.go index b78efbc350f9e..67d93a421a77a 100644 --- a/cmd/docker-driver/config.go +++ b/cmd/docker-driver/config.go @@ -13,11 +13,12 @@ import ( "github.com/cortexproject/cortex/pkg/util/flagext" "github.com/docker/docker/daemon/logger" "github.com/docker/docker/daemon/logger/templates" + "github.com/prometheus/common/model" + "github.com/grafana/loki/pkg/helpers" "github.com/grafana/loki/pkg/logentry/stages" "github.com/grafana/loki/pkg/promtail/client" "github.com/grafana/loki/pkg/promtail/targets" - "github.com/prometheus/common/model" ) const ( diff --git a/cmd/docker-driver/loki.go b/cmd/docker-driver/loki.go index adf8e7fe2fb5c..27e369d54dcb1 100644 --- a/cmd/docker-driver/loki.go +++ b/cmd/docker-driver/loki.go @@ -6,11 +6,12 @@ import ( "github.com/docker/docker/daemon/logger" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/model" + "github.com/grafana/loki/pkg/logentry/stages" "github.com/grafana/loki/pkg/promtail/api" "github.com/grafana/loki/pkg/promtail/client" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/model" ) var jobName = "docker" diff --git a/cmd/docker-driver/main.go b/cmd/docker-driver/main.go index dbd5581929ee9..6dd8d1f87b4fc 100644 --- a/cmd/docker-driver/main.go +++ b/cmd/docker-driver/main.go @@ -8,9 +8,10 @@ import ( "github.com/docker/go-plugins-helpers/sdk" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - _ "github.com/grafana/loki/pkg/build" "github.com/prometheus/common/version" "github.com/weaveworks/common/logging" + + _ "github.com/grafana/loki/pkg/build" ) const socketAddress = "/run/docker/plugins/loki.sock" diff --git a/cmd/fluent-bit/config.go b/cmd/fluent-bit/config.go index 11c9d1be34450..9f7d407061f10 100644 --- a/cmd/fluent-bit/config.go +++ b/cmd/fluent-bit/config.go @@ -10,11 +10,12 @@ import ( "time" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/prometheus/common/model" + "github.com/weaveworks/common/logging" + "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/promtail/client" lokiflag "github.com/grafana/loki/pkg/util/flagext" - "github.com/prometheus/common/model" - "github.com/weaveworks/common/logging" ) var defaultClientCfg = client.Config{} diff --git a/cmd/fluent-bit/config_test.go b/cmd/fluent-bit/config_test.go index 7e5af8de1ec94..d297364b8928d 100644 --- a/cmd/fluent-bit/config_test.go +++ b/cmd/fluent-bit/config_test.go @@ -11,9 +11,10 @@ import ( "github.com/prometheus/common/model" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/weaveworks/common/logging" + "github.com/grafana/loki/pkg/promtail/client" lokiflag "github.com/grafana/loki/pkg/util/flagext" - "github.com/weaveworks/common/logging" ) type fakeConfig map[string]string diff --git a/cmd/fluent-bit/loki.go b/cmd/fluent-bit/loki.go index 62afe671009e0..5a3fec1a34745 100644 --- a/cmd/fluent-bit/loki.go +++ b/cmd/fluent-bit/loki.go @@ -10,10 +10,11 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/promtail/client" jsoniter "github.com/json-iterator/go" "github.com/prometheus/common/model" "github.com/weaveworks/common/logging" + + "github.com/grafana/loki/pkg/promtail/client" ) type loki struct { diff --git a/cmd/fluent-bit/out_loki.go b/cmd/fluent-bit/out_loki.go index 1a1aac65e7b96..4d2fc3f383aef 100644 --- a/cmd/fluent-bit/out_loki.go +++ b/cmd/fluent-bit/out_loki.go @@ -9,9 +9,10 @@ import ( "github.com/fluent/fluent-bit-go/output" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - _ "github.com/grafana/loki/pkg/build" "github.com/prometheus/common/version" "github.com/weaveworks/common/logging" + + _ "github.com/grafana/loki/pkg/build" ) var ( diff --git a/cmd/logcli/main.go b/cmd/logcli/main.go index 0a1c336fcf686..104527b6b546a 100644 --- a/cmd/logcli/main.go +++ b/cmd/logcli/main.go @@ -6,13 +6,14 @@ import ( "os" "time" + "github.com/prometheus/common/config" + "github.com/prometheus/common/version" + _ "github.com/grafana/loki/pkg/build" "github.com/grafana/loki/pkg/logcli/client" "github.com/grafana/loki/pkg/logcli/labelquery" "github.com/grafana/loki/pkg/logcli/output" "github.com/grafana/loki/pkg/logcli/query" - "github.com/prometheus/common/config" - "github.com/prometheus/common/version" "gopkg.in/alecthomas/kingpin.v2" ) diff --git a/cmd/loki/main.go b/cmd/loki/main.go index 4107548a9aadb..1f8d0cb3d0899 100644 --- a/cmd/loki/main.go +++ b/cmd/loki/main.go @@ -7,15 +7,17 @@ import ( "reflect" "github.com/go-kit/kit/log/level" - _ "github.com/grafana/loki/pkg/build" - "github.com/grafana/loki/pkg/cfg" - "github.com/grafana/loki/pkg/loki" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/version" "github.com/weaveworks/common/logging" "github.com/weaveworks/common/tracing" + _ "github.com/grafana/loki/pkg/build" + "github.com/grafana/loki/pkg/cfg" + "github.com/grafana/loki/pkg/loki" + "github.com/cortexproject/cortex/pkg/util" + "github.com/grafana/loki/pkg/util/validation" ) diff --git a/pkg/canary/reader/reader.go b/pkg/canary/reader/reader.go index 18a085f3344ae..b439e359b05a8 100644 --- a/pkg/canary/reader/reader.go +++ b/pkg/canary/reader/reader.go @@ -13,12 +13,13 @@ import ( "time" "github.com/gorilla/websocket" - loghttp "github.com/grafana/loki/pkg/loghttp/legacy" - "github.com/grafana/loki/pkg/logproto" json "github.com/json-iterator/go" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + + loghttp "github.com/grafana/loki/pkg/loghttp/legacy" + "github.com/grafana/loki/pkg/logproto" ) var ( diff --git a/pkg/chunkenc/lazy_chunk.go b/pkg/chunkenc/lazy_chunk.go index 2a0bbb852b083..e57cbf21edeb9 100644 --- a/pkg/chunkenc/lazy_chunk.go +++ b/pkg/chunkenc/lazy_chunk.go @@ -6,6 +6,7 @@ import ( "time" "github.com/cortexproject/cortex/pkg/chunk" + "github.com/grafana/loki/pkg/iter" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" diff --git a/pkg/chunkenc/memchunk_test.go b/pkg/chunkenc/memchunk_test.go index 5c283578a19e8..cef1be42ff199 100644 --- a/pkg/chunkenc/memchunk_test.go +++ b/pkg/chunkenc/memchunk_test.go @@ -12,10 +12,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/dustin/go-humanize" + "github.com/stretchr/testify/require" + "github.com/grafana/loki/pkg/chunkenc/testdata" "github.com/grafana/loki/pkg/iter" "github.com/grafana/loki/pkg/logproto" - "github.com/stretchr/testify/require" ) var testEncoding = []Encoding{ diff --git a/pkg/distributor/ingestion_rate_strategy.go b/pkg/distributor/ingestion_rate_strategy.go index e418057970831..8e9ab145b9e37 100644 --- a/pkg/distributor/ingestion_rate_strategy.go +++ b/pkg/distributor/ingestion_rate_strategy.go @@ -2,6 +2,7 @@ package distributor import ( "github.com/cortexproject/cortex/pkg/util/limiter" + "github.com/grafana/loki/pkg/util/validation" ) diff --git a/pkg/distributor/ingestion_rate_strategy_test.go b/pkg/distributor/ingestion_rate_strategy_test.go index 880542f66e6ba..eed80d2232508 100644 --- a/pkg/distributor/ingestion_rate_strategy_test.go +++ b/pkg/distributor/ingestion_rate_strategy_test.go @@ -4,10 +4,11 @@ import ( "testing" "github.com/cortexproject/cortex/pkg/util/limiter" - "github.com/grafana/loki/pkg/util/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/util/validation" ) const ( diff --git a/pkg/distributor/validator.go b/pkg/distributor/validator.go index 9e7510b985136..1b816de4ac2ba 100644 --- a/pkg/distributor/validator.go +++ b/pkg/distributor/validator.go @@ -7,10 +7,11 @@ import ( cortex_client "github.com/cortexproject/cortex/pkg/ingester/client" cortex_validation "github.com/cortexproject/cortex/pkg/util/validation" + "github.com/weaveworks/common/httpgrpc" + "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util/flagext" - "github.com/weaveworks/common/httpgrpc" ) type Validator struct { diff --git a/pkg/ingester/chunk_test.go b/pkg/ingester/chunk_test.go index 0f915a4ed073c..f24533960d8c9 100644 --- a/pkg/ingester/chunk_test.go +++ b/pkg/ingester/chunk_test.go @@ -7,11 +7,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/grafana/loki/pkg/chunkenc" "github.com/grafana/loki/pkg/iter" "github.com/grafana/loki/pkg/logproto" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func testIteratorForward(t *testing.T, iter iter.EntryIterator, from, through int64) { diff --git a/pkg/ingester/client/client.go b/pkg/ingester/client/client.go index 69f400992901d..a69f436585c24 100644 --- a/pkg/ingester/client/client.go +++ b/pkg/ingester/client/client.go @@ -7,12 +7,13 @@ import ( cortex_client "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/util/grpcclient" - "github.com/grafana/loki/pkg/logproto" "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" opentracing "github.com/opentracing/opentracing-go" "github.com/weaveworks/common/middleware" "google.golang.org/grpc" "google.golang.org/grpc/health/grpc_health_v1" + + "github.com/grafana/loki/pkg/logproto" ) // Config for an ingester client. diff --git a/pkg/ingester/flush.go b/pkg/ingester/flush.go index 16f75f22366c6..cc06bfb2632d5 100644 --- a/pkg/ingester/flush.go +++ b/pkg/ingester/flush.go @@ -16,6 +16,7 @@ import ( "github.com/cortexproject/cortex/pkg/chunk" "github.com/cortexproject/cortex/pkg/util" + "github.com/grafana/loki/pkg/chunkenc" loki_util "github.com/grafana/loki/pkg/util" ) diff --git a/pkg/ingester/instance_test.go b/pkg/ingester/instance_test.go index 086fc7d1c322a..9a768d82aa3b5 100644 --- a/pkg/ingester/instance_test.go +++ b/pkg/ingester/instance_test.go @@ -8,9 +8,10 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/util" "github.com/prometheus/prometheus/pkg/labels" + "github.com/grafana/loki/pkg/util" + "github.com/grafana/loki/pkg/chunkenc" "github.com/grafana/loki/pkg/logproto" diff --git a/pkg/ingester/limiter_test.go b/pkg/ingester/limiter_test.go index d03e04388186b..c01a06862824d 100644 --- a/pkg/ingester/limiter_test.go +++ b/pkg/ingester/limiter_test.go @@ -5,9 +5,10 @@ import ( "math" "testing" - "github.com/grafana/loki/pkg/util/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/util/validation" ) func TestLimiter_maxStreamsPerUser(t *testing.T) { diff --git a/pkg/ingester/stream_test.go b/pkg/ingester/stream_test.go index e3f8f8b341858..6f5146d74d35c 100644 --- a/pkg/ingester/stream_test.go +++ b/pkg/ingester/stream_test.go @@ -9,12 +9,13 @@ import ( "testing" "time" - "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/httpgrpc" + + "github.com/grafana/loki/pkg/chunkenc" + "github.com/grafana/loki/pkg/logproto" ) func TestMaxReturnedStreamsErrors(t *testing.T) { diff --git a/pkg/ingester/tailer.go b/pkg/ingester/tailer.go index b0927a2cb73d7..710432f5bba20 100644 --- a/pkg/ingester/tailer.go +++ b/pkg/ingester/tailer.go @@ -8,11 +8,12 @@ import ( cortex_util "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log/level" + "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/pkg/labels" + "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/util" - "github.com/prometheus/common/model" - "github.com/prometheus/prometheus/pkg/labels" ) const bufferSizeForTailResponse = 5 diff --git a/pkg/ingester/tailer_test.go b/pkg/ingester/tailer_test.go index da3adf85e909b..9d3e4643ff917 100644 --- a/pkg/ingester/tailer_test.go +++ b/pkg/ingester/tailer_test.go @@ -6,9 +6,10 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestTailer_sendRaceConditionOnSendWhileClosing(t *testing.T) { diff --git a/pkg/ingester/transfer.go b/pkg/ingester/transfer.go index 38934cdcb6635..36f3e3dd01ff7 100644 --- a/pkg/ingester/transfer.go +++ b/pkg/ingester/transfer.go @@ -10,13 +10,14 @@ import ( "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/helpers" - "github.com/grafana/loki/pkg/logproto" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/weaveworks/common/user" "golang.org/x/net/context" + + "github.com/grafana/loki/pkg/helpers" + "github.com/grafana/loki/pkg/logproto" ) var ( diff --git a/pkg/ingester/transfer_test.go b/pkg/ingester/transfer_test.go index 1ac61f31284cb..817122e8570a6 100644 --- a/pkg/ingester/transfer_test.go +++ b/pkg/ingester/transfer_test.go @@ -18,9 +18,10 @@ import ( "github.com/stretchr/testify/require" "github.com/weaveworks/common/user" + "golang.org/x/net/context" + "github.com/grafana/loki/pkg/ingester/client" "github.com/grafana/loki/pkg/logproto" - "golang.org/x/net/context" ) func TestTransferOut(t *testing.T) { diff --git a/pkg/iter/iterator_test.go b/pkg/iter/iterator_test.go index 698464da5e8f7..756b54932d51c 100644 --- a/pkg/iter/iterator_test.go +++ b/pkg/iter/iterator_test.go @@ -9,8 +9,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/assert" + + "github.com/grafana/loki/pkg/logproto" ) const testSize = 10 diff --git a/pkg/logcli/client/client.go b/pkg/logcli/client/client.go index d8a82643e1993..29c3258d37103 100644 --- a/pkg/logcli/client/client.go +++ b/pkg/logcli/client/client.go @@ -11,11 +11,12 @@ import ( "time" "github.com/gorilla/websocket" + json "github.com/json-iterator/go" + "github.com/prometheus/common/config" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/util" - json "github.com/json-iterator/go" - "github.com/prometheus/common/config" ) const ( diff --git a/pkg/logcli/output/default.go b/pkg/logcli/output/default.go index 959db33d88be9..0a3e1bcb96eae 100644 --- a/pkg/logcli/output/default.go +++ b/pkg/logcli/output/default.go @@ -6,6 +6,7 @@ import ( "time" "github.com/fatih/color" + "github.com/grafana/loki/pkg/loghttp" ) diff --git a/pkg/logcli/output/default_test.go b/pkg/logcli/output/default_test.go index f1591964ee8b1..8cbe5b038dfe2 100644 --- a/pkg/logcli/output/default_test.go +++ b/pkg/logcli/output/default_test.go @@ -5,8 +5,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/loghttp" "github.com/stretchr/testify/assert" + + "github.com/grafana/loki/pkg/loghttp" ) func TestDefaultOutput_Format(t *testing.T) { diff --git a/pkg/logcli/output/jsonl_test.go b/pkg/logcli/output/jsonl_test.go index cfe445b725e03..49de0432a1b15 100644 --- a/pkg/logcli/output/jsonl_test.go +++ b/pkg/logcli/output/jsonl_test.go @@ -5,8 +5,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/loghttp" "github.com/stretchr/testify/assert" + + "github.com/grafana/loki/pkg/loghttp" ) func TestJSONLOutput_Format(t *testing.T) { diff --git a/pkg/logcli/output/raw_test.go b/pkg/logcli/output/raw_test.go index 43f1a317bac96..358fecd0d2dc9 100644 --- a/pkg/logcli/output/raw_test.go +++ b/pkg/logcli/output/raw_test.go @@ -4,8 +4,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/loghttp" "github.com/stretchr/testify/assert" + + "github.com/grafana/loki/pkg/loghttp" ) func TestRawOutput_Format(t *testing.T) { diff --git a/pkg/logcli/query/query.go b/pkg/logcli/query/query.go index cf5fb3c04c6f9..c0ef779b204da 100644 --- a/pkg/logcli/query/query.go +++ b/pkg/logcli/query/query.go @@ -10,14 +10,15 @@ import ( "time" "github.com/fatih/color" + json "github.com/json-iterator/go" + "github.com/prometheus/prometheus/promql" + "github.com/grafana/loki/pkg/logcli/client" "github.com/grafana/loki/pkg/logcli/output" "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/logql/stats" - json "github.com/json-iterator/go" - "github.com/prometheus/prometheus/promql" ) type streamEntryPair struct { diff --git a/pkg/logcli/query/tail.go b/pkg/logcli/query/tail.go index 63f71439ad3c4..ba05a494ba456 100644 --- a/pkg/logcli/query/tail.go +++ b/pkg/logcli/query/tail.go @@ -10,6 +10,7 @@ import ( "github.com/fatih/color" "github.com/gorilla/websocket" + "github.com/grafana/loki/pkg/logcli/client" "github.com/grafana/loki/pkg/logcli/output" "github.com/grafana/loki/pkg/loghttp" diff --git a/pkg/logentry/stages/tenant.go b/pkg/logentry/stages/tenant.go index 2fdf41a64c9e1..010488fc766ec 100644 --- a/pkg/logentry/stages/tenant.go +++ b/pkg/logentry/stages/tenant.go @@ -6,10 +6,11 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/promtail/client" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/promtail/client" ) const ( diff --git a/pkg/logentry/stages/tenant_test.go b/pkg/logentry/stages/tenant_test.go index b07b0ff26ef5e..dec3d9626760d 100644 --- a/pkg/logentry/stages/tenant_test.go +++ b/pkg/logentry/stages/tenant_test.go @@ -8,12 +8,13 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log" - "github.com/grafana/loki/pkg/promtail/client" - lokiutil "github.com/grafana/loki/pkg/util" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/promtail/client" + lokiutil "github.com/grafana/loki/pkg/util" ) var testTenantYaml = ` diff --git a/pkg/logentry/stages/timestamp.go b/pkg/logentry/stages/timestamp.go index 0c652224cc3c1..685aa486fe4c4 100644 --- a/pkg/logentry/stages/timestamp.go +++ b/pkg/logentry/stages/timestamp.go @@ -8,10 +8,11 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/util" lru "github.com/hashicorp/golang-lru" "github.com/mitchellh/mapstructure" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/util" ) const ( diff --git a/pkg/logentry/stages/timestamp_test.go b/pkg/logentry/stages/timestamp_test.go index c58fd4b9067d8..029bfc3952248 100644 --- a/pkg/logentry/stages/timestamp_test.go +++ b/pkg/logentry/stages/timestamp_test.go @@ -9,12 +9,13 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log" - lokiutil "github.com/grafana/loki/pkg/util" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + lokiutil "github.com/grafana/loki/pkg/util" ) var testTimestampYaml = ` diff --git a/pkg/loghttp/labels.go b/pkg/loghttp/labels.go index 688b2ebabe109..a635ffa2723fe 100644 --- a/pkg/loghttp/labels.go +++ b/pkg/loghttp/labels.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/gorilla/mux" + "github.com/grafana/loki/pkg/logproto" ) diff --git a/pkg/loghttp/labels_test.go b/pkg/loghttp/labels_test.go index 760487c01dfd1..c2f0f0315b30b 100644 --- a/pkg/loghttp/labels_test.go +++ b/pkg/loghttp/labels_test.go @@ -7,8 +7,9 @@ import ( "time" "github.com/gorilla/mux" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestParseLabelQuery(t *testing.T) { diff --git a/pkg/loghttp/params_test.go b/pkg/loghttp/params_test.go index 8343668be6284..e8401dd001501 100644 --- a/pkg/loghttp/params_test.go +++ b/pkg/loghttp/params_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/prometheus/prometheus/pkg/labels" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestHttp_defaultQueryRangeStep(t *testing.T) { diff --git a/pkg/loghttp/query.go b/pkg/loghttp/query.go index 66bb773688419..6a87be152bf65 100644 --- a/pkg/loghttp/query.go +++ b/pkg/loghttp/query.go @@ -8,10 +8,11 @@ import ( "time" "unsafe" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql/stats" json "github.com/json-iterator/go" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql/stats" ) var ( diff --git a/pkg/loghttp/query_test.go b/pkg/loghttp/query_test.go index 19bfd8f5bb76a..54495a0b7d680 100644 --- a/pkg/loghttp/query_test.go +++ b/pkg/loghttp/query_test.go @@ -7,8 +7,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestParseRangeQuery(t *testing.T) { diff --git a/pkg/loghttp/series_test.go b/pkg/loghttp/series_test.go index 97b1f00e994ee..885a653c868e2 100644 --- a/pkg/loghttp/series_test.go +++ b/pkg/loghttp/series_test.go @@ -5,8 +5,9 @@ import ( "net/url" "testing" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestParseSeriesQuery(t *testing.T) { diff --git a/pkg/loghttp/tail.go b/pkg/loghttp/tail.go index 22fbe6d80aed0..4fdbae1b0a117 100644 --- a/pkg/loghttp/tail.go +++ b/pkg/loghttp/tail.go @@ -6,8 +6,9 @@ import ( "strconv" "time" - "github.com/grafana/loki/pkg/logproto" json "github.com/json-iterator/go" + + "github.com/grafana/loki/pkg/logproto" ) const ( diff --git a/pkg/loghttp/tail_test.go b/pkg/loghttp/tail_test.go index 3c5aa71aedb2d..f5b2039723699 100644 --- a/pkg/loghttp/tail_test.go +++ b/pkg/loghttp/tail_test.go @@ -6,8 +6,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestParseTailQuery(t *testing.T) { diff --git a/pkg/logql/ast.go b/pkg/logql/ast.go index 162cc068c1294..31900723c8051 100644 --- a/pkg/logql/ast.go +++ b/pkg/logql/ast.go @@ -9,11 +9,12 @@ import ( "strings" "time" - "github.com/grafana/loki/pkg/iter" - "github.com/grafana/loki/pkg/logproto" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" + + "github.com/grafana/loki/pkg/iter" + "github.com/grafana/loki/pkg/logproto" ) // Expr is the root expression which can be a SampleExpr or LogSelectorExpr diff --git a/pkg/logql/engine.go b/pkg/logql/engine.go index cb94254458ae7..e3ee1e0e1fe81 100644 --- a/pkg/logql/engine.go +++ b/pkg/logql/engine.go @@ -8,14 +8,15 @@ import ( "github.com/go-kit/kit/log/level" "github.com/cortexproject/cortex/pkg/util/spanlogger" - "github.com/grafana/loki/pkg/helpers" - "github.com/grafana/loki/pkg/iter" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql/stats" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" + + "github.com/grafana/loki/pkg/helpers" + "github.com/grafana/loki/pkg/iter" + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql/stats" ) var ( diff --git a/pkg/logql/engine_test.go b/pkg/logql/engine_test.go index b226d116c65df..c82245d987562 100644 --- a/pkg/logql/engine_test.go +++ b/pkg/logql/engine_test.go @@ -7,14 +7,15 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/iter" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql/stats" json "github.com/json-iterator/go" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/iter" + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql/stats" ) var testSize = int64(300) diff --git a/pkg/logql/evaluator.go b/pkg/logql/evaluator.go index 2140eda558228..e3f9b2db8e309 100644 --- a/pkg/logql/evaluator.go +++ b/pkg/logql/evaluator.go @@ -7,11 +7,12 @@ import ( "sort" "time" - "github.com/grafana/loki/pkg/iter" - "github.com/grafana/loki/pkg/logproto" "github.com/pkg/errors" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" + + "github.com/grafana/loki/pkg/iter" + "github.com/grafana/loki/pkg/logproto" ) type QueryRangeType string diff --git a/pkg/logql/expr.y.go b/pkg/logql/expr.y.go index 60052c3d7f667..451430fd76a22 100644 --- a/pkg/logql/expr.y.go +++ b/pkg/logql/expr.y.go @@ -2,12 +2,11 @@ package logql -import __yyfmt__ "fmt" - - import ( - "github.com/prometheus/prometheus/pkg/labels" + __yyfmt__ "fmt" "time" + + "github.com/prometheus/prometheus/pkg/labels" ) type exprSymType struct { @@ -128,7 +127,6 @@ const exprEofCode = 1 const exprErrCode = 2 const exprInitialStackSize = 16 - var exprExca = [...]int{ -1, 1, 1, -1, @@ -283,7 +281,6 @@ var exprErrorMessages = [...]struct { msg string }{} - /* parser for yacc output */ var ( diff --git a/pkg/logql/marshal/labels.go b/pkg/logql/marshal/labels.go index 6300d486d2f23..41e16756e1a6f 100644 --- a/pkg/logql/marshal/labels.go +++ b/pkg/logql/marshal/labels.go @@ -1,8 +1,9 @@ package marshal import ( - "github.com/grafana/loki/pkg/loghttp" "github.com/prometheus/prometheus/promql" + + "github.com/grafana/loki/pkg/loghttp" ) // NewLabelSet constructs a Labelset from a promql metric list as a string diff --git a/pkg/logql/marshal/legacy/marshal.go b/pkg/logql/marshal/legacy/marshal.go index 886b21ce3c983..40a0cdf757d7e 100644 --- a/pkg/logql/marshal/legacy/marshal.go +++ b/pkg/logql/marshal/legacy/marshal.go @@ -7,10 +7,11 @@ import ( "io" "github.com/gorilla/websocket" + json "github.com/json-iterator/go" + loghttp "github.com/grafana/loki/pkg/loghttp/legacy" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" - json "github.com/json-iterator/go" ) // Note that the below methods directly marshal the values passed in. This is because these objects currently marshal diff --git a/pkg/logql/marshal/legacy/marshal_test.go b/pkg/logql/marshal/legacy/marshal_test.go index b2a5fc8b158a1..db6c34fc3b99c 100644 --- a/pkg/logql/marshal/legacy/marshal_test.go +++ b/pkg/logql/marshal/legacy/marshal_test.go @@ -6,11 +6,12 @@ import ( "testing" "time" + json "github.com/json-iterator/go" + "github.com/stretchr/testify/require" + loghttp "github.com/grafana/loki/pkg/loghttp/legacy" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" - json "github.com/json-iterator/go" - "github.com/stretchr/testify/require" ) // covers responses from /api/prom/query diff --git a/pkg/logql/marshal/marshal.go b/pkg/logql/marshal/marshal.go index baad9e86484da..7faecbdd23dfd 100644 --- a/pkg/logql/marshal/marshal.go +++ b/pkg/logql/marshal/marshal.go @@ -8,10 +8,11 @@ import ( "github.com/grafana/loki/pkg/logql" "github.com/gorilla/websocket" + json "github.com/json-iterator/go" + "github.com/grafana/loki/pkg/loghttp" legacy "github.com/grafana/loki/pkg/loghttp/legacy" "github.com/grafana/loki/pkg/logproto" - json "github.com/json-iterator/go" ) // WriteQueryResponseJSON marshals the promql.Value to v1 loghttp JSON and then diff --git a/pkg/logql/marshal/marshal_test.go b/pkg/logql/marshal/marshal_test.go index fb26b64192494..e6bee5b4e5f81 100644 --- a/pkg/logql/marshal/marshal_test.go +++ b/pkg/logql/marshal/marshal_test.go @@ -6,14 +6,15 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/loghttp" - legacy "github.com/grafana/loki/pkg/loghttp/legacy" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql" json "github.com/json-iterator/go" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/loghttp" + legacy "github.com/grafana/loki/pkg/loghttp/legacy" + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql" ) // covers responses from /loki/api/v1/query_range and /loki/api/v1/query diff --git a/pkg/logql/marshal/query.go b/pkg/logql/marshal/query.go index 7ec1f70fdb15d..b9bef5765f63b 100644 --- a/pkg/logql/marshal/query.go +++ b/pkg/logql/marshal/query.go @@ -3,12 +3,13 @@ package marshal import ( "fmt" - "github.com/grafana/loki/pkg/loghttp" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" + + "github.com/grafana/loki/pkg/loghttp" + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql" ) // NewResultValue constructs a ResultValue from a promql.Value diff --git a/pkg/logql/metrics.go b/pkg/logql/metrics.go index 86ececb935846..bc61e91a0304b 100644 --- a/pkg/logql/metrics.go +++ b/pkg/logql/metrics.go @@ -3,9 +3,10 @@ package logql import ( "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/logql/stats" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + + "github.com/grafana/loki/pkg/logql/stats" ) const ( diff --git a/pkg/logql/range_vector.go b/pkg/logql/range_vector.go index 63f2725ddc3b2..8aabcf0532c04 100644 --- a/pkg/logql/range_vector.go +++ b/pkg/logql/range_vector.go @@ -3,9 +3,10 @@ package logql import ( "sync" - "github.com/grafana/loki/pkg/iter" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" + + "github.com/grafana/loki/pkg/iter" ) // RangeVectorAggregator aggregates samples for a given range of samples. diff --git a/pkg/logql/range_vector_test.go b/pkg/logql/range_vector_test.go index d7a463375f4e0..980b9ab2352dd 100644 --- a/pkg/logql/range_vector_test.go +++ b/pkg/logql/range_vector_test.go @@ -6,10 +6,11 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/iter" - "github.com/grafana/loki/pkg/logproto" "github.com/prometheus/prometheus/promql" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/iter" + "github.com/grafana/loki/pkg/logproto" ) var entries = []logproto.Entry{ diff --git a/pkg/logql/stats/grpc_test.go b/pkg/logql/stats/grpc_test.go index aad971ed6dfaf..92f68a31cb40b 100644 --- a/pkg/logql/stats/grpc_test.go +++ b/pkg/logql/stats/grpc_test.go @@ -7,10 +7,11 @@ import ( "net" "testing" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/test/bufconn" + + "github.com/grafana/loki/pkg/logproto" ) const bufSize = 1024 * 1024 diff --git a/pkg/logql/unmarshal/legacy/unmarshal.go b/pkg/logql/unmarshal/legacy/unmarshal.go index 70ecd3493813d..0f62b6df04c5f 100644 --- a/pkg/logql/unmarshal/legacy/unmarshal.go +++ b/pkg/logql/unmarshal/legacy/unmarshal.go @@ -3,8 +3,9 @@ package unmarshal import ( "io" - "github.com/grafana/loki/pkg/logproto" json "github.com/json-iterator/go" + + "github.com/grafana/loki/pkg/logproto" ) // DecodePushRequest directly decodes json to a logproto.PushRequest diff --git a/pkg/logql/unmarshal/legacy/unmarshal_test.go b/pkg/logql/unmarshal/legacy/unmarshal_test.go index 00c34a0050688..959e5cddb3e57 100644 --- a/pkg/logql/unmarshal/legacy/unmarshal_test.go +++ b/pkg/logql/unmarshal/legacy/unmarshal_test.go @@ -7,8 +7,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) // covers requests to /api/prom/push diff --git a/pkg/logql/unmarshal/unmarshal.go b/pkg/logql/unmarshal/unmarshal.go index 12597bbea88df..182a57bbfe62e 100644 --- a/pkg/logql/unmarshal/unmarshal.go +++ b/pkg/logql/unmarshal/unmarshal.go @@ -3,9 +3,10 @@ package unmarshal import ( "io" + json "github.com/json-iterator/go" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logproto" - json "github.com/json-iterator/go" ) // DecodePushRequest directly decodes json to a logproto.PushRequest diff --git a/pkg/logql/unmarshal/unmarshal_test.go b/pkg/logql/unmarshal/unmarshal_test.go index 10b67a9865070..13659a517dc6e 100644 --- a/pkg/logql/unmarshal/unmarshal_test.go +++ b/pkg/logql/unmarshal/unmarshal_test.go @@ -6,8 +6,9 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) // covers requests to /loki/api/v1/push diff --git a/pkg/promtail/client/batch.go b/pkg/promtail/client/batch.go index c8424f021b7fd..5e2420911e848 100644 --- a/pkg/promtail/client/batch.go +++ b/pkg/promtail/client/batch.go @@ -5,6 +5,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/golang/snappy" + "github.com/grafana/loki/pkg/logproto" ) diff --git a/pkg/promtail/client/batch_test.go b/pkg/promtail/client/batch_test.go index d08d994b6df8a..d029c6c4c951c 100644 --- a/pkg/promtail/client/batch_test.go +++ b/pkg/promtail/client/batch_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logproto" "github.com/prometheus/common/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/logproto" ) func TestBatch_add(t *testing.T) { diff --git a/pkg/promtail/client/client.go b/pkg/promtail/client/client.go index f9d1c84caed86..8b24324d3cdd1 100644 --- a/pkg/promtail/client/client.go +++ b/pkg/promtail/client/client.go @@ -18,11 +18,12 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/helpers" - "github.com/grafana/loki/pkg/logproto" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/config" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/helpers" + "github.com/grafana/loki/pkg/logproto" ) const ( diff --git a/pkg/promtail/client/client_test.go b/pkg/promtail/client/client_test.go index 9a1ab2627b2cf..439f2ece5be07 100644 --- a/pkg/promtail/client/client_test.go +++ b/pkg/promtail/client/client_test.go @@ -14,12 +14,13 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" - "github.com/grafana/loki/pkg/logproto" - lokiflag "github.com/grafana/loki/pkg/util/flagext" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" "github.com/prometheus/common/config" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/logproto" + lokiflag "github.com/grafana/loki/pkg/util/flagext" ) var ( diff --git a/pkg/promtail/client/config.go b/pkg/promtail/client/config.go index 30351deb1f873..5b7cdf6029172 100644 --- a/pkg/promtail/client/config.go +++ b/pkg/promtail/client/config.go @@ -6,8 +6,9 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" - lokiflag "github.com/grafana/loki/pkg/util/flagext" "github.com/prometheus/common/config" + + lokiflag "github.com/grafana/loki/pkg/util/flagext" ) // Config describes configuration for a HTTP pusher client. diff --git a/pkg/promtail/client/fake/client.go b/pkg/promtail/client/fake/client.go index a195690dead56..b104388912c27 100644 --- a/pkg/promtail/client/fake/client.go +++ b/pkg/promtail/client/fake/client.go @@ -3,8 +3,9 @@ package fake import ( "time" - "github.com/grafana/loki/pkg/promtail/api" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/promtail/api" ) // Client is a fake client used for testing. diff --git a/pkg/promtail/client/multi.go b/pkg/promtail/client/multi.go index 47249948eeb78..b172643b29805 100644 --- a/pkg/promtail/client/multi.go +++ b/pkg/promtail/client/multi.go @@ -5,8 +5,9 @@ import ( "time" "github.com/go-kit/kit/log" - "github.com/grafana/loki/pkg/util" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/util" ) // MultiClient is client pushing to one or more loki instances. diff --git a/pkg/promtail/client/multi_test.go b/pkg/promtail/client/multi_test.go index 383e2921817df..47e6aa698aa28 100644 --- a/pkg/promtail/client/multi_test.go +++ b/pkg/promtail/client/multi_test.go @@ -11,8 +11,9 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" - "github.com/grafana/loki/pkg/promtail/client/fake" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/promtail/client/fake" ) func TestNewMulti(t *testing.T) { diff --git a/pkg/promtail/server/template.go b/pkg/promtail/server/template.go index 15e1280796c2e..03d0b0a87c15a 100644 --- a/pkg/promtail/server/template.go +++ b/pkg/promtail/server/template.go @@ -10,10 +10,11 @@ import ( template_text "text/template" "time" - "github.com/grafana/loki/pkg/promtail/server/ui" "github.com/pkg/errors" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/template" + + "github.com/grafana/loki/pkg/promtail/server/ui" ) // templateOptions is a set of options to render a template. diff --git a/pkg/promtail/server/ui/assets_generate.go b/pkg/promtail/server/ui/assets_generate.go index 57074ef579c15..48412675e0adc 100644 --- a/pkg/promtail/server/ui/assets_generate.go +++ b/pkg/promtail/server/ui/assets_generate.go @@ -6,9 +6,10 @@ import ( "log" "time" - "github.com/grafana/loki/pkg/promtail/server/ui" "github.com/prometheus/prometheus/pkg/modtimevfs" "github.com/shurcooL/vfsgen" + + "github.com/grafana/loki/pkg/promtail/server/ui" ) func main() { diff --git a/pkg/promtail/targets/journaltarget.go b/pkg/promtail/targets/journaltarget.go index 905ff94bc6430..bbaa98af32bed 100644 --- a/pkg/promtail/targets/journaltarget.go +++ b/pkg/promtail/targets/journaltarget.go @@ -18,12 +18,14 @@ import ( "github.com/grafana/loki/pkg/promtail/positions" "github.com/go-kit/kit/log" + "github.com/grafana/loki/pkg/promtail/scrape" "github.com/coreos/go-systemd/sdjournal" - "github.com/grafana/loki/pkg/promtail/api" "github.com/pkg/errors" "github.com/prometheus/common/model" + + "github.com/grafana/loki/pkg/promtail/api" ) const ( diff --git a/pkg/promtail/targets/journaltarget_test.go b/pkg/promtail/targets/journaltarget_test.go index afa5442c9fb1a..873e30d3ded8d 100644 --- a/pkg/promtail/targets/journaltarget_test.go +++ b/pkg/promtail/targets/journaltarget_test.go @@ -19,8 +19,9 @@ import ( "github.com/grafana/loki/pkg/promtail/scrape" "github.com/go-kit/kit/log" - "github.com/grafana/loki/pkg/promtail/positions" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/promtail/positions" ) type mockJournalReader struct { diff --git a/pkg/promtail/targets/journaltargetmanager.go b/pkg/promtail/targets/journaltargetmanager.go index b6f3641ce8cf3..08b689eab9158 100644 --- a/pkg/promtail/targets/journaltargetmanager.go +++ b/pkg/promtail/targets/journaltargetmanager.go @@ -5,6 +5,7 @@ package targets import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/grafana/loki/pkg/promtail/api" "github.com/grafana/loki/pkg/promtail/positions" "github.com/grafana/loki/pkg/promtail/scrape" diff --git a/pkg/promtail/targets/journaltargetmanager_linux.go b/pkg/promtail/targets/journaltargetmanager_linux.go index f4a8e45ee36bd..b6293dfaa3a79 100644 --- a/pkg/promtail/targets/journaltargetmanager_linux.go +++ b/pkg/promtail/targets/journaltargetmanager_linux.go @@ -5,11 +5,12 @@ package targets import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" + "github.com/prometheus/client_golang/prometheus" + "github.com/grafana/loki/pkg/logentry/stages" "github.com/grafana/loki/pkg/promtail/api" "github.com/grafana/loki/pkg/promtail/positions" "github.com/grafana/loki/pkg/promtail/scrape" - "github.com/prometheus/client_golang/prometheus" ) // JournalTargetManager manages a series of JournalTargets. diff --git a/pkg/promtail/targets/stdin_target_manager.go b/pkg/promtail/targets/stdin_target_manager.go index d14a64b12b84b..075a5265fcc29 100644 --- a/pkg/promtail/targets/stdin_target_manager.go +++ b/pkg/promtail/targets/stdin_target_manager.go @@ -12,13 +12,14 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/logentry/stages" - "github.com/grafana/loki/pkg/promtail/api" - "github.com/grafana/loki/pkg/promtail/scrape" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/discovery/config" "github.com/prometheus/prometheus/discovery/targetgroup" + + "github.com/grafana/loki/pkg/logentry/stages" + "github.com/grafana/loki/pkg/promtail/api" + "github.com/grafana/loki/pkg/promtail/scrape" ) // bufferSize is the size of the buffered reader diff --git a/pkg/promtail/targets/stdin_target_manager_test.go b/pkg/promtail/targets/stdin_target_manager_test.go index d4d63cdcdfa2f..7414928ec31d1 100644 --- a/pkg/promtail/targets/stdin_target_manager_test.go +++ b/pkg/promtail/targets/stdin_target_manager_test.go @@ -8,11 +8,12 @@ import ( "testing" "time" - "github.com/grafana/loki/pkg/logentry/stages" - "github.com/grafana/loki/pkg/promtail/scrape" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" + + "github.com/grafana/loki/pkg/logentry/stages" + "github.com/grafana/loki/pkg/promtail/scrape" ) type line struct { diff --git a/pkg/promtail/targets/syslogparser/syslogparser_test.go b/pkg/promtail/targets/syslogparser/syslogparser_test.go index b3b7e4ea1d754..b2360d1bcbdd6 100644 --- a/pkg/promtail/targets/syslogparser/syslogparser_test.go +++ b/pkg/promtail/targets/syslogparser/syslogparser_test.go @@ -5,9 +5,10 @@ import ( "strings" "testing" - "github.com/grafana/loki/pkg/promtail/targets/syslogparser" "github.com/influxdata/go-syslog/v2" "github.com/stretchr/testify/require" + + "github.com/grafana/loki/pkg/promtail/targets/syslogparser" ) func TestParseStream_OctetCounting(t *testing.T) { diff --git a/pkg/querier/querier_mock_test.go b/pkg/querier/querier_mock_test.go index b041df302f4ad..21ed94a1538e0 100644 --- a/pkg/querier/querier_mock_test.go +++ b/pkg/querier/querier_mock_test.go @@ -11,17 +11,18 @@ import ( "github.com/cortexproject/cortex/pkg/chunk" cortex_client "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/ring" - "github.com/grafana/loki/pkg/ingester/client" - "github.com/grafana/loki/pkg/iter" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql" - "github.com/grafana/loki/pkg/util" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/pkg/labels" "google.golang.org/grpc" "google.golang.org/grpc/health/grpc_health_v1" grpc_metadata "google.golang.org/grpc/metadata" + + "github.com/grafana/loki/pkg/ingester/client" + "github.com/grafana/loki/pkg/iter" + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql" + "github.com/grafana/loki/pkg/util" ) // querierClientMock is a mockable version of QuerierClient, used in querier diff --git a/pkg/querier/queryrange/codec.go b/pkg/querier/queryrange/codec.go index 87b4575f1d554..1243ad61af052 100644 --- a/pkg/querier/queryrange/codec.go +++ b/pkg/querier/queryrange/codec.go @@ -14,16 +14,17 @@ import ( "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/querier/queryrange" + json "github.com/json-iterator/go" + "github.com/opentracing/opentracing-go" + otlog "github.com/opentracing/opentracing-go/log" + "github.com/weaveworks/common/httpgrpc" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/logql/marshal" marshal_legacy "github.com/grafana/loki/pkg/logql/marshal/legacy" "github.com/grafana/loki/pkg/logql/stats" - json "github.com/json-iterator/go" - "github.com/opentracing/opentracing-go" - otlog "github.com/opentracing/opentracing-go/log" - "github.com/weaveworks/common/httpgrpc" ) var lokiCodec = &codec{} diff --git a/pkg/querier/queryrange/codec_test.go b/pkg/querier/queryrange/codec_test.go index dfcf244b9a082..91913bbc29595 100644 --- a/pkg/querier/queryrange/codec_test.go +++ b/pkg/querier/queryrange/codec_test.go @@ -12,10 +12,11 @@ import ( "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/cortexproject/cortex/pkg/querier/queryrange" + "github.com/stretchr/testify/require" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql/stats" - "github.com/stretchr/testify/require" ) func init() { diff --git a/pkg/querier/queryrange/prometheus.go b/pkg/querier/queryrange/prometheus.go index e4007defc75a1..293ffe245eeca 100644 --- a/pkg/querier/queryrange/prometheus.go +++ b/pkg/querier/queryrange/prometheus.go @@ -7,10 +7,11 @@ import ( "net/http" "github.com/cortexproject/cortex/pkg/querier/queryrange" - "github.com/grafana/loki/pkg/logql/stats" jsoniter "github.com/json-iterator/go" "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" + + "github.com/grafana/loki/pkg/logql/stats" ) var jsonStd = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/pkg/querier/queryrange/roundtrip.go b/pkg/querier/queryrange/roundtrip.go index cba817903868e..9682f6a1b2e85 100644 --- a/pkg/querier/queryrange/roundtrip.go +++ b/pkg/querier/queryrange/roundtrip.go @@ -10,9 +10,10 @@ import ( "github.com/cortexproject/cortex/pkg/querier/queryrange" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" - "github.com/grafana/loki/pkg/logql" "github.com/prometheus/prometheus/pkg/labels" "github.com/weaveworks/common/httpgrpc" + + "github.com/grafana/loki/pkg/logql" ) // Config is the configuration for the queryrange tripperware diff --git a/pkg/querier/queryrange/roundtrip_test.go b/pkg/querier/queryrange/roundtrip_test.go index 651254ae49836..7bd69f262ad38 100644 --- a/pkg/querier/queryrange/roundtrip_test.go +++ b/pkg/querier/queryrange/roundtrip_test.go @@ -12,14 +12,15 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/querier/queryrange" "github.com/cortexproject/cortex/pkg/util" - "github.com/grafana/loki/pkg/logproto" - "github.com/grafana/loki/pkg/logql" - "github.com/grafana/loki/pkg/logql/marshal" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" "github.com/stretchr/testify/require" "github.com/weaveworks/common/middleware" "github.com/weaveworks/common/user" + + "github.com/grafana/loki/pkg/logproto" + "github.com/grafana/loki/pkg/logql" + "github.com/grafana/loki/pkg/logql/marshal" ) var ( diff --git a/pkg/querier/queryrange/split_by_interval.go b/pkg/querier/queryrange/split_by_interval.go index c6d83c9aee02d..209e32a9ae5f8 100644 --- a/pkg/querier/queryrange/split_by_interval.go +++ b/pkg/querier/queryrange/split_by_interval.go @@ -6,11 +6,12 @@ import ( "time" "github.com/cortexproject/cortex/pkg/querier/queryrange" - "github.com/grafana/loki/pkg/logproto" "github.com/opentracing/opentracing-go" otlog "github.com/opentracing/opentracing-go/log" "github.com/weaveworks/common/httpgrpc" "github.com/weaveworks/common/user" + + "github.com/grafana/loki/pkg/logproto" ) // SplitByIntervalMiddleware creates a new Middleware that splits log requests by a given interval. diff --git a/pkg/querier/queryrange/split_by_interval_test.go b/pkg/querier/queryrange/split_by_interval_test.go index a30faaa054c3f..4a2b7736ed167 100644 --- a/pkg/querier/queryrange/split_by_interval_test.go +++ b/pkg/querier/queryrange/split_by_interval_test.go @@ -9,10 +9,11 @@ import ( "time" "github.com/cortexproject/cortex/pkg/querier/queryrange" - "github.com/grafana/loki/pkg/loghttp" - "github.com/grafana/loki/pkg/logproto" "github.com/stretchr/testify/require" "github.com/weaveworks/common/user" + + "github.com/grafana/loki/pkg/loghttp" + "github.com/grafana/loki/pkg/logproto" ) func Test_splitQuery(t *testing.T) { diff --git a/pkg/querier/queryrange/stats.go b/pkg/querier/queryrange/stats.go index 6273304cce8e7..51d7f94cbcec9 100644 --- a/pkg/querier/queryrange/stats.go +++ b/pkg/querier/queryrange/stats.go @@ -9,6 +9,7 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/spanlogger" "github.com/go-kit/kit/log/level" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/logql/stats" diff --git a/pkg/querier/queryrange/stats_test.go b/pkg/querier/queryrange/stats_test.go index 23227a39cc9d4..61b286fa52ddd 100644 --- a/pkg/querier/queryrange/stats_test.go +++ b/pkg/querier/queryrange/stats_test.go @@ -7,10 +7,11 @@ import ( "time" "github.com/cortexproject/cortex/pkg/querier/queryrange" + "github.com/stretchr/testify/require" + "github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/logql/stats" - "github.com/stretchr/testify/require" ) func TestStatsMiddleware(t *testing.T) { diff --git a/pkg/querier/tail.go b/pkg/querier/tail.go index e3eba5a15533e..73f8e4576a584 100644 --- a/pkg/querier/tail.go +++ b/pkg/querier/tail.go @@ -7,10 +7,11 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/go-kit/kit/log/level" + "github.com/pkg/errors" + "github.com/grafana/loki/pkg/iter" loghttp "github.com/grafana/loki/pkg/loghttp/legacy" "github.com/grafana/loki/pkg/logproto" - "github.com/pkg/errors" ) const ( diff --git a/pkg/querier/tail_test.go b/pkg/querier/tail_test.go index f84f2a8513274..14b38be653f0e 100644 --- a/pkg/querier/tail_test.go +++ b/pkg/querier/tail_test.go @@ -5,11 +5,12 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/grafana/loki/pkg/iter" loghttp "github.com/grafana/loki/pkg/loghttp/legacy" "github.com/grafana/loki/pkg/logproto" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) const ( diff --git a/pkg/storage/iterator_test.go b/pkg/storage/iterator_test.go index 38c761adbf243..2a42251b50f39 100644 --- a/pkg/storage/iterator_test.go +++ b/pkg/storage/iterator_test.go @@ -6,11 +6,12 @@ import ( "testing" "time" + "github.com/prometheus/prometheus/pkg/labels" + "github.com/stretchr/testify/require" + "github.com/grafana/loki/pkg/chunkenc" "github.com/grafana/loki/pkg/iter" "github.com/grafana/loki/pkg/logproto" - "github.com/prometheus/prometheus/pkg/labels" - "github.com/stretchr/testify/require" ) func Test_newBatchChunkIterator(t *testing.T) { diff --git a/pkg/storage/util_test.go b/pkg/storage/util_test.go index 57d9f974488de..0619148e1a1e1 100644 --- a/pkg/storage/util_test.go +++ b/pkg/storage/util_test.go @@ -10,13 +10,14 @@ import ( "github.com/cortexproject/cortex/pkg/chunk/cache" "github.com/cortexproject/cortex/pkg/ingester/client" "github.com/davecgh/go-spew/spew" + "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/pkg/labels" + "github.com/stretchr/testify/assert" + "github.com/grafana/loki/pkg/chunkenc" "github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/util" - "github.com/prometheus/common/model" - "github.com/prometheus/prometheus/pkg/labels" - "github.com/stretchr/testify/assert" ) var fooLabelsWithName = "{foo=\"bar\", __name__=\"log\"}" diff --git a/pkg/util/conv.go b/pkg/util/conv.go index 40eb756115ac5..5938d4398302c 100644 --- a/pkg/util/conv.go +++ b/pkg/util/conv.go @@ -7,9 +7,10 @@ import ( "time" "github.com/cortexproject/cortex/pkg/ingester/client" - "github.com/grafana/loki/pkg/logql" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/pkg/labels" + + "github.com/grafana/loki/pkg/logql" ) type byLabel []client.LabelAdapter