Log Streaming | Medplum

Medplum Logs

Medplum server can stream the following to STDOUT

Warning

To capture AuditEvent resources for any RESTful interactions you must set the server configuration for logAuditEvents

For batch requests and GraphQL queries, each individual read/search operation executed by the query generates its own log line. While these operations are logged separately, they all share the same request ID / trace ID for easy correlation and tracing.

Forwarding Logs via AWS Lambda

To forward logs from CloudWatch to external platforms, AWS Lambda functions are utilized. This involves creating Lambda functions that are triggered by new log entries in CloudWatch and are configured to push these logs to the chosen external logging system.

Log Correlation

Medplum uses includes both request IDs and trace IDs to aid in log correlation, enhancing debugging and monitoring capabilities.

The request ID is automatically generated by the Medplum server for each unique HTTP request.

Clients can pass in their own trace id in their request headers. Medplum supports both the headers X-TRACE-ID or traceparent.

Example: Adding a trace id to a medplum GET request

await medplum.readResource('Patient', 'homer-simpson', {

headers: {

'X-TRACE-ID': 'MY-TRACE-ID',

},

});
curl https://api.medplum.com/fhir/R4/Patient/homer-simpson \

-H "Authorization: Bearer $TOKEN" \

-H "Content-Type: application/fhir+json" \

-H "X-TRACE-ID: "MY-TRACE-ID