E2B
Stream E2B sandbox logs to Sazabi for code execution observability.
Stream your E2B sandbox logs directly to Sazabi for comprehensive observability of your AI code execution environments. Monitor sandbox sessions, code executions, and resource usage.
About this data source
E2B provides secure sandboxes for AI code execution. By configuring log forwarding from your E2B SDK usage, you can:
- Capture stdout and stderr from sandbox code executions
- Monitor sandbox session lifecycle
- Track resource usage and execution times
- Correlate E2B activity with other AI agent logs
- Use AI to analyze execution patterns and errors
Prerequisites
Before you begin, make sure you have:
- An E2B account with sandbox access
- An application using the E2B SDK
- A Sazabi public API key (project-scoped)
Get your API key
Create a public key
Click Create API key and select Public as the key type. Public keys are scoped to a single project.
Copy the key and store it securely. You will not be able to see it again.
Setup
Set environment variables
Add the following environment variables to your application:
SAZABI_INTAKE_URL=https://e2b.<region>.intake.sazabi.com
SAZABI_API_KEY=<your-api-key>Replace <region> with your Sazabi project region (e.g., us-east-1) and
<your-api-key> with your Sazabi public API key.
Configure log forwarding in your code
Use the onStdout and onStderr callbacks in sandbox.runCode() to
capture and forward logs:
import { Sandbox } from "@e2b/code-interpreter";
const sandbox = await Sandbox.create();
// Forward sandbox output to Sazabi
const forwardToSazabi = async (output: string, stream: "stdout" | "stderr") => {
await fetch(process.env.SAZABI_INTAKE_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.SAZABI_API_KEY}`,
},
body: JSON.stringify({
stream,
output,
timestamp: new Date().toISOString(),
}),
});
};
const result = await sandbox.runCode("print('Hello, World!')", {
onStdout: (output) => forwardToSazabi(output, "stdout"),
onStderr: (output) => forwardToSazabi(output, "stderr"),
});Deploy your application
Deploy your application with the new configuration. Sandbox output will begin flowing to Sazabi when code executes.
What gets captured
E2B log forwarding captures:
- stdout: Standard output from code execution
- stderr: Error output and exceptions
- Execution metadata: Sandbox ID, timing, and status
- Session events: Sandbox creation and termination
Verifying logs are flowing
Once configured, verify that logs are flowing to Sazabi:
-
Run code in a sandbox: Execute code that produces output.
-
Ask the assistant: Open a thread in Sazabi and ask "Show me recent E2B sandbox output" or "What errors occurred in E2B executions today?"
Troubleshooting
Logs not appearing in Sazabi
- Verify environment variables are set correctly
- Check that the onStdout/onStderr callbacks are configured
- Ensure the endpoint URL includes the correct region
- Run code that produces output to generate logs
401 Unauthorized errors
- Your API key may be invalid or expired
- Verify the Authorization header format
- Create a new public API key in Settings > API Keys
Missing execution data
Make sure you're forwarding both stdout and stderr. Some errors may only appear in stderr.