Repository navigation
feat(k8scontainer): enrich cilium-agent logs with subsystem, level and Pod references - #1261
Conversation
There was a problem hiding this comment.
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.
3bbfcc5 to
3df2999
Compare
…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.
3df2999 to
1fa8e0d
Compare
Code Quality Report — ✅ Cloud Build
|
b7eb853 to
bcf1a6e
Compare
…meline, and tighten tests
bcf1a6e to
8e8f36c
Compare
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 (
subsysormodule), theerrorand the Pod the log refers to. Logs such asIdentity of endpoint changedork8sErrorwere hard to understand, and endpoint lifecycle events were not visible from the Pod they belong to.Changes
k8scontainer/extractor.go: addedCiliumAgentContainerName,CiliumAgentLogFieldSetandExtractCiliumAgentLog.subsysfield, or the last segment of the Hive slogmodulefield (for exampleendpoint-api).levelfield of JSON payloads (debug/info→ INFO,warn→ WARNING,error→ ERROR,fatal/panic→ FATAL). Text payloads keep the level from the existing logfmt parser.<namespace>/<pod>ink8sPodNameorciliumEndpointName(logrus), or separatek8sNamespaceandk8sPodNamefields (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 thecilium-agentcontainer is affected.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: errorlogs were shown as ERROR.Verification
make pre-commitmake build-go && make lint-go && make test-go