# Disable multi-tenant auth for now. You can turn this on later if needed.
auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9095
  log_level: info

# Common settings shared by all Loki components when running as a single binary.
common:
  # Where Loki keeps WAL, indexes cache, compactor work dir, etc.
  path_prefix: /var/loki

  # For a single-node deployment, in-memory ring is ok.
  ring:
    kvstore:
      store: inmemory

  # Replication factor = 1 is fine for single node.
  replication_factor: 1

# TSDB single-store schema using 'filesystem'.
# Note: TSDB is still used, but the object_store is local filesystem.
schema_config:
  configs:
    - from: "2024-04-01"
      store: tsdb
      object_store: filesystem
      schema: v13
      index:
        prefix: index_
        period: 24h

# Storage configuration:
storage_config:
  # tsdb_shipper handles local index cache & sync.
  tsdb_shipper:
    active_index_directory: /var/loki/index
    cache_location: /var/loki/index_cache

  filesystem:
    directory: /var/loki/chunks

# Compactor handles TSDB index compaction + retention pruning.
compactor:
  working_directory: /var/loki/compactor
  compaction_interval: 10m
  retention_enabled: true
  retention_delete_delay: 2h
  retention_delete_worker_count: 150
  delete_request_store: inmemory

# Global limits – these protect Loki from abusive tenants and give you retention.
limits_config:
  ingestion_rate_mb: 10              # per-tenant soft limit
  ingestion_burst_size_mb: 20
  max_label_names_per_series: 30
  max_label_value_length: 2048
  max_streams_per_user: 100000
  max_query_series: 500000
  max_query_length: 2160h
  max_query_parallelism: 32
  retention_period: 2160h
  allow_structured_metadata: true

# Ingestion / WAL / chunk behavior.
ingester:
  chunk_encoding: snappy
  lifecycler:
    num_tokens: 512
    join_after: 0s
    observe_period: 5s
    final_sleep: 0s

  chunk_idle_period: 5m
  max_chunk_age: 1h
  chunk_target_size: 1536000

# Query path settings – these matter for performance.
querier:
  max_concurrent: 8

query_range:
  align_queries_with_step: true
  cache_results: true
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 100

frontend:
  log_queries_longer_than: 5s
  max_outstanding_per_tenant: 1024

frontend_worker:
  frontend_address: 127.0.0.1:9095

# Ruler is optional; you can disable this if you don’t use log-based alerts yet.
#ruler:
#  rule_path: /var/loki/rules
#  enable_api: true
#  alertmanager_url: http://alertmanager:9093
#  ring:
#    kvstore:
#      store: inmemory
#  storage:
#    type: local
#    local:
#      directory: /var/loki/rules

# Turn off telemetry if you don’t want to send usage data.
analytics:
  reporting_enabled: false