Skip to content

feat(k8scontainer): enrich cilium-agent logs with subsystem, level and Pod references - #1261

Merged
kyasbal merged 4 commits into
push-ottutrxmkoxpfrom
push-zwspwslosuqz
Nov 17, 2026
Merged

kyasbal merged 4 commits into
push-ottutrxmkoxpfrom
push-zwspwslosuqz

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Makes cilium-agent (anetd) container logs of GKE Dataplane V2 useful on timelines: shows the subsystem, error and referenced Pod in the summary, uses the log level as the severity, and adds the log to the timeline of the referenced Pod.

Stacked on #1260. Part of the GKE Dataplane V2 log support stack.

Motivation

The generic container log parser reads only the message field of JSON logs. For cilium-agent, this dropped the subsystem (subsys or module), the error and the Pod the log refers to. Logs such as Identity of endpoint changed or k8sError were hard to understand, and endpoint lifecycle events were not visible from the Pod they belong to.

Changes

  • k8scontainer/extractor.go: added CiliumAgentContainerName, CiliumAgentLogFieldSet and ExtractCiliumAgentLog.
    • Subsystem: the logrus subsys field, or the last segment of the Hive slog module field (for example endpoint-api).
    • Severity: the level field of JSON payloads (debug/info → INFO, warn → WARNING, error → ERROR, fatal/panic → FATAL). Text payloads keep the level from the existing logfmt parser.
    • Pod reference: <namespace>/<pod> in k8sPodName or ciliumEndpointName (logrus), or separate k8sNamespace and k8sPodName fields (Hive slog). Host endpoints ("/") are ignored.
  • k8scontainer/impl/mapper.go: formats the summary as [<subsys>] <msg>(error=<error>) 【<pod> (Namespace: <ns>)】 and adds the log to the timeline of the referenced Pod. Only the cilium-agent container is affected.
before: Successful endpoint creation
after : [endpoint-api] Successful endpoint creation 【test-pod (Namespace: default)】
before: Network logging obj is invalid             (severity from Cloud Logging)
after : [gke-network-logging-controller] Network logging obj is invalid(error=...)   (ERROR from jsonPayload.level)

Screenshots

Verified on real cilium-agent logs from 15 anetd Pods (20,453 logs). 1,220 logs with a Pod reference were linked to the referenced Pods, and 714 level: error logs were shown as ERROR.

📷 Screenshot — e2e_cilium_agent.png: the cilium-agent container timeline and a Pod timeline that receives the same endpoint event (E2). E1 has no subsys field in the raw log, so it has no prefix, but it is still ERROR.

image

Verification

  • make pre-commit
  • make build-go && make lint-go && make test-go
  • Ran the Kubernetes container logs feature on real anetd logs and checked the summaries, severities and Pod timelines with the KHI MCP tools.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for extracting and enriching cilium-agent logs. It adds a new ExtractCiliumAgentLog function to parse structured fields (such as subsystem, error, severity, and pod references) from both JSON and logfmt text payloads, and updates the log mapper to enrich container log summaries and map events to the referenced Pod's timeline. The review feedback recommends simplifying ExtractCiliumAgentLog by removing a defensive nil check on the reader parameter. This allows removing the error return type from the function signature, thereby simplifying error handling across all call sites and test cases.

…d Pod references

The generic container log parser reads only the message field of JSON logs, so cilium-agent logs of GKE Dataplane V2 lost their subsystem, error and Pod reference. Prefix the summary of cilium-agent logs with the logrus subsys or the last segment of the Hive slog module, append the error and the referenced Pod, and use the level in JSON payloads as the severity.

Normalize the Pod reference written as namespace/name in k8sPodName or ciliumEndpointName by logrus logs and in separate k8sNamespace and k8sPodName fields by Hive slog logs, and add the log to the timeline of the referenced Pod so that endpoint lifecycle events are visible from the Pod.
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Code Quality Report — ✅ Cloud Build success

Cloud Build completed without an embedded report envelope.


Commit: 8e8f36c09a87 · Cloud Build Logs

@kyasbal
kyasbal force-pushed the push-zwspwslosuqz branch 2 times, most recently from b7eb853 to bcf1a6e Compare November 17, 2026 07:10
@kyasbal
kyasbal added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 22fc100 Nov 17, 2026
22 checks passed
@kyasbal
kyasbal deleted the push-zwspwslosuqz branch November 17, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant