Request Logs
This guide provides a comprehensive overview of how to use the Request Logs feature in the Alchemy Dashboard to monitor and debug JSON-RPC API requests.
Why It Matters
The Request Logs feature in the Alchemy Dashboard is a powerful tool for developers building on different blockchains. It solves several critical problems:
- Debugging Made Easy: Request Logs provides a user-friendly interface to search, filter, and analyze historical API requests, saving hours of manual debugging compared to raw log files or custom scripts.
- Transparency and Control: Developers gain visibility into every JSON-RPC request sent through Alchemy’s infrastructure, including successes, failures, and errors, helping identify bottlenecks or misconfigured requests.
- Performance Optimization: By analyzing request durations, error rates, and method usage, developers can optimize dApp performance and ensure a seamless user experience.
Request Logs empowers developers to maintain reliable dApps, reduce downtime, and improve user satisfaction with actionable insights into API interactions.
How to Use It
Overview of the Request Logs Feature
The Request Logs feature, accessible via the Alchemy Dashboard’s Request Explorer, allows you to view and analyze all JSON-RPC requests made to Alchemy’s API endpoints for your application. Key functionalities include:
Search and Filter: Filter requests by parameters such as:
- App: Filter by a specific app.
- Network: Filter by a specific blockchain network.
- Method: Specific JSON-RPC methods (e.g.,
eth_blockNumber
,eth_getLogs
). - HTTP Response: Success (2xx) or error codes (4xx, 5xx).
- JSON-RPC Error code: Filter by specific error codes.
- All errors: See all requests that resulted in an error.
- Response time: Time taken for the request to complete.
- JSON-RPC ID: Filter by a specific request ID.
Detailed Request View: Inspect individual requests to see:
- Request payload and response.
- Error messages (if any).
- Node-specific details or network errors.
To access Request Logs:
- Log in to the Alchemy Dashboard.
- Navigate to the tools section on the sidebar.
- Click request logs to enter the request logs dashboard.
Code Samples
Below are code samples to help you interact with Alchemy’s API and troubleshoot issues using insights from Request Logs.
Sample 1: Fetching the Latest Nonce Before Sending a Transaction
If Request Logs show “nonce too low” errors for eth_sendRawTransaction, use this code to fetch the latest nonce:
Usage: Run this before sending a transaction to ensure the correct nonce. Check Request Logs to confirm eth_getTransactionCount requests succeed (HTTP 200).
Sample 2: Batching Requests to Avoid Rate Limits
If Request Logs show HTTP 429 (Too Many Requests) errors, batch requests using the Alchemy SDK:
Usage: Batching reduces the number of requests, lowering the chance of hitting rate limits. Monitor Request Logs for fewer eth_blockNumber and eth_getBalance entries.
Best Practices
Pro Tips
- Use Specific Filters: Combine filters (e.g., method + error code) to quickly isolate issues in Request Explorer.
- Monitor Regularly: Check Request Logs daily or use Alchemy’s Notify API for real-time alerts on errors.
- Leverage Timestamps: Filter by timestamp to focus on specific timeframes when debugging reported issues.
Limits
- Data Retention: Logs are available for up to 10 days. Export logs regularly for longer-term analysis.
- Rate Limits: HTTP 429 errors indicate rate limit breaches. Optimize with batching or upgrade your plan.
- Block Range for eth_getLogs: Limit eth_getLogs block ranges (e.g., 5,000 blocks) to avoid timeouts.
Common Issues and Solutions
- Issue: HTTP 429 (Too Many Requests) in logs.
- Solution: Use batch requests (see Sample 2) or reduce request frequency.
- Issue: “Nonce too low” errors in eth_sendRawTransaction.
- Solution: Fetch the latest nonce before each transaction (see Sample 1).
- Issue: Empty or missing logs.
- Solution: Verify API key, app, and network filters. Check for dashboard delays during high network congestion.
Additional Notes
- Security: Avoid exposing API keys in client-side code. Use HTTP header-based authentication.
- Documentation: See Alchemy’s Error Reference for JSON-RPC error codes.
- Support: Contact Alchemy Support via the dashboard or check the FAQ.
By leveraging Request Logs and these practices, you can monitor, debug, and optimize your dApp’s API interactions for a reliable user experience.