拉取helm-charts源

[root@iZj6c1l5tx8mlviyq0z462Z kube-prometheus-stack]# helm repo add grafana https://grafana.github.io/helm-charts
"grafana" has been added to your repositories
[root@iZj6c1l5tx8mlviyq0z462Z kube-prometheus-stack]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "grafana" chart repository
...Successfully got an update from the "prometheus-community" chart repository
Update Complete. ⎈Happy Helming!⎈

将helm源pull到本地

[root@iZj6c1l5tx8mlviyq0z462Z cloud-prometheus]# helm pull grafana/loki-stack
[root@iZj6c1l5tx8mlviyq0z462Z cloud-prometheus]# ls
loki-stack-2.10.3.tgz
[root@iZj6c1l5tx8mlviyq0z462Z cloud-prometheus]# tar -xf loki-stack-2.10.3.tgz

loki内存资源限制标准

日志量/天推荐 memory request推荐 memory limit备注
<5 GB1 Gi2 Gidev 或小型生产环境
5-20 GB2-4 Gi4-8 Gi中型生产
20-50 GB4-8 Gi8-12 Gi高频写入 + 查询
>50 GB8+ Gi16+ Gi需要水平扩展

自定义 values配置loki-values.yaml

loki:
  enabled: true
  image:
    tag: 2.9.17
  config:
    schema_config:
      configs:
      - from: 2025-12-01
        store: boltdb-shipper
        object_store: filesystem
        schema: v11
        index:
          prefix: index_
          period: 24h
    ingester: 
      # 单个 chunk 的目标大小,太小内存占用高,太大查询延迟增加, 调大,减少索引和内存占用    
      chunk_target_size: 3145728   # 3 * 1024 * 1024 = 3MB
      # chunk 在内存中最大存在时间,超过后 flush 到存储
      max_chunk_age: 3600          # 秒为单位,1h = 3600s  
  resources:
    limits:
      cpu: 1
      memory: 2Gi
    requests:
      cpu: 0.5
      memory: 1Gi
  persistence:
    enabled: true
    # 需要注意云供应商的最小硬盘空间大小是否大于10Gi
    size: 50Gi
    storageClassName: alicloud-disk-essd

grafana:
  enabled: false   # 你已经有 kube-prometheus-stack 自带 Grafana
  sidecar:
    datasources:
      enabled: true

promtail:
  enabled: true
  config:
    clients:
      - url: http://loki:3100/loki/api/v1/push

grafanaServiceAccount:
  enabled: true

安装loki+promtail

[root@iZj6c1l5tx8mlviyq0z462Z kube-prometheus-stack]# helm upgrade --install loki grafana/loki-stack   -n monitoring   -f loki-values.yaml
Release "loki" does not exist. Installing it now.
WARNING: This chart is deprecated
NAME: loki
LAST DEPLOYED: Mon Dec  1 10:28:47 2025
NAMESPACE: monitoring
STATUS: deployed
REVISION: 1
NOTES:
The Loki stack has been deployed to your cluster. Loki can now be added as a datasource in Grafana.

See http://docs.grafana.org/features/datasources/loki/ for more detail.

查看安装好的stack

[root@iZj6c1l5tx8mlviyq0z462Z kube-prometheus-stack]# helm list -n monitoring
NAME      	NAMESPACE 	REVISION	UPDATED                                	STATUS  	CHART                        	APP VERSION        
loki      	monitoring	1       	2025-12-01 10:06:16.34834821 +0800 CST 	deployed	loki-stack-2.10.3            	v2.9.3 
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐