From 3ef384b62afe3dfb3142a5f631ec7be754a6393e Mon Sep 17 00:00:00 2001 From: Bruce Becker Date: Sun, 23 Apr 2023 19:41:44 +0200 Subject: [PATCH] fix(loki): use consul as distributor ring (#28) fix(loki): use consul as distributor ring Signed-off-by: Bruce Becker fix(loki): provide working configuration for S3 object store on R2 Signed-off-by: Bruce Becker --------- Signed-off-by: Bruce Becker --- loki.nomad | 28 ++++++++++++++++++++++------ loki.yml.tpl | 24 ++++++++++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/loki.nomad b/loki.nomad index 8aa2013..b71de99 100644 --- a/loki.nomad +++ b/loki.nomad @@ -3,6 +3,21 @@ variable "loki_version" { default = "v2.7.5" } +variable "cloudflare_account_id" { + type = string + description = "Cloudflare Account ID if using r2" +} + +variable "s3_access_key_id" { + type = string + description = "Access Key ID for S3 object storage" +} + +variable "s3_secret_access_key" { + type = string + description = "Secret Access Key for S3 object storage" +} + job "loki" { datacenters = ["dc1"] type = "service" @@ -28,12 +43,8 @@ job "loki" { count = 1 network { - port "http" { - static = 3100 - } - port "grpc" { - static = 9096 - } + port "http" {} + port "grpc" {} } service { name = "loki-http-server" @@ -64,6 +75,11 @@ job "loki" { "-config.file=local/loki.yml" ] } + env { + s3_endpoint = var.cloudflare_account_id + access_key_id = var.s3_access_key_id + secret_access_key = var.s3_secret_access_key + } resources { cpu = 128 memory = 200 diff --git a/loki.yml.tpl b/loki.yml.tpl index efcf293..b29a2e6 100644 --- a/loki.yml.tpl +++ b/loki.yml.tpl @@ -1,5 +1,4 @@ auth_enabled: false - server: http_listen_port: {{ env "NOMAD_PORT_http" }} grpc_listen_port: {{ env "NOMAD_PORT_grpc" }} @@ -7,11 +6,11 @@ server: http_server_read_timeout: "40s" http_server_write_timeout: "50s" -{{/* distributor: +distributor: ring: kvstore: store: consul - prefix: loki/collectors */}} + prefix: loki/collectors ingester: lifecycler: @@ -27,9 +26,11 @@ ingester: flush_op_timeout: 20m schema_config: configs: +{{/* store: boltdb-shipper + object_store: filesystem*/}} - from: 2022-01-01 store: boltdb-shipper - object_store: filesystem + object_store: aws schema: v11 index: prefix: loki_ @@ -41,6 +42,21 @@ storage_config: cache_location: local/index_cache filesystem: directory: local/index + aws: + bucketnames: hah-logs + endpoint: {{ env "s3_endpoint" }}.r2.cloudflarestorage.com + region: auto + access_key_id: {{ env "access_key_id" }} + secret_access_key: {{ env "secret_access_key" }} + insecure: false + sse_encryption: false + http_config: + idle_conn_timeout: 90s + insecure_skip_verify: false + s3forcepathstyle: true + dynamodb: + dynamodb_url: inmemory + limits_config: enforce_metric_name: false