From 7a7fcf1398004d35e0a3bafbee8f0fceeeb78311 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 31 Jul 2025 10:14:55 +0800 Subject: [PATCH] fix: optimize central storage logging configuration to resolve hourly log bursts - Change start_at from beginning to end to avoid historical log duplication - Add poll_interval: 1s for real-time file monitoring - Optimize batch processing: send_batch_size: 1, timeout: 1s - Add PVC template for log persistence to reduce log loss risk - Update deployment to support persistent volume for logs --- .../templates/central-storage/deployment.yaml | 5 +++++ .../central-storage/opentelemetry.yaml | 7 ++++--- .../templates/central-storage/pvc.yaml | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 freeleaps/helm-pkg/centralStorage/templates/central-storage/pvc.yaml diff --git a/freeleaps/helm-pkg/centralStorage/templates/central-storage/deployment.yaml b/freeleaps/helm-pkg/centralStorage/templates/central-storage/deployment.yaml index c4f19a38..cc83273a 100644 --- a/freeleaps/helm-pkg/centralStorage/templates/central-storage/deployment.yaml +++ b/freeleaps/helm-pkg/centralStorage/templates/central-storage/deployment.yaml @@ -114,5 +114,10 @@ spec: {{- if .Values.logIngest.enabled }} volumes: - name: app-logs + {{- if .Values.logIngest.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ .Release.Name }}-logs-pvc + {{- else }} emptyDir: {} + {{- end }} {{- end }} \ No newline at end of file diff --git a/freeleaps/helm-pkg/centralStorage/templates/central-storage/opentelemetry.yaml b/freeleaps/helm-pkg/centralStorage/templates/central-storage/opentelemetry.yaml index f50ce6d9..152f2bb3 100644 --- a/freeleaps/helm-pkg/centralStorage/templates/central-storage/opentelemetry.yaml +++ b/freeleaps/helm-pkg/centralStorage/templates/central-storage/opentelemetry.yaml @@ -46,7 +46,8 @@ spec: filelog: include: - {{ .Values.logIngest.logPathPattern }} - start_at: beginning + start_at: end + poll_interval: 1s include_file_path: false include_file_name: false operators: @@ -96,8 +97,8 @@ spec: - set(log.body, resource.attributes["body_json"]) - delete_key(resource.attributes, "body_json") batch: - send_batch_size: 5 - timeout: 10s + send_batch_size: 1 + timeout: 1s exporters: otlphttp/logs: endpoint: {{ .Values.logIngest.lokiEndpoint }}/otlp diff --git a/freeleaps/helm-pkg/centralStorage/templates/central-storage/pvc.yaml b/freeleaps/helm-pkg/centralStorage/templates/central-storage/pvc.yaml new file mode 100644 index 00000000..3ac7bee2 --- /dev/null +++ b/freeleaps/helm-pkg/centralStorage/templates/central-storage/pvc.yaml @@ -0,0 +1,19 @@ +{{- if and .Values.logIngest.enabled .Values.logIngest.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-logs-pvc + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: "central-storage" + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.logIngest.persistence.size | default "1Gi" }} + {{- if .Values.logIngest.persistence.storageClass }} + storageClassName: {{ .Values.logIngest.persistence.storageClass }} + {{- end }} +{{- end }} \ No newline at end of file