Akash Haldankar
06/03/2025, 6:13 AMNagesh Bansal
06/03/2025, 6:20 PMAkash Haldankar
06/04/2025, 4:02 AMAkash Haldankar
06/04/2025, 4:33 AMotelAgent:
extraVolumeMounts:
- name: fastapi-app-logs-pvc
mountPath: /var/lib/kubelet/pods
extraVolumes:
- name: fastapi-app-logs-pvc
hostPath:
path: /var/lib/kubelet/pods
type: Directory
daemonset:
volumes:
- name: fastapi-app-logs-pvc
hostPath:
path: /var/lib/kubelet/pods
type: Directory
- name: varlog
hostPath:
path: /var/log
type: Directory
containers:
- name: signoz-infra-metrics-k8s-infra-otel-agent
volumeMounts:
- name: fastapi-app-logs-pvc
mountPath: /var/lib/kubelet/pods
readOnly: true
# Mount /var/log for standard container logs
- name: varlog
mountPath: /var/log
readOnly: true
config:
receivers:
filelog/app-logs:
include:
# This is the correct and specific path for your FastAPI app's log file
# within the emptyDir volume mounted by Kubelet.
- /var/app/pods/*/*/*.log
- /app_log/logs/*.log
- /var/log/*.log
# - /var/lib/kubelet/pods/*/volumes/kubernetes.io~csi/*/*.log
start_at: beginning
operators:
# This is a list item, so it starts with a hyphen '-'
- id: my-app-regex-parser
type: regex_parser
regex: '^(?P<message>.*)$'
body:
# 'parse_from' is indented 2 spaces from 'body'
parse_from: message
- id: add-app-service-name
type: add
field: attributes.service_name
value: fast-api-app-sample
- id: add-log-source-type
type: add
field: attributes.log_source_type
value: file-persistent-volume
exporters:
otlp/log:
endpoint: 172.20.223.230:4317
tls:
insecure: true
service:
pipelines:
logs:
# Ensure both standard K8s logs and your custom app logs are collected
receivers: [ filelog/app-logs ]
processors: []
exporters: [ otlp/log ]