Skip to content

Commit

Permalink
Update local and docker default config files to use boltdb-shipper wi…
Browse files Browse the repository at this point in the history
…th a few other config changes (#2803)

* change the default local and docker config files to use boltdb-shipper
also change them to use chunk_target_size

* create ruler local filesystems directories if they don't exist
change the ruler paths to be a little more consistent

* don't need to create temp dir, also checking for the storage type

* add compactor config to docker config file.
  • Loading branch information
slim-bean authored Oct 25, 2020
1 parent 2793499 commit af6e8cb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
31 changes: 19 additions & 12 deletions cmd/loki/loki-docker-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,36 @@ ingester:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m
chunk_retain_period: 30s
max_transfer_retries: 0
chunk_idle_period: 1h # Any chunk not receiving new logs in this time will be flushed
max_chunk_age: 1h # All chunks will be flushed when they hit this age, default is 1h
chunk_target_size: 1048576 # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
chunk_retain_period: 30s # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
max_transfer_retries: 0 # Chunk transfers disabled

schema_config:
configs:
- from: 2018-04-15
store: boltdb
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 168h
period: 24h

storage_config:
boltdb:
directory: /loki/index

boltdb_shipper:
active_index_directory: /loki/boltdb-shipper-active
cache_location: /loki/boltdb-shipper-cache
cache_ttl: 24h # Can be increased for faster performance over longer query periods, uses more disk space
shared_store: filesystem
filesystem:
directory: /loki/chunks

compactor:
working_directory: /loki/boltdb-shipper-compactor
shared_store: filesystem

limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h

Expand All @@ -49,8 +56,8 @@ ruler:
type: local
local:
directory: /loki/rules
rule_path: /loki/tmprules
alertmanager_url: http://localhost
rule_path: /loki/rules-temp
alertmanager_url: http://localhost:9093
ring:
kvstore:
store: inmemory
Expand Down
33 changes: 20 additions & 13 deletions cmd/loki/loki-local-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,36 @@ ingester:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m
chunk_retain_period: 30s
max_transfer_retries: 0
chunk_idle_period: 1h # Any chunk not receiving new logs in this time will be flushed
max_chunk_age: 1h # All chunks will be flushed when they hit this age, default is 1h
chunk_target_size: 1048576 # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
chunk_retain_period: 30s # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
max_transfer_retries: 0 # Chunk transfers disabled

schema_config:
configs:
- from: 2018-04-15
store: boltdb
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 168h
period: 24h

storage_config:
boltdb:
directory: /tmp/loki/index

boltdb_shipper:
active_index_directory: /tmp/loki/boltdb-shipper-active
cache_location: /tmp/loki/boltdb-shipper-cache
cache_ttl: 24h # Can be increased for faster performance over longer query periods, uses more disk space
shared_store: filesystem
filesystem:
directory: /tmp/loki/chunks

compactor:
working_directory: /tmp/loki/boltdb-shipper-compactor
shared_store: filesystem

limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h

Expand All @@ -48,9 +55,9 @@ ruler:
storage:
type: local
local:
directory: /tmp/rules
rule_path: /tmp/scratch
alertmanager_url: http://localhost
directory: /tmp/loki/rules
rule_path: /tmp/loki/rules-temp
alertmanager_url: http://localhost:9093
ring:
kvstore:
store: inmemory
Expand Down
9 changes: 9 additions & 0 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cortexproject/cortex/pkg/chunk/cache"
"github.com/cortexproject/cortex/pkg/chunk/storage"
cortex_storage "github.com/cortexproject/cortex/pkg/chunk/storage"
chunk_util "github.com/cortexproject/cortex/pkg/chunk/util"
"github.com/cortexproject/cortex/pkg/cortex"
cortex_querier "github.com/cortexproject/cortex/pkg/querier"
"github.com/cortexproject/cortex/pkg/querier/frontend"
Expand Down Expand Up @@ -426,6 +427,14 @@ func (t *Loki) initRulerStorage() (_ services.Service, err error) {
return nil, errors.New("configdb is not supported as a Loki rules backend type")
}

// Make sure storage directory exists if using filesystem store
if t.cfg.Ruler.StoreConfig.Type == "local" && t.cfg.Ruler.StoreConfig.Local.Directory != "" {
err := chunk_util.EnsureDirectory(t.cfg.Ruler.StoreConfig.Local.Directory)
if err != nil {
return nil, err
}
}

t.RulerStorage, err = cortex_ruler.NewRuleStorage(t.cfg.Ruler.StoreConfig, manager.GroupLoader{})

return
Expand Down

0 comments on commit af6e8cb

Please sign in to comment.