Skip to content

Commit

Permalink
Merge branch 'main' into callum-shard-last
Browse files Browse the repository at this point in the history
Signed-off-by: Callum Styan <[email protected]>
  • Loading branch information
cstyan committed Jan 23, 2024
2 parents f8c9c2b + b32d993 commit b6503d9
Show file tree
Hide file tree
Showing 184 changed files with 7,085 additions and 3,071 deletions.
1 change: 1 addition & 0 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ local build_image_tag = '0.33.0';
'GIT_TARGET_BRANCH="$DRONE_TARGET_BRANCH"',
]) { depends_on: ['loki'], when: onPRs },
make('validate-example-configs', container=false) { depends_on: ['loki'] },
make('validate-dev-cluster-config', container=false) { depends_on: ['validate-example-configs'] },
make('check-example-config-doc', container=false) { depends_on: ['clone'] },
{
name: 'build-docs-website',
Expand Down
9 changes: 8 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ steps:
environment: {}
image: grafana/loki-build-image:0.33.0
name: validate-example-configs
- commands:
- make BUILD_IN_CONTAINER=false validate-dev-cluster-config
depends_on:
- validate-example-configs
environment: {}
image: grafana/loki-build-image:0.33.0
name: validate-dev-cluster-config
- commands:
- make BUILD_IN_CONTAINER=false check-example-config-doc
depends_on:
Expand Down Expand Up @@ -2106,6 +2113,6 @@ kind: secret
name: gpg_private_key
---
kind: signature
hmac: 30f2fb121d8271e00dc2ae8fe83a32e0e22fd2bd268609d0c3f295033fcd4fb6
hmac: 457592d17208477ceb480f81dbdb88f7b95a5ad015c88d9d6fed06c2422a52f9

...
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

##### Enhancements

* [11571](https://github.com/grafana/loki/pull/11571) **MichelHollands**: Add a metrics.go log line for requests from querier to ingester
* [11633](https://github.com/grafana/loki/pull/11633) **cyriltovena**: Add profiling integrations to tracing instrumentation.
* [11571](https://github.com/grafana/loki/pull/11571) **MichelHollands**: Add a metrics.go log line for requests from querier to ingester
* [11477](https://github.com/grafana/loki/pull/11477) **MichelHollands**: support GET for /ingester/shutdown
* [11363](https://github.com/grafana/loki/pull/11363) **kavirajk**: bugfix(memcached): Make memcached batch fetch truely context aware.
* [11319](https://github.com/grafana/loki/pull/11319) **someStrangerFromTheAbyss**: Helm: Add extraContainers to the write pods.
Expand Down Expand Up @@ -46,14 +47,22 @@
* [11539](https://github.com/grafana/loki/pull/11539) **kaviraj,ashwanthgoli** Support caching /series and /labels query results
* [11545](https://github.com/grafana/loki/pull/11545) **dannykopping** Force correct memcached timeout when fetching chunks.
* [11589](https://github.com/grafana/loki/pull/11589) **ashwanthgoli** Results Cache: Adds `query_length_served` cache stat to measure the length of the query served from cache.
* [11535](https://github.com/grafana/loki/pull/11535) **dannykopping** Query Frontend: Allow customisable splitting of queries which overlap the `query_ingester_within` window to reduce query pressure on ingesters.
* [11654](https://github.com/grafana/loki/pull/11654) **dannykopping** Cache: atomically check background cache size limit correctly.
* [11682](https://github.com/grafana/loki/pull/11682) **ashwanthgoli** Metadata cache: Adds `frontend.max-metadata-cache-freshness` to configure the time window for which metadata results are not cached. This helps avoid returning inaccurate results by not caching recent results.
* [11679](https://github.com/grafana/loki/pull/11679) **dannykopping** Cache: extending #11535 to align custom ingester query split with cache keys for correct caching of results.
* [11499](https://github.com/grafana/loki/pull/11284) **jmichalek132** Config: Adds `frontend.log-query-request-headers` to enable logging of request headers in query logs.

##### Fixes
* [11074](https://github.com/grafana/loki/pull/11074) **hainenber** Fix panic in lambda-promtail due to mishandling of empty DROP_LABELS env var.
* [11195](https://github.com/grafana/loki/pull/11195) **canuteson** Generate tsdb_shipper storage_config even if using_boltdb_shipper is false
* [9831](https://github.com/grafana/loki/pull/9831) **sijmenhuizenga**: Fix Promtail excludepath not evaluated on newly added files.
* [11551](https://github.com/grafana/loki/pull/11551) **dannykopping** Do not reflect label names in request metrics' "route" label.
* [11563](https://github.com/grafana/loki/pull/11563) **ptqa** Fix duplicate logs from docker containers.
* [11601](https://github.com/grafana/loki/pull/11601) **dannykopping** Ruler: Fixed a panic that can be caused by concurrent read-write access of tenant configs when there are a large amount of rules.
* [11606](https://github.com/grafana/loki/pull/11606) **dannykopping** Fixed regression adding newlines to HTTP error response bodies which may break client integrations.
* [11657](https://github.com/grafana/loki/pull/11657) **ashwanthgoli** Log results cache: compose empty response based on the request being served to avoid returning incorrect limit or direction.
* [11587](https://github.com/grafana/loki/pull/11587) **trevorwhitney** Fix semantics of label parsing logic of metrics and logs queries. Both only parse the first label if multiple extractions into the same label are requested.

##### Changes

Expand All @@ -64,10 +73,12 @@
* [10959](https://github.com/grafana/loki/pull/10959) **slim-bean** introduce a backoff wait on subquery retries.
* [11121](https://github.com/grafana/loki/pull/11121) **periklis** Ensure all lifecycler cfgs ref a valid IPv6 addr and port combination
* [10650](https://github.com/grafana/loki/pull/10650) **matthewpi** Ensure the frontend uses a valid IPv6 addr and port combination
* [11665](https://github.com/grafana/loki/pull/11665) **salvacorts** Deprecate and flip `-legacy-read-mode` flag to `false` by default.

#### Promtail

* [10752](https://github.com/grafana/loki/pull/10752) **gonzalesraul**: structured_metadata: enable structured_metadata convert labels
* [11511](https://github.com/grafana/loki/pull/11511) **kavirajk**: chore(promtail): Improve default configuration that is shipped with rpm/deb packages to avoid possible high CPU utilisation if there are lots of files inside `/var/log`.

##### Enhancements

Expand All @@ -92,6 +103,7 @@
#### Mixins

* [11087](https://github.com/grafana/loki/pull/11087) **JoaoBraveCoding**: Adds structured metadata panels for ingested data
* [11637](https://github.com/grafana/loki/pull/11637) **JoaoBraveCoding**: Add route to write Distributor Latency dashboard

#### Fixes

Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@slim-bean is the main/default maintainer.

Some parts of the codebase have other maintainers:
- `@grafana/docs-logs`, which includes [@osg-grafana](https://github.com/osg-grafana) ([Grafana Labs](https://grafana.com/)) and [@knylander-grafana](https://github.com/knylander-grafana) ([Grafana Labs](https://grafana.com/))
- `@grafana/docs-logs`, which includes [@knylander-grafana](https://github.com/knylander-grafana) ([Grafana Labs](https://grafana.com/))
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ EXAMPLES_SKIP_VALIDATION_FLAG := "doc-example:skip-validation=true"
validate-example-configs: loki
for f in $$(grep -rL $(EXAMPLES_SKIP_VALIDATION_FLAG) $(EXAMPLES_YAML_PATH)/*.yaml); do echo "Validating provided example config: $$f" && ./cmd/loki/loki -config.file=$$f -verify-config || exit 1; done

validate-dev-cluster-config: loki
./cmd/loki/loki -config.file=./tools/dev/loki-boltdb-storage-s3/config/loki.yaml -verify-config

# Dynamically generate ./docs/sources/configure/examples.md using the example configs that we provide.
# This target should be run if any of our example configs change.
generate-example-config-doc:
Expand Down
19 changes: 9 additions & 10 deletions clients/cmd/fluent-bit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"encoding/json"
"errors"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -67,7 +66,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
}
err := clientURL.Set(url)
if err != nil {
return nil, errors.New("failed to parse client URL")
return nil, fmt.Errorf("failed to parse client URL: %w", err)
}
res.clientConfig.URL = clientURL

Expand All @@ -83,7 +82,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
} else {
batchWaitValue, err := time.ParseDuration(batchWait)
if err != nil {
return nil, fmt.Errorf("failed to parse BatchWait: %s", batchWait)
return nil, fmt.Errorf("failed to parse BatchWait %s: %w", batchWait, err)
}
res.clientConfig.BatchWait = batchWaitValue
}
Expand All @@ -93,7 +92,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if batchSize != "" {
batchSizeValue, err := strconv.Atoi(batchSize)
if err != nil {
return nil, fmt.Errorf("failed to parse BatchSize: %s", batchSize)
return nil, fmt.Errorf("failed to parse BatchSize %s: %w", batchSize, err)
}
res.clientConfig.BatchSize = batchSizeValue
}
Expand All @@ -102,7 +101,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if timeout != "" {
timeoutValue, err := time.ParseDuration(timeout)
if err != nil {
return nil, fmt.Errorf("failed to parse Timeout: %s", timeout)
return nil, fmt.Errorf("failed to parse Timeout %s: %w", timeout, err)
}
res.clientConfig.Timeout = timeoutValue
}
Expand All @@ -111,7 +110,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if minBackoff != "" {
minBackoffValue, err := time.ParseDuration(minBackoff)
if err != nil {
return nil, fmt.Errorf("failed to parse MinBackoff: %s", minBackoff)
return nil, fmt.Errorf("failed to parse MinBackoff %s: %w", minBackoff, err)
}
res.clientConfig.BackoffConfig.MinBackoff = minBackoffValue
}
Expand All @@ -120,7 +119,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if maxBackoff != "" {
maxBackoffValue, err := time.ParseDuration(maxBackoff)
if err != nil {
return nil, fmt.Errorf("failed to parse MaxBackoff: %s", maxBackoff)
return nil, fmt.Errorf("failed to parse MaxBackoff %s: %w", maxBackoff, err)
}
res.clientConfig.BackoffConfig.MaxBackoff = maxBackoffValue
}
Expand All @@ -129,7 +128,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if maxRetries != "" {
maxRetriesValue, err := strconv.Atoi(maxRetries)
if err != nil {
return nil, fmt.Errorf("failed to parse MaxRetries: %s", maxRetries)
return nil, fmt.Errorf("failed to parse MaxRetries %s: %w", maxRetries, err)
}
res.clientConfig.BackoffConfig.MaxRetries = maxRetriesValue
}
Expand All @@ -154,7 +153,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
}
var level log.Level
if err := level.Set(logLevel); err != nil {
return nil, fmt.Errorf("invalid log level: %v", logLevel)
return nil, fmt.Errorf("invalid log level %v: %w", logLevel, err)
}
res.logLevel = level

Expand Down Expand Up @@ -238,7 +237,7 @@ func parseConfig(cfg ConfigGetter) (*config, error) {
if queueSegmentSize != "" {
res.bufferConfig.dqueConfig.queueSegmentSize, err = strconv.Atoi(queueSegmentSize)
if err != nil {
return nil, fmt.Errorf("impossible to convert string to integer DqueSegmentSize: %v", queueSegmentSize)
return nil, fmt.Errorf("impossible to convert string to integer DqueSegmentSize %v: %w", queueSegmentSize, err)
}
}

Expand Down
1 change: 1 addition & 0 deletions clients/pkg/promtail/targets/docker/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (t *Target) process(r io.Reader, logStream string) {
}
t.metrics.dockerEntries.Inc()
t.positions.Put(positions.CursorKey(t.containerName), ts.Unix())
t.since = ts.Unix()
}
}

Expand Down
34 changes: 32 additions & 2 deletions clients/pkg/promtail/targets/docker/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ func Test_DockerTarget(t *testing.T) {
h := func(w http.ResponseWriter, r *http.Request) {
switch path := r.URL.Path; {
case strings.HasSuffix(path, "/logs"):
dat, err := os.ReadFile("testdata/flog.log")
var filePath string
if strings.Contains(r.URL.RawQuery, "since=0") {
filePath = "testdata/flog.log"
} else {
filePath = "testdata/flog_after_restart.log"
}
dat, err := os.ReadFile(filePath)
require.NoError(t, err)
_, err = w.Write(dat)
require.NoError(t, err)
Expand Down Expand Up @@ -59,7 +65,7 @@ func Test_DockerTarget(t *testing.T) {
})
require.NoError(t, err)

_, err = NewTarget(
target, err := NewTarget(
NewMetrics(prometheus.NewRegistry()),
logger,
entryHandler,
Expand Down Expand Up @@ -92,4 +98,28 @@ func Test_DockerTarget(t *testing.T) {
actualLines = append(actualLines, entry.Line)
}
require.ElementsMatch(t, actualLines, expectedLines)

// restart target to simulate container restart
target.startIfNotRunning()
entryHandler.Clear()
require.Eventually(t, func() bool {
return len(entryHandler.Received()) >= 5
}, 5*time.Second, 100*time.Millisecond)

receivedAfterRestart := entryHandler.Received()
sort.Slice(receivedAfterRestart, func(i, j int) bool {
return receivedAfterRestart[i].Timestamp.Before(receivedAfterRestart[j].Timestamp)
})
actualLinesAfterRestart := make([]string, 0, 5)
for _, entry := range receivedAfterRestart[:5] {
actualLinesAfterRestart = append(actualLinesAfterRestart, entry.Line)
}
expectedLinesAfterRestart := []string{
"243.115.12.215 - - [09/Dec/2023:09:16:57 +0000] \"DELETE /morph/exploit/granular HTTP/1.0\" 500 26468",
"221.41.123.237 - - [09/Dec/2023:09:16:57 +0000] \"DELETE /user-centric/whiteboard HTTP/2.0\" 205 22487",
"89.111.144.144 - - [09/Dec/2023:09:16:57 +0000] \"DELETE /open-source/e-commerce HTTP/1.0\" 401 11092",
"62.180.191.187 - - [09/Dec/2023:09:16:57 +0000] \"DELETE /cultivate/integrate/technologies HTTP/2.0\" 302 12979",
"156.249.2.192 - - [09/Dec/2023:09:16:57 +0000] \"POST /revolutionize/mesh/metrics HTTP/2.0\" 401 5297",
}
require.ElementsMatch(t, actualLinesAfterRestart, expectedLinesAfterRestart)
}
Binary file not shown.
6 changes: 5 additions & 1 deletion cmd/loki/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

"github.com/go-kit/log/level"
"github.com/grafana/dskit/log"
"github.com/grafana/dskit/spanprofiler"
"github.com/grafana/dskit/tracing"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"

Expand Down Expand Up @@ -84,7 +86,9 @@ func main() {
if err != nil {
level.Error(util_log.Logger).Log("msg", "error in initializing tracing. tracing will not be enabled", "err", err)
}

if config.Tracing.ProfilingEnabled {
opentracing.SetGlobalTracer(spanprofiler.NewTracer(opentracing.GlobalTracer()))
}
defer func() {
if trace != nil {
if err := trace.Close(); err != nil {
Expand Down
21 changes: 21 additions & 0 deletions docs/sources/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,11 @@ The `frontend` block configures the Loki query-frontend.
# CLI flag: -frontend.log-queries-longer-than
[log_queries_longer_than: <duration> | default = 0s]
# Comma-separated list of request header names to include in query logs. Applies
# to both query stats and slow queries logs.
# CLI flag: -frontend.log-query-request-headers
[log_query_request_headers: <string> | default = ""]
# Max body size for downstream prometheus.
# CLI flag: -frontend.max-body-size
[max_body_size: <int> | default = 10485760]
Expand Down Expand Up @@ -2830,6 +2835,12 @@ The `limits_config` block configures global and per-tenant limits in Loki.
# CLI flag: -frontend.max-cache-freshness
[max_cache_freshness_per_query: <duration> | default = 10m]

# Do not cache metadata request if the end time is within the
# frontend.max-metadata-cache-freshness window. Set this to 0 to apply no such
# limits. Defaults to 24h.
# CLI flag: -frontend.max-metadata-cache-freshness
[max_metadata_cache_freshness: <duration> | default = 1d]

# Do not cache requests with an end time that falls within Now minus this
# duration. 0 disables this feature (default).
# CLI flag: -frontend.max-stats-cache-freshness
Expand Down Expand Up @@ -2884,6 +2895,12 @@ The `limits_config` block configures global and per-tenant limits in Loki.
# CLI flag: -querier.split-metadata-queries-by-interval
[split_metadata_queries_by_interval: <duration> | default = 1d]

# Interval to use for time-based splitting when a request is within the
# `query_ingesters_within` window; defaults to `split-queries-by-interval` by
# setting to 0.
# CLI flag: -querier.split-ingester-queries-by-interval
[split_ingester_queries_by_interval: <duration> | default = 0s]

# Limit queries that can be sharded. Queries within the time range of now and
# now minus this sharding lookback are not sharded. The default value of 0s
# disables the lookback, causing sharding of all queries at all times.
Expand Down Expand Up @@ -3088,6 +3105,10 @@ shard_streams:
# CLI flag: -bloom-compactor.enable-compaction
[bloom_compactor_enable_compaction: <boolean> | default = false]

# The batch size of the chunks the bloom-compactor downloads at once.
# CLI flag: -bloom-compactor.chunks-batch-size
[bloom_compactor_chunks_batch_size: <int> | default = 100]

# Length of the n-grams created when computing blooms from log lines.
# CLI flag: -bloom-compactor.ngram-length
[bloom_ngram_length: <int> | default = 4]
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/query/query_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ These LogQL query examples have explanations of what the queries accomplish.
!= "grafana_com"
|= "session opened"
!= "sudo: "
|regexp "(^(?P<user>\\S+ {1,2}){11})"
| regexp "(^(?P<user>\\S+ {1,2}){11})"
| line_format "USER = {{.user}}"
```

Expand Down
Loading

0 comments on commit b6503d9

Please sign in to comment.