Skip to content

Commit

Permalink
Docker Compose(logs): Enable caches
Browse files Browse the repository at this point in the history
Signed-off-by: Weifeng Wang <qclaogui@gmail.com>

Docker Compose(logs): Enable caches in monolithic-mode

Signed-off-by: Weifeng Wang <qclaogui@gmail.com>
  • Loading branch information
qclaogui committed Mar 19, 2024
1 parent fe9ddcd commit 3112b3a
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 75 deletions.
1 change: 1 addition & 0 deletions docker-compose/common/compose-include/memcached.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:

memcached-exporter:
labels:
- logs.agent.grafana.com/scrape=false
- metrics.agent.grafana.com/scrape=true
# - metrics.agent.grafana.com/job=memcached
- metrics.agent.grafana.com/port=9150
Expand Down
66 changes: 49 additions & 17 deletions docker-compose/common/config/loki/microservices-mode-logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,76 @@ common:
insecure_skip_verify: true

compactor:
working_directory: /tmp/compactor
shared_store: s3

memberlist:
join_members:
- loki-memberlist:7946

frontend:
scheduler_address: query-scheduler:9095
tail_proxy_url: http://querier:3100
frontend_worker:
scheduler_address: query-scheduler:9095
query_range:
align_queries_with_step: true

cache_results: true
results_cache:
cache:
memcached_client:
consistent_hash: true
addresses: "dns+memcached:11211"

cache_index_stats_results: true
index_stats_results_cache:
cache:
memcached_client:
consistent_hash: true
addresses: "dns+memcached:11211"

limits_config:
max_cache_freshness_per_query: 10m
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 30m
split_queries_by_interval: 15m

ruler:
storage:
type: s3
s3:
bucketnames: loki-ruler

runtime_config:
file: /etc/loki/runtime.yaml

schema_config:
configs:
- from: "2023-08-01"
index:
period: 24h
prefix: loki_index_
period: 24h
object_store: s3
store: tsdb
schema: v12

chunk_store_config:
chunk_cache_config:
embedded_cache:
enabled: true
memcached_client:
addresses: "dns+memcached:11211"

query_range:
align_queries_with_step: true
cache_results: true
max_retries: 5
results_cache:
cache:
embedded_cache:
enabled: true
ttl: 1h
ingester:
lifecycler:
join_after: 10s
observe_period: 5s
ring:
replication_factor: 2
chunk_idle_period: 1m
max_chunk_age: 1m
chunk_retain_period: 30s
chunk_encoding: snappy
flush_op_timeout: 10s


frontend:
scheduler_address: query-scheduler:9095
tail_proxy_url: http://querier:3100
frontend_worker:
scheduler_address: query-scheduler:9095
10 changes: 1 addition & 9 deletions docker-compose/common/config/loki/monolithic-mode-logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,13 @@ query_range:
cache_results: true
results_cache:
cache:
default_validity: 12h
memcached_client:
consistent_hash: true
addresses: "dns+memcached:11211"
max_idle_conns: 16
timeout: 500ms
update_interval: 1m

cache_index_stats_results: true
index_stats_results_cache:
cache:
default_validity: 12h
memcached_client:
consistent_hash: true
addresses: "dns+memcached:11211"
Expand All @@ -60,19 +55,16 @@ query_range:
# cache_instant_metric_results: true
# instant_metric_results_cache:
# cache:
# default_validity: 12h
# memcached_client:
# consistent_hash: true
# addresses: "dns+memcached:11211"
# series_results_cache:
# cache:
# default_validity: 12h
# memcached_client:
# consistent_hash: true
# addresses: dns+memcached:11211"
# volume_results_cache:
# cache:
# default_validity: 12h
# memcached_client:
# consistent_hash: true
# addresses: "dns+memcached:11211"
Expand All @@ -96,8 +88,8 @@ schema_config:
configs:
- from: "2023-08-01"
index:
period: 24h
prefix: loki_index_
period: 24h
object_store: s3
store: tsdb
schema: v12
Expand Down
52 changes: 30 additions & 22 deletions docker-compose/common/config/loki/read-write-mode-logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,37 @@ memberlist:

query_range:
align_queries_with_step: true

cache_results: true
results_cache:
cache:
embedded_cache:
enabled: true
memcached_client:
consistent_hash: true
addresses: "dns+memcached:11211"

cache_index_stats_results: true
index_stats_results_cache:
cache:
memcached_client:
consistent_hash: true
addresses: "dns+memcached:11211"

limits_config:
max_cache_freshness_per_query: 10m
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 30m
split_queries_by_interval: 15m

ingester:
lifecycler:
join_after: 10s
observe_period: 5s
ring:
replication_factor: 2
chunk_idle_period: 1m
max_chunk_age: 1m
chunk_retain_period: 30s
chunk_encoding: snappy
flush_op_timeout: 10s

ruler:
storage:
type: s3
s3:
bucketnames: loki-ruler
type: s3


runtime_config:
file: /etc/loki/runtime.yaml

schema_config:
configs:
Expand All @@ -77,11 +79,17 @@ schema_config:

chunk_store_config:
chunk_cache_config:
embedded_cache:
enabled: true

frontend:
compress_responses: true
memcached_client:
addresses: "dns+memcached:11211"

query_scheduler:
max_outstanding_requests_per_tenant: 1024
ingester:
lifecycler:
join_after: 10s
observe_period: 5s
ring:
replication_factor: 2
chunk_idle_period: 1m
max_chunk_age: 1m
chunk_retain_period: 30s
chunk_encoding: snappy
flush_op_timeout: 10s
33 changes: 17 additions & 16 deletions docker-compose/microservices-mode/logs/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version: '3.9'
include:
- path: ../../common/compose-include/minio.yaml
- path: ../../common/compose-include/agent-collect-logs.yaml
- path: ../../common/compose-include/memcached.yaml

x-labels: &loki-labels
- logs.agent.grafana.com/log-format=json
Expand Down Expand Up @@ -48,9 +49,9 @@ services:
condition: service_started
image: &lokiImage ${LOKI_IMAGE:-docker.io/grafana/loki:latest}
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=distributor
- -config.expand-env=true
healthcheck:
Expand All @@ -72,9 +73,9 @@ services:
condition: service_healthy
image: *lokiImage
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=ingester
- -config.expand-env=true
deploy:
Expand All @@ -91,19 +92,19 @@ services:
condition: service_started
image: *lokiImage
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=query-frontend
- -config.expand-env=true

query-scheduler:
labels: *loki-labels
image: *lokiImage
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=query-scheduler
- -config.expand-env=true
deploy:
Expand All @@ -120,9 +121,9 @@ services:
condition: service_started
image: *lokiImage
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=querier
- -config.expand-env=true

Expand All @@ -133,11 +134,11 @@ services:
condition: service_healthy
image: *lokiImage
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -target=ruler
- -config.expand-env=true
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=ruler
- -config.expand-env=true
networks:
default:
aliases:
Expand All @@ -147,9 +148,9 @@ services:
labels: *loki-labels
image: *lokiImage
volumes:
- ../../common/config/loki/microservices-mode-logs.yaml:/etc/loki.yaml # Note: Loki use microservices-mode-logs.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/microservices-mode-logs.yaml
- -target=compactor
- -config.expand-env=true
networks:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose/monolithic-mode/all-in-one/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ services:
condition: service_healthy
image: ${LOKI_IMAGE:-docker.io/grafana/loki:latest}
volumes:
- ../../common/config/loki/monolithic-mode-logs.yaml:/etc/config.yaml
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/config.yaml
- -config.file=/etc/loki/monolithic-mode-logs.yaml
- -target=all
- -config.expand-env=true
environment:
Expand Down
19 changes: 10 additions & 9 deletions docker-compose/read-write-mode/logs/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ version: '3.9'
include:
- path: ../../common/compose-include/minio.yaml
- path: ../../common/compose-include/agent-collect-logs.yaml
- path: ../../common/compose-include/memcached.yaml

x-labels: &loki-labels
- logs.agent.grafana.com/log-format=json
Expand Down Expand Up @@ -47,13 +48,13 @@ services:
minio:
condition: service_healthy
image: &lokiImage ${LOKI_IMAGE:-docker.io/grafana/loki:latest}
volumes:
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/read-write-mode-logs.yaml
- -target=read
- -legacy-read-mode=false
- -config.expand-env=true
volumes:
- ../../common/config/loki/read-write-mode-logs.yaml:/etc/loki.yaml
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
interval: 10s
Expand All @@ -72,12 +73,12 @@ services:
minio:
condition: service_healthy
image: *lokiImage
volumes:
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/read-write-mode-logs.yaml
- -target=write
- -config.expand-env=true
volumes:
- ../../common/config/loki/read-write-mode-logs.yaml:/etc/loki.yaml
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
interval: 10s
Expand All @@ -98,13 +99,13 @@ services:
image: *lokiImage
deploy:
replicas: 2
volumes:
- ../../common/config/loki:/etc/loki
command:
- -config.file=/etc/loki.yaml
- -config.file=/etc/loki/read-write-mode-logs.yaml
- -target=backend
- -legacy-read-mode=false
- -config.expand-env=true
volumes:
- ../../common/config/loki/read-write-mode-logs.yaml:/etc/loki.yaml
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
interval: 10s
Expand Down

0 comments on commit 3112b3a

Please sign in to comment.