迁移到 Thanos 存储客户端
Loki 3.4 版本引入了基于 Thanos 对象存储客户端 Go 模块的新对象存储客户端。
进行此更改的原因之一是使 Grafana Loki、Mimir 以及 Grafana Labs 其他遥测数据库的存储配置保持一致。如果您已经在使用 Grafana Mimir 或 Pyroscope,则可以重复使用存储配置来设置 Loki。
在 Loki 3.4 版本中,这是一项可选功能。在未来的版本中,Thanos 将成为配置存储的默认方式,现有存储客户端将被弃用。
注意
新的存储配置与现有格式不同。以下各节详细描述了每个提供商的更改。请参阅Thanos 存储配置参考以查看支持的存储提供商及其配置选项的完整列表。
启用新的存储客户端
通过在
storage_config
部分设置use_thanos_objstore
为true
,或通过将-use-thanos-objstore
标志设置为 true 来启用 Thanos 存储客户端。启用后,storage_config.object_store
下的配置将生效,而不是现有的存储配置。# 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"
作为替代方案,如果您更喜欢使用
common
配置部分,也可以在公共的storage
部分配置新客户端。storage_config: use_thanos_objstore: true # enable the new storage clients common: storage: object_store: gcs: bucket_name: "example-bucket"
使用新的存储客户端时,Ruler 存储应配置在
ruler_storage
部分下。storage_config: use_thanos_objstore: true # enable the new storage clients ruler_storage: backend: gcs gcs: bucket_name: "example-bucket"
如果您使用的是
store.object-prefix
标志或相应的object_prefix
YAML 设置,您需要更新配置以使用新的object_store.storage-prefix
标志或相应的storage_prefix
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_name | bucket_name | 无需更改 |
service_account | service_account | 无需更改 |
chunk_buffer_size | chunk_buffer_size | 无需更改 |
enable_retries | max_retries | 将 enable_retries (bool) 替换为 max_retries (int)。设置值 > 1 以启用重试,或设置 1 以禁用重试。 |
request_timeout | 已移除 | 移除参数 |
enable_opencensus | 已移除 | 移除参数 |
enable_http2 | 已移除 | 移除参数 |
配置迁移示例 (GCS)
现有配置
storage_config:
gcs:
bucket_name: example-bucket
chunk_buffer_size: 10MB
enable_retries: true
新配置 (基于 Thanos)
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_names | bucket_name | 重命名此参数。如果您以前使用多个桶,则必须合并为一个桶(Thanos 仅支持一个)。 |
endpoint | endpoint | 无需更改。 |
region | region | 无需更改。 |
access_key_id | access_key_id | 无需更改。 |
secret_access_key | secret_access_key | 无需更改。 |
session_token | session_token | 无需更改。 |
insecure | insecure | 无需更改。 |
disable_dualstack | dualstack_enabled | 已重命名并反转。如果您的 disable_dualstack 为 false ,请设置 dualstack_enabled 为 true 。 |
storage_class | storage_class | 无需更改。 |
s3 | 已移除 | 如果您使用了基于 URL 的设置,请移除或替换为 endpoint 。 |
S3ForcePathStyle | 已移除或替换 | 如果您需要基于路径的寻址,请在新配置中设置 bucket_lookup_type: path 。否则,将其移除。 |
signature_version | 已移除 | 移除参数。Thanos 始终使用 Signature Version 4 (V4)。 |
http_config | http | 将子字段(例如超时、CA 文件等)移动到 Thanos 配置中的 http: 块中。 |
sse | sse | 将所有 SSE 设置(例如 type 、kms_key_id )迁移到 Thanos 配置中的 sse: 块中。 |
backoff_config | max_retries | 将高级退避设置替换为单个整数 (max_retries )。设置为 1 以禁用重试,或设置为更高的值以启用重试。 |
配置迁移示例 (S3)
现有配置
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)
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_version
、bucket_lookup_type
等),请参阅Thanos S3 配置参考。
Azure 存储迁移
从现有 Azure 存储客户端迁移到新的基于 Thanos 的客户端时,如果您使用以下参数,则无需更改
现有参数 | 新参数 | 所需更改 |
---|---|---|
account_name | account_name | 无需更改 |
account_key | account_key | 无需更改 |
container_name | container_name | 无需更改 |
endpoint_suffix | endpoint_suffix | 无需更改 |
user_assigned_id | user_assigned_id | 无需更改 |
connection_string | connection_string | 无需更改 |
max_retries | max_retries | 无需更改 |
chunk_delimiter | chunk_delimiter | 无需更改 |
如果您使用的身份验证方法不是存储帐户密钥或用户分配的托管身份,则必须使用环境变量传递必要的凭据。有关更多详细信息,请参阅 Azure Identity Client Module for Go。
文件系统存储迁移
从现有 文件系统存储 客户端迁移到新的基于 Thanos 的客户端时,请按如下方式更新或移除参数
现有参数 | 新参数 | 所需更改 |
---|---|---|
directory | dir | 将 directory 重命名为 dir 。 |
配置迁移示例 (文件系统)
现有配置 (FSConfig
)
storage_config:
filesystem:
directory: /var/loki/chunks
新配置 (基于 Thanos)
storage_config:
use_thanos_objstore: true
object_store:
filesystem:
dir: /var/loki/chunks
注意
对于此处未列出的提供商,请参阅 Thanos 存储配置参考。