Monitoring Medplum Bots in production: what it involves and when you need it
A self-hosted Medplum deployment with Bots triggered by Subscriptions or called as custom operations can fail quietly. A Bot that stops running, throws on a malformed resource or writes to the wrong place may leave clinical data out of step with the systems that depend on it, and nobody sees an error on screen. Monitoring is the work of making those executions visible before a clinician, a claims team or a downstream system notices the gap. It needs to be in place before go-live, not added after the first incident, because the first failures usually happen during the period when volume and edge cases are least understood.
The monitoring picture has four layers. AuditEvents record what happened: Bot executions and the Subscription triggers that started them, which lets you reconstruct a sequence after the fact. Bot logs capture what the code itself reported during a run, which is where you learn why a Bot failed. Alerts tell an on-call person that something needs attention, and they only work if you have decided which failure signals matter and who receives them. Replay lets you re-send an event or re-run a Bot against the original input once the cause is fixed. Each layer depends on the one before it, so a team that has alerts but no reliable execution record will struggle to decide what to replay.
The exact resource types, log retention, alerting hooks and replay mechanics depend on the Medplum version you run, and they have changed between releases. Before you design your monitoring, confirm the current behavior for your version in the Medplum self-hosting documentation and in the release notes for your target version. Also confirm which of these signals reach your own observability stack, since that determines how much custom wiring your team will own.
How a resource change becomes a Bot run and an audit trail
The flow starts when a client writes a FHIR resource to the Medplum server. A Subscription whose criteria match that change dispatches the work to a Bot on the execution backend you chose. The run writes its own logs and an AuditEvent record, and a failed run branches to an alert or a replay of the original event. When you troubleshoot, check the AuditEvent first, then the Bot logs, and then confirm the input resource that triggered the run.
Path from a resource change to a Bot run, its audit record and the failure branch.
Which monitoring signal fits which question
This table compares AuditEvents, Bot log output, external log and metrics pipelines, failure alerts and manual replay by the question each one answers. Read it by starting from the question you are asking during an incident, then check the limits column before relying on a single signal. The main takeaway is that no one signal shows the whole picture, and the retention and export options in your release decide how much history you can investigate.
| Question | Signal | When it fits | What it cannot show |
|---|---|---|---|
| Did the Bot run? | AuditEvents for Bot executions | Confirming an execution was recorded for a given Bot and time window, including the outcome Medplum recorded. | The business meaning of the result, or what the Bot did to external systems after it returned. |
| Why did it fail? | Bot log output | Reading the messages and stack traces your Bot wrote during the failing run, tied to the input it received. | Logs from runs you did not instrument, and anything your code never printed before the error. |
| Who or what triggered it? | AuditEvents for Subscription triggers | Tracing a run back to the resource change, Subscription or caller that started it. | Triggers that never reached the Subscription, such as a change made outside the audited path. Confirm coverage for your release. |
| Is it happening now? | Failure alerts and metrics pipeline | Detecting a spike in errors or a stalled queue soon after it starts, based on alert rules you define. | Root cause or individual records. Alerts only tell you a threshold was crossed. |
| Is it still happening across systems? | External log and metrics pipeline | Correlating Bot output with infrastructure logs, deployment events and downstream system logs in one place. | Medplum-internal decisions unless they were logged or exported. Confirm which Medplum logs your deployment ships. |
| Can I reproduce the failure? | Manual replay of the original input | Re-running a failing input in a non-production project to test a fix, using the same payload the Bot received. | Side effects on the original system. Replay can duplicate writes, so confirm idempotency first. |
| How far back can I investigate? | AuditEvents and exported logs | Historical review for incidents, audits or access questions, provided retention and export are configured. | Anything beyond your configured retention or export window. Confirm the retention and export options in your release. |
Setting up Bot monitoring on a self-hosted deployment
This sequence confirms what your deployment records for Bot runs, sends that output to a store your team can search, turns failures into alerts, and proves the path works with a deliberate failure before you rely on it. The result is a documented way to find and replay any failed Bot execution.
Confirm which Bot logs and AuditEvents exist
The platform engineer who runs the self-hosted Medplum server runs a test Bot in a non-production project and reviews what the deployment records for it. Check the Bot's execution log in the Medplum app, then search for the AuditEvent created for the execution and, if the Bot was triggered by a Subscription, the AuditEvent for the trigger. Write down the fields you see for the Bot identity, the input, the outcome and the timestamp, and note any field that is missing. Ask your Medplum contact or check the self-hosting and Bot documentation for the version you run, since record types and fields can change between releases. This step is done when you have a written list of the records each Bot run produces and the fields your team can rely on.
Route server and Bot output to a central log store
The platform team configures the container or host logging for the Medplum server and any execution backend so that server output and Bot console output go to one central log store that your security and operations teams already use. Set up a parser or index for the fields you need to search on, such as Bot ID, project ID, Subscription ID and request or correlation ID. Confirm that log entries from a test run arrive, that they carry the same identifiers as the AuditEvent from the previous step, and that they are retained for the period your policy requires. Keep log content free of patient data and secrets, and confirm this with a sample of real log lines before you enable wider access. This step is done when a single test execution can be found in the central store using its Bot ID or correlation ID.
Define failure alert conditions
The operations lead and the integration owner agree which failures should page someone and which should only be recorded. Typical conditions include a Bot execution that ends in an error, a Subscription trigger that produces no Bot run within the window you expect, and a burst of errors from one Bot. Express each condition as a query against the central store or against the AuditEvent data, and assign an owner and a receiving channel for each. Record the thresholds your team chooses and the reason for each, because these values are a local decision and not a vendor default. This step is done when each alert condition has a written query, a named owner and a documented threshold.
Test a deliberate failing Bot
In a non-production project, the integration owner deploys a small illustrative Bot that throws an error on a known input, and attaches it to a test Subscription or runs it by hand. Trigger it with the failing input and confirm three things: the execution is recorded with an error outcome, the central log store shows the stack trace and identifiers, and the alert condition from the previous step fires and reaches the right channel. Then trigger it with a valid input and confirm the alert clears or does not fire. Keep the test Bot and its results so that the procedure can be repeated after upgrades. This step is done when the failure is visible in all three places and the alert reaches the named owner.
Document and rehearse the replay procedure
The integration owner writes the procedure for replaying a failed event once the cause is fixed. It should identify the failing AuditEvent or Subscription trigger, retrieve the original input from the record, confirm that the input contains no data that should not be re-sent, and re-run the Bot against the corrected code in the same project. It should also state who may approve a replay in production and how the replay is logged. Confirm with your Medplum contact or the Subscription documentation how a resend or re-run behaves for your version, so the steps match what the platform actually does. Rehearse the procedure once with the test Bot and keep the outcome in the runbook. This step is done when a second team member can follow the written steps to replay the test failure and the replay appears in the audit trail.
Tracing a failing integration back to its input
Start from the alert and work backward: find the AuditEvent for the failed Bot execution, read which resource triggered it, and pin down the exact version of that resource the Bot received. The AuditEvent records the outcome and the references involved, so it tells you which Bot ran and against which input. Then fetch the triggering resource by its version (the meta.versionId in the Bot's input) rather than its current state, because a later update may have changed the data you need to reproduce the failure. Confirm in your own environment which fields your Medplum version records on the AuditEvent for Subscription-triggered runs, since this determines how much you can recover without digging into logs.
Reproduce the failure in a test project, never against production data. Copy the historical resource version into the test project, deploy the same Bot version that failed (keep the Bot source and version tied to your release process), and invoke it with the same input. If the failure depends on other resources, such as a Patient or an Organization the Bot looked up, record those versions too. If you cannot reproduce it, the difference is usually the Bot version, the secret values or the access policy of the identity the Bot ran as, so check those before changing code.
Once you know the cause, decide whether to resend or correct. Resending re-runs the Bot against the original input, which is safe only if the Bot is idempotent: it should detect records it already created, for example through a deterministic identifier or a conditional create, and skip or update them instead of writing duplicates. Correcting the source data is the right choice when the input itself was wrong, and the corrected version should flow through the same Subscription path so the audit trail stays complete. Make the replay decision with the owner of the downstream system, and confirm how your Bot handles retries before you replay anything in bulk.
Protecting PHI in logs, alerts and replayed events
Bot logs, alert messages and replayed events are copies of your data, and they often end up in places with weaker controls than the Medplum project itself. The cards below cover the controls that keep patient information out of those copies, limit who can read what remains, and set retention that matches your own compliance obligations.
Keep identifiers out of Bot logs
Anything a Bot writes with console output can carry names, dates of birth, MRNs or free-text notes from the resource it processed. Log resource IDs and event types instead of payloads, and redact fields before logging any error object that contains a resource body. Review a sample of logs from each Bot during testing, because a single careless line in a commonly triggered Bot can copy PHI thousands of times.
Bots documentationKeep alert messages free of patient data
Failure alerts often go to chat channels, pager tools or email, where many people see them and where retention is set by a different team. Build alert text from the Bot name, the execution ID and the AuditEvent reference, and let engineers open the project to see the details. Ask the alert platform vendor whether it will sign a BAA before any message can contain PHI.
Confirm BAA coverage for external log platforms
Any external logging, tracing or alerting service that receives Bot output becomes a business associate question under HIPAA if it stores PHI. Confirm in writing whether the vendor signs a business associate agreement, which features fall under it, and whether the plan you buy includes it. Do not assume that a vendor's general security certifications cover PHI handling.
Restrict who can read AuditEvents
AuditEvents record who ran a Bot, what it touched and when, so they are sensitive even when they contain no clinical content. Use Medplum access policies to limit AuditEvent reads to the operations and security roles that investigate incidents, and keep Bot-execution access separate from general clinical roles. Test the policy with a non-admin account before go-live.
Control access to replayed events
Replaying a Subscription trigger re-sends the original resource to a Bot, which means replay is a data access path. Restrict replay rights to named responders, record who replayed what, and confirm the Bot runs under the identity you intend, since a replay can execute with the same permissions as the original event. Consider a replay approval step for Bots that handle high-volume or high-sensitivity resources.
Set retention for logs and AuditEvents
Logs, alerts, replay queues and AuditEvents may each need different retention, and your HIPAA, state or contractual obligations set the period, not the platform default. Write down the retention for each store, the deletion method and who approves exceptions. Confirm with your compliance lead and legal counsel whether any audit or litigation hold changes the schedule.
Questions teams ask before monitoring Medplum Bots
What does it cost to build monitoring for Medplum Bots?
Most of the cost is engineering time, with log volume and storage as the recurring items. Build effort covers defining which Bot executions and Subscription triggers must be visible, wiring Bot logs and AuditEvents into your log platform, writing alert rules, and testing replay. Recurring costs depend on how many executions your Bots run, how long you keep logs and AuditEvents, and how many alerting or log tools you license or host. Ask any partner to quote these as separate lines: one-time setup, log and storage capacity you will pay for each month, alerting tooling, and the hours needed for handover and runbooks. A quote should state which of these it includes and which remain with your team.
How long does it take to set up Bot monitoring?
The timeline depends on three things: how many Bots and Subscriptions need coverage, which log platform receives the data, and how much test coverage the Bots already have. A small set of Bots writing to a platform your team already runs is a much shorter job than dozens of Bots feeding a new stack with no tests. Before agreeing a schedule, inventory your Bots and their triggers, confirm where logs must land, and decide who signs off on alert thresholds. Any written scope should tie the timeline to those inputs rather than to a generic duration.
What must our team provide before monitoring work starts?
Three inputs unblock the work quickly:
- Access to the self-hosted Medplum deployment, including the project or projects where Bots run, with permissions to read AuditEvents and Bot logs.
- A Bot and Subscription inventory listing each Bot, its trigger, its owner and the systems it calls.
- Named alert recipients, with the channel (paging, chat or ticket queue) and the hours each group covers.
You should also confirm the log platform and retention rules your security and compliance teams require, since those decisions shape what gets stored.
Can our own team build Bot monitoring without a partner?
Yes. Medplum exposes Bot execution and Subscription activity through AuditEvents, Bots can write their own logs, and the monitoring itself uses standard log, metrics and alerting tools that many teams already operate. An internal team needs people who understand the Bot code, the FHIR resources involved and the log platform. The main risk is not the first build but ongoing ownership: alert rules must change when Bots change, and someone must own replay procedures during an incident. Teams that want to hand over this work can ask for a fixed-scope build with a written runbook, or a retainer for continued tuning.
What changes in our monitoring after a Medplum upgrade?
Upgrades can change the fields, event types and behavior your monitoring depends on, so check them every time. Medplum ships patch versions weekly and minor versions two to three times a year, and self-hosted servers must move through each minor version in sequence. After each step, confirm that AuditEvents for Bot executions and Subscription triggers still arrive with the fields your dashboards and alerts read, that Bot logs still reach your platform, and that replay procedures still work against a test project. Plan this check into the upgrade window, not after an incident.
Does monitoring Bots create compliance or security obligations?
It can. AuditEvents and Bot logs may contain protected health information, identifiers or request payloads, so the log platform becomes part of your data flow. Confirm with your compliance team how long logs are kept, who can read them, and whether payloads are redacted before storage. Medplum's compliance documentation states that compliance is a shared responsibility between Medplum and its customers, so the logging configuration in your own infrastructure is your responsibility to review. DeployOpen prepares systems and evidence for compliance assessments, but independent auditors issue any audit reports or certifications.
How do we trace a failing Bot back to its input?
Start from the alert, find the matching AuditEvent for the failed execution or Subscription trigger, and follow the referenced resource to see the input that caused it. Then check the Bot's own log output for the same time window and compare it with the Bot version that ran. Keep test fixtures that mirror real input shapes so you can replay the same event against a non-production project. Confirm in your environment which identifiers link each AuditEvent to the triggering resource, since the exact fields depend on your Medplum version and configuration.
How DeployOpen scopes and delivers Bot monitoring
DeployOpen scopes Bot monitoring as a fixed-scope engagement agreed in writing before work starts, so the deliverables and boundaries are clear to both sides. The first step is a review of the Bot inventory: which Bots run, which Subscriptions and cron schedules trigger them, which external systems they call, and which ones touch patient data or write to other systems. From that inventory the team defines the signals that matter for each Bot, such as execution outcomes recorded as AuditEvents, errors written by Bot logging, delayed or missing Subscription deliveries, and runs that exceed expected duration. Each signal gets a named owner, an alert threshold and a decision about who acts on it and how fast. The scope also records which Bots are out of reach for the engagement, such as Bots owned by a third-party vendor, so gaps are visible rather than assumed away.
Implementation happens in the client's own infrastructure, using the client's logging stack, alert channels and paging tools. DeployOpen configures alert routing, log retention and access to AuditEvent queries, then tests the failure and replay paths on a non-production project before anything is trusted in production. Tests cover a Bot that throws, a downstream system that times out, a Subscription that fires twice, and a replay of a stored input that must produce the same outcome without writing duplicate records. The client should confirm during scoping how replay is permitted in its environment, who may trigger it, and whether replayed runs are distinguishable from original runs in the audit trail. Replay tests are where unclear ownership usually surfaces, so they are worth scheduling early.
The handover includes runbooks for each alert: what it means, which record to inspect first, how to trace a failing integration back to its input, and when to escalate. Teams that want continued help can add a retainer for ongoing support, which covers alert tuning, new Bots, and periodic replay testing as the inventory changes. Ask any provider for the written scope, the list of deliverables and the acceptance criteria for the replay tests, and confirm which parts of the work recur and which are one-time before signing.

