Try   HackMD

Loki Helm 安裝時的參數控制

Loki Configuration Doc : https://grafana.com/docs/loki/latest/configuration/

環境

依據 這篇 官方部落格新聞指出,未來 Loki 使用 Helm 安裝時,建議使用 Loki 這個選項安裝即可。

Loki Helm Package Name: Loki
Loki Helm Version : 4.6.0
Loki Version : 2.7.*

Kubernetes : RKE2 1.24.*
Istio : Rancher 內建安裝工具所提供的版本 (1.14)

Grafana Dashboard : https://grafana.com/grafana/dashboards/14876-grafana-loki-dashboard-for-istio-service-mesh/

問題

  • too many outstanding requests

參考解決方案:https://github.com/grafana/loki/issues/5123#issuecomment-1248358971

調整 query_scheduler.max_outstanding_requests_per_tenant 設定值,此值預設為 100,可以考慮往上增加。
在參考解決方案的資料中,多數回覆者會將此值設定為 10,000 或更高,但目前我調整到 2,000 就可以解決大多數問題,若資料量夠多,我也建議再往上增加。

  • maximum of series (500) reached for a single query

參考解決方案:https://github.com/grafana/loki/issues/3045#issuecomment-1178904555

調整 limits_config.max_query_series 設定值,此值預設為 500,可以考慮往上增加。
在參考解決方案的文件中,多數回覆者會將此值設定為 100,000 或更高,但目前我調整到 2,000 就可以解決大多數問題,若資料量夠多,我也建議再往上增加。

  • net/http: timeout awaiting response headers

當有些條件式查詢內容過多,或是時間區間過長時,會出現查詢 timeout 的問題,可以調整 server.http_server_read_timeout 參數來控制 timeout 時間;預設為 30 秒。

也可以依據狀況去調整 Querier 的相關 timeout 時間。

ArgoCD Application Yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  labels:
    type: cluster-infra
  namespace: argocd
  name: loki
spec:
  destination:
    name: 'in-cluster'
    namespace: kube-monitor
  source:
    repoURL: 'https://grafana.github.io/helm-charts'
    targetRevision: 4.6.0
    chart: loki
    helm:
      releaseName: loki
      valueFiles:
        - values.yaml
      parameters:
        - name: global.dnsService
          value: rke2-coredns-rke2-coredns
        - name: 'loki.auth_enabled'
          value: 'false'
        - name: loki.storage.s3.endpoint
          value: 'http://<endpoint>/<bucketnames>'
        - name: loki.storage.s3.accessKeyId
          value: 'accessKeyId'
        - name: loki.storage.s3.secretAccessKey
          value: 'secretAccessKey'
        - name: loki.storage.s3.s3ForcePathStyle
          value: 'true'
        - name: loki.limits_config.max_query_series
          value: '2000'
        - name: loki.query_scheduler.max_outstanding_requests_per_tenant
          value: '2000'
        - name: loki.server.http_server_read_timeout
          value: 1m
        - name: write.persistence.size
          value: 2Gi
        - name: read.persistence.size
          value: 2Gi
  project: default
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
      - ApplyOutOfSyncOnly=true
      - PruneLast=true
      - RespectIgnoreDifferences=true
  ignoreDifferences:
    - group: apps
      kind: Deployment
      jsonPointers:
        - /spec/replicas
  revisionHistoryLimit: 3