Log aggregation differs from application performance monitoring (APM) in the data it collects and the problems it helps you investigate. APM uses traces to measure request performance and identify slow or failing operations, while log aggregation collects timestamped events from applications, containers, and infrastructure into searchable storage. For example, if a checkout request slows down, APM can show where the delay occurred, while logs can reveal connection timeouts, retries, or other events that explain it.
This guide explains how to use APM and log aggregation together during investigations, including how trace IDs connect slow requests to their related logs. You’ll also learn how their collection pipelines, data volumes, and costs differ, when centralized logging provides enough information, and when distributed tracing is needed to pinpoint performance problems across services.
APM vs. Log Aggregation: Key Differences
APM and log aggregation differ in the data they capture, how they collect and analyze it, and how storage and retention affect costs.
Traces connect operations through a shared trace ID and parent-child relationships between spans. Each span records an operation’s timing, while a root span has no parent. This structure allows APM backends to reconstruct request waterfalls and build dependency maps when the relevant service interactions are instrumented. Log records have no equivalent request hierarchy by default, so connecting events across services depends on consistent fields and correlation IDs.
What APM Captures: Transactions, Spans, Errors, and Latency
APM tracks request rate, errors, and duration (RED) to measure application performance. Request metrics show how services behave across many requests, while distributed traces let you inspect individual executions. These metrics can be collected directly or calculated from spans, depending on the instrumentation and backend.
A distributed trace contains spans representing operations such as inbound HTTP requests, database queries, and downstream service calls. Each span has a trace ID, a span ID, and start and end timestamps. Child spans reference their parent, allowing you to reconstruct the execution path across instrumented operations. Attributes and span events can provide additional context, including errors and exceptions.
When a request crosses services, trace context propagation lets the receiving service continue the same trace. The calling service passes its trace ID and span ID to the next service, which creates a new span linked to the caller. For HTTP requests, the W3C traceparent header carries that context:
The fields contain the version (00), a 16-byte trace ID, the caller’s 8-byte span ID, and trace flags. The final 01 indicates that the sampled flag is set.
Latency percentiles help identify slow requests that averages can hide. A p99 latency of 900 ms means approximately 99% of requests completed in 900 ms or less, while the slowest 1% took at least that long. Comparing p50, p95, and p99 helps you determine whether a slowdown affects typical requests or the tail of the latency distribution.
Service dependency maps use instrumented service-to-service calls to show which services communicate. Consistent service.name attributes help the backend identify each service rather than splitting its operations across multiple names. However, trace sampling limits how many individual executions reach storage. Request metrics may still show an error-rate or latency spike even when the trace for a particular failed request was not retained.
How APM Collects Data: Agents, OpenTelemetry, and eBPF
APM collects telemetry through application instrumentation, external observation, or a combination of both. The collection method determines which operations and attributes you can see, along with the changes required to instrument your services.
- Language agents: Agents such as the OpenTelemetry Java agent instrument supported libraries at runtime without requiring developers to create every span manually. They can capture HTTP and database operations and integrate trace context with supported logging frameworks.
- OpenTelemetry SDKs: Developers instrument application code to record custom operations and attributes, such as pricing calculations, order states, or specific business transactions.
- Compile-time instrumentation: OpenTelemetry Go compile-time instrumentation adds tracing and metrics instrumentation during the build process. It requires rebuilding the application but avoids manual instrumentation for supported libraries.
- eBPF instrumentation: OpenTelemetry eBPF Instrumentation (OBI) observes supported application and network operations from outside the process. It can capture HTTP, gRPC, database, and TLS transactions without modifying application code or decrypting TLS traffic.
eBPF-based collection cannot automatically reveal business decisions or custom operations that its probes cannot observe. For those details, you still need application instrumentation. Distributed tracing also depends on context propagation: for encrypted HTTPS, OBI’s network-level propagation can connect other OBI-instrumented services when enabled, but Layer 7 proxies can interrupt that connection.
OBI requires Linux 5.8 or later, or a supported RHEL-family 4.18 kernel with the necessary backports, along with BTF and an amd64 or arm64 node.
How Log Aggregation Works: Collection, Storage, and Search
In Kubernetes, applications commonly write logs to stdout and stderr. The container runtime stores those records in files, typically under /var/log/pods, and a log shipper running as a DaemonSet reads them from each node. The shipper parses the records, adds Kubernetes metadata, and sends them to a centralized backend.
Containerd and CRI-O commonly use the CRI logging format. Each record contains a timestamp, output stream, partial or full-record flag, and message:
Here, stdout identifies the output stream, while F marks a full or final log entry. The P flag identifies a partial fragment that a collector may need to combine with subsequent fragments.
Common Kubernetes log shippers include:
- Fluent Bit: Its tail input and Kubernetes filter read container log files, parse runtime formats, and add metadata such as pod names, namespaces, labels, and annotations. Metadata can come from the Kubernetes API server or kubelet.
- Vector: The
kubernetes_logssource collects container logs and enriches them with Kubernetes metadata, including workload and container information. - OpenTelemetry Collector: The
filelogreceiver’s container parser handles container log formats and combines partial entries. Thek8sattributesprocessor can add Kubernetes metadata when the Collector is configured with the necessary pod association and permissions.
Reading log files requires access to the node’s log directories, while fetching additional metadata through the Kubernetes API requires appropriate RBAC permissions. The exact permissions depend on the shipper and its configuration. After collection, the backend stores records for querying and retention, with its indexing design affecting search performance and cost. For example, Loki indexes stream labels rather than every log field, so putting a unique trace ID into a stream label creates excessive label cardinality. Trace IDs are better stored as structured metadata.
What Logs Capture Beyond APM
APM spans can contain error details, attributes, and exception stack traces, but they only record information captured by the instrumentation. Application and infrastructure logs can preserve additional events and state that aren’t represented in those spans, including events outside the instrumented request path.
- Diagnostic details: Logs can record validation failures, application branches, and relevant state when a request fails. A span may identify the failed operation without containing those details.
- Retries: Application logs can show each retry attempt, its backoff interval, and the error that triggered it. A trace may show the overall delay without capturing every retry as a separate span or event.
- Resource state: HikariCP can log connection-pool state during timeouts, including the number of active, idle, and waiting connections. Those values help distinguish connection acquisition delays from slow SQL execution.
- Business and audit events: Order transitions, refunds, permission changes, and authentication failures may need to be retained even when no application performance problem occurs.
- Infrastructure and background failures: Kubelet messages, container crashes, startup errors, and scheduled-job failures can occur outside an HTTP request. Some background work can be traced separately, but not every system event produces an application span.
Structured Logging and Log Levels
Structured logging records events using consistent fields, often serialized as JSON. Instead of searching an entire message for an error, you can filter by fields such as service.name, severity, k8s.pod.name, or trace_id. If one application writes trace_id, another writes traceId, and a third writes tid, correlation queries must account for all three formats.
You can normalize fields across services using the OpenTelemetry Logs Data Model, including Timestamp, SeverityText, SeverityNumber, Body, Attributes, TraceId, and SpanId. Log severity levels use these numerical ranges:
Individual logging frameworks use different severity names and defaults. In production, INFO is a common starting point, with DEBUG enabled selectively when more detail is needed. For example, Rails defaults to INFO in production and DEBUG in other environments, unless you override its configuration.
Higher verbosity increases the number of emitted records and can increase ingestion, indexing, and storage costs. Filtering noisy DEBUG or health-check records before ingestion reduces that volume, but those discarded events will no longer be available for later investigations.
How APM and Log Aggregation Work Together
Trace-log correlation connects application logs with the traces that record request execution. When logs contain the active trace ID and span ID, an APM trace can link a slow operation to events recorded during that operation. An error log can also link back to its corresponding trace, provided the trace was collected and retained. This connection depends on trace context being included in the logs and recognized by the observability backend.
Connecting Logs and Traces Using Trace IDs
A trace ID identifies the entire request execution path, while a span ID identifies an individual operation within that trace. When a service receives a request, its instrumentation extracts the incoming trace context and makes the relevant span active. A logging integration reads that context and attaches the IDs to log records emitted during the operation.
In JSON logs, the IDs appear as lowercase hexadecimal trace_id and span_id fields, with an optional trace_flags field, following OpenTelemetry’s correlation conventions. Not every log record contains these fields, since correlation depends on an available trace context and compatible logging instrumentation. A checkout service encountering a database connection timeout can emit a record like this:
The trace_id connects this error to other logs from the same request, while span_id identifies the operation during which it occurred. The Kubernetes metadata identifies the pod responsible for the event, even when the corresponding trace is unavailable. Both IDs must reach the log output and survive collection for the backend to use them.
Trace context reaches application logs differently across languages and logging frameworks:
- Java: The OpenTelemetry Java agent injects
trace_id,span_id, andtrace_flagsinto the mapped diagnostic context (MDC) for supported logging frameworks. Log4j and Logback can include those values in their output, with Log4j using patterns such as%X{trace_id}. - Python: OpenTelemetry logging instrumentation adds trace context attributes to
LogRecordobjects when injection is enabled. Those attributes reach the emitted log only when the formatter includes them.OTEL_PYTHON_LOG_CORRELATION=truecan configure that format throughlogging.basicConfig(), although an existing logging configuration may prevent the format change. - .NET: OpenTelemetry .NET logging automatically populates
TraceId,SpanId, andTraceFlagsfromActivity.Currentwhen an activity is active. These fields allow logs captured during an application operation to be linked to its trace. - Node.js: OpenTelemetry’s Pino instrumentation can attach
trace_id,span_id, andtrace_flagsto log records emitted within an active span. - Go: The
otelslogbridge connectslog/slogto OpenTelemetry logging. The request context passed to a logging call carries the active span information used for correlation. - Without application changes: OBI log enrichment uses eBPF to add trace context to supported JSON and plain-text logs. It modifies the existing log stream rather than forwarding logs to a backend. The feature requires Linux kernel 6.0 or later and explicit configuration; in Config v2, it is disabled by default and available only when OBI runs as a standalone process.
The observability backend must recognize the correlation fields to connect the two signals. Field names differ across platforms, and some backends require mapping or linking configuration.
In Grafana, for example, a derived field can extract a trace ID from a Loki log record and create a link to Tempo. The link uses the ID to retrieve the corresponding trace. If the trace was sampled out or has expired, the log remains searchable, but the link cannot display the missing trace.
Investigating a Slow Checkout Request Using APM and Logs
A Kubernetes checkout service begins taking nearly 30 seconds to process some requests. Its database query spans remain short, but requests are failing with connection acquisition timeouts. APM helps identify where the delay occurs, while correlated logs reveal what the application was waiting for.
- Detect the slowdown: A latency alert fires for
checkout. The RED dashboard shows p99 latency approaching 30 seconds while request rate stays steady and errors increase. The slowdown is affecting request processing rather than being explained by a rise in incoming traffic. - Locate the delay: A slow request trace shows an inbound HTTP span lasting roughly 30 seconds. The recorded database operations account for only a small portion of that time. Because connection acquisition has no dedicated span in this trace, the remaining delay isn’t explained by its child spans.
- Correlate the error log: The trace ID
4bf92f3577b34da6a3ce929d0e0e4736links to the ERROR record shown earlier:HikariPool-1 - Connection is not available, request timed out after 30000ms.HikariCP’sconnectionTimeoutcontrols how long a request waits for an available database connection before failing, with a default of 30 seconds. The log identifies failed connection acquisition rather than a slow SQL query. - Investigate the connection pool: The logs’
k8s.pod.namefields show whether timeouts affect one replica or several. HikariCP metrics provide the corresponding pool state, including total, active, idle, and pending connections. Values such astotal=10, active=10, idle=0, waiting=189indicate that all ten connections are occupied while additional requests wait. Connection usage and query timing can then help distinguish long-running queries, connections not being returned, and insufficient pool capacity.
The timeout message identifies the immediate failure, but it doesn’t establish why connections are unavailable. Slow queries holding connections, a connection leak, and a pool that cannot serve the current concurrency can produce similar symptoms. Connection-pool metrics and query timing provide the additional evidence needed to distinguish them.
Correlation can also fail when the log and trace pipelines are working independently. A log without a trace ID cannot be matched directly to a request, while an ID that points to no stored trace may indicate sampling, retention, or field-mapping problems. Service names, pod metadata, and timestamps still allow engineers to narrow the investigation when a direct trace match is unavailable.
Log Ingestion vs. APM Tracing: Volume and Cost
Log and trace volumes depend on different factors. Log volume grows with request traffic, the number of events recorded, and the size of each record. Trace volume depends on how many requests are instrumented, how many spans each request generates, and what percentage of traces are retained through sampling. A single request can generate dozens of log entries and spans, so the volume of one signal does not reliably predict the other.
For example, a workload generating 100 GB of logs per day produces approximately 3 TB over 30 days before filtering and compression. Whether the platform charges for all that data depends on where filtering occurs and which billing units it uses. A platform may charge for bytes ingested, records indexed, data retained, or queries executed, while others charge by monitored host or node.
The billing models also overlap across logs and APM:
Reducing telemetry volume changes costs differently depending on the billing model. Filtering a log before ingestion reduces billable data on ingestion-based plans, while retaining fewer traces reduces stored span volume. With fixed host- or node-based pricing, changes in log and trace volume do not directly affect the subscription charge.
How Filtering and Sampling Affect Observability Costs
Filtering, sampling, and retention settings determine how much telemetry reaches storage and how long it remains available. Reducing that volume can lower costs on usage-based plans, but it also limits the data available during investigations. Each method affects logs and traces differently.
- Log filtering and levels: Collecting INFO and higher-severity events while excluding routine DEBUG or health-check logs reduces ingestion volume. Collector-side filtering drops matching records before they reach the backend, so those events are unavailable for later searches.
- Head sampling: A sampling decision is made near the beginning of a trace, commonly using a fixed probability. The decision can be propagated across services, reducing the number of spans collected and exported. Because it happens before the complete request is known, head sampling cannot guarantee that every failed or slow request is retained.
- Tail sampling: The OpenTelemetry Collector can buffer spans before deciding whether to retain a trace based on latency, errors, or attributes. This makes it possible to prioritize problematic requests, but the tail sampling processor consumes memory while waiting for decisions. If its trace buffer fills, older traces may be discarded before evaluation. In scaled deployments, spans belonging to the same trace must reach the same Collector instance.
- Retention: Individual traces can have shorter retention periods than aggregate latency and error metrics, which remain useful for identifying historical trends. Logs may need longer retention for incident investigations or audit requirements. Keeping both signals available during the usual investigation window also prevents trace-to-log links from failing solely because one signal expired earlier.
When Should You Use Log Aggregation, APM, or Both?
The choice depends on what you need to investigate, not simply how many services an application has. Structured logs may provide enough context to diagnose failures and measure request duration, while APM helps identify which operations consume that time. Combining both becomes useful when performance problems require information that neither signal captures on its own.
- Log aggregation alone: For a small application with few dependencies, structured access logs containing request duration, HTTP status, and route information may provide enough visibility. Engineers can calculate latency percentiles from these records and search application logs for errors. However, request duration alone does not identify which internal operation caused a slowdown.
- APM for performance investigations: APM becomes useful when you need latency and error-rate metrics across services or traces showing how time is spent within individual requests. Logs can record response times and failures, but traces connect instrumented operations such as database queries and downstream API calls. This applies to monoliths as well as microservices.
- Both for application troubleshooting: Logs and APM complement each other when engineers need to investigate performance alongside application behavior. A trace can identify the operation responsible for a delay, while logs provide details such as retries, connection-pool failures, or application decisions. With trace-log correlation enabled, engineers can examine the relevant events without relying only on timestamps.
Designing an Observability Stack With Logs and APM
For a Kubernetes application, the stack needs to collect logs and traces reliably, associate them with the correct workloads, and preserve enough data to investigate incidents. An OpenTelemetry-based architecture can use the same Collector deployment for both signals, but their collection and processing requirements differ.
There are five decisions to make when designing an observability stack that combines log aggregation and APM:
- Choose how logs enter the pipeline: Kubernetes applications commonly write logs to stdout and stderr, which the container runtime stores under
/var/log/pods. A node-level Collector running as a DaemonSet can use the Filelog receiver to read and parse those files. Applications that already export logs through OTLP can send them directly to a compatible receiver. Centralized collection keeps logs available beyond the lifecycle of individual pods, unlike relying solely onkubectl logs. - Capture request performance: Application instrumentation generates spans for operations such as incoming HTTP requests, database queries, and downstream service calls. SDKs and compatible agents can export these spans through OTLP, which uses port
4317for gRPC and4318for HTTP by default. The corresponding HTTP endpoints are/v1/tracesand/v1/logs. The instrumentation method determines which operations appear in traces, so coverage needs to match the performance problems engineers expect to investigate. - Preserve correlation fields: Logs and traces need consistent service and Kubernetes metadata. The Collector’s Kubernetes attributes processor can enrich telemetry with fields such as
k8s.namespace.name,k8s.pod.name, andk8s.node.name. Application logging integrations can addtrace_idandspan_idto individual records. The backend must recognize those identifiers to link an error log to its trace; Kubernetes metadata alone does not provide an exact request-level match. - Choose the Collector topology: Logs and traces use separate pipelines under
service.pipelines, even when they share an OTLP receiver. This allows log filtering and trace sampling to operate independently. A node-level Collector may be sufficient for local collection and direct export. A gateway becomes useful when centralized processing, routing, or tail sampling is required. With multiple tail-sampling Collectors, trace-ID-aware routing keeps spans from the same trace together. - Set retention and test the investigation workflow: Logs and traces should overlap in retention for the period when engineers need to correlate them. Test correlation by generating a slow checkout request, finding its trace, and retrieving the associated logs using the trace ID. The reverse lookup should also work from the error log to the trace. If sampling removes the trace, the logs should remain searchable by service, pod, and time. Backend selection should also account for query performance, access controls, data residency, and the billing model.
How groundcover Combines Log Aggregation and APM
groundcover brings Kubernetes logs, application performance metrics, and traces into one observability platform. Its eBPF sensor collects telemetry without requiring application code changes, while OpenTelemetry integration allows you to incorporate traces from existing instrumentation.
Collecting Logs and APM Data in One Platform
The groundcover eBPF sensor runs as a Kubernetes DaemonSet, automatically collecting pod logs and observing application traffic across supported HTTP, gRPC, and database protocols. With eBPF auto-instrumentation, you get request-rate, error-rate, and latency metrics without deploying separate instrumentation agents for every service.
groundcover also generates traces from observed interactions and enriches telemetry with Kubernetes context, including workloads, pods, and namespaces. You can combine these traces with OpenTelemetry data and investigate application performance alongside centralized logs, infrastructure metrics, and Kubernetes events.
Connecting Application Performance to Logs
When latency or error rates increase, you can use APM metrics to identify the affected workload, inspect slow requests in the trace waterfall, and search application logs for relevant errors, timeouts, and retries. Kubernetes metadata helps you narrow the investigation to the workloads and pods handling those requests.
With log and trace correlation, you can navigate between application logs containing trace IDs and their corresponding traces. Instead of searching separate systems and manually matching timestamps, you can follow a request and examine the events recorded during its execution.
For example, if an API request spends most of its time waiting on a database operation, you can inspect its trace and associated logs for connection-pool warnings, query failures, or repeated retries. This combination of distributed tracing and logs helps you move from identifying a performance bottleneck to investigating what caused it.
Investigating Root Causes Across Logs and APM
Suppose your checkout service experiences a sudden increase in p95 latency. You can identify the affected endpoints through APM metrics, examine slow traces to locate the operations consuming time, and inspect related logs for errors. Kubernetes metrics and events provide additional context about resource pressure, pod restarts, and deployment changes.
groundcover Agent Mode can investigate these signals together, allowing you to ask why latency increased or what contributed to an error spike. For collaborative root cause analysis, groundcover Investigations lets you review hypotheses, examine supporting evidence, and track findings in a shared workspace. The groundcover MCP Server also connects compatible coding assistants to production telemetry, allowing you to investigate issues from your development environment.
You can review the evidence behind a suspected cause, apply a fix, and compare subsequent logs and performance metrics to verify recovery. Having the relevant telemetry and investigation findings in one place reduces manual searches and context switching, helping you shorten mean time to resolution (MTTR).
FAQs
Log aggregation collects and centralizes application and infrastructure logs so you can search events, errors, and diagnostic messages. APM monitors application performance by collecting metrics and traces through SDKs, automatically instrumented agents, or eBPF, helping you identify slow requests, failing dependencies, and performance bottlenecks. When logs contain matching trace IDs, you can correlate them with APM traces to investigate both where a request failed and what happened during its execution.
Yes. If your application has few dependencies, structured logs containing request duration, HTTP status, and route information may be enough to monitor performance and troubleshoot failures. However, APM becomes useful when you need to identify which database queries, external calls, or internal operations are causing delays.
Yes. APM identifies failed operations and their timing, while application logs provide details such as exception messages, retries, connection failures, and business-logic decisions. Logs also capture failures outside traced requests, including startup errors and background job failures.
APM logging refers to application logs associated with monitored requests, usually through trace IDs and span IDs. These identifiers let you navigate between log records and distributed traces. Regular logs can contain the same diagnostic information, but without tracing context, they cannot be linked directly to a specific trace.
The trace may have been excluded by head or tail sampling, expired under a shorter retention policy, or failed to reach the backend. Incorrect trace ID formatting or field mapping can also prevent correlation. Check whether the trace exists before investigating its ID format and logging configuration.
Use INFO for routine events, WARN for unexpected conditions, and ERROR for failures. Keep DEBUG and TRACE disabled unless you need detailed troubleshooting information. Enable DEBUG only for the affected component during an investigation, and alert on actionable error patterns rather than every warning or error.





