diff --git a/docker compositions/loki/docker-compose.yml b/docker compositions/loki/docker-compose.yml new file mode 100644 index 0000000..d49e787 --- /dev/null +++ b/docker compositions/loki/docker-compose.yml @@ -0,0 +1,29 @@ +--- + +services: + loki-1: &loki + image: grafana/loki:3.5.0 + command: >- + -config.file=/etc/loki/local-config.yaml + -target=all + + -reporting.enabled=false + -auth.enabled=false + + -common.storage.ring.instance-addr=localhost + -common.storage.ring.store=memberlist + -memberlist.join=dns+localhost:7946 + + -s3.region=eu-west-1 + -s3.buckets=loki-chunks + loki-2: + <<: *loki + load-balancer: + image: nginx + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - loki-1 + - loki-2 + ports: + - 3100:3100 diff --git a/docker compositions/loki/nginx.conf b/docker compositions/loki/nginx.conf new file mode 100644 index 0000000..9b8ca98 --- /dev/null +++ b/docker compositions/loki/nginx.conf @@ -0,0 +1,18 @@ +events { + worker_connections 1024; +} + +http { + upstream backend { + server loki-1:3100 max_fails=1 fail_timeout=1s; + server loki-2:3100 max_fails=1 fail_timeout=1s; + } + + server { + listen 3100; + access_log /dev/null; + location / { + proxy_pass http://backend; + } + } +} \ No newline at end of file diff --git a/knowledge base/loki.md b/knowledge base/loki.md index dc3e27f..031558c 100644 --- a/knowledge base/loki.md +++ b/knowledge base/loki.md @@ -26,6 +26,8 @@ Designed to be cost-effective and easy to operate. 1. [Microservices mode](#microservices-mode) 1. [Object storage](#object-storage) 1. [Analytics](#analytics) +1. [Troubleshooting](#troubleshooting) + 1. [Too many storage configs provided in the common config](#too-many-storage-configs-provided-in-the-common-config) 1. [Further readings](#further-readings) 1. [Sources](#sources) @@ -71,6 +73,8 @@ Loki runs in multi-tenant mode by default. It: - Ignores that header, and sets the tenant ID to `fake` when multi-tenant mode is disabled. This **will** appear in the index and in stored chunks. +Loki accepts out-of-order writes by default. +
Setup @@ -695,6 +699,93 @@ analytics: reporting_enabled: false ``` +## Troubleshooting + +### Too many storage configs provided in the common config + +Error message example: + +> failed parsing config: too many storage configs provided in the common config, please only define one storage backend + +
+ Context + +Loki is running locally from its Docker container image using the default configuration file and the following flags: + +```yml +--- +# docker-compose.yml +services: + loki: + image: grafana/loki:3.5.0 + command: >- + -config.file=/etc/loki/local-config.yaml + -target=all + + -reporting.enabled=false + -auth.enabled=false + + -common.storage.ring.instance-addr=localhost + -common.storage.ring.store=memberlist + -memberlist.join=dns+localhost:7946 + + -common.storage.s3.region=eu-west-1 + -common.storage.s3.buckets=loki-chunks +``` + +
+ +
+ Root cause + +It seems the command flags for S3 storage are not working as expected. + +
+ +
+ Solution + +Configure those settings (or): + +- In the configuration file: + + ```yml + storage_config: + aws: + bucketnames: loki-chunks + region: eu-west-1 + ``` + +- By removing the `common.storage` part in the command: + + ```yml + command: >- + … + -s3.region=eu-west-1 + -s3.buckets=loki-chunks + ``` + +The end result in `GET /config` is the same: + +```yml +… +storage_config: + alibabacloud: … + aws: + dynamodb: … + s3: "" + s3forcepathstyle: false + bucketnames: loki-chunks + endpoint: "" + region: eu-west-1 + access_key_id: "" + secret_access_key: "" + … + azure: … +``` + +
+ ## Further readings - [Website] diff --git a/snippets/docker.sh b/snippets/docker.sh index 3b94efc..d0f1529 100644 --- a/snippets/docker.sh +++ b/snippets/docker.sh @@ -52,3 +52,6 @@ docker volume create --driver 'convoy' --opt 'size=100m' 'test' # The example uses a 2GB RAM disk hdiutil attach -nomount 'ram://4194304' | xargs diskutil erasevolume HFS+ 'ramdisk' \ && docker run --rm --name 'alpine' -v "/Volumes/ramdisk/:/ramdisk" -it 'alpine' sh + +# Remove containers +docker ps -aq | xargs docker container rm