8.4. ログの LokiStack への転送

LokiStack ゲートウェイへのログ転送を設定するには、ClusterLogging カスタムリソース (CR) を作成する必要があります。

前提条件

  • Red Hat OpenShift のロギングサブシステム: 5.5 以降
  • Loki Operator Operator

手順

  1. ClusterLogging カスタムリソース (CR) を定義する YAML ファイルを作成または編集します。
apiVersion: logging.openshift.io/v1
kind: ClusterLogging
metadata:
  name: instance
  namespace: openshift-logging
spec:
  managementState: Managed
  logStore:
    type: lokistack
    lokistack:
      name: logging-loki
  collection:
    type: vector

8.4.1. "entry out of order" エラーのトラブルシューティング

Fluentd がレート制限を超えるサイズの大きいメッセージブロックを Loki ロギングシステムに転送する場合には、Loki は "entry out of order" のエラーを生成します。この問題を修正するには、Loki サーバー設定ファイル loki.yaml のいくつかの値を更新します。

注記

loki.yaml は、Grafana がホストする Loki では使用できません。このトピックは、Grafana がホストする Loki サーバーには適用されません。

条件

  • Cluster Log Forwarder カスタムリソースは、ログを Loki に転送するように設定されています。
  • システムは、次のような 2MB を超えるメッセージのブロックを Loki に送信します。

    "values":[["1630410392689800468","{\"kind\":\"Event\",\"apiVersion\":\
    .......
    ......
    ......
    ......
    \"received_at\":\"2021-08-31T11:46:32.800278+00:00\",\"version\":\"1.7.4 1.6.0\"}},\"@timestamp\":\"2021-08-31T11:46:32.799692+00:00\",\"viaq_index_name\":\"audit-write\",\"viaq_msg_id\":\"MzFjYjJkZjItNjY0MC00YWU4LWIwMTEtNGNmM2E5ZmViMGU4\",\"log_type\":\"audit\"}"]]}]}
  • oc logs -c fluentd と入力すると、OpenShift Logging クラスターの Fluentd ログに次のメッセージが表示されます。

    429 Too Many Requests Ingestion rate limit exceeded (limit: 8388608 bytes/sec) while attempting to ingest '2140' lines totaling '3285284' bytes
    
    429 Too Many Requests Ingestion rate limit exceeded' or '500 Internal Server Error rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5277702 vs. 4194304)'
  • Loki サーバーでログを開くと、次のような entry out of order メッセージが表示されます。

    ,\nentry with timestamp 2021-08-18 05:58:55.061936 +0000 UTC ignored, reason: 'entry out of order' for stream:
    
    {fluentd_thread=\"flush_thread_0\", log_type=\"audit\"},\nentry with timestamp 2021-08-18 06:01:18.290229 +0000 UTC ignored, reason: 'entry out of order' for stream: {fluentd_thread="flush_thread_0", log_type="audit"}

手順

  1. Loki サーバーの loki.yaml 設定ファイルの次のフィールドを、ここに示す値で更新します。

    • grpc_server_max_recv_msg_size: 8388608
    • chunk_target_size: 8388608
    • ingestion_rate_mb: 8
    • ingestion_burst_size_mb: 16
  2. loki.yaml の変更を Loki サーバーに適用します。

loki.yaml ファイルの例

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096
  grpc_server_max_recv_msg_size: 8388608

ingester:
  wal:
    enabled: true
    dir: /tmp/wal
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 1h       # Any chunk not receiving new logs in this time will be flushed
  chunk_target_size: 8388608
  max_chunk_age: 1h           # All chunks will be flushed when they hit this age, default is 1h
  chunk_retain_period: 30s    # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
  max_transfer_retries: 0     # Chunk transfers disabled

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

storage_config:
  boltdb_shipper:
    active_index_directory: /tmp/loki/boltdb-shipper-active
    cache_location: /tmp/loki/boltdb-shipper-cache
    cache_ttl: 24h         # Can be increased for faster performance over longer query periods, uses more disk space
    shared_store: filesystem
  filesystem:
    directory: /tmp/loki/chunks

compactor:
  working_directory: /tmp/loki/boltdb-shipper-compactor
  shared_store: filesystem

limits_config:
  reject_old_samples: true
  reject_old_samples_max_age: 12h
  ingestion_rate_mb: 8
  ingestion_burst_size_mb: 16

chunk_store_config:
  max_look_back_period: 0s

table_manager:
  retention_deletes_enabled: false
  retention_period: 0s

ruler:
  storage:
    type: local
    local:
      directory: /tmp/loki/rules
  rule_path: /tmp/loki/rules-temp
  alertmanager_url: http://localhost:9093
  ring:
    kvstore:
      store: inmemory
  enable_api: true

関連情報