Skip to content

Commit

Permalink
Merge branch 'main' into kavirajk/sane-init-config-packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
kavirajk committed Jan 9, 2024
2 parents 6c000c6 + 61a4205 commit 47c551a
Show file tree
Hide file tree
Showing 385 changed files with 11,460 additions and 3,684 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Checks
on: [push]
jobs:
checks:
runs-on: ubuntu-latest
env:
BUILD_IN_CONTAINER: false
container:
image: grafana/loki-build-image:0.32.0
steps:
- uses: actions/checkout@v4
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- run: make lint
- run: make check-doc
- run: make check-mod
- run: make validate-example-configs
- run: make check-example-config-doc
- run: make check-drone-drift
- run: make check-generated-files
- run: make test
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

##### Enhancements

* [11363](https://github.com/grafana/loki/pull/11477) **MichelHollands**: support GET for /ingester/shutdown
* [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.
* [11243](https://github.com/grafana/loki/pull/11243) **kavirajk**: Inflight-logging: Add extra metadata to inflight requests logging.
Expand Down Expand Up @@ -42,10 +43,17 @@
* [10956](https://github.com/grafana/loki/pull/10956) **jeschkies** do not wrap requests but send pure Protobuf from frontend v2 via scheduler to querier when `-frontend.encoding=protobuf`.
* [10417](https://github.com/grafana/loki/pull/10417) **jeschkies** shard `quantile_over_time` range queries using probabilistic data structures.
* [11284](https://github.com/grafana/loki/pull/11284) **ashwanthgoli** Config: Adds `frontend.max-query-capacity` to tune per-tenant query capacity.
* [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.

##### 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.
* [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.

##### Changes

Expand All @@ -72,6 +80,7 @@

* [10677](https://github.com/grafana/loki/pull/10677) **chaudum** Remove deprecated `stream_lag_labels` setting from both the `options` and `client` configuration sections.
* [10689](https://github.com/grafana/loki/pull/10689) **dylanguedes**: Ingester: Make jitter to be 20% of flush check period instead of 1%.
* [11420](https://github.com/grafana/loki/pull/11420) **zry98**: Show a clearer reason in "disable watchConfig" log message when server is disabled.

##### Fixes

Expand Down
36 changes: 20 additions & 16 deletions clients/pkg/promtail/promtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,25 +255,29 @@ func (p *Promtail) watchConfig() {
level.Warn(p.logger).Log("msg", "disable watchConfig", "reason", "Promtail newConfig func is Empty")
return
}
promtailServer, ok := p.server.(*server.PromtailServer)
if !ok {
level.Warn(p.logger).Log("msg", "disable watchConfig", "reason", "promtailServer cast fail")
switch srv := p.server.(type) {
case *server.NoopServer:
level.Warn(p.logger).Log("msg", "disable watchConfig", "reason", "Promtail server is disabled")
return
}
level.Warn(p.logger).Log("msg", "enable watchConfig")
hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)
for {
select {
case <-hup:
_ = p.reload()
case rc := <-promtailServer.Reload():
if err := p.reload(); err != nil {
rc <- err
} else {
rc <- nil
case *server.PromtailServer:
level.Warn(p.logger).Log("msg", "enable watchConfig")
hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)
for {
select {
case <-hup:
_ = p.reload()
case rc := <-srv.Reload():
if err := p.reload(); err != nil {
rc <- err
} else {
rc <- nil
}
}
}
default:
level.Warn(p.logger).Log("msg", "disable watchConfig", "reason", "Unknown Promtail server type")
return
}
}

Expand Down
10 changes: 5 additions & 5 deletions clients/pkg/promtail/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,25 @@ func computeExternalURL(u string, port int) (*url.URL, error) {
return eu, nil
}

type noopServer struct {
type NoopServer struct {
log log.Logger
sigs chan os.Signal
}

func newNoopServer(log log.Logger) *noopServer {
return &noopServer{
func newNoopServer(log log.Logger) *NoopServer {
return &NoopServer{
log: log,
sigs: make(chan os.Signal, 1),
}
}

func (s *noopServer) Run() error {
func (s *NoopServer) Run() error {
signal.Notify(s.sigs, syscall.SIGINT, syscall.SIGTERM)
sig := <-s.sigs
level.Info(s.log).Log("msg", "received shutdown signal", "sig", sig)
return nil
}

func (s *noopServer) Shutdown() {
func (s *NoopServer) Shutdown() {
s.sigs <- syscall.SIGTERM
}
14 changes: 14 additions & 0 deletions clients/pkg/promtail/targets/file/filetarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,20 @@ func (t *FileTarget) startTailing(ps []string) {
continue
}

if t.pathExclude != "" {
matched, err := doublestar.Match(t.pathExclude, p)
if err != nil {
level.Error(t.logger).Log("msg", "ignoring file, exclude pattern match failed", "error", err, "filename", p, "pathExclude", t.pathExclude)
t.metrics.totalBytes.DeleteLabelValues(p)
continue
}
if matched {
level.Info(t.logger).Log("msg", "ignoring file", "error", "file matches exclude pattern", "filename", p, "pathExclude", t.pathExclude)
t.metrics.totalBytes.DeleteLabelValues(p)
continue
}
}

var reader Reader
if t.decompressCfg != nil && t.decompressCfg.Enabled {
level.Debug(t.logger).Log("msg", "reading from compressed file", "filename", p)
Expand Down
12 changes: 11 additions & 1 deletion clients/pkg/promtail/targets/file/filetarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ func TestHandleFileCreationEvent(t *testing.T) {
positionsFileName := filepath.Join(dirName, "positions.yml")
logDir := filepath.Join(dirName, "log")
logFile := filepath.Join(logDir, "test1.log")
logFileIgnored := filepath.Join(logDir, "test.donot.log")

if err := os.MkdirAll(logDir, 0750); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -511,7 +512,8 @@ func TestHandleFileCreationEvent(t *testing.T) {
}
}()

target, err := NewFileTarget(metrics, logger, client, ps, path, "", nil, nil, &Config{
pathExclude := "**/*.donot.log"
target, err := NewFileTarget(metrics, logger, client, ps, path, pathExclude, nil, nil, &Config{
// To handle file creation event from channel, set enough long time as sync period
SyncPeriod: 10 * time.Minute,
}, DefaultWatchConig, fakeFileHandler, fakeTargetHandler, "", nil)
Expand All @@ -523,10 +525,18 @@ func TestHandleFileCreationEvent(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = os.Create(logFileIgnored)
if err != nil {
t.Fatal(err)
}
fakeFileHandler <- fsnotify.Event{
Name: logFile,
Op: fsnotify.Create,
}
fakeFileHandler <- fsnotify.Event{
Name: logFileIgnored,
Op: fsnotify.Create,
}
requireEventually(t, func() bool {
return len(target.readers) == 1
}, "Expected tails to be 1 at this point in the test...")
Expand Down
87 changes: 87 additions & 0 deletions cmd/loki/loki-local-with-memcached.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
auth_enabled: false

server:
http_listen_port: 3100
grpc_listen_port: 9096

common:
instance_addr: 127.0.0.1
path_prefix: /tmp/loki
storage:
filesystem:
chunks_directory: /tmp/loki/chunks
rules_directory: /tmp/loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory

query_range:
align_queries_with_step: true
cache_index_stats_results: true
cache_results: true
cache_volume_results: true
cache_series_results: true
series_results_cache:
cache:
default_validity: 12h
memcached_client:
consistent_hash: true
addresses: "dns+localhost:11211"
max_idle_conns: 16
timeout: 500ms
update_interval: 1m
index_stats_results_cache:
cache:
default_validity: 12h
memcached_client:
consistent_hash: true
addresses: "dns+localhost:11211"
max_idle_conns: 16
timeout: 500ms
update_interval: 1m
max_retries: 5
results_cache:
cache:
default_validity: 12h
memcached_client:
consistent_hash: true
addresses: "dns+localhost:11211"
max_idle_conns: 16
timeout: 500ms
update_interval: 1m
volume_results_cache:
cache:
default_validity: 12h
memcached_client:
consistent_hash: true
addresses: "dns+localhost:11211"
max_idle_conns: 16
timeout: 500ms
update_interval: 1m

schema_config:
configs:
- from: 2020-10-24
store: tsdb
object_store: filesystem
schema: v12
index:
prefix: index_
period: 24h

ruler:
alertmanager_url: http://localhost:9093

# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
#
# Statistics help us better understand how Loki is used, and they show us performance
# levels for most users. This helps us prioritize features and documentation.
# For more information on what's sent, look at
# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go
# Refer to the buildReport method to see what goes into a report.
#
# If you would like to disable reporting, uncomment the following lines:
#analytics:
# reporting_enabled: false
3 changes: 1 addition & 2 deletions cmd/migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ func (m *chunkMover) moveChunks(ctx context.Context, threadID int, syncRangeCh <
start := time.Now()
var totalBytes uint64
var totalChunks uint64
//log.Printf("%d processing sync range %d - Start: %v, End: %v\n", threadID, sr.number, time.Unix(0, sr.from).UTC(), time.Unix(0, sr.to).UTC())
schemaGroups, fetchers, err := m.source.GetChunks(m.ctx, m.sourceUser, model.TimeFromUnixNano(sr.from), model.TimeFromUnixNano(sr.to), m.matchers...)
schemaGroups, fetchers, err := m.source.GetChunks(m.ctx, m.sourceUser, model.TimeFromUnixNano(sr.from), model.TimeFromUnixNano(sr.to), chunk.NewPredicate(m.matchers, nil))
if err != nil {
log.Println(threadID, "Error querying index for chunk refs:", err)
errCh <- err
Expand Down
49 changes: 42 additions & 7 deletions docs/sources/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,40 @@ volume_results_cache:
# compression. Supported values are: 'snappy' and ''.
# CLI flag: -frontend.volume-results-cache.compression
[compression: <string> | default = ""]
# Cache series query results.
# CLI flag: -querier.cache-series-results
[cache_series_results: <boolean> | default = false]
# If series_results_cache is not configured and cache_series_results is true,
# the config for the results cache is used.
series_results_cache:
# The cache block configures the cache backend.
# The CLI flags prefix for this block configuration is:
# frontend.series-results-cache
[cache: <cache_config>]
# Use compression in cache. The default is an empty value '', which disables
# compression. Supported values are: 'snappy' and ''.
# CLI flag: -frontend.series-results-cache.compression
[compression: <string> | default = ""]
# Cache label query results.
# CLI flag: -querier.cache-label-results
[cache_label_results: <boolean> | default = false]
# If label_results_cache is not configured and cache_label_results is true, the
# config for the results cache is used.
label_results_cache:
# The cache block configures the cache backend.
# The CLI flags prefix for this block configuration is:
# frontend.label-results-cache
[cache: <cache_config>]
# Use compression in cache. The default is an empty value '', which disables
# compression. Supported values are: 'snappy' and ''.
# CLI flag: -frontend.label-results-cache.compression
[compression: <string> | default = ""]
```

### ruler
Expand Down Expand Up @@ -2844,6 +2878,12 @@ The `limits_config` block configures global and per-tenant limits in Loki.
# CLI flag: -querier.split-queries-by-interval
[split_queries_by_interval: <duration> | default = 1h]

# Split metadata queries by a time interval and execute in parallel. The value 0
# disables splitting metadata queries by time. This also determines how cache
# keys are chosen when label/series result caching is enabled.
# CLI flag: -querier.split-metadata-queries-by-interval
[split_metadata_queries_by_interval: <duration> | default = 1d]

# 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 @@ -3044,13 +3084,6 @@ shard_streams:
# CLI flag: -bloom-compactor.max-table-age
[bloom_compactor_max_table_age: <duration> | default = 168h]

# The minimum age of a table before it is compacted. Do not compact tables newer
# than the the configured time. Default to 1 hour. 0s means no limit. This is
# useful to avoid compacting tables that will be updated with out-of-order
# writes.
# CLI flag: -bloom-compactor.min-table-age
[bloom_compactor_min_table_age: <duration> | default = 1h]

# Whether to compact chunks into bloom filters.
# CLI flag: -bloom-compactor.enable-compaction
[bloom_compactor_enable_compaction: <boolean> | default = false]
Expand Down Expand Up @@ -4283,6 +4316,8 @@ The cache block configures the cache backend. The supported CLI flags `<prefix>`
- `bloom-gateway-client.cache`
- `frontend`
- `frontend.index-stats-results-cache`
- `frontend.label-results-cache`
- `frontend.series-results-cache`
- `frontend.volume-results-cache`
- `store.chunks-cache`
- `store.index-cache-read`
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/configure/bp-configure.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Configuration best practices
menuTitle: Best practices
description: Grafana Loki configuration best practices
description: Describes configuration best practices for Grafana Loki.
weight: 100
---
# Configuration best practices
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/get-started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Get started with Grafana Loki
menuTitle: Get started
weight: 200
description: Overview of the steps for getting started using Loki to collect logs.
description: Provides an overview of the steps for implementing Grafana Loki to collect and view logs.
---

# Get started with Grafana Loki
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/get-started/architecture.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Loki architecture
menutitle: Architecture
description: Grafana Loki's architecture.
description: Describes Grafana Loki's architecture.
weight: 300
aliases:
- ../architecture/
Expand Down
Loading

0 comments on commit 47c551a

Please sign in to comment.