QuestionHello, I opened a discussion some time ago about my vector config (see #24635). This week we finally went to production and we found out some problems not seen in our test environment. Namely, it seems we had some issues for the exec source, which is a bash script that just dumps metadata from K8s API server and fuels our enrichment_table. We run the script manually inside vector pods and it run fast with no error (returned 0), so probably that wasn't the root cause. So my reasoning is, our current lua script is not optimized enough with our current load. You can see it in the section below. Vector's lua does not support HTTP external libraries, right? So the only way I have to fetch the application name for what is not present in the enrichment_table is spawning a curl process. Do you think I have other alternatives if I want to try to remediate a missing app name when the record is not present in the enrichment table? In general this seems to happen to less of 1% of our logs, so it's relatively rare, but on absolute numbers it happens thousands of times. Thank you in advance. Note the vector config below only includes what I think is in scope for this question. Vector ConfigVector Logs |
Replies: 1 comment
|
You should not need Lua, Replace the generic sources:
logs:
type: kubernetes_logs
self_node_name: ${VECTOR_SELF_NODE_NAME}
# Keep metadata longer for logs drained after a Pod is deleted.
delay_deletion_ms: 300000
transforms:
set_app:
type: remap
inputs:
- logs
source: |
if exists(.kubernetes.pod_labels."app.kubernetes.io/name") {
.app_name = .kubernetes.pod_labels."app.kubernetes.io/name"
.enrichment_source = "kubernetes_logs"
} else {
.k8s_label_error = "app.kubernetes.io/name is absent from Pod labels"
}The source needs This removes a synchronous child process from the per-event hot path. Thousands of If the missing events mainly occur after Pods terminate, tune References:
This assumes Vector runs as a node agent/DaemonSet and the endpoint is only returning that Pod label, as the posted |
You should not need Lua,
curl,jq, the scheduledexecsource, or the memory table for this label. The value fetched by the fallback is exactly a Pod label, and Vector'skubernetes_logssource already watches Pods through the Kubernetes API and adds their labels to each log event under.kubernetes.pod_labels.Replace the generic
filesource withkubernetes_logsand read the label in VRL: