Chore: Add pkg/util/log package (#5187)

* Chore: Add pkg/util/log package

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Add changelog entry

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix documentation of loki_log_messages_total

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
pull/5202/head
Arve Knudsen 4 years ago committed by GitHub
parent 7fca88debd
commit a2dd731586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 3
      clients/cmd/docker-driver/config_test.go
  3. 3
      clients/cmd/docker-driver/loki_test.go
  4. 2
      clients/cmd/docker-driver/main.go
  5. 12
      clients/cmd/promtail/main.go
  6. 5
      clients/pkg/logentry/stages/drop_test.go
  7. 3
      clients/pkg/logentry/stages/extensions_test.go
  8. 3
      clients/pkg/logentry/stages/json_test.go
  9. 5
      clients/pkg/logentry/stages/labelallow_test.go
  10. 5
      clients/pkg/logentry/stages/labeldrop_test.go
  11. 3
      clients/pkg/logentry/stages/labels_test.go
  12. 3
      clients/pkg/logentry/stages/logfmt_test.go
  13. 3
      clients/pkg/logentry/stages/match_test.go
  14. 3
      clients/pkg/logentry/stages/metrics_test.go
  15. 8
      clients/pkg/logentry/stages/multiline_test.go
  16. 3
      clients/pkg/logentry/stages/output_test.go
  17. 4
      clients/pkg/logentry/stages/pack_test.go
  18. 2
      clients/pkg/logentry/stages/pipeline_test.go
  19. 3
      clients/pkg/logentry/stages/regex_test.go
  20. 3
      clients/pkg/logentry/stages/replace_test.go
  21. 3
      clients/pkg/logentry/stages/static_labels_test.go
  22. 3
      clients/pkg/logentry/stages/template_test.go
  23. 2
      clients/pkg/logentry/stages/tenant_test.go
  24. 2
      clients/pkg/logentry/stages/timestamp_test.go
  25. 2
      clients/pkg/promtail/client/logger_test.go
  26. 8
      clients/pkg/promtail/client/multi_test.go
  27. 3
      clients/pkg/promtail/positions/positions_test.go
  28. 5
      clients/pkg/promtail/promtail.go
  29. 10
      clients/pkg/promtail/promtail_test.go
  30. 11
      clients/pkg/promtail/targets/lokipush/pushtarget.go
  31. 4
      clients/pkg/promtail/targets/lokipush/pushtarget_test.go
  32. 2
      clients/pkg/promtail/targets/lokipush/pushtargetmanager.go
  33. 2
      clients/pkg/promtail/targets/stdin/stdin_target_manager_test.go
  34. 3
      clients/pkg/promtail/targets/windows/target.go
  35. 4
      clients/pkg/promtail/targets/windows/target_test.go
  36. 3
      clients/pkg/promtail/targets/windows/win_eventlog/win_eventlog.go
  37. 16
      cmd/loki/main.go
  38. 2
      cmd/migrate/main.go
  39. 4
      cmd/querytee/main.go
  40. 2
      cmd/querytee/response_comparator.go
  41. 2
      docs/sources/operations/observability.md
  42. 5
      pkg/chunkenc/memchunk.go
  43. 2
      pkg/distributor/distributor.go
  44. 2
      pkg/distributor/distributor_ring.go
  45. 2
      pkg/distributor/http.go
  46. 2
      pkg/ingester/checkpoint.go
  47. 8
      pkg/ingester/flush.go
  48. 3
      pkg/ingester/flush_test.go
  49. 5
      pkg/ingester/ingester.go
  50. 3
      pkg/ingester/ingester_test.go
  51. 5
      pkg/ingester/instance.go
  52. 6
      pkg/ingester/mapper.go
  53. 2
      pkg/ingester/recovery.go
  54. 3
      pkg/ingester/replay_controller.go
  55. 2
      pkg/ingester/stream.go
  56. 2
      pkg/ingester/tailer.go
  57. 2
      pkg/ingester/transfer.go
  58. 2
      pkg/ingester/transfer_test.go
  59. 2
      pkg/ingester/wal.go
  60. 3
      pkg/logcli/client/file.go
  61. 4
      pkg/logcli/query/query.go
  62. 65
      pkg/logcli/query/query_test.go
  63. 3
      pkg/loghttp/push/push_test.go
  64. 16
      pkg/logql/engine.go
  65. 15
      pkg/logql/engine_test.go
  66. 2
      pkg/logql/metrics.go
  67. 2
      pkg/logql/metrics_test.go
  68. 8
      pkg/logql/sharding.go
  69. 5
      pkg/logql/sharding_test.go
  70. 2
      pkg/logql/shardmapper.go
  71. 3
      pkg/logqlmodel/stats/context_test.go
  72. 2
      pkg/loki/loki.go
  73. 9
      pkg/loki/modules.go
  74. 2
      pkg/loki/runtime_config.go
  75. 2
      pkg/lokifrontend/frontend/transport/handler.go
  76. 2
      pkg/querier/astmapper/parallel.go
  77. 5
      pkg/querier/http.go
  78. 2
      pkg/querier/ingester_querier.go
  79. 11
      pkg/querier/querier.go
  80. 2
      pkg/querier/queryrange/limits_test.go
  81. 2
      pkg/querier/queryrange/queryrangebase/results_cache.go
  82. 2
      pkg/querier/queryrange/queryrangebase/retry.go
  83. 5
      pkg/querier/queryrange/querysharding.go
  84. 2
      pkg/querier/queryrange/roundtrip_test.go
  85. 2
      pkg/querier/tail.go
  86. 2
      pkg/querier/worker/scheduler_processor.go
  87. 2
      pkg/querier/worker_service.go
  88. 2
      pkg/ruler/base/api.go
  89. 2
      pkg/ruler/base/compat.go
  90. 9
      pkg/ruler/base/ruler.go
  91. 3
      pkg/ruler/compat_test.go
  92. 3
      pkg/ruler/storage/instance/manager.go
  93. 3
      pkg/scheduler/scheduler.go
  94. 6
      pkg/scheduler/scheduler_test.go
  95. 2
      pkg/storage/async_store.go
  96. 2
      pkg/storage/batch.go
  97. 2
      pkg/storage/chunk/aws/dynamodb_storage_client.go
  98. 2
      pkg/storage/chunk/aws/dynamodb_table_client.go
  99. 3
      pkg/storage/chunk/aws/metrics_autoscaling.go
  100. 2
      pkg/storage/chunk/aws/mock.go
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,5 +1,6 @@
## Main
* [5187](https://github.com/grafana/loki/pull/5187) **aknuds1** Rename metric `cortex_experimental_features_in_use_total` to `loki_experimental_features_in_use_total` and metric `log_messages_total` to `loki_log_messages_total`.
* [5170](https://github.com/grafana/loki/pull/5170) **chaudum** Fix deadlock in Promtail caused when targets got removed from a target group by the discovery manager.
* [5163](https://github.com/grafana/loki/pull/5163) **chaudum** Fix regression in fluentd plugin introduced with #5107 that caused `NoMethodError` when parsing non-string values of log lines.
* [5144](https://github.com/grafana/loki/pull/5144) **dannykopping** Ruler: fix remote write basic auth credentials.

@ -7,13 +7,14 @@ import (
"reflect"
"testing"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/docker/docker/daemon/logger"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/clients/pkg/logentry/stages"
util_log "github.com/grafana/loki/pkg/util/log"
)
var jobRename = `

@ -4,9 +4,10 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/docker/docker/daemon/logger"
"github.com/stretchr/testify/require"
util_log "github.com/grafana/loki/pkg/util/log"
)
func Test_loki_LogWhenClosed(t *testing.T) {

@ -6,7 +6,6 @@ import (
_ "net/http/pprof"
"os"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/docker/go-plugins-helpers/sdk"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
@ -15,6 +14,7 @@ import (
"github.com/grafana/loki/pkg/util"
_ "github.com/grafana/loki/pkg/util/build"
util_log "github.com/grafana/loki/pkg/util/log"
)
const socketAddress = "/run/docker/plugins/loki.sock"

@ -11,7 +11,6 @@ import (
"k8s.io/klog"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
"github.com/prometheus/client_golang/prometheus"
@ -22,9 +21,10 @@ import (
"github.com/grafana/loki/clients/pkg/promtail"
"github.com/grafana/loki/clients/pkg/promtail/config"
logutil "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util"
_ "github.com/grafana/loki/pkg/util/build"
"github.com/grafana/loki/pkg/util/cfg"
util_log "github.com/grafana/loki/pkg/util/log"
)
func init() {
@ -81,7 +81,7 @@ func main() {
fmt.Println("Invalid log level")
os.Exit(1)
}
util_log.InitLogger(&config.ServerConfig.Config)
util_log.InitLogger(&config.ServerConfig.Config, prometheus.DefaultRegisterer)
// Use Stderr instead of files for the klog.
klog.SetOutput(os.Stderr)
@ -97,20 +97,20 @@ func main() {
}
if config.printConfig {
err := logutil.PrintConfig(os.Stderr, &config)
err := util.PrintConfig(os.Stderr, &config)
if err != nil {
level.Error(util_log.Logger).Log("msg", "failed to print config to stderr", "err", err.Error())
}
}
if config.logConfig {
err := logutil.LogConfig(&config)
err := util.LogConfig(&config)
if err != nil {
level.Error(util_log.Logger).Log("msg", "failed to log config object", "err", err.Error())
}
}
p, err := promtail.New(config.Config, config.dryRun)
p, err := promtail.New(config.Config, config.dryRun, prometheus.DefaultRegisterer)
if err != nil {
level.Error(util_log.Logger).Log("msg", "error creating promtail", "error", err)
os.Exit(1)

@ -6,12 +6,13 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"
util_log "github.com/grafana/loki/pkg/util/log"
)
// Not all these are tested but are here to make sure the different types marshal without error
@ -39,7 +40,7 @@ func Test_dropStage_Process(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
tests := []struct {

@ -4,9 +4,10 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -5,11 +5,12 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testJSONYamlSingleStageWithoutSource = `

@ -4,18 +4,19 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"
util_log "github.com/grafana/loki/pkg/util/log"
)
func Test_addLabelStage_Process(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
tests := []struct {

@ -4,18 +4,19 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"
util_log "github.com/grafana/loki/pkg/util/log"
)
func Test_dropLabelStage_Process(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
tests := []struct {

@ -8,11 +8,12 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testLabelsYaml = `

@ -4,11 +4,12 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testLogfmtYamlSingleStageWithoutSource = `

@ -5,9 +5,10 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testMatchYaml = `

@ -6,7 +6,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -15,6 +14,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/grafana/loki/clients/pkg/logentry/metric"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testMetricYaml = `

@ -6,7 +6,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
ww "github.com/weaveworks/common/server"
@ -14,13 +13,14 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
func Test_multilineStage_Process(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
mcfg := &MultilineConfig{Expression: ptrFromString("^START"), MaxWaitTime: ptrFromString("3s")}
@ -52,7 +52,7 @@ func Test_multilineStage_MultiStreams(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
mcfg := &MultilineConfig{Expression: ptrFromString("^START"), MaxWaitTime: ptrFromString("3s")}
@ -97,7 +97,7 @@ func Test_multilineStage_MaxWaitTime(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
maxWait := 2 * time.Second

@ -6,11 +6,12 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testOutputYaml = `

@ -4,7 +4,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
json "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
@ -16,6 +15,7 @@ import (
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logqlmodel"
util_log "github.com/grafana/loki/pkg/util/log"
)
// Not all these are tested but are here to make sure the different types marshal without error
@ -105,7 +105,7 @@ func Test_packStage_Run(t *testing.T) {
// Enable debug logging
cfg := &ww.Config{}
require.Nil(t, cfg.LogLevel.Set("debug"))
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
Debug = true
tests := []struct {

@ -6,7 +6,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
@ -19,6 +18,7 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/client/fake"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -7,13 +7,14 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testRegexYamlSingleStageWithoutSource = `

@ -5,11 +5,12 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testReplaceYamlSingleStageWithoutSource = `

@ -4,9 +4,10 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
func Test_staticLabelStage_Process(t *testing.T) {

@ -7,11 +7,12 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testTemplateYaml = `

@ -6,7 +6,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
@ -16,6 +15,7 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/client"
lokiutil "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testTenantYaml = `

@ -7,7 +7,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -16,6 +15,7 @@ import (
"github.com/stretchr/testify/require"
lokiutil "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
)
var testTimestampYaml = `

@ -5,7 +5,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
cortexflag "github.com/grafana/dskit/flagext"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
@ -13,6 +12,7 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
func TestNewLogger(t *testing.T) {

@ -6,7 +6,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/flagext"
@ -14,11 +13,12 @@ import (
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
"github.com/grafana/loki/clients/pkg/promtail/api"
"github.com/grafana/loki/clients/pkg/promtail/client/fake"
"github.com/grafana/loki/pkg/logproto"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
util_log "github.com/grafana/loki/pkg/util/log"
)
func TestNewMulti(t *testing.T) {

@ -7,9 +7,10 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/stretchr/testify/require"
util_log "github.com/grafana/loki/pkg/util/log"
)
func tempFilename(t *testing.T) string {

@ -3,7 +3,6 @@ package promtail
import (
"sync"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/grafana/loki/clients/pkg/logentry/stages"
"github.com/prometheus/client_golang/prometheus"
@ -12,6 +11,8 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/config"
"github.com/grafana/loki/clients/pkg/promtail/server"
"github.com/grafana/loki/clients/pkg/promtail/targets"
util_log "github.com/grafana/loki/pkg/util/log"
)
// Option is a function that can be passed to the New method of Promtail and
@ -45,7 +46,7 @@ type Promtail struct {
}
// New makes a new Promtail.
func New(cfg config.Config, dryRun bool, opts ...Option) (*Promtail, error) {
func New(cfg config.Config, dryRun bool, reg prometheus.Registerer, opts ...Option) (*Promtail, error) {
// Initialize promtail with some defaults and allow the options to override
// them.
promtail := &Promtail{

@ -16,7 +16,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
@ -41,6 +40,7 @@ import (
file2 "github.com/grafana/loki/clients/pkg/promtail/targets/file"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
const httpTestPort = 9080
@ -103,7 +103,7 @@ func TestPromtail(t *testing.T) {
}()
// Run.
p, err := New(buildTestConfig(t, positionsFileName, testDir), false)
p, err := New(buildTestConfig(t, positionsFileName, testDir), false, nil)
if err != nil {
t.Error("error creating promtail", err)
return
@ -646,7 +646,7 @@ func Test_DryRun(t *testing.T) {
require.NoError(t, err)
defer os.Remove(f.Name())
_, err = New(config.Config{}, true)
_, err = New(config.Config{}, true, nil)
require.Error(t, err)
// Set the minimum config needed to start a server. We need to do this since we
@ -668,7 +668,7 @@ func Test_DryRun(t *testing.T) {
PositionsFile: f.Name(),
SyncPeriod: time.Second,
},
}, true)
}, true, nil)
require.NoError(t, err)
prometheus.DefaultRegisterer = prometheus.NewRegistry()
@ -680,7 +680,7 @@ func Test_DryRun(t *testing.T) {
PositionsFile: f.Name(),
SyncPeriod: time.Second,
},
}, false)
}, false, nil)
require.NoError(t, err)
require.IsType(t, &client.MultiClient{}, p.client)
}

@ -9,10 +9,10 @@ import (
"strings"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/imdario/mergo"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/relabel"
@ -27,6 +27,7 @@ import (
"github.com/grafana/loki/pkg/loghttp/push"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
type PushTarget struct {
@ -36,13 +37,16 @@ type PushTarget struct {
relabelConfig []*relabel.Config
jobName string
server *server.Server
registerer prometheus.Registerer
}
func NewPushTarget(logger log.Logger,
handler api.EntryHandler,
relabel []*relabel.Config,
jobName string,
config *scrapeconfig.PushTargetConfig) (*PushTarget, error) {
config *scrapeconfig.PushTargetConfig,
reg prometheus.Registerer,
) (*PushTarget, error) {
pt := &PushTarget{
logger: logger,
@ -50,6 +54,7 @@ func NewPushTarget(logger log.Logger,
relabelConfig: relabel,
jobName: jobName,
config: config,
registerer: reg,
}
// Bit of a chicken and egg problem trying to register the defaults and apply overrides from the loaded config.
@ -87,7 +92,7 @@ func (t *PushTarget) run() error {
// We don't want the /debug and /metrics endpoints running
t.config.Server.RegisterInstrumentation = false
util_log.InitLogger(&t.config.Server)
util_log.InitLogger(&t.config.Server, t.registerer)
srv, err := server.New(t.config.Server)
if err != nil {

@ -70,7 +70,7 @@ func TestLokiPushTarget(t *testing.T) {
},
}
pt, err := NewPushTarget(logger, eh, rlbl, "job1", config)
pt, err := NewPushTarget(logger, eh, rlbl, "job1", config, nil)
require.NoError(t, err)
// Build a client to send logs
@ -162,7 +162,7 @@ func TestPlaintextPushTarget(t *testing.T) {
KeepTimestamp: true,
}
pt, err := NewPushTarget(logger, eh, []*relabel.Config{}, "job2", config)
pt, err := NewPushTarget(logger, eh, []*relabel.Config{}, "job2", config, nil)
require.NoError(t, err)
// Send some logs

@ -44,7 +44,7 @@ func NewPushTargetManager(
return nil, err
}
t, err := NewPushTarget(logger, pipeline.Wrap(client), cfg.RelabelConfigs, cfg.JobName, cfg.PushConfig)
t, err := NewPushTarget(logger, pipeline.Wrap(client), cfg.RelabelConfigs, cfg.JobName, cfg.PushConfig, reg)
if err != nil {
return nil, err
}

@ -7,7 +7,6 @@ import (
"strings"
"testing"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
@ -19,6 +18,7 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/scrapeconfig"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
func Test_newReaderTarget(t *testing.T) {

@ -9,7 +9,6 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/common/model"
@ -23,6 +22,8 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/scrapeconfig"
"github.com/grafana/loki/clients/pkg/promtail/targets/target"
"github.com/grafana/loki/clients/pkg/promtail/targets/windows/win_eventlog"
util_log "github.com/grafana/loki/pkg/util/log"
)
var fs = afero.NewOsFs()

@ -7,7 +7,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"
"github.com/spf13/afero"
@ -21,6 +20,7 @@ import (
"github.com/grafana/loki/clients/pkg/promtail/targets/windows/win_eventlog"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
func init() {
@ -28,7 +28,7 @@ func init() {
// Enable debug logging
cfg := &server.Config{}
_ = cfg.LogLevel.Set("debug")
util_log.InitLogger(cfg)
util_log.InitLogger(cfg, nil)
}
// Test that you can use to generate event logs locally.

@ -33,11 +33,12 @@ import (
"strings"
"syscall"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
"golang.org/x/sys/windows"
util_log "github.com/grafana/loki/pkg/util/log"
)
var sampleConfig = `

@ -8,17 +8,17 @@ import (
"runtime"
"github.com/go-kit/log/level"
"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/loki"
logutil "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util"
_ "github.com/grafana/loki/pkg/util/build"
"github.com/grafana/loki/pkg/util/cfg"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
util_log "github.com/cortexproject/cortex/pkg/util/log"
)
func main() {
@ -43,7 +43,7 @@ func main() {
level.Error(util_log.Logger).Log("msg", "invalid log level")
os.Exit(1)
}
util_log.InitLogger(&config.Server)
util_log.InitLogger(&config.Server, prometheus.DefaultRegisterer)
// Validate the config once both the config file has been loaded
// and CLI flags parsed.
@ -54,14 +54,14 @@ func main() {
}
if config.PrintConfig {
err := logutil.PrintConfig(os.Stderr, &config)
err := util.PrintConfig(os.Stderr, &config)
if err != nil {
level.Error(util_log.Logger).Log("msg", "failed to print config to stderr", "err", err.Error())
}
}
if config.LogConfig {
err := logutil.LogConfig(&config)
err := util.LogConfig(&config)
if err != nil {
level.Error(util_log.Logger).Log("msg", "failed to log config object", "err", err.Error())
}
@ -96,7 +96,7 @@ func main() {
// Start Loki
t, err := loki.New(config.Config)
util_log.CheckFatal("initialising loki", err)
util_log.CheckFatal("initialising loki", err, util_log.Logger)
if config.ListTargets {
t.ListTargets()
@ -106,5 +106,5 @@ func main() {
level.Info(util_log.Logger).Log("msg", "Starting Loki", "version", version.Info())
err = t.Run(loki.RunOpts{})
util_log.CheckFatal("running loki", err)
util_log.CheckFatal("running loki", err, util_log.Logger)
}

@ -12,7 +12,6 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
@ -28,6 +27,7 @@ import (
chunk_storage "github.com/grafana/loki/pkg/storage/chunk/storage"
"github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/cfg"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
)

@ -4,7 +4,6 @@ import (
"flag"
"os"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
@ -12,6 +11,7 @@ import (
"github.com/weaveworks/common/server"
"github.com/grafana/loki/pkg/loghttp"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/tools/querytee"
)
@ -31,7 +31,7 @@ func main() {
util_log.InitLogger(&server.Config{
LogLevel: cfg.LogLevel,
})
}, prometheus.DefaultRegisterer)
// Run the instrumentation server.
registry := prometheus.NewRegistry()

@ -4,11 +4,11 @@ import (
"encoding/json"
"fmt"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
jsoniter "github.com/json-iterator/go"
"github.com/grafana/loki/pkg/loghttp"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/tools/querytee"
)

@ -14,7 +14,7 @@ All components of Loki expose the following metrics:
| Metric Name | Metric Type | Description |
| ------------------------------- | ----------- | ---------------------------------------- |
| `log_messages_total` | Counter | Total number of messages logged by Loki. |
| `loki_log_messages_total` | Counter | Total number of messages logged by Loki. |
| `loki_request_duration_seconds` | Histogram | Number of received HTTP requests. |
The Loki Distributors expose the following metrics:

@ -14,17 +14,16 @@ import (
"unsafe"
"github.com/cespare/xxhash/v2"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/prometheus/model/labels"
"github.com/grafana/loki/pkg/storage/chunk/encoding"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/log"
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/storage/chunk/encoding"
util_log "github.com/grafana/loki/pkg/util/log"
)
const (

@ -6,7 +6,6 @@ import (
"net/http"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/limiter"
"github.com/grafana/dskit/ring"
@ -30,6 +29,7 @@ import (
"github.com/grafana/loki/pkg/storage/stores/shipper/compactor/retention"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
)

@ -10,7 +10,7 @@ import (
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/ring"
util_log "github.com/cortexproject/cortex/pkg/util/log"
util_log "github.com/grafana/loki/pkg/util/log"
)
// RingConfig masks the ring lifecycler config which contains

@ -4,7 +4,6 @@ import (
"net/http"
"strings"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/weaveworks/common/httpgrpc"
@ -12,6 +11,7 @@ import (
"github.com/grafana/loki/pkg/loghttp/push"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
serverutil "github.com/grafana/loki/pkg/util/server"
"github.com/grafana/loki/pkg/validation"
)

@ -12,7 +12,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/dustin/go-humanize"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
@ -24,6 +23,7 @@ import (
prompool "github.com/prometheus/prometheus/util/pool"
"github.com/grafana/loki/pkg/chunkenc"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/pool"
)

@ -9,6 +9,7 @@ import (
"golang.org/x/net/context"
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
@ -16,14 +17,11 @@ import (
"github.com/prometheus/prometheus/model/labels"
"github.com/weaveworks/common/user"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/tenant"
loki_util "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -21,8 +21,6 @@ import (
"github.com/weaveworks/common/user"
"golang.org/x/net/context"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/iter"
@ -32,6 +30,7 @@ import (
"github.com/grafana/loki/pkg/runtime"
"github.com/grafana/loki/pkg/storage"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/validation"
)

@ -11,7 +11,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/ring"
"github.com/grafana/dskit/services"
@ -22,8 +21,6 @@ import (
"github.com/prometheus/prometheus/model/labels"
"google.golang.org/grpc/health/grpc_health_v1"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/ingester/index"
@ -35,7 +32,9 @@ import (
"github.com/grafana/loki/pkg/storage"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/storage/stores/shipper"
"github.com/grafana/loki/pkg/tenant"
errUtil "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
)

@ -18,8 +18,6 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/ingester/index"
@ -29,6 +27,7 @@ import (
"github.com/grafana/loki/pkg/runtime"
"github.com/grafana/loki/pkg/storage"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/validation"
)

@ -8,6 +8,7 @@ import (
"syscall"
"github.com/cortexproject/cortex/pkg/cortexpb"
cutil "github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -19,9 +20,6 @@ import (
"github.com/weaveworks/common/httpgrpc"
"go.uber.org/atomic"
cutil "github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/grafana/loki/pkg/ingester/index"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
@ -30,6 +28,7 @@ import (
"github.com/grafana/loki/pkg/querier/astmapper"
"github.com/grafana/loki/pkg/runtime"
"github.com/grafana/loki/pkg/storage"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/math"
"github.com/grafana/loki/pkg/validation"
)

@ -6,12 +6,12 @@ import (
"strings"
"sync"
"github.com/prometheus/prometheus/model/labels"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"go.uber.org/atomic"
util_log "github.com/grafana/loki/pkg/util/log"
)
const maxMappedFP = 1 << 20 // About 1M fingerprints reserved for mapping.

@ -6,7 +6,6 @@ import (
"sync"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/prometheus/tsdb/chunks"
@ -15,6 +14,7 @@ import (
"golang.org/x/net/context"
"github.com/grafana/loki/pkg/logproto"
util_log "github.com/grafana/loki/pkg/util/log"
)
type WALReader interface {

@ -3,10 +3,11 @@ package ingester
import (
"sync"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/dustin/go-humanize"
"github.com/go-kit/log/level"
"go.uber.org/atomic"
util_log "github.com/grafana/loki/pkg/util/log"
)
type replayFlusher struct {

@ -8,7 +8,6 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -22,6 +21,7 @@ import (
"github.com/grafana/loki/pkg/logql/log"
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/util/flagext"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
)

@ -6,7 +6,6 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/prometheus/prometheus/model/labels"
"golang.org/x/net/context"
@ -15,6 +14,7 @@ import (
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/log"
"github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
)
const bufferSizeForTailResponse = 5

@ -6,7 +6,6 @@ import (
"os"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/ring"
@ -19,6 +18,7 @@ import (
"github.com/grafana/loki/pkg/logproto"
lokiutil "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -8,7 +8,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
gokitlog "github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/kv"
@ -24,6 +23,7 @@ import (
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/log"
util_log "github.com/grafana/loki/pkg/util/log"
)
func TestTransferOut(t *testing.T) {

@ -5,7 +5,6 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -13,6 +12,7 @@ import (
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/util/flagext"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -17,6 +17,7 @@ import (
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
logqllog "github.com/grafana/loki/pkg/logql/log"
"github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/marshal"
"github.com/prometheus/prometheus/model/labels"
@ -54,7 +55,7 @@ func NewFileClient(r io.ReadCloser) *FileClient {
},
}
eng := logql.NewEngine(logql.EngineOpts{}, &querier{r: r, labels: lbs}, &limiter{n: defaultMetricSeriesLimit})
eng := logql.NewEngine(logql.EngineOpts{}, &querier{r: r, labels: lbs}, &limiter{n: defaultMetricSeriesLimit}, log.Logger)
return &FileClient{
r: r,
orgID: defaultOrgID,

@ -12,7 +12,6 @@ import (
"text/tabwriter"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/fatih/color"
json "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
@ -30,6 +29,7 @@ import (
chunk_storage "github.com/grafana/loki/pkg/storage/chunk/storage"
"github.com/grafana/loki/pkg/storage/stores/shipper"
"github.com/grafana/loki/pkg/util/cfg"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/marshal"
"github.com/grafana/loki/pkg/validation"
)
@ -201,7 +201,7 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
return err
}
eng := logql.NewEngine(conf.Querier.Engine, querier, limits)
eng := logql.NewEngine(conf.Querier.Engine, querier, limits, util_log.Logger)
var query logql.Query
if q.isInstant() {

@ -3,14 +3,15 @@ package query
import (
"bytes"
"context"
"log"
"reflect"
"strings"
"testing"
"time"
"github.com/go-kit/log"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logcli/output"
"github.com/grafana/loki/pkg/loghttp"
@ -31,35 +32,35 @@ func Test_commonLabels(t *testing.T) {
{
"Extract common labels source > target",
args{
[]loghttp.LabelSet{mustParseLabels(`{foo="bar", bar="foo"}`), mustParseLabels(`{bar="foo", foo="foo", baz="baz"}`)},
[]loghttp.LabelSet{mustParseLabels(t, `{foo="bar", bar="foo"}`), mustParseLabels(t, `{bar="foo", foo="foo", baz="baz"}`)},
},
mustParseLabels(`{bar="foo"}`),
mustParseLabels(t, `{bar="foo"}`),
},
{
"Extract common labels source > target",
args{
[]loghttp.LabelSet{mustParseLabels(`{foo="bar", bar="foo"}`), mustParseLabels(`{bar="foo", foo="bar", baz="baz"}`)},
[]loghttp.LabelSet{mustParseLabels(t, `{foo="bar", bar="foo"}`), mustParseLabels(t, `{bar="foo", foo="bar", baz="baz"}`)},
},
mustParseLabels(`{foo="bar", bar="foo"}`),
mustParseLabels(t, `{foo="bar", bar="foo"}`),
},
{
"Extract common labels source < target",
args{
[]loghttp.LabelSet{mustParseLabels(`{foo="bar", bar="foo"}`), mustParseLabels(`{bar="foo"}`)},
[]loghttp.LabelSet{mustParseLabels(t, `{foo="bar", bar="foo"}`), mustParseLabels(t, `{bar="foo"}`)},
},
mustParseLabels(`{bar="foo"}`),
mustParseLabels(t, `{bar="foo"}`),
},
{
"Extract common labels source < target no common",
args{
[]loghttp.LabelSet{mustParseLabels(`{foo="bar", bar="foo"}`), mustParseLabels(`{fo="bar"}`)},
[]loghttp.LabelSet{mustParseLabels(t, `{foo="bar", bar="foo"}`), mustParseLabels(t, `{fo="bar"}`)},
},
loghttp.LabelSet{},
},
{
"Extract common labels source = target no common",
args{
[]loghttp.LabelSet{mustParseLabels(`{foo="bar"}`), mustParseLabels(`{fooo="bar"}`)},
[]loghttp.LabelSet{mustParseLabels(t, `{foo="bar"}`), mustParseLabels(t, `{fooo="bar"}`)},
},
loghttp.LabelSet{},
},
@ -95,50 +96,50 @@ func Test_subtract(t *testing.T) {
{
"Subtract labels source > target",
args{
mustParseLabels(`{foo="bar", bar="foo"}`),
mustParseLabels(`{bar="foo", foo="foo", baz="baz"}`),
mustParseLabels(t, `{foo="bar", bar="foo"}`),
mustParseLabels(t, `{bar="foo", foo="foo", baz="baz"}`),
},
mustParseLabels(`{foo="bar"}`),
mustParseLabels(t, `{foo="bar"}`),
},
{
"Subtract labels source < target",
args{
mustParseLabels(`{foo="bar", bar="foo"}`),
mustParseLabels(`{bar="foo"}`),
mustParseLabels(t, `{foo="bar", bar="foo"}`),
mustParseLabels(t, `{bar="foo"}`),
},
mustParseLabels(`{foo="bar"}`),
mustParseLabels(t, `{foo="bar"}`),
},
{
"Subtract labels source < target no sub",
args{
mustParseLabels(`{foo="bar", bar="foo"}`),
mustParseLabels(`{fo="bar"}`),
mustParseLabels(t, `{foo="bar", bar="foo"}`),
mustParseLabels(t, `{fo="bar"}`),
},
mustParseLabels(`{bar="foo", foo="bar"}`),
mustParseLabels(t, `{bar="foo", foo="bar"}`),
},
{
"Subtract labels source = target no sub",
args{
mustParseLabels(`{foo="bar"}`),
mustParseLabels(`{fiz="buz"}`),
mustParseLabels(t, `{foo="bar"}`),
mustParseLabels(t, `{fiz="buz"}`),
},
mustParseLabels(`{foo="bar"}`),
mustParseLabels(t, `{foo="bar"}`),
},
{
"Subtract labels source > target no sub",
args{
mustParseLabels(`{foo="bar"}`),
mustParseLabels(`{fiz="buz", foo="baz"}`),
mustParseLabels(t, `{foo="bar"}`),
mustParseLabels(t, `{fiz="buz", foo="baz"}`),
},
mustParseLabels(`{foo="bar"}`),
mustParseLabels(t, `{foo="bar"}`),
},
{
"Subtract labels source > target no sub",
args{
mustParseLabels(`{a="b", foo="bar", baz="baz", fizz="fizz"}`),
mustParseLabels(`{foo="bar", baz="baz", buzz="buzz", fizz="fizz"}`),
mustParseLabels(t, `{a="b", foo="bar", baz="baz", fizz="fizz"}`),
mustParseLabels(t, `{foo="bar", baz="baz", buzz="buzz", fizz="fizz"}`),
},
mustParseLabels(`{a="b"}`),
mustParseLabels(t, `{a="b"}`),
},
}
for _, tt := range tests {
@ -485,12 +486,10 @@ func Test_batch(t *testing.T) {
}
}
func mustParseLabels(s string) loghttp.LabelSet {
func mustParseLabels(t *testing.T, s string) loghttp.LabelSet {
t.Helper()
l, err := marshal.NewLabelSet(s)
if err != nil {
log.Fatalf("Failed to parse %s", s)
}
require.NoErrorf(t, err, "Failed to parse %q", s)
return l
}
@ -502,7 +501,7 @@ type testQueryClient struct {
func newTestQueryClient(testStreams ...logproto.Stream) *testQueryClient {
q := logql.NewMockQuerier(0, testStreams)
e := logql.NewEngine(logql.EngineOpts{}, q, logql.NoLimits)
e := logql.NewEngine(logql.EngineOpts{}, q, logql.NoLimits, log.NewNopLogger())
return &testQueryClient{
engine: e,
queryRangeCalls: 0,

@ -8,8 +8,9 @@ import (
"strings"
"testing"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/stretchr/testify/assert"
util_log "github.com/grafana/loki/pkg/util/log"
)
// GZip source string and return compressed string

@ -8,6 +8,7 @@ import (
"sort"
"time"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
@ -15,16 +16,14 @@ import (
"github.com/prometheus/prometheus/promql"
promql_parser "github.com/prometheus/prometheus/promql/parser"
"github.com/grafana/loki/pkg/util/spanlogger"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logqlmodel"
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/httpreq"
"github.com/grafana/loki/pkg/util/spanlogger"
)
var (
@ -62,15 +61,20 @@ func (opts *EngineOpts) applyDefault() {
// Engine is the LogQL engine.
type Engine struct {
logger log.Logger
timeout time.Duration
evaluator Evaluator
limits Limits
}
// NewEngine creates a new LogQL Engine.
func NewEngine(opts EngineOpts, q Querier, l Limits) *Engine {
func NewEngine(opts EngineOpts, q Querier, l Limits, logger log.Logger) *Engine {
opts.applyDefault()
if logger == nil {
logger = log.NewNopLogger()
}
return &Engine{
logger: logger,
timeout: opts.Timeout,
evaluator: NewDefaultEvaluator(q, opts.MaxLookBackPeriod),
limits: l,
@ -80,6 +84,7 @@ func NewEngine(opts EngineOpts, q Querier, l Limits) *Engine {
// Query creates a new LogQL query. Instant/Range type is derived from the parameters.
func (ng *Engine) Query(params Params) Query {
return &query{
logger: ng.logger,
timeout: ng.timeout,
params: params,
evaluator: ng.evaluator,
@ -98,6 +103,7 @@ type Query interface {
}
type query struct {
logger log.Logger
timeout time.Duration
params Params
parse func(context.Context, string) (Expr, error)

@ -9,6 +9,7 @@ import (
"testing"
"time"
"github.com/go-kit/log"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql"
@ -62,7 +63,7 @@ func TestEngine_LogsRateUnwrap(t *testing.T) {
t.Run(fmt.Sprintf("%s %s", test.qs, test.direction), func(t *testing.T) {
t.Parallel()
eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits)
eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits, log.NewNopLogger())
q := eng.Query(LiteralParams{
qs: test.qs,
start: test.ts,
@ -827,7 +828,7 @@ func TestEngine_LogsInstantQuery(t *testing.T) {
t.Run(fmt.Sprintf("%s %s", test.qs, test.direction), func(t *testing.T) {
t.Parallel()
eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits)
eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits, log.NewNopLogger())
q := eng.Query(LiteralParams{
qs: test.qs,
start: test.ts,
@ -2026,7 +2027,7 @@ func TestEngine_RangeQuery(t *testing.T) {
t.Run(fmt.Sprintf("%s %s", test.qs, test.direction), func(t *testing.T) {
t.Parallel()
eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits)
eng := NewEngine(EngineOpts{}, newQuerierRecorder(t, test.data, test.params), NoLimits, log.NewNopLogger())
q := eng.Query(LiteralParams{
qs: test.qs,
@ -2061,7 +2062,7 @@ func (statsQuerier) SelectSamples(ctx context.Context, p SelectSampleParams) (it
}
func TestEngine_Stats(t *testing.T) {
eng := NewEngine(EngineOpts{}, &statsQuerier{}, NoLimits)
eng := NewEngine(EngineOpts{}, &statsQuerier{}, NoLimits, log.NewNopLogger())
queueTime := 2 * time.Nanosecond
q := eng.Query(LiteralParams{
@ -2137,7 +2138,7 @@ func TestStepEvaluator_Error(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
tc := tc
eng := NewEngine(EngineOpts{}, tc.querier, NoLimits)
eng := NewEngine(EngineOpts{}, tc.querier, NoLimits, log.NewNopLogger())
q := eng.Query(LiteralParams{
qs: tc.qs,
start: time.Unix(0, 0),
@ -2151,7 +2152,7 @@ func TestStepEvaluator_Error(t *testing.T) {
}
func TestEngine_MaxSeries(t *testing.T) {
eng := NewEngine(EngineOpts{}, getLocalQuerier(100000), &fakeLimits{maxSeries: 1})
eng := NewEngine(EngineOpts{}, getLocalQuerier(100000), &fakeLimits{maxSeries: 1}, log.NewNopLogger())
for _, test := range []struct {
qs string
@ -2205,7 +2206,7 @@ var result promql_parser.Value
func benchmarkRangeQuery(testsize int64, b *testing.B) {
b.ReportAllocs()
eng := NewEngine(EngineOpts{}, getLocalQuerier(testsize), NoLimits)
eng := NewEngine(EngineOpts{}, getLocalQuerier(testsize), NoLimits, log.NewNopLogger())
start := time.Unix(0, 0)
end := time.Unix(testsize, 0)
b.ResetTimer()

@ -4,7 +4,6 @@ import (
"context"
"strings"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/dustin/go-humanize"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
@ -14,6 +13,7 @@ import (
"github.com/grafana/loki/pkg/logqlmodel"
logql_stats "github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log"
)
const (

@ -7,7 +7,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/opentracing/opentracing-go"
"github.com/stretchr/testify/assert"
@ -19,6 +18,7 @@ import (
"github.com/grafana/loki/pkg/logqlmodel"
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log"
)
func TestQueryType(t *testing.T) {

@ -6,7 +6,7 @@ import (
"fmt"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/prometheus/promql"
@ -15,6 +15,7 @@ import (
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/querier/astmapper"
"github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
)
/*
@ -31,6 +32,7 @@ which can then take advantage of our sharded execution model.
// ShardedEngine is an Engine implementation that can split queries into more parallelizable forms via
// querying the underlying backend shards individually and reaggregating them.
type ShardedEngine struct {
logger log.Logger
timeout time.Duration
downstreamable Downstreamable
limits Limits
@ -38,9 +40,10 @@ type ShardedEngine struct {
}
// NewShardedEngine constructs a *ShardedEngine
func NewShardedEngine(opts EngineOpts, downstreamable Downstreamable, metrics *ShardingMetrics, limits Limits) *ShardedEngine {
func NewShardedEngine(opts EngineOpts, downstreamable Downstreamable, metrics *ShardingMetrics, limits Limits, logger log.Logger) *ShardedEngine {
opts.applyDefault()
return &ShardedEngine{
logger: logger,
timeout: opts.Timeout,
downstreamable: downstreamable,
metrics: metrics,
@ -51,6 +54,7 @@ func NewShardedEngine(opts EngineOpts, downstreamable Downstreamable, metrics *S
// Query constructs a Query
func (ng *ShardedEngine) Query(p Params, mapped Expr) Query {
return &query{
logger: ng.logger,
timeout: ng.timeout,
params: p,
evaluator: NewDownstreamEvaluator(ng.downstreamable.Downstreamer()),

@ -6,6 +6,7 @@ import (
"testing"
"time"
"github.com/go-kit/log"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
@ -59,8 +60,8 @@ func TestMappingEquivalence(t *testing.T) {
)
opts := EngineOpts{}
regular := NewEngine(opts, q, NoLimits)
sharded := NewShardedEngine(opts, MockDownstreamer{regular}, nilMetrics, NoLimits)
regular := NewEngine(opts, q, NoLimits, log.NewNopLogger())
sharded := NewShardedEngine(opts, MockDownstreamer{regular}, nilMetrics, NoLimits, log.NewNopLogger())
t.Run(tc.query, func(t *testing.T) {
params := NewLiteralParams(

@ -3,13 +3,13 @@ package logql
import (
"fmt"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/grafana/loki/pkg/querier/astmapper"
util_log "github.com/grafana/loki/pkg/util/log"
)
// keys used in metrics

@ -5,8 +5,9 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/stretchr/testify/require"
util_log "github.com/grafana/loki/pkg/util/log"
)
func TestResult(t *testing.T) {

@ -10,7 +10,6 @@ import (
rt "runtime"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/fatih/color"
"github.com/felixge/fgprof"
"github.com/go-kit/log/level"
@ -47,6 +46,7 @@ import (
"github.com/grafana/loki/pkg/storage/stores/shipper/compactor"
"github.com/grafana/loki/pkg/tracing"
"github.com/grafana/loki/pkg/util/fakeauth"
util_log "github.com/grafana/loki/pkg/util/log"
serverutil "github.com/grafana/loki/pkg/util/server"
"github.com/grafana/loki/pkg/validation"
)

@ -11,7 +11,6 @@ import (
"time"
"github.com/NYTimes/gziphandler"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/kv/codec"
"github.com/grafana/dskit/kv/memberlist"
@ -52,6 +51,7 @@ import (
"github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway/indexgatewaypb"
"github.com/grafana/loki/pkg/storage/stores/shipper/uploads"
"github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log"
serverutil "github.com/grafana/loki/pkg/util/server"
"github.com/grafana/loki/pkg/validation"
)
@ -329,7 +329,7 @@ func (t *Loki) initTableManager() (services.Service, error) {
}
bucketClient, err := storage.NewBucketClient(t.Cfg.StorageConfig.Config)
util_log.CheckFatal("initializing bucket client", err)
util_log.CheckFatal("initializing bucket client", err, util_log.Logger)
t.tableManager, err = chunk.NewTableManager(t.Cfg.TableManager, t.Cfg.SchemaConfig.SchemaConfig, maxChunkAgeForTableManager, tableClient, bucketClient, nil, prometheus.DefaultRegisterer)
if err != nil {
@ -619,7 +619,7 @@ func (t *Loki) initRuler() (_ services.Service, err error) {
return nil, err
}
engine := logql.NewEngine(t.Cfg.Querier.Engine, q, t.overrides)
engine := logql.NewEngine(t.Cfg.Querier.Engine, q, t.overrides, util_log.Logger)
t.ruler, err = ruler.NewRuler(
t.Cfg.Ruler,
@ -668,7 +668,8 @@ func (t *Loki) initRuler() (_ services.Service, err error) {
func (t *Loki) initMemberlistKV() (services.Service, error) {
reg := prometheus.DefaultRegisterer
t.Cfg.MemberlistKV.MetricsRegisterer = prometheus.DefaultRegisterer
t.Cfg.MemberlistKV.MetricsRegisterer = reg
t.Cfg.MemberlistKV.Codecs = []codec.Codec{
ring.GetCodec(),
}

@ -4,13 +4,13 @@ import (
"fmt"
"io"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/kv"
"github.com/grafana/dskit/runtimeconfig"
"gopkg.in/yaml.v2"
"github.com/grafana/loki/pkg/runtime"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
)

@ -14,7 +14,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
@ -22,6 +21,7 @@ import (
querier_stats "github.com/grafana/loki/pkg/querier/stats"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
serverutil "github.com/grafana/loki/pkg/util/server"
)

@ -6,7 +6,7 @@ import (
"github.com/go-kit/log/level"
"github.com/prometheus/prometheus/promql/parser"
util_log "github.com/cortexproject/cortex/pkg/util/log"
util_log "github.com/grafana/loki/pkg/util/log"
)
var summableAggregates = map[parser.ItemType]struct{}{

@ -5,19 +5,18 @@ import (
"net/http"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/gorilla/websocket"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql/parser"
"github.com/weaveworks/common/httpgrpc"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/loghttp"
loghttp_legacy "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logqlmodel"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/marshal"
marshal_legacy "github.com/grafana/loki/pkg/util/marshal/legacy"
serverutil "github.com/grafana/loki/pkg/util/server"

@ -6,7 +6,6 @@ import (
"strings"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/grafana/dskit/ring"
ring_client "github.com/grafana/dskit/ring/client"
"github.com/grafana/dskit/services"
@ -21,6 +20,7 @@ import (
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logqlmodel/stats"
util_log "github.com/grafana/loki/pkg/util/log"
)
type responseFromIngesters struct {

@ -14,16 +14,15 @@ import (
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/grafana/loki/pkg/util/spanlogger"
"github.com/grafana/loki/pkg/tenant"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/storage"
"github.com/grafana/loki/pkg/tenant"
listutil "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/spanlogger"
"github.com/grafana/loki/pkg/validation"
)
@ -91,13 +90,13 @@ func New(cfg Config, store storage.Store, ingesterQuerier *IngesterQuerier, limi
limits: limits,
}
querier.engine = logql.NewEngine(cfg.Engine, &querier, limits)
querier.engine = logql.NewEngine(cfg.Engine, &querier, limits, util_log.Logger)
return &querier, nil
}
func (q *Querier) SetQueryable(queryable logql.Querier) {
q.engine = logql.NewEngine(q.cfg.Engine, queryable, q.limits)
q.engine = logql.NewEngine(q.cfg.Engine, queryable, q.limits, util_log.Logger)
}
// Select Implements logql.Querier which select logs via matchers and regex filters.

@ -8,7 +8,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/require"
@ -19,6 +18,7 @@ import (
"github.com/grafana/loki/pkg/logqlmodel"
"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase"
"github.com/grafana/loki/pkg/storage/chunk"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/marshal"
)

@ -10,7 +10,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/cortexproject/cortex/pkg/util/validation"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
@ -30,6 +29,7 @@ import (
"github.com/grafana/loki/pkg/storage/chunk/cache"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/spanlogger"
)

@ -9,7 +9,7 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/weaveworks/common/httpgrpc"
util_log "github.com/cortexproject/cortex/pkg/util/log"
util_log "github.com/grafana/loki/pkg/util/log"
)
type RetryMiddlewareMetrics struct {

@ -7,7 +7,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
@ -21,6 +20,7 @@ import (
"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/marshal"
)
@ -70,12 +70,11 @@ func newASTMapperware(
metrics *logql.ShardingMetrics,
limits logql.Limits,
) *astMapperware {
return &astMapperware{
confs: confs,
logger: log.With(logger, "middleware", "QueryShard.astMapperware"),
next: next,
ng: logql.NewShardedEngine(logql.EngineOpts{}, DownstreamHandler{next}, metrics, limits),
ng: logql.NewShardedEngine(logql.EngineOpts{}, DownstreamHandler{next}, metrics, limits, logger),
metrics: metrics,
}
}

@ -13,7 +13,6 @@ import (
"testing"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
@ -27,6 +26,7 @@ import (
"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/storage/chunk/cache"
util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/marshal"
)

@ -5,13 +5,13 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-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"
util_log "github.com/grafana/loki/pkg/util/log"
)
const (

@ -7,7 +7,6 @@ import (
"strings"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/backoff"
@ -27,6 +26,7 @@ import (
querier_stats "github.com/grafana/loki/pkg/querier/stats"
"github.com/grafana/loki/pkg/scheduler/schedulerpb"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
)
func newSchedulerProcessor(cfg Config, handler RequestHandler, log log.Logger, metrics *Metrics) (*schedulerProcessor, []services.Service) {

@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/gorilla/mux"
"github.com/grafana/dskit/ring"
@ -17,6 +16,7 @@ import (
querier_worker "github.com/grafana/loki/pkg/querier/worker"
"github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log"
serverutil "github.com/grafana/loki/pkg/util/server"
)

@ -11,7 +11,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/gorilla/mux"
@ -25,6 +24,7 @@ import (
"github.com/grafana/loki/pkg/ruler/rulespb"
"github.com/grafana/loki/pkg/ruler/rulestore"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
)
// In order to reimplement the prometheus rules API, a large amount of code was copied over

@ -6,7 +6,6 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/cortexpb"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
@ -22,6 +21,7 @@ import (
"github.com/weaveworks/common/user"
"github.com/grafana/loki/pkg/querier"
util_log "github.com/grafana/loki/pkg/util/log"
)
// Pusher is an ingester server that accepts pushes.

@ -12,6 +12,9 @@ import (
"sync"
"time"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/validation"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/concurrency"
@ -30,14 +33,10 @@ import (
"github.com/weaveworks/common/user"
"golang.org/x/sync/errgroup"
"github.com/cortexproject/cortex/pkg/cortexpb"
"github.com/cortexproject/cortex/pkg/util"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/cortexproject/cortex/pkg/util/validation"
"github.com/grafana/loki/pkg/ruler/rulespb"
"github.com/grafana/loki/pkg/ruler/rulestore"
"github.com/grafana/loki/pkg/tenant"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -15,6 +15,7 @@ import (
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logql"
ruler "github.com/grafana/loki/pkg/ruler/base"
"github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation"
)
@ -304,7 +305,7 @@ func TestNonMetricQuery(t *testing.T) {
overrides, err := validation.NewOverrides(validation.Limits{}, nil)
require.Nil(t, err)
engine := logql.NewEngine(logql.EngineOpts{}, &FakeQuerier{}, overrides)
engine := logql.NewEngine(logql.EngineOpts{}, &FakeQuerier{}, overrides, log.Logger)
queryFunc := engineQueryFunc(engine, overrides, fakeChecker{}, "fake")
_, err = queryFunc(context.TODO(), `{job="nginx"}`, time.Now())

@ -10,10 +10,11 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/prometheus/storage"
util_log "github.com/grafana/loki/pkg/util/log"
)
var (

@ -9,8 +9,6 @@ import (
"sync"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/validation"
"github.com/go-kit/log"
@ -39,6 +37,7 @@ import (
lokiutil "github.com/grafana/loki/pkg/util"
lokigrpc "github.com/grafana/loki/pkg/util/httpgrpc"
lokihttpreq "github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log"
)
var errSchedulerIsNotRunning = errors.New("scheduler is not running")

@ -4,14 +4,14 @@ import (
"context"
"testing"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/grafana/loki/pkg/scheduler/schedulerpb"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/metadata"
"github.com/grafana/loki/pkg/scheduler/schedulerpb"
util_log "github.com/grafana/loki/pkg/util/log"
)
func TestScheduler_setRunState(t *testing.T) {

@ -5,7 +5,6 @@ import (
"fmt"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
@ -13,6 +12,7 @@ import (
"github.com/grafana/loki/pkg/util/spanlogger"
"github.com/grafana/loki/pkg/storage/chunk"
util_log "github.com/grafana/loki/pkg/util/log"
)
type IngesterQuerier interface {

@ -5,7 +5,6 @@ import (
"sort"
"time"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -22,6 +21,7 @@ import (
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/querier/astmapper"
"github.com/grafana/loki/pkg/storage/chunk"
util_log "github.com/grafana/loki/pkg/util/log"
)
type ChunkMetrics struct {

@ -18,7 +18,6 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/flagext"
@ -32,6 +31,7 @@ import (
"github.com/grafana/loki/pkg/storage/chunk"
chunk_util "github.com/grafana/loki/pkg/storage/chunk/util"
"github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/math"
"github.com/grafana/loki/pkg/util/spanlogger"
)

@ -8,7 +8,6 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/cortexproject/cortex/pkg/util/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/backoff"
"github.com/pkg/errors"
@ -17,6 +16,7 @@ import (
"golang.org/x/time/rate"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/util/log"
)
// Pluggable auto-scaler implementation

@ -13,9 +13,8 @@ import (
"github.com/prometheus/common/model"
"github.com/weaveworks/common/mtime"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"github.com/grafana/loki/pkg/storage/chunk"
util_log "github.com/grafana/loki/pkg/util/log"
)
const (

@ -18,7 +18,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3/s3iface"
"github.com/go-kit/log/level"
util_log "github.com/cortexproject/cortex/pkg/util/log"
util_log "github.com/grafana/loki/pkg/util/log"
)
const arnPrefix = "arn:"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save