Skip to content

Commit

Permalink
Merge pull request grafana#86 from grafana/main
Browse files Browse the repository at this point in the history
[release-5.6] Update from upstream/main repository
  • Loading branch information
periklis authored Nov 30, 2022
2 parents f822feb + d3615f7 commit 5182f7e
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

* [7708](https://github.com/grafana/loki/pull/7708) **DylanGuedes**: Fix multitenant querying.

* [7784](https://github.com/grafana/loki/pull/7784) **isodude**: Fix default values of connect addresses for compactor and querier workers to work with IPv6.

##### Changes

#### Promtail
Expand All @@ -31,6 +33,7 @@
* [7602](https://github.com/grafana/loki/pull/7602) **vmax**: Add decolorize stage to Promtail to easily parse colored logs.

##### Fixes
* [7771](https://github.com/grafana/loki/pull/7771) **GeorgeTsilias**: Handle nil error on target Details() call.

* [7461](https://github.com/grafana/loki/pull/7461) **MarNicGit**: Promtail: Fix collecting userdata field from Windows Event Log

Expand Down
6 changes: 5 additions & 1 deletion clients/pkg/promtail/targets/cloudflare/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,13 @@ func (t *Target) Ready() bool {

func (t *Target) Details() interface{} {
fields, _ := Fields(FieldsType(t.config.FieldsType))
var errMsg string
if t.err != nil {
errMsg = t.err.Error()
}
return map[string]string{
"zone_id": t.config.ZoneID,
"error": t.err.Error(),
"error": errMsg,
"position": t.positions.GetString(positions.CursorKey(t.config.ZoneID)),
"last_timestamp": t.to.String(),
"fields": strings.Join(fields, ","),
Expand Down
6 changes: 5 additions & 1 deletion clients/pkg/promtail/targets/docker/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ func (t *Target) Labels() model.LabelSet {

// Details returns target-specific details.
func (t *Target) Details() interface{} {
var errMsg string
if t.err != nil {
errMsg = t.err.Error()
}
return map[string]string{
"id": t.containerName,
"error": t.err.Error(),
"error": errMsg,
"position": t.positions.GetString(positions.CursorKey(t.containerName)),
"running": strconv.FormatBool(t.running.Load()),
}
Expand Down
1 change: 1 addition & 0 deletions cmd/loki-canary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func main() {
config.DefaultHTTPClientConfig,
*lName, *lVal,
*sName, *sValue,
*useTLS,
tlsConfig,
*caFile,
*user, *pass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ tests:
values: '0+100x20'

- series: 'loki_logql_querystats_latency_seconds_bucket{namespace="my-ns", job="querier", route="my-route", le="1"}'
values: '0x20'
- series: 'loki_logql_querystats_latency_seconds_bucket{namespace="my-ns", job="querier", route="my-route", le="30"}'
values: '0+10x20'
- series: 'loki_logql_querystats_latency_seconds_bucket{namespace="my-ns", job="querier", route="my-route", le="5"}'
values: '0+50x20'
- series: 'loki_logql_querystats_latency_seconds_bucket{namespace="my-ns", job="querier", route="my-route", le="10"}'
- series: 'loki_logql_querystats_latency_seconds_bucket{namespace="my-ns", job="querier", route="my-route", le="60"}'
values: '0+100x20'
- series: 'loki_logql_querystats_latency_seconds_bucket{namespace="my-ns", job="querier", route="my-route", le="+Inf"}'
values: '0+100x20'
Expand Down Expand Up @@ -119,7 +119,7 @@ tests:
severity: critical
exp_annotations:
summary: "The 99th percentile is experiencing high latency (higher than 1 second)."
message: "ingester my-route is experiencing 990.00s 99th percentile latency."
message: "ingester my-route is experiencing 9.90s 99th percentile latency."
runbook_url: "[[ .RunbookURL ]]#Loki-Request-Latency"
- eval_time: 16m
alertname: LokiTenantRateLimit
Expand Down
5 changes: 5 additions & 0 deletions pkg/canary/writer/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func NewPush(
cfg config.HTTPClientConfig,
labelName, labelValue string,
streamName, streamValue string,
useTLS bool,
tlsCfg *tls.Config,
caFile string,
username, password string,
Expand Down Expand Up @@ -90,6 +91,10 @@ func NewPush(
scheme = "https"
}

if useTLS {
scheme = "https"
}

u := url.URL{
Scheme: scheme,
Host: lokiAddr,
Expand Down
7 changes: 3 additions & 4 deletions pkg/canary/writer/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Test_Push(t *testing.T) {
defer mock.Close()

// without TLS
push, err := NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", nil, "", "", "", &backoff, log.NewNopLogger())
push, err := NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", false, nil, "", "", "", &backoff, log.NewNopLogger())
require.NoError(t, err)
ts, payload := testPayload()
n, err := push.Write([]byte(payload))
Expand All @@ -52,7 +52,7 @@ func Test_Push(t *testing.T) {
assertResponse(t, resp, false, labelSet("name", "loki-canary", "stream", "stdout"), ts, payload)

// with basic Auth
push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", nil, "", testUsername, testPassword, &backoff, log.NewNopLogger())
push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", false, nil, "", testUsername, testPassword, &backoff, log.NewNopLogger())
require.NoError(t, err)
ts, payload = testPayload()
n, err = push.Write([]byte(payload))
Expand All @@ -62,7 +62,7 @@ func Test_Push(t *testing.T) {
assertResponse(t, resp, true, labelSet("name", "loki-canary", "stream", "stdout"), ts, payload)

// with custom labels
push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "pod", "abc", nil, "", testUsername, testPassword, &backoff, log.NewNopLogger())
push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "pod", "abc", false, nil, "", testUsername, testPassword, &backoff, log.NewNopLogger())
require.NoError(t, err)
ts, payload = testPayload()
n, err = push.Write([]byte(payload))
Expand Down Expand Up @@ -133,7 +133,6 @@ func createServerHandler(responses chan response) http.HandlerFunc {
rw.WriteHeader(500)
return
}
fmt.Println("decoded", decoded)
toks := strings.FieldsFunc(string(decoded), func(r rune) bool {
return r == ':'
})
Expand Down
7 changes: 6 additions & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ func (t *Loki) initQuerier() (services.Service, error) {
querierWorkerServiceConfig := querier.WorkerServiceConfig{
AllEnabled: t.Cfg.isModuleEnabled(All),
ReadEnabled: t.Cfg.isModuleEnabled(Read),
GrpcListenAddress: t.Cfg.Server.GRPCListenAddress,
GrpcListenPort: t.Cfg.Server.GRPCListenPort,
QuerierMaxConcurrent: t.Cfg.Querier.MaxConcurrent,
QuerierWorkerConfig: &t.Cfg.Worker,
Expand Down Expand Up @@ -703,7 +704,11 @@ func (t *Loki) supportIndexDeleteRequest() bool {
func (t *Loki) compactorAddress() (string, error) {
if t.Cfg.isModuleEnabled(All) || t.Cfg.isModuleEnabled(Read) {
// In single binary or read modes, this module depends on Server
return fmt.Sprintf("http://127.0.0.1:%d", t.Cfg.Server.HTTPListenPort), nil
proto := "http"
if len(t.Cfg.Server.HTTPTLSConfig.TLSCertPath) > 0 && len(t.Cfg.Server.HTTPTLSConfig.TLSKeyPath) > 0 {
proto = "https"
}
return fmt.Sprintf("%s://%s:%d", proto, t.Cfg.Server.HTTPListenAddress, t.Cfg.Server.HTTPListenPort), nil
}

if t.Cfg.Common.CompactorAddress == "" {
Expand Down
7 changes: 6 additions & 1 deletion pkg/querier/worker_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
type WorkerServiceConfig struct {
AllEnabled bool
ReadEnabled bool
GrpcListenAddress string
GrpcListenPort int
QuerierMaxConcurrent int
QuerierWorkerConfig *querier_worker.Config
Expand Down Expand Up @@ -112,7 +113,11 @@ func InitWorkerService(
// Since we must be running a querier with either a frontend and/or scheduler at this point, if no scheduler ring, frontend, or scheduler address
// is configured, Loki will default to using the frontend on localhost on it's own GRPC listening port.
if cfg.SchedulerRing == nil && (*cfg.QuerierWorkerConfig).FrontendAddress == "" && (*cfg.QuerierWorkerConfig).SchedulerAddress == "" {
address := fmt.Sprintf("127.0.0.1:%d", cfg.GrpcListenPort)
listenAddress := "127.0.0.1"
if cfg.GrpcListenAddress != "" {
listenAddress = cfg.GrpcListenAddress
}
address := fmt.Sprintf("%s:%d", listenAddress, cfg.GrpcListenPort)
level.Warn(util_log.Logger).Log(
"msg", "Worker address is empty, attempting automatic worker configuration. If queries are unresponsive consider configuring the worker explicitly.",
"address", address)
Expand Down

0 comments on commit 5182f7e

Please sign in to comment.