8.4. LokiStack으로 로그 전달
LokiStack 게이트웨이에 대한 로그 전달을 구성하려면 ClusterLogging 사용자 정의 리소스(CR)를 생성해야 합니다.
사전 요구 사항
- logging subsystem for Red Hat OpenShift: 5.5 이상
-
Loki OperatorOperator
절차
-
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: vector8.4.1. Loki "주문 부족" 오류 문제 해결
Fluentd가 대량의 메시지 블록을 속도 제한을 초과하는 Loki 로깅 시스템에 전달하는 경우 Loki는 "주문 부족" 오류를 생성합니다. 이 문제를 해결하려면 Loki 서버 구성 파일인 loki.yaml에서 일부 값을 업데이트합니다.
참고
Loki.yaml은 Grafana 호스팅 Loki에서 사용할 수 없습니다. 이는 Grafana 호스팅 Loki 서버에는 적용되지 않습니다.
조건
-
ClusterLogForwarder사용자 정의 리소스는 로그를 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"}
절차
Loki 서버의
loki.yaml구성 파일에서 다음 필드를 여기에 표시된 값으로 업데이트합니다.-
grpc_server_max_recv_msg_size: 8388608 -
chunk_target_size: 8388608 -
ingestion_rate_mb: 8 -
ingestion_burst_size_mb: 16
-
-
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
추가 리소스