Log Correlation, Retrieval, and Troubleshooting Across Distributed BTP Runtimes
Learn how to trace a single business transaction across multiple BTP microservices using correlation IDs, retrieve logs efficiently through the Log and Trace Viewer or Kibana, and apply a structured troubleshooting approach when logs are missing, delayed, or inconsistent.
Explanation
Once an application is bound to the Application Logging service and emitting structured entries, the harder operational challenge begins: making sense of logs that span multiple microservices, API calls, and asynchronous events. A single business transaction in an integration scenario - for example, an inbound IDoc-triggered call from S/4HANA through an Integration Suite iFlow into a Kyma-hosted custom service - may generate log entries in three or four different runtime components. Without a shared correlation mechanism, a support engineer would have to guess which log lines belong together based on timestamps alone, which is unreliable under load. Correlation IDs solve this. Cloud Foundry's routing layer and many SAP-provided components automatically inject an X-CorrelationID (or similar) HTTP header into requests as they pass through the platform. Well-instrumented applications read this header on inbound requests and propagate it on outbound calls, then include it in every log statement they write. When correlation is implemented consistently, a support engineer can take the ID from one failing log entry and search across every bound service's logs to reconstruct the full transaction path in the exact order events occurred, even when they span different Cloud Foundry orgs/spaces or Kyma namespaces. Retrieval itself differs by runtime and service tier. For Cloud Foundry apps with the entry-level Application Logging plan, the cf logs command against a running application shows only a recent tail and is primarily useful for live debugging during deployment, not historical investigation. For anything beyond that window, teams rely on the Application Logging service's own persistence, exposed either through the SAP BTP cockpit's Log and Trace Viewer or through a Kibana/OpenSearch dashboard when the lite or standard plan with a dedicated log store is provisioned. Kibana allows filtering by correlation ID, log level, component name, and time range, and supports saved searches that operations teams reuse for recurring investigations, such as isolating all ERROR-level entries for a specific integration flow over the last 24 hours. A structured troubleshooting approach starts with three questions: is the log missing entirely, is it delayed, or is it present but incomplete? Missing logs are often caused by the application never being bound to the logging service, by log level thresholds filtering out the events (for example, DEBUG statements suppressed in production configuration), or by the destination/service key being invalidated after a credential rotation. Delayed logs typically point to buffering or backpressure in the log shipping pipeline, which is more common under sudden load spikes and is usually transient. Incomplete logs - where correlation IDs are missing on some hops - almost always trace back to inconsistent instrumentation, commonly when a custom Kyma service or a third-party library does not read or forward the correlation header. In Kyma, the troubleshooting path also includes checking whether the namespace-level log collection agent is running and whether pod restarts have caused gaps, since container logs are ephemeral by default and depend entirely on the collection layer to persist them centrally. In Cloud Foundry, application crashes before graceful shutdown can also truncate the final log entries for a request, which matters when diagnosing why a transaction appears to stop mid-flow with no explicit error logged. Finally, retention and cost considerations shape how long historical logs remain searchable. Application Logging service plans define retention windows and storage quotas, and once a quota is exceeded, older entries are typically purged on a rolling basis. Production support teams should never assume logs are permanently available; for compliance or long-term audit needs, log entries of business significance should be exported or forwarded to an external, longer-retention sink rather than relying solely on the BTP service's default window.
Code example
// Example: propagating and logging a correlation ID in a Node.js service running on Cloud Foundry or Kymaconst express = require('express');const axios = require('axios');const app = express(); app.use((req, res, next) => { // Reuse inbound correlation ID if present, otherwise generate one req.correlationId = req.header('X-CorrelationID') || require('crypto').randomUUID(); res.setHeader('X-CorrelationID', req.correlationId); next();}); app.post('/process-order', async (req, res) => { const cid = req.correlationId; console.log(JSON.stringify({ level: 'INFO', correlation_id: cid, component: 'order-service', msg: 'Received order processing request', order_id: req.body.orderId })); try { // Propagate correlation ID to downstream call const downstream = await axios.post('https://inventory-service/reserve', req.body, { headers: { 'X-CorrelationID': cid } }); console.log(JSON.stringify({ level: 'INFO', correlation_id: cid, component: 'order-service', msg: 'Inventory reserved successfully', order_id: req.body.orderId })); res.status(200).json(downstream.data); } catch (err) { console.error(JSON.stringify({ level: 'ERROR', correlation_id: cid, component: 'order-service', msg: 'Inventory reservation failed', order_id: req.body.orderId, error: err.message })); res.status(502).json({ error: 'Downstream failure', correlationId: cid }); }}); app.listen(process.env.PORT || 3000);Real project scenario
During a production incident, an order placed through a custom Kyma-hosted ordering service failed intermittently, but the ordering service's own logs showed no errors. The support team searched the Application Logging Kibana dashboard using the correlation ID from a customer-reported failed order and discovered the downstream inventory microservice was returning intermittent 502 errors that were being silently swallowed by a retry wrapper in the ordering service. Without the shared correlation ID linking both services' logs, the team would have spent hours manually correlating timestamps across two separate namespaces before identifying the actual failing component.
Common mistakes
⢠Assuming cf logs shows full historical logs rather than only a short live tail, leading to missed evidence after an incident window closes ⢠Not propagating correlation IDs on outbound calls, breaking the trace chain at service boundaries ⢠Relying on timestamp matching instead of correlation IDs when investigating multi-service transactions under concurrent load ⢠Ignoring log retention limits and assuming logs remain searchable indefinitely for audit purposes ⢠Failing to check whether a service was still bound to the Application Logging service after a credential or service key rotation ⢠Overlooking that container log gaps in Kyma can result from pod restarts if the log collection agent was briefly unavailable
Best practices
⢠Always propagate an existing correlation ID rather than generating a new one when one is present in the inbound request ⢠Include the correlation ID as a structured field in every log entry, not just in free-text messages ⢠Use Kibana or the Log and Trace Viewer for historical investigation rather than relying on live tail commands ⢠Export business-critical or compliance-relevant log data to an external long-term store rather than depending on default retention ⢠Build a documented, repeatable troubleshooting checklist distinguishing missing, delayed, and incomplete log scenarios ⢠Periodically verify that all services in an integration chain still forward and log the correlation header after deployments
Interview angle
Interviewers assess whether a candidate understands log correlation as an architectural discipline rather than a debugging afterthought. Strong answers explain how correlation IDs are generated, propagated across HTTP boundaries, and included in every log statement, and can describe a concrete troubleshooting method distinguishing missing, delayed, and incomplete logs rather than describing debugging as trial and error.