remove cert in freeleaps and add logs in magicleaps

This commit is contained in:
Nicolas 2025-09-02 17:36:19 +08:00
parent 6a1b456f10
commit e7c326902d
15 changed files with 700 additions and 47 deletions

View File

@ -25,8 +25,7 @@ data:
FREELEAPS_AUTHENTICATION_ENDPOINT: {{ .Values.freeleaps.configs.freeleapsAuthenticationEndpoint | b64enc | quote }} FREELEAPS_AUTHENTICATION_ENDPOINT: {{ .Values.freeleaps.configs.freeleapsAuthenticationEndpoint | b64enc | quote }}
FREELEAPS_AILAB_ENDPOINT: {{ .Values.freeleaps.configs.freeleapsAilabEndpoint | b64enc | quote }} FREELEAPS_AILAB_ENDPOINT: {{ .Values.freeleaps.configs.freeleapsAilabEndpoint | b64enc | quote }}
FREELEAPS_NOTIFICATION_ENDPOINT: {{ .Values.freeleaps.configs.freeleapsNotificationEndpoint | b64enc | quote }} FREELEAPS_NOTIFICATION_ENDPOINT: {{ .Values.freeleaps.configs.freeleapsNotificationEndpoint | b64enc | quote }}
FREELEAPS_ENV: {{ .Values.freeleaps.configs.freeleapsEnv | b64enc | quote }} APP_ENV: {{ .Values.freeleaps.configs.appEnv | b64enc | quote }}
CERT_PATH: {{ .Values.freeleaps.configs.certPath | b64enc | quote }}
REDIS_IS_CLUSTER: {{ .Values.freeleaps.configs.redisIsCluster | b64enc | quote }} REDIS_IS_CLUSTER: {{ .Values.freeleaps.configs.redisIsCluster | b64enc | quote }}
METRICS_ENABLED: {{ .Values.freeleaps.configs.metricsEnabled | default false | toString | b64enc }} METRICS_ENABLED: {{ .Values.freeleaps.configs.metricsEnabled | default false | toString | b64enc }}
PROBES_ENABLED: {{ .Values.freeleaps.configs.probesEnabled | default false | toString | b64enc }} PROBES_ENABLED: {{ .Values.freeleaps.configs.probesEnabled | default false | toString | b64enc }}

View File

@ -76,8 +76,7 @@ freeleaps:
freeleapsAuthenticationEndpoint: http://authentication-service.freeleaps-alpha.svc.freeleaps.cluster:8004/api/auth/ freeleapsAuthenticationEndpoint: http://authentication-service.freeleaps-alpha.svc.freeleaps.cluster:8004/api/auth/
freeleapsNotificationEndpoint: http://notification-service.freeleaps-alpha.svc.freeleaps.cluster:8003/api/notification/ freeleapsNotificationEndpoint: http://notification-service.freeleaps-alpha.svc.freeleaps.cluster:8003/api/notification/
freeleapsAilabEndpoint: '' freeleapsAilabEndpoint: ''
freeleapsEnv: alpha appEnv: 'alpha'
certPath: ''
redisIsCluster: 'false' redisIsCluster: 'false'
metricsEnabled: 'false' metricsEnabled: 'false'
probesEnabled: 'true' probesEnabled: 'true'

View File

@ -67,8 +67,8 @@ freeleaps:
freeleapsAuthenticationEndpoint: http://authentication-service.freeleaps-prod.svc.freeleaps.cluster:8004/api/auth/ freeleapsAuthenticationEndpoint: http://authentication-service.freeleaps-prod.svc.freeleaps.cluster:8004/api/auth/
freeleapsNotificationEndpoint: http://notification-service.freeleaps-prod.svc.freeleaps.cluster:8003/api/notification/ freeleapsNotificationEndpoint: http://notification-service.freeleaps-prod.svc.freeleaps.cluster:8003/api/notification/
freeleapsAilabEndpoint: '' freeleapsAilabEndpoint: ''
freeleapsEnv: alpha appEnv: prod
certPath: ''
redisIsCluster: 'true' redisIsCluster: 'true'
metricsEnabled: 'true' metricsEnabled: 'true'
probesEnabled: 'true' probesEnabled: 'true'
@ -82,38 +82,38 @@ freeleaps:
creationPolicy: Owner creationPolicy: Owner
refreshInterval: 30s refreshInterval: 30s
data: data:
- key: mongodbUri - key: mongodbUri
remoteRef: remoteRef:
key: freeleaps-prod-mongodb-uri key: freeleaps-prod-mongodb-uri
type: Secret type: Secret
- key: jwtSecretKey - key: jwtSecretKey
remoteRef: remoteRef:
key: freeleaps-prod-jwt-secret-key key: freeleaps-prod-jwt-secret-key
type: Secret type: Secret
- key: stripeApiKey - key: stripeApiKey
remoteRef: remoteRef:
key: freeleaps-prod-stripe-api-key key: freeleaps-prod-stripe-api-key
type: Secret type: Secret
- key: stripeWebhookSecret - key: stripeWebhookSecret
remoteRef: remoteRef:
key: freeleaps-prod-stripe-webhook-secret key: freeleaps-prod-stripe-webhook-secret
type: Secret type: Secret
- key: stripeAccountWebhookSecret - key: stripeAccountWebhookSecret
remoteRef: remoteRef:
key: freeleaps-prod-stripe-account-webhook-secret key: freeleaps-prod-stripe-account-webhook-secret
type: Secret type: Secret
- key: rabbitmqPassword - key: rabbitmqPassword
remoteRef: remoteRef:
key: freeleaps-prod-rabbitmq-password key: freeleaps-prod-rabbitmq-password
type: Secret type: Secret
- key: redisUrl - key: redisUrl
remoteRef: remoteRef:
key: freeleaps-prod-redis-url key: freeleaps-prod-redis-url
type: Secret type: Secret
- key: giteaApiKey - key: giteaApiKey
remoteRef: remoteRef:
key: freeleaps-prod-gitea-api-key key: freeleaps-prod-gitea-api-key
type: Secret type: Secret
vpa: vpa:
minAllowed: minAllowed:
enabled: true enabled: true

View File

@ -89,10 +89,8 @@ freeleaps:
freeleapsNotificationEndpoint: "" freeleapsNotificationEndpoint: ""
# FREELEAPS_AILAB_ENDPOINT # FREELEAPS_AILAB_ENDPOINT
freeleapsAilabEndpoint: "" freeleapsAilabEndpoint: ""
# FREELEAPS_ENV # APP_ENV
freeleapsEnv: "" appEnv: ""
# CERT_PATH
certPath: ""
# REDIS_IS_CLUSTER # REDIS_IS_CLUSTER
redisIsCluster: "false" redisIsCluster: "false"
# METRICS_ENABLED # METRICS_ENABLED

View File

@ -95,4 +95,59 @@ spec:
secretKeyRef: secretKeyRef:
name: magicleaps-backend-config name: magicleaps-backend-config
key: {{ $key | snakecase | upper }} key: {{ $key | snakecase | upper }}
{{- end }} {{- end }}
{{- if .Values.logIngest.enabled }}
volumeMounts:
- name: app-logs
mountPath: {{ .Values.logIngest.backendLogPath }}
{{- end }}
{{- if .Values.logIngest.enabled }}
- name: opentelemetry-collector
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest
command:
- /otelcol-contrib
- --config=/etc/otelcol-contrib/otelcol-contrib.yaml
volumeMounts:
- name: app-logs
mountPath: {{ .Values.logIngest.backendLogPath }}
- name: otelcol-config
mountPath: /etc/otelcol-contrib
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']
{{- end }}
volumes:
{{- if .Values.logIngest.enabled }}
- name: app-logs
emptyDir: {}
- name: otelcol-config
configMap:
name: {{ .Release.Name }}-backend-otelcol-config
{{- end }}

View File

@ -0,0 +1,53 @@
{{- if .Values.logIngest.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-backend-otel-collector
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-backend-otel-collector
rules:
- apiGroups: [""]
resources: ["nodes", "nodes/proxy", "services", "endpoints", "pods", "events"]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["replicasets", "deployments"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list", "watch"]
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "watch"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["authentication.k8s.io"]
resources: ["tokenreviews"]
verbs: ["create"]
- apiGroups: ["authorization.k8s.io"]
resources: ["subjectaccessreviews"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-backend-otel-collector
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-backend-otel-collector
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-backend-otel-collector
namespace: {{ .Release.Namespace }}
{{- end }}

View File

@ -0,0 +1,123 @@
{{- if .Values.logIngest.enabled }}
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: {{ .Release.Name }}-backend-opentelemetry-collector
namespace: {{ .Release.Namespace }}
spec:
mode: sidecar
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest
serviceAccount: "{{ .Release.Name }}-backend-otel-collector"
volumeMounts:
- name: app-logs
mountPath: {{ .Values.logIngest.backendLogPath }}
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.backendLogPathPattern }}
start_at: end
include_file_path: false
include_file_name: false
operators:
- type: json_parser
parse_from: body
parse_to: attributes
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}
- action: insert
key: service.name
value: magicleaps-backend
- action: insert
key: service.component
value: backend
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"])
- 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.pod.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(resource.attributes["body_json"]["service"]["name"], "magicleaps-backend")
- set(resource.attributes["body_json"]["service"]["component"], "backend")
- set(log.body, resource.attributes["body_json"])
- delete_key(resource.attributes, "body_json")
batch:
send_batch_size: 5
timeout: 10s
exporters:
otlphttp/logs:
endpoint: {{ .Values.logIngest.lokiEndpoint }}/otlp
tls:
insecure: true
service:
telemetry:
logs:
level: info
pipelines:
logs:
receivers: [filelog]
processors: [resource, transform, batch]
exporters: [otlphttp/logs]
{{- end }}

View File

@ -0,0 +1,87 @@
{{- if .Values.logIngest.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-backend-otelcol-config
namespace: {{ .Release.Namespace }}
data:
otelcol-contrib.yaml: |
receivers:
filelog:
include:
- {{ .Values.logIngest.backendLogPathPattern }}
start_at: end
include_file_path: false
include_file_name: false
operators:
- type: json_parser
parse_from: body
parse_to: attributes
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}
- action: insert
key: service.name
value: magicleaps-backend
- action: insert
key: service.component
value: backend
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"])
- 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.pod.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(resource.attributes["body_json"]["service"]["name"], "magicleaps-backend")
- set(resource.attributes["body_json"]["service"]["component"], "backend")
- set(log.body, resource.attributes["body_json"])
- delete_key(resource.attributes, "body_json")
batch:
send_batch_size: 5
timeout: 10s
exporters:
otlphttp/logs:
endpoint: {{ .Values.logIngest.lokiEndpoint }}/otlp
tls:
insecure: true
service:
telemetry:
logs:
level: info
pipelines:
logs:
receivers: [filelog]
processors: [resource, transform, batch]
exporters: [otlphttp/logs]
{{- end }}

View File

@ -95,4 +95,59 @@ spec:
secretKeyRef: secretKeyRef:
name: magicleaps-frontend-config name: magicleaps-frontend-config
key: {{ $key | snakecase | upper }} key: {{ $key | snakecase | upper }}
{{- end }} {{- end }}
{{- if .Values.logIngest.enabled }}
volumeMounts:
- name: app-logs
mountPath: {{ .Values.logIngest.frontendLogPath }}
{{- end }}
{{- if .Values.logIngest.enabled }}
- name: opentelemetry-collector
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest
command:
- /otelcol-contrib
- --config=/etc/otelcol-contrib/otelcol-contrib.yaml
volumeMounts:
- name: app-logs
mountPath: {{ .Values.logIngest.frontendLogPath }}
- name: otelcol-config
mountPath: /etc/otelcol-contrib
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']
{{- end }}
volumes:
{{- if .Values.logIngest.enabled }}
- name: app-logs
emptyDir: {}
- name: otelcol-config
configMap:
name: {{ .Release.Name }}-frontend-otelcol-config
{{- end }}

View File

@ -0,0 +1,53 @@
{{- if .Values.logIngest.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-frontend-otel-collector
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-frontend-otel-collector
rules:
- apiGroups: [""]
resources: ["nodes", "nodes/proxy", "services", "endpoints", "pods", "events"]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["replicasets", "deployments"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list", "watch"]
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "watch"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["authentication.k8s.io"]
resources: ["tokenreviews"]
verbs: ["create"]
- apiGroups: ["authorization.k8s.io"]
resources: ["subjectaccessreviews"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-frontend-otel-collector
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-frontend-otel-collector
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-frontend-otel-collector
namespace: {{ .Release.Namespace }}
{{- end }}

View File

@ -0,0 +1,123 @@
{{- if .Values.logIngest.enabled }}
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: {{ .Release.Name }}-frontend-opentelemetry-collector
namespace: {{ .Release.Namespace }}
spec:
mode: sidecar
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest
serviceAccount: "{{ .Release.Name }}-frontend-otel-collector"
volumeMounts:
- name: app-logs
mountPath: {{ .Values.logIngest.frontendLogPath }}
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.frontendLogPathPattern }}
start_at: end
include_file_path: false
include_file_name: false
operators:
- type: json_parser
parse_from: body
parse_to: attributes
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}
- action: insert
key: service.name
value: magicleaps-frontend
- action: insert
key: service.component
value: frontend
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"])
- 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.pod.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(resource.attributes["body_json"]["service"]["name"], "magicleaps-frontend")
- set(resource.attributes["body_json"]["service"]["component"], "frontend")
- set(log.body, resource.attributes["body_json"])
- delete_key(resource.attributes, "body_json")
batch:
send_batch_size: 5
timeout: 10s
exporters:
otlphttp/logs:
endpoint: {{ .Values.logIngest.lokiEndpoint }}/otlp
tls:
insecure: true
service:
telemetry:
logs:
level: info
pipelines:
logs:
receivers: [filelog]
processors: [resource, transform, batch]
exporters: [otlphttp/logs]
{{- end }}

View File

@ -0,0 +1,87 @@
{{- if .Values.logIngest.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-frontend-otelcol-config
namespace: {{ .Release.Namespace }}
data:
otelcol-contrib.yaml: |
receivers:
filelog:
include:
- {{ .Values.logIngest.frontendLogPathPattern }}
start_at: end
include_file_path: false
include_file_name: false
operators:
- type: json_parser
parse_from: body
parse_to: attributes
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}
- action: insert
key: service.name
value: magicleaps-frontend
- action: insert
key: service.component
value: frontend
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"])
- 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.pod.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(resource.attributes["body_json"]["service"]["name"], "magicleaps-frontend")
- set(resource.attributes["body_json"]["service"]["component"], "frontend")
- set(log.body, resource.attributes["body_json"])
- delete_key(resource.attributes, "body_json")
batch:
send_batch_size: 5
timeout: 10s
exporters:
otlphttp/logs:
endpoint: {{ .Values.logIngest.lokiEndpoint }}/otlp
tls:
insecure: true
service:
telemetry:
logs:
level: info
pipelines:
logs:
receivers: [filelog]
processors: [resource, transform, batch]
exporters: [otlphttp/logs]
{{- end }}

View File

@ -2,6 +2,13 @@ global:
registry: docker.io registry: docker.io
repository: sunzhenyucn repository: sunzhenyucn
nodeSelector: {} nodeSelector: {}
logIngest:
enabled: true
lokiEndpoint: http://loki-gateway.magicleaps-logging-system
backendLogPathPattern: /app/log/*.log
backendLogPath: /app/log
frontendLogPathPattern: /app/logs/*.log
frontendLogPath: /app/logs
frontend: frontend:
replicas: 1 replicas: 1
image: image:
@ -104,6 +111,6 @@ backend:
twilioAccountSid: '' twilioAccountSid: ''
twilioAuthToken: '' twilioAuthToken: ''
eveluationTaskFolderBase: temp/interview/eveluation_task/ eveluationTaskFolderBase: temp/interview/eveluation_task/
logDir: logs logDir: /app/log
appLogFile: app.log appLogFile: app.log
appLogLevel: INFO appLogLevel: INFO

View File

@ -2,6 +2,13 @@ global:
registry: docker.io registry: docker.io
repository: sunzhenyucn repository: sunzhenyucn
nodeSelector: {} nodeSelector: {}
logIngest:
enabled: true
lokiEndpoint: http://loki-gateway.magicleaps-logging-system
backendLogPathPattern: /app/log/*.log
backendLogPath: /app/log
frontendLogPathPattern: /app/logs/*.log
frontendLogPath: /app/logs
frontend: frontend:
replicas: 1 replicas: 1
image: image:
@ -104,6 +111,6 @@ backend:
twilioAccountSid: '' twilioAccountSid: ''
twilioAuthToken: '' twilioAuthToken: ''
eveluationTaskFolderBase: temp/interview/eveluation_task/ eveluationTaskFolderBase: temp/interview/eveluation_task/
logDir: logs logDir: /app/log
appLogFile: app.log appLogFile: app.log
appLogLevel: INFO appLogLevel: INFO

View File

@ -3,6 +3,13 @@ global:
registry: docker.io registry: docker.io
repository: sunzhenyucn repository: sunzhenyucn
nodeSelector: {} nodeSelector: {}
logIngest:
enabled: true
lokiEndpoint: http://loki-gateway.magicleaps-logging-system
backendLogPathPattern: /app/log/*.log
backendLogPath: /app/log
frontendLogPathPattern: /app/logs/*.log
frontendLogPath: /app/logs
frontend: frontend:
replicas: 1 replicas: 1
image: image:
@ -105,6 +112,6 @@ backend:
twilioAccountSid: "" twilioAccountSid: ""
twilioAuthToken: "" twilioAuthToken: ""
eveluationTaskFolderBase: "temp/interview/eveluation_task/" eveluationTaskFolderBase: "temp/interview/eveluation_task/"
logDir: "logs" logDir: "/app/log"
appLogFile: "app.log" appLogFile: "app.log"
appLogLevel: "INFO" appLogLevel: "INFO"