2025-04-21 14:03:00 +00:00
|
|
|
{{- if .Values.logIngest.enabled }}
|
|
|
|
|
apiVersion: opentelemetry.io/v1beta1
|
|
|
|
|
kind: OpenTelemetryCollector
|
|
|
|
|
metadata:
|
|
|
|
|
name: {{ .Release.Name }}-opentelemetry-collector
|
|
|
|
|
namespace: {{ .Release.Namespace }}
|
|
|
|
|
spec:
|
|
|
|
|
mode: sidecar
|
|
|
|
|
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest
|
|
|
|
|
serviceAccount: "{{ .Release.Name }}-otel-collector"
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: app-logs
|
|
|
|
|
mountPath: {{ .Values.logIngest.logPath }}
|
|
|
|
|
securityContext:
|
|
|
|
|
allowPrivilegeEscalation: true
|
|
|
|
|
privileged: true
|
|
|
|
|
runAsUser: 0
|
|
|
|
|
runAsGroup: 0
|
|
|
|
|
env:
|
|
|
|
|
- name: KUBE_META_POD_NAME
|
|
|
|
|
valueFrom:
|
|
|
|
|
fieldRef:
|
|
|
|
|
fieldPath: metadata.name
|
|
|
|
|
- name: KUBE_META_NAMESPACE
|
|
|
|
|
valueFrom:
|
|
|
|
|
fieldRef:
|
|
|
|
|
fieldPath: metadata.namespace
|
|
|
|
|
- name: KUBE_META_NODE_NAME
|
|
|
|
|
valueFrom:
|
|
|
|
|
fieldRef:
|
|
|
|
|
fieldPath: spec.nodeName
|
|
|
|
|
- name: KUBE_META_POD_IP
|
|
|
|
|
valueFrom:
|
|
|
|
|
fieldRef:
|
|
|
|
|
fieldPath: status.podIP
|
|
|
|
|
- name: KUBE_META_POD_UID
|
|
|
|
|
valueFrom:
|
|
|
|
|
fieldRef:
|
|
|
|
|
fieldPath: metadata.uid
|
|
|
|
|
- name: KUBE_META_OBJECT_NAME
|
|
|
|
|
valueFrom:
|
|
|
|
|
fieldRef:
|
|
|
|
|
fieldPath: metadata.labels['app.kubernetes.io/instance']
|
|
|
|
|
config:
|
|
|
|
|
receivers:
|
|
|
|
|
filelog:
|
|
|
|
|
include:
|
|
|
|
|
- {{ .Values.logIngest.logPathPattern }}
|
2025-07-31 02:14:55 +00:00
|
|
|
start_at: end
|
|
|
|
|
poll_interval: 1s
|
2025-07-28 13:00:33 +00:00
|
|
|
include_file_path: false
|
|
|
|
|
include_file_name: false
|
2025-07-29 07:40:26 +00:00
|
|
|
operators:
|
|
|
|
|
- type: json_parser
|
|
|
|
|
parse_from: body
|
|
|
|
|
parse_to: attributes
|
2025-07-31 03:27:28 +00:00
|
|
|
# Add container logs receiver
|
2025-04-21 14:03:00 +00:00
|
|
|
processors:
|
|
|
|
|
resource:
|
|
|
|
|
attributes:
|
|
|
|
|
- action: insert
|
|
|
|
|
key: k8s.node.name
|
|
|
|
|
value: ${KUBE_META_NODE_NAME}
|
|
|
|
|
- action: insert
|
|
|
|
|
key: k8s.pod.name
|
|
|
|
|
value: ${KUBE_META_POD_NAME}
|
|
|
|
|
- action: insert
|
|
|
|
|
key: k8s.pod.ip
|
|
|
|
|
value: ${KUBE_META_POD_IP}
|
|
|
|
|
- action: insert
|
|
|
|
|
key: k8s.pod.uid
|
|
|
|
|
value: ${KUBE_META_POD_UID}
|
|
|
|
|
- action: insert
|
|
|
|
|
key: k8s.namespace.name
|
|
|
|
|
value: ${KUBE_META_NAMESPACE}
|
|
|
|
|
- action: insert
|
|
|
|
|
key: k8s.deployment.name
|
|
|
|
|
value: ${KUBE_META_OBJECT_NAME}
|
2025-07-29 06:30:00 +00:00
|
|
|
transform:
|
|
|
|
|
log_statements:
|
|
|
|
|
- context: log
|
|
|
|
|
statements:
|
|
|
|
|
- set(resource.attributes["application"], log.attributes["context"]["app"])
|
|
|
|
|
- set(resource.attributes["environment"], log.attributes["context"]["env"])
|
|
|
|
|
- set(resource.attributes["kubernetes_node_name"], resource.attributes["k8s.node.name"])
|
|
|
|
|
- set(resource.attributes["kubernetes_pod_name"], resource.attributes["k8s.pod.name"])
|
|
|
|
|
- set(resource.attributes["kubernetes_pod_ip"], resource.attributes["k8s.pod.ip"])
|
|
|
|
|
- set(resource.attributes["kubernetes_deployment_name"], resource.attributes["k8s.deployment.name"])
|
|
|
|
|
- set(resource.attributes["kubernetes_namespace"], resource.attributes["k8s.namespace.name"])
|
2025-07-29 08:47:47 +00:00
|
|
|
- set(resource.attributes["body_json"], ParseJSON(log.body))
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["pod"], resource.attributes["k8s.pod.name"])
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["namespace"], resource.attributes["k8s.namespace.name"])
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["pod_ip"], resource.attributes["k8s.pod.ip"])
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["pod_uid"], resource.attributes["k8s.pod.uid"])
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["deployment"], resource.attributes["k8s.deployment.name"])
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["node"], resource.attributes["k8s.node.name"])
|
|
|
|
|
- set(resource.attributes["body_json"]["kubernetes"]["namespace"], resource.attributes["k8s.namespace.name"])
|
|
|
|
|
- set(log.body, resource.attributes["body_json"])
|
|
|
|
|
- delete_key(resource.attributes, "body_json")
|
2025-04-21 14:03:00 +00:00
|
|
|
batch:
|
2025-07-31 02:14:55 +00:00
|
|
|
send_batch_size: 1
|
|
|
|
|
timeout: 1s
|
2025-04-21 14:03:00 +00:00
|
|
|
exporters:
|
2025-07-29 09:16:46 +00:00
|
|
|
otlphttp/logs:
|
|
|
|
|
endpoint: {{ .Values.logIngest.lokiEndpoint }}/otlp
|
2025-04-21 14:03:00 +00:00
|
|
|
tls:
|
|
|
|
|
insecure: true
|
2025-07-29 09:22:40 +00:00
|
|
|
headers:
|
|
|
|
|
X-Scope-OrgID: "central-storage"
|
2025-04-21 14:03:00 +00:00
|
|
|
service:
|
|
|
|
|
telemetry:
|
|
|
|
|
logs:
|
|
|
|
|
level: info
|
|
|
|
|
pipelines:
|
|
|
|
|
logs:
|
2025-07-31 15:17:45 +00:00
|
|
|
receivers: [filelog] # Only use filelog receiver to prevent duplicate collection
|
2025-07-29 06:30:00 +00:00
|
|
|
processors: [resource, transform, batch]
|
2025-07-29 09:16:46 +00:00
|
|
|
exporters: [otlphttp/logs]
|
2025-04-21 14:03:00 +00:00
|
|
|
{{- end }}
|