Loki

Prerequisites

This guide assumes you have the following prerequisites in place:

Loki

Loki is a log aggregation system designed to store and query logs. It is used in conjunction with Grafana-Alloy

Installation

  1. Create the following directory structure for Loki:

    loki/
    ├── loki-repo.yml
    ├── loki-cm.yml
    ├── loki-release.yml
    └── loki-s3.yml
  2. Add the following content to loki-repo.yml:

    ---
    apiVersion: source.toolkit.fluxcd.io/v1
    kind: HelmRepository
    metadata:
      name: grafana
      namespace: flux-system
    spec:
      interval: 6h
      url: https://grafana.github.io/helm-charts
  3. Add the following content to loki-cm.yml:

    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: loki-helm-values
      namespace: monitoring
    data:
      loki-values.yaml: |-
    
        chunksCache:
          enabled: false
    
        resultsCache:
          enabled: false
    
        loki:
          auth_enabled: false
    
          commonConfig:
            replication_factor: 1
    
          storage:
            type: s3
            bucketNames:
              chunks: loki-chunks
              ruler: loki-chunks
              admin: loki-chunks
            s3:
              endpoint: http://rook-ceph-rgw-ceph-objectstore.rook-ceph.svc.cluster.local:7480
              region: us-east-1
              accessKeyId: ""                     # Set this to your actual access key ID
              secretAccessKey: ""                 # Set this to your actual secret access key
              s3ForcePathStyle: true
              insecure: true
    
          schemaConfig:
            configs:
              - from: "2024-01-01"
                store: tsdb
                object_store: s3
                schema: v13
                index:
                  prefix: loki_index_
                  period: 24h
    
          limits_config:
            allow_structured_metadata: true
            volume_enabled: true
            reject_old_samples: true
            reject_old_samples_max_age: 168h
            ingestion_rate_mb: 32
            ingestion_burst_size_mb: 64
    
        deploymentMode: SingleBinary
    
        singleBinary:
          replicas: 1
          persistence:
            enabled: true
            size: 10Gi
    
        backend:
          replicas: 0
        read:
          replicas: 0
        write:
          replicas: 0
        ingester:
          replicas: 0
        querier:
          replicas: 0
        queryFrontend:
          replicas: 0
        queryScheduler:
          replicas: 0
        distributor:
          replicas: 0
        compactor:
          replicas: 0
        indexGateway:
          replicas: 0
  4. Add the following content to loki-release.yml:

    ---
    apiVersion: helm.toolkit.fluxcd.io/v2
    kind: HelmRelease
    metadata:
      name: loki
      namespace: monitoring
    spec:
      interval: 6h
      chart:
        spec:
          chart: loki
          version: "6.55.0"
          sourceRef:
            kind: HelmRepository
            name: grafana
            namespace: flux-system
          interval: 6h
      upgrade:
        remediation:
          retries: 3
      rollback:
        timeout: 5m
        cleanupOnFail: true
      valuesFrom:
        - kind: ConfigMap
          name: loki-helm-values
          valuesKey: loki-values.yaml
  5. Add the following content to loki-s3.yml to create the S3 bucket for loki:

    ---
    apiVersion: objectbucket.io/v1alpha1
    kind: ObjectBucketClaim
    metadata:
      name: loki-chunks
      namespace: monitoring
    spec:
      bucketName: loki-chunks
      storageClassName: ceph-bucket
  6. Commit and push the files to your Git repository. Flux will deploy loki to your cluster.