Grafana Loki with S3 Backend Using Tanka

官網文件安裝起不來,因為文件跟很深的預設值會裝出 schema on GCP + data on AWS 組態。

如果不依賴 helm charts 做自動化的話,建議依照官方建議用 Tanka | Grafana Labs 安裝。

要補上的主要是 schema_config 那一段

local gateway = import 'loki/gateway.libsonnet';
local loki = import 'loki/loki.libsonnet';
local promtail = import 'promtail/promtail.libsonnet';

loki + promtail + gateway {
  _config+:: {
    namespace: 'loki',
    htpasswd_contents: '',

    // S3 variables remove if not using aws
    storage_backend: 's3',
    s3_access_key: '',
    s3_secret_access_key: '',
    s3_address: 'ap-northeast-1',
    s3_bucket_name: 'loki',

    //Set this variable based on the type of object storage you're using.
    boltdb_shipper_shared_store: 's3',
    compactor_pvc_class: 'gp2',

    loki+: {
      schema_config: {
        configs: [{
          from: '2020-10-24',
          store: 'boltdb-shipper',
          object_store: 's3',
          schema: 'v11',
          index: {
            prefix: '%s_index_' % $._config.table_prefix,
            period: '%dh' % $._config.index_period_hours,
          },
        }],
      },
    },

    promtail_config+: {
      clients: [{
        scheme:: 'http',
        hostname:: 'gateway.%(namespace)s.svc' % $._config,
        username:: 'loki',
        password:: '',
        container_root_path:: '/var/lib/docker',
      }],
    },

    replication_factor: 3,
    consul_replicas: 1,
  },
}

在 Grafana Data Source 用 http://gateway.loki.svc 就可以了

發表留言