|
| 1 | +--- |
| 2 | +role: Agent |
| 3 | +resources: |
| 4 | + requests: |
| 5 | + cpu: 200m |
| 6 | + memory: 1024Mi |
| 7 | + limits: |
| 8 | + cpu: 1000m |
| 9 | + memory: 2048Mi |
| 10 | +customConfig: |
| 11 | + data_dir: /vector-data-dir |
| 12 | + api: |
| 13 | + enabled: true |
| 14 | + address: 127.0.0.1:8686 |
| 15 | + playground: false |
| 16 | + sources: |
| 17 | + k8s_logs: |
| 18 | + type: kubernetes_logs |
| 19 | + rotate_wait_secs: 5 |
| 20 | + glob_minimum_cooldown_ms: 500 |
| 21 | + max_line_bytes: 3145728 |
| 22 | + auto_partial_merge: true |
| 23 | + transforms: |
| 24 | + reduce_events: |
| 25 | + type: reduce |
| 26 | + inputs: |
| 27 | + - k8s_logs |
| 28 | + group_by: |
| 29 | + - file |
| 30 | + flush_period_ms: 2000 |
| 31 | + end_every_period_ms: 2000 |
| 32 | + merge_strategies: |
| 33 | + message: concat_newline |
| 34 | + remap_app_logs: |
| 35 | + type: remap |
| 36 | + inputs: |
| 37 | + - reduce_events |
| 38 | + source: |- |
| 39 | + .tmp = del(.) |
| 40 | + # Preserve original kubernetes fields for Loki labels |
| 41 | + if exists(.tmp.kubernetes.pod_uid) { |
| 42 | + .pod_id = del(.tmp.kubernetes.pod_uid) |
| 43 | + } else { |
| 44 | + .pod_id = "unknown_pod_id" |
| 45 | + } |
| 46 | + if exists(.tmp.kubernetes.pod_name) { |
| 47 | + .pod_name = del(.tmp.kubernetes.pod_name) |
| 48 | + } else { |
| 49 | + .pod_name = "unknown_pod" |
| 50 | + } |
| 51 | + if exists(.tmp.kubernetes.container_name) { |
| 52 | + .container = del(.tmp.kubernetes.container_name) |
| 53 | + } else { |
| 54 | + .container = "unknown_container" |
| 55 | + } |
| 56 | + if exists(.tmp.kubernetes.pod_namespace) { |
| 57 | + .namespace = del(.tmp.kubernetes.pod_namespace) |
| 58 | + } else { |
| 59 | + .namespace = "unlabeled" |
| 60 | + } |
| 61 | + # Handling Tekton-specific labels |
| 62 | + if exists(.tmp.kubernetes.pod_labels."tekton.dev/taskRunUID") { |
| 63 | + .taskRunUID = del(.tmp.kubernetes.pod_labels."tekton.dev/taskRunUID") |
| 64 | + } else { |
| 65 | + .taskRunUID = "none" |
| 66 | + } |
| 67 | + if exists(.tmp.kubernetes.pod_labels."tekton.dev/pipelineRunUID") { |
| 68 | + .pipelineRunUID = del(.tmp.kubernetes.pod_labels."tekton.dev/pipelineRunUID") |
| 69 | + .result = .pipelineRunUID |
| 70 | + } else { |
| 71 | + .result = .taskRunUID |
| 72 | + } |
| 73 | + # --- Start: Cronjob Specific Handling --- |
| 74 | + if exists(.tmp.kubernetes.pod_labels."job-name") { |
| 75 | + .job_name = del(.tmp.kubernetes.pod_labels."job-name") |
| 76 | + .log_type = "cronjob" |
| 77 | + if exists(.tmp.kubernetes.pod_labels."cronjob-name") { |
| 78 | + .cronjob_name = del(.tmp.kubernetes.pod_labels."cronjob-name") |
| 79 | + } else { |
| 80 | + # Using corrected regex pattern without \d |
| 81 | + .job_name = to_string(.job_name) ?? "default" |
| 82 | + if match(.job_name, r'^(.*)-[0-9]{8,10}$') { |
| 83 | + .cronjob_name = replace(.job_name, r'-[0-9]{8,10}$', "") |
| 84 | + } else { |
| 85 | + .cronjob_name = "unknown_cronjob" |
| 86 | + } |
| 87 | + } |
| 88 | + if exists(.tmp.kubernetes.pod_labels."controller-uid") { |
| 89 | + .job_uid = del(.tmp.kubernetes.pod_labels."controller-uid") |
| 90 | + } |
| 91 | + } else { |
| 92 | + .log_type = "application" |
| 93 | + } |
| 94 | + # --- End: Cronjob Specific Handling --- |
| 95 | + # Handling general Kubernetes labels |
| 96 | + if exists(.tmp.kubernetes.pod_labels) { |
| 97 | + .pod_labels = .tmp.kubernetes.pod_labels |
| 98 | + } else { |
| 99 | + .pod_labels = "no_labels" |
| 100 | + } |
| 101 | + # General message field handling |
| 102 | + if exists(.tmp.message) { |
| 103 | + .message = to_string(del(.tmp.message)) ?? "no_message" |
| 104 | + } else { |
| 105 | + .message = "no_message" |
| 106 | + } |
| 107 | + # Basic data sanitization to prevent 400 errors |
| 108 | + # Truncate very long messages |
| 109 | + if length(.message) > 32768 { |
| 110 | + .message = slice!(.message, 0, 32768) + "...[TRUNCATED]" |
| 111 | + } |
| 112 | + # Clean up temporary fields |
| 113 | + del(.tmp) |
| 114 | + sinks: |
| 115 | + loki: |
| 116 | + type: loki |
| 117 | + inputs: ["remap_app_logs"] |
| 118 | + # Direct connection to Loki service (no gateway) |
| 119 | + endpoint: "http://vector-kubearchive-log-collector-loki.product-kubearchive-logging.svc.cluster.local:3100" |
| 120 | + encoding: |
| 121 | + codec: "json" |
| 122 | + auth: |
| 123 | + strategy: "basic" |
| 124 | + user: "${LOKI_USERNAME}" |
| 125 | + password: "${LOKI_PASSWORD}" |
| 126 | + tenant_id: "kubearchive" |
| 127 | + request: |
| 128 | + headers: |
| 129 | + X-Scope-OrgID: kubearchive |
| 130 | + batch: |
| 131 | + max_bytes: 10485760 |
| 132 | + timeout_secs: 300 |
| 133 | + compression: "none" |
| 134 | + labels: |
| 135 | + job: "vector" |
| 136 | + pod_id: "{{`{{ pod_id }}`}}" |
| 137 | + container: "{{`{{ container }}`}}" |
| 138 | + namespace: "{{`{{ namespace }}`}}" |
| 139 | + pod: "{{`{{ pod_name }}`}}" |
| 140 | + buffer: |
| 141 | + type: "memory" |
| 142 | + max_events: 10000 |
| 143 | + when_full: "block" |
| 144 | +env: |
| 145 | + - name: LOKI_USERNAME |
| 146 | + valueFrom: |
| 147 | + secretKeyRef: |
| 148 | + name: kubearchive-loki |
| 149 | + key: USERNAME |
| 150 | + - name: LOKI_PASSWORD |
| 151 | + valueFrom: |
| 152 | + secretKeyRef: |
| 153 | + name: kubearchive-loki |
| 154 | + key: PASSWORD |
| 155 | +nodeSelector: |
| 156 | + konflux-ci.dev/workload: konflux-tenants |
| 157 | +tolerations: |
| 158 | + - effect: NoSchedule |
| 159 | + key: konflux-ci.dev/workload |
| 160 | + operator: Equal |
| 161 | + value: konflux-tenants |
| 162 | +image: |
| 163 | + repository: quay.io/kubearchive/vector |
| 164 | + tag: 0.46.1-distroless-libc |
| 165 | +serviceAccount: |
| 166 | + create: true |
| 167 | + name: vector-kubearchive-log-collector |
| 168 | +securityContext: |
| 169 | + allowPrivilegeEscalation: false |
| 170 | + runAsUser: 0 |
| 171 | + capabilities: |
| 172 | + drop: |
| 173 | + - CHOWN |
| 174 | + - DAC_OVERRIDE |
| 175 | + - FOWNER |
| 176 | + - FSETID |
| 177 | + - KILL |
| 178 | + - NET_BIND_SERVICE |
| 179 | + - SETGID |
| 180 | + - SETPCAP |
| 181 | + - SETUID |
| 182 | + readOnlyRootFilesystem: true |
| 183 | + seLinuxOptions: |
| 184 | + type: spc_t |
| 185 | + seccompProfile: |
| 186 | + type: RuntimeDefault |
| 187 | + |
| 188 | +# Override default volumes to be more specific and secure |
| 189 | +extraVolumes: |
| 190 | + - name: varlog |
| 191 | + hostPath: |
| 192 | + path: /var/log/pods |
| 193 | + type: Directory |
| 194 | + - name: varlibdockercontainers |
| 195 | + hostPath: |
| 196 | + path: /var/lib/containers |
| 197 | + type: DirectoryOrCreate |
| 198 | + |
| 199 | +extraVolumeMounts: |
| 200 | + - name: varlog |
| 201 | + mountPath: /var/log/pods |
| 202 | + readOnly: true |
| 203 | + - name: varlibdockercontainers |
| 204 | + mountPath: /var/lib/containers |
| 205 | + readOnly: true |
| 206 | + |
| 207 | +# Configure Vector to use emptyDir for its default data volume instead of hostPath |
| 208 | +persistence: |
| 209 | + enabled: false |
| 210 | + |
| 211 | + |
0 commit comments