菜单
文档breadcrumb arrow Grafana Lokibreadcrumb arrow 设置breadcrumb arrow 迁移breadcrumb arrow 迁移到 Thanos 存储客户端
开源 RSS

迁移到 Thanos 存储客户端

Loki 3.4 版本引入了基于 Thanos 对象存储客户端 Go 模块的新对象存储客户端。

进行此更改的原因之一是使 Grafana Loki、Mimir 以及 Grafana Labs 其他遥测数据库的存储配置保持一致。如果您已经在使用 Grafana Mimir 或 Pyroscope,则可以重复使用存储配置来设置 Loki。

在 Loki 3.4 版本中,这是一项可选功能。在未来的版本中,Thanos 将成为配置存储的默认方式,现有存储客户端将被弃用。

注意

新的存储配置与现有格式不同。以下各节详细描述了每个提供商的更改。请参阅Thanos 存储配置参考以查看支持的存储提供商及其配置选项的完整列表。

启用新的存储客户端

  1. 通过在 storage_config 部分设置 use_thanos_objstoretrue,或通过将 -use-thanos-objstore 标志设置为 true 来启用 Thanos 存储客户端。启用后,storage_config.object_store 下的配置将生效,而不是现有的存储配置。

    yaml
    # Uses the new storage clients for connecting to gcs backend
    storage_config:
      use_thanos_objstore: true # enable the new storage clients
      object_store:
        gcs:
          bucket_name: "example-bucket"
  2. 作为替代方案,如果您更喜欢使用 common 配置部分,也可以在公共的 storage 部分配置新客户端。

    yaml
    storage_config:
       use_thanos_objstore: true # enable the new storage clients
    common:
      storage:
        object_store:
          gcs:
            bucket_name: "example-bucket"
  3. 使用新的存储客户端时,Ruler 存储应配置在 ruler_storage 部分下。

    yaml
    storage_config:
       use_thanos_objstore: true # enable the new storage clients
    ruler_storage:
       backend: gcs
       gcs:
          bucket_name: "example-bucket"
  4. 如果您使用的是 store.object-prefix 标志或相应的 object_prefix YAML 设置,您需要更新配置以使用新的 object_store.storage-prefix 标志或相应的 storage_prefix YAML 设置。

    yaml
    # Example configuration to prefix all objects with "prefix"
    storage_config:
       use_thanos_objstore: true # enable the new storage clients
       object_store:
          storage_prefix: "prefix"

GCS 存储迁移

从现有 Google Cloud Storage (GCS) 存储客户端迁移到新的基于 Thanos 的客户端时,您需要按如下方式更新配置参数

现有参数新参数所需更改
bucket_namebucket_name无需更改
service_accountservice_account无需更改
chunk_buffer_sizechunk_buffer_size无需更改
enable_retriesmax_retriesenable_retries (bool) 替换为 max_retries (int)。设置值 > 1 以启用重试,或设置 1 以禁用重试。
request_timeout已移除移除参数
enable_opencensus已移除移除参数
enable_http2已移除移除参数

配置迁移示例 (GCS)

现有配置

yaml
storage_config:
  gcs:
    bucket_name: example-bucket
    chunk_buffer_size: 10MB
    enable_retries: true

新配置 (基于 Thanos)

yaml
storage_config:
  use_thanos_objstore: true
  object_store:
    gcs:
      bucket_name: example-bucket
      chunk_buffer_size: 10MB
      max_retries: 5

Amazon S3 存储迁移

从现有 Amazon S3 存储客户端迁移到新的基于 Thanos 的客户端时,请按如下方式更新或移除参数

现有参数新参数所需更改
bucket_namesbucket_name重命名此参数。如果您以前使用多个桶,则必须合并为一个桶(Thanos 仅支持一个)。
endpointendpoint无需更改。
regionregion无需更改。
access_key_idaccess_key_id无需更改。
secret_access_keysecret_access_key无需更改。
session_tokensession_token无需更改。
insecureinsecure无需更改。
disable_dualstackdualstack_enabled已重命名并反转。如果您的 disable_dualstackfalse,请设置 dualstack_enabledtrue
storage_classstorage_class无需更改。
s3已移除如果您使用了基于 URL 的设置,请移除或替换为 endpoint
S3ForcePathStyle已移除或替换如果您需要基于路径的寻址,请在新配置中设置 bucket_lookup_type: path。否则,将其移除。
signature_version已移除移除参数。Thanos 始终使用 Signature Version 4 (V4)。
http_confighttp将子字段(例如超时、CA 文件等)移动到 Thanos 配置中的 http: 块中。
ssesse将所有 SSE 设置(例如 typekms_key_id)迁移到 Thanos 配置中的 sse: 块中。
backoff_configmax_retries将高级退避设置替换为单个整数 (max_retries)。设置为 1 以禁用重试,或设置为更高的值以启用重试。

配置迁移示例 (S3)

现有配置

yaml
storage_config:
  aws:
    bucket_names: my-bucket1,my-bucket2   # multiple buckets no longer supported
    endpoint: s3.amazonaws.com
    region: us-west-2
    access_key_id: example-key
    secret_access_key: example-secret
    signature_version: v4
    disable_dualstack: true
    storage_class: STANDARD
    http_config:
      timeout: 1m
      insecure_skip_verify: false
    # ...
    backoff_config:
      max_retries: 5
    sse:
      type: SSE-KMS
      kms_key_id: mySSEKey

新配置 (基于 Thanos)

yaml
storage_config:
  use_thanos_objstore: true
  object_store:
    s3:
      bucket_name: my-bucket1                       # single bucket
      endpoint: s3.amazonaws.com
      region: us-west-2
      access_key_id: example-key
      secret_access_key: example-secret
      dualstack_enabled: false                        # was disable_dualstack: true
      storage_class: STANDARD
      max_retries: 5
      http:
        insecure_skip_verify: false
      sse:
        type: SSE-KMS
        kms_key_id: mySSEKey

有关更多高级配置选项(例如 list_objects_versionbucket_lookup_type 等),请参阅Thanos S3 配置参考

Azure 存储迁移

从现有 Azure 存储客户端迁移到新的基于 Thanos 的客户端时,如果您使用以下参数,则无需更改

现有参数新参数所需更改
account_nameaccount_name无需更改
account_keyaccount_key无需更改
container_namecontainer_name无需更改
endpoint_suffixendpoint_suffix无需更改
user_assigned_iduser_assigned_id无需更改
connection_stringconnection_string无需更改
max_retriesmax_retries无需更改
chunk_delimiterchunk_delimiter无需更改

如果您使用的身份验证方法不是存储帐户密钥或用户分配的托管身份,则必须使用环境变量传递必要的凭据。有关更多详细信息,请参阅 Azure Identity Client Module for Go

文件系统存储迁移

从现有 文件系统存储 客户端迁移到新的基于 Thanos 的客户端时,请按如下方式更新或移除参数

现有参数新参数所需更改
directorydirdirectory 重命名为 dir

配置迁移示例 (文件系统)

现有配置 (FSConfig)

yaml
storage_config:
  filesystem:
    directory: /var/loki/chunks

新配置 (基于 Thanos)

yaml
storage_config:
  use_thanos_objstore: true
  object_store:
    filesystem:
      dir: /var/loki/chunks

注意

对于此处未列出的提供商,请参阅 Thanos 存储配置参考