Loki service configuration.

This commit is contained in:
2023-07-21 06:31:05 +01:00
parent 3c1fbc7103
commit 0e7a34a341
2 changed files with 119 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ in
allow_privileged = true; allow_privileged = true;
# for keepalived, though only really needing "NET_ADMIN","NET_BROADCAST","NET_RAW" on top of default # for keepalived, though only really needing "NET_ADMIN","NET_BROADCAST","NET_RAW" on top of default
allow_caps = ["all"]; allow_caps = ["all"];
volumes.enabled = true;
}; };
}; };

118
services/loki.hcl Normal file
View File

@@ -0,0 +1,118 @@
job "loki" {
datacenters = ["alo"]
type = "service"
update {
max_parallel = 1
health_check = "checks"
min_healthy_time = "10s"
healthy_deadline = "3m"
progress_deadline = "5m"
}
group "loki" {
count = 1
restart {
attempts = 3
interval = "5m"
delay = "25s"
mode = "delay"
}
network {
port "loki" {
# static so that it can be hardcoded in the grafana data source
static = 3100
}
}
task "loki" {
driver = "docker"
config {
image = "grafana/loki:2.8.2"
args = [
"-config.file",
"local/loki/local-config.yaml",
]
ports = ["loki"]
volumes = ["/data/compute/appdata/loki:/loki"]
}
template {
data = <<EOH
auth_enabled: false
server:
http_listen_port: 3100
ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
# Any chunk not receiving new logs in this time will be flushed
chunk_idle_period: 1h
# All chunks will be flushed when they hit this age, default is 1h
max_chunk_age: 1h
# Loki will attempt to build chunks up to 1.5MB, flushing if chunk_idle_period or max_chunk_age is reached first
chunk_target_size: 1048576
# Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
chunk_retain_period: 30s
max_transfer_retries: 0 # Chunk transfers disabled
wal:
dir: "/tmp/wal"
schema_config:
configs:
- from: 2023-01-01
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
storage_config:
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: /tmp/loki/boltdb-shipper-compactor
shared_store: filesystem
limits_config:
reject_old_samples: true
reject_old_samples_max_age: 168h
chunk_store_config:
max_look_back_period: 0s
table_manager:
retention_deletes_enabled: false
retention_period: 0s
EOH
destination = "local/loki/local-config.yaml"
}
resources {
cpu = 512
memory = 256
}
service {
name = "loki"
port = "loki"
check {
name = "Loki healthcheck"
port = "loki"
type = "http"
path = "/ready"
interval = "20s"
timeout = "5s"
check_restart {
limit = 3
grace = "60s"
ignore_warnings = false
}
}
tags = [
"traefik.enable=true",
"traefik.http.routers.loki.entryPoints=websecure",
]
}
}
}
}