本人环境:我直接用hostpath存储数据,不建议生产环境这样子,应该使用云存储或者nfs服务器。hostpath:/data/loki
报错:
[root@150m01 ~/kind]# kubectl logs loki-0 -n middle-ware
failed parsing config: /etc/loki/local-config.yaml: yaml: unmarshal errors:
line 3: field chunks_directory not found in type local.FSConfig
line 4: field rules_directory not found in type local.FSConfig
源configmap.yaml文件配置:
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-config
namespace: middle-ware
data:
loki-config.yaml: |
storage_config:
filesystem:
compaction_interval: 1h
working_directory: /data/loki/blocks
compaction_interval: 1h
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
compactor:
working_directory: /data/loki/blocks
shared_store: filesystem
compaction_interval: 1h
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
原因版本问题,loki的配置文件有变更.
storage_config结构调整-->filesystem和boltdb_shipprt必须成对出现,不能独立存在,且schema_config在2.7.*版本必须定义,本次示例将boltdb-shipper作为索引存储方式,filesystem作为对象存储,目录结构也有所调整,active_index_directory作为loki索引存储路径,cache_location作为boltdb缓存位置,chunks_directory&rules_direstory作为日志块和规则存储路径
修改后配置文件
---
apiVersion: v1
kind: ConfigMap
metadata:
name: loki-config
namespace: middle-ware
data:
local-config.yaml: |
storage_config:
boltdb_shipper:
active_index_directory: /data/loki/index
cache_location: /data/loki/boltdb-cache
shared_store: filesystem
filesystem:
chunks_directory: /data/loki/chunks
rules_directory: /data/loki/rules
compactor:
working_directory: /data/loki/blocks
shared_store: filesystem
compaction_interval: 1h
retention_enabled: true
retention_delete_delay: 2h
retention_delete_worker_count: 150
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h