fix(syslog): skip empty KubernetesMinimal prefixes for non-container logs - #3374
Conversation
…logs (LOG-9694) Syslog forwarding with KubernetesMinimal enrichment unconditionally added namespace_name=, container_name=, pod_name= prefixes even to audit and journald logs that have no Kubernetes metadata. Now these fields are only included when present and non-empty. Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughChangesSyslog enrichment behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoFix syslog KubernetesMinimal enrichment to skip empty prefixes on non-container logs
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
9 rules 1. Audit logs omit kubernetes_metadata
|
| if length(parts) > 0 { | ||
| parts = push(parts, "message=" + msg_value) | ||
| .message = join!(parts, ", ") | ||
| } else { | ||
| .message = msg_value | ||
| }` |
There was a problem hiding this comment.
1. Audit logs omit kubernetes_metadata 📘 Rule violation ◔ Observability
In KubernetesMinimal enrichment, when no Kubernetes fields are present the code sets `.message = msg_value`, producing syslog payloads without any Kubernetes metadata placeholder. This conflicts with the requirement that every processed log entry include kubernetes_metadata even when empty.
Agent Prompt
## Issue description
KubernetesMinimal enrichment currently drops Kubernetes metadata entirely for non-container logs (e.g., audit/journald) by setting `.message = msg_value` when no `parts` are present. Compliance requires every processed log entry to include `kubernetes_metadata` even if it is empty.
## Issue Context
The current implementation intentionally avoids emitting empty `namespace_name=`, `container_name=`, `pod_name=` prefixes, and functional tests assert those empty prefixes are absent. To satisfy the compliance requirement without reintroducing empty prefixes, emit an explicit placeholder (e.g., `kubernetes_metadata={}` or an equivalent agreed-upon serialization) when Kubernetes metadata is missing.
## Fix Focus Areas
- internal/generator/vector/output/syslog/syslog.go[163-186]
- internal/generator/vector/output/syslog/tcp_with_kubernetes_minimal_enrichment.toml[81-107]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
…logs (LOG-9694) Syslog forwarding with KubernetesMinimal enrichment unconditionally added namespace_name=, container_name=, pod_name= prefixes even to audit and journald logs that have no Kubernetes metadata. Now these fields are only included when present and non-empty. Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
|
/retest-required |
|
@vparfonov: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jcantrill, vparfonov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d3b6f7a
into
openshift:master
Description
/cc @Clee2691
/assign @jcantrill
Links
Summary by CodeRabbit
namespace_name,container_name, andpod_namefields..messageformatting is cleaner when Kubernetes metadata is absent, avoiding unnecessary prefixes.