1+ # Custom Promtail configuration to scrape only application logs
2+
3+ config :
4+ # Loki server URL
5+ clients :
6+ - url : http://loki.observability.svc.cluster.local:3100/loki/api/v1/push
7+
8+ # Server configuration
9+ server :
10+ http_listen_port : 3101
11+ grpc_listen_port : 0
12+
13+ # Positions file
14+ positions :
15+ filename : /tmp/positions.yaml
16+
17+ # Scrape configurations - ONLY application logs
18+ scrape_configs :
19+ - job_name : kubernetes-pods-app
20+ kubernetes_sd_configs :
21+ - role : pod
22+
23+ relabel_configs :
24+ # ONLY keep student-api namespace
25+ - source_labels : [__meta_kubernetes_namespace]
26+ action : keep
27+ regex : student-api
28+
29+ # Drop system containers
30+ - source_labels : [__meta_kubernetes_pod_container_name]
31+ action : drop
32+ regex : " .*(prometheus|grafana|loki|promtail|node-exporter|blackbox|postgres-exporter).*"
33+
34+ # Set labels
35+ - source_labels : [__meta_kubernetes_pod_name]
36+ target_label : pod
37+ - source_labels : [__meta_kubernetes_pod_container_name]
38+ target_label : container
39+ - source_labels : [__meta_kubernetes_namespace]
40+ target_label : namespace
41+ - source_labels : [__meta_kubernetes_pod_label_app]
42+ target_label : app
43+ - source_labels : [__meta_kubernetes_pod_node_name]
44+ target_label : instance
45+ - target_label : job
46+ replacement : student-api-app
47+
48+ # Set log path
49+ - source_labels : [__meta_kubernetes_pod_uid, __meta_kubernetes_pod_container_name]
50+ target_label : __path__
51+ replacement : /var/log/pods/*$1/*.log
52+ separator : /
53+
54+ # Pipeline stages
55+ pipeline_stages :
56+ - cri : {}
57+ - labelallow :
58+ - " app"
59+ - " container"
60+ - " namespace"
61+ - " pod"
62+ - " instance"
63+ - " job"
64+
65+ # Explicitly drop ALL other namespaces
66+ - job_name : drop-other-namespaces
67+ kubernetes_sd_configs :
68+ - role : pod
69+ relabel_configs :
70+ - source_labels : [__meta_kubernetes_namespace]
71+ action : drop
72+ regex : student-api
73+ - action : drop
74+ regex : .+
75+ source_labels : []
76+
77+ # DaemonSet configuration
78+ daemonset :
79+ enabled : true
80+
81+ # Service configuration
82+ service :
83+ enabled : true
84+ type : ClusterIP
85+ port : 3101
86+
87+ # Resource limits
88+ resources :
89+ requests :
90+ memory : 64Mi
91+ cpu : 50m
92+ limits :
93+ memory : 128Mi
94+ cpu : 200m
95+
96+ # Security context
97+ securityContext :
98+ runAsUser : 0
99+ runAsGroup : 0
100+ fsGroup : 0
101+
102+ # Tolerations to run on all nodes
103+ tolerations :
104+ - effect : NoSchedule
105+ operator : Exists
106+ - effect : NoExecute
107+ operator : Exists
108+
109+ # Service account
110+ serviceAccount :
111+ create : true
112+ name : " "
113+
114+ # RBAC
115+ rbac :
116+ pspEnabled : false
117+ namespaced : false
0 commit comments