Skip to content

[release-6.6]fix(syslog): skip empty KubernetesMinimal prefixes for non-container logs (LOG-9694) - #3373

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:release-6.6from
vparfonov:log9694
Jul 27, 2026
Merged

[release-6.6]fix(syslog): skip empty KubernetesMinimal prefixes for non-container logs (LOG-9694)#3373
openshift-merge-bot[bot] merged 1 commit into
openshift:release-6.6from
vparfonov:log9694

Conversation

@vparfonov

Copy link
Copy Markdown
Contributor

Description

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.

/cc @Clee2691
/assign @jcantrill

Links

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 03634d57-d69e-4307-8b50-1f16198a1fd7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from alanconway and cahartma July 24, 2026 18:30
@qodo-for-rh-openshift

Copy link
Copy Markdown

PR Summary by Qodo

Fix syslog KubernetesMinimal to omit empty k8s prefixes on non-container logs

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Stop prepending empty KubernetesMinimal fields to audit/journald syslog messages.
• Build syslog message prefixes only from present, non-empty Kubernetes metadata.
• Add functional coverage for RFC3164/RFC5424 to prevent regressions.
Diagram

graph TD
  A["Audit / Journald inputs"] --> B["Vector VRL: KubernetesMinimal"] --> C["Syslog sink"] --> D{{"External syslog receiver"}}
  E["App container logs"] --> B
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Deduplicate the VRL snippet (single source of truth)
  • ➕ Avoids drift between the Go-generated transform and the example TOML
  • ➕ Simplifies future enrichment tweaks and reduces copy/paste risk
  • ➖ May require generator/template refactoring work beyond the immediate bug fix
  • ➖ Could increase coupling between generator code and documentation/examples
2. Always emit keys but omit separators when empty
  • ➕ Keeps a more uniform message shape across sources
  • ➕ Potentially simpler matching logic for receivers expecting fixed ordering
  • ➖ Still risks awkward/ambiguous formatting and parsing issues
  • ➖ Does not fully address the visual/semantic noise that prompted the bug report

Recommendation: The PR’s approach (build a prefix list from present + non-empty Kubernetes fields, otherwise forward the original message) is the best behavioral fix and minimizes surprises for non-container logs. Consider a follow-up to deduplicate the VRL logic between the generator and the TOML example to prevent future divergence.

Files changed (4) +158 / -14

Bug fix (2) +42 / -14
syslog.goConditionally build KubernetesMinimal syslog message prefix +21/-7

Conditionally build KubernetesMinimal syslog message prefix

• Reworks the VRL used for KubernetesMinimal enrichment to only prepend namespace/container/pod fields when they exist and are non-empty. If no Kubernetes fields are present, the message is forwarded without any empty prefixes.

internal/generator/vector/output/syslog/syslog.go

tcp_with_kubernetes_minimal_enrichment.tomlUpdate syslog TOML example to skip empty KubernetesMinimal prefixes +21/-7

Update syslog TOML example to skip empty KubernetesMinimal prefixes

• Updates the TOML transform example to mirror the new conditional-prefix behavior. Ensures audit/journald-like records without Kubernetes metadata do not get 'namespace_name=, container_name=, pod_name=' prefixes.

internal/generator/vector/output/syslog/tcp_with_kubernetes_minimal_enrichment.toml

Tests (2) +116 / -0
rfc3164_test.goAdd RFC3164 functional coverage for non-container logs with KubernetesMinimal +58/-0

Add RFC3164 functional coverage for non-container logs with KubernetesMinimal

• Adds functional tests asserting that audit and infrastructure journal logs do not include empty KubernetesMinimal prefixes when forwarded via RFC3164 syslog. Also checks collector logs for absence of VRL compilation warnings.

test/functional/outputs/syslog/rfc3164_test.go

rfc5424_test.goAdd RFC5424 functional coverage for non-container logs with KubernetesMinimal +58/-0

Add RFC5424 functional coverage for non-container logs with KubernetesMinimal

• Adds the same regression coverage as RFC3164, validating that audit and infrastructure journal logs forwarded via RFC5424 do not contain empty Kubernetes prefix fragments and that the collector has no VRL compilation warnings.

test/functional/outputs/syslog/rfc5424_test.go

@vparfonov vparfonov changed the title fix(syslog): skip empty KubernetesMinimal prefixes for non-container logs (LOG-9694) [release-6.6]fix(syslog): skip empty KubernetesMinimal prefixes for non-container logs (LOG-9694) Jul 24, 2026
@jcantrill

Copy link
Copy Markdown
Contributor

/label release/6.6

@qodo-for-rh-openshift

qodo-for-rh-openshift Bot commented Jul 24, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
⚠️ Tickets: not configured — ticket URL found in PR but could not be fetched — check ticket provider credentials
✅ Compliance rules (platform): 9 rules

Grey Divider


Action required

1. VRL precedence breaks condition ✓ Resolved 🐞 Bug ≡ Correctness
Description
In KubernetesMinimal enrichment, to_string(.kubernetes.*) ?? "" != "" is unparenthesized and can
be parsed as to_string(...) ?? ("" != ""), producing a non-boolean expression in the if and
potentially failing VRL compilation (breaking syslog forwarding when enrichment is enabled). The
same expression is duplicated in the generated example TOML, so both need to be fixed to keep
templates consistent.
Code

internal/generator/vector/output/syslog/syslog.go[167]

+if exists(.kubernetes.namespace_name) && to_string(.kubernetes.namespace_name) ?? "" != "" {
Relevance

⭐⭐⭐ High

Syslog VRL compilation warnings/regressions are routinely fixed; parenthesizing avoids
invalid/non-boolean if expressions.

PR-#3344
PR-#3322

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR introduces unparenthesized ?? combined with != in the new KubernetesMinimal if
conditions. Elsewhere in this repo, when combining a comparison with ??, the expression is
explicitly parenthesized, indicating precedence matters and should be made explicit here too.

internal/generator/vector/output/syslog/syslog.go[159-186]
internal/generator/vector/output/syslog/tcp_with_kubernetes_minimal_enrichment.toml[81-107]
internal/generator/vector/filter/apiaudit/policy.vrl.tmpl[39-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The VRL condition `to_string(.kubernetes.<field>) ?? "" != ""` is ambiguous without parentheses and may be parsed as `to_string(...) ?? ("" != "")`, which can lead to VRL type-check/compilation failure.

### Issue Context
This VRL is used for syslog `KubernetesMinimal` enrichment. The same VRL snippet is duplicated in an example TOML and should remain consistent.

### Fix Focus Areas
- internal/generator/vector/output/syslog/syslog.go[167-176]
- internal/generator/vector/output/syslog/tcp_with_kubernetes_minimal_enrichment.toml[88-97]

### Suggested change
Update each condition to explicitly coalesce first, then compare, e.g.:
```vrl
if exists(.kubernetes.namespace_name) && ((to_string(.kubernetes.namespace_name) ?? "") != "") {
 parts = push(parts, "namespace_name=" + to_string!(.kubernetes.namespace_name))
}
```
Repeat for `container_name` and `pod_name` in both files (or assign the coalesced string to a variable and reuse it).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@jcantrill: The label(s) /label release/6.6 cannot be applied. These labels are supported: acknowledge-critical-fixes-only, platform/aws, platform/azure, platform/baremetal, platform/google, platform/libvirt, platform/openstack, ga, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, px-approved, docs-approved, qe-approved, ux-approved, no-qe, rebase/manual, cluster-config-api-changed, run-integration-tests, verified, ready-for-human-review, approved, backport-risk-assessed, bugzilla/valid-bug, cherry-pick-approved, jira/skip-dependent-bug-check, jira/valid-bug, ok-to-test, stability-fix-approved, staff-eng-approved. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

Details

In response to this:

/label release/6.6

Instructions 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.

Comment thread internal/generator/vector/output/syslog/syslog.go Outdated
@jcantrill

Copy link
Copy Markdown
Contributor

/approve

@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vparfonov

Copy link
Copy Markdown
Contributor Author

/label release/6.6

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 24, 2026
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@vparfonov: The label(s) /label release/6.6 cannot be applied. These labels are supported: acknowledge-critical-fixes-only, platform/aws, platform/azure, platform/baremetal, platform/google, platform/libvirt, platform/openstack, ga, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, px-approved, docs-approved, qe-approved, ux-approved, no-qe, rebase/manual, cluster-config-api-changed, run-integration-tests, verified, ready-for-human-review, approved, backport-risk-assessed, bugzilla/valid-bug, cherry-pick-approved, jira/skip-dependent-bug-check, jira/valid-bug, ok-to-test, stability-fix-approved, staff-eng-approved. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

Details

In response to this:

/label release/6.6

Instructions 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.

…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>
@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@vparfonov: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions 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.

@vparfonov

Copy link
Copy Markdown
Contributor Author

/refresh

@jcantrill

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 177f5ce into openshift:release-6.6 Jul 27, 2026
9 checks passed
@vparfonov
vparfonov deleted the log9694 branch July 27, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release/6.6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants