diff --git a/fern/api-reference/dashboard-tools/request-logs.mdx b/fern/api-reference/dashboard-tools/request-logs.mdx new file mode 100644 index 00000000..61cc0ce0 --- /dev/null +++ b/fern/api-reference/dashboard-tools/request-logs.mdx @@ -0,0 +1,131 @@ +--- +title: "Request Logs" +--- + +Alchemy RPC API Request Logs Documentation +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. It covers the value of request logs, step-by-step instructions for using the feature, code samples for interacting with logs, and best practices to optimize your experience. + +### Why It Matters +The Request Logs feature in the Alchemy Dashboard is a powerful tool for developers building decentralized applications (dApps) on Ethereum and other supported 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. +* **Proactive Issue Resolution**: With historical data (up to 10 days), developers can investigate issues retroactively, spot patterns, and prevent recurring problems. + +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: +* **Method**: Specific JSON-RPC methods (e.g., eth_blockNumber, eth_getLogs). +* **HTTP Status**: Success (2xx) or error codes (4xx, 5xx). +* **Timestamp**: Requests from 1 second to 10 days ago. +* **Duration**: Time taken for the request to complete. +* **App or Network**: Filter by specific apps or blockchain networks (e.g., Ethereum Mainnet, Polygon). + + +**Detailed Request View**: Inspect individual requests to see: +* Request payload and response. +* Error messages (if any). +* Node-specific details or network errors. + + +**Export and Analysis**: Export logs as CSV for further analysis or sharing with your team. + +To access Request Logs: + +1. Log in to the Alchemy Dashboard. +2. Navigate to the Apps tab and select your app. +3. Click Request Explorer under the app details to view the logs interface. + +**Screenshot Example:**Caption: The Request Explorer shows a table of requests with filters for method, status, and timestamp. +#### 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: +```javascript +const { ethers } = require("ethers"); +const provider = new ethers.providers.JsonRpcProvider("https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY"); + +async function getLatestNonce(walletAddress) { + try { + const nonce = await provider.getTransactionCount(walletAddress, "latest"); + console.log(`Latest nonce: ${nonce}`); + return nonce; + } catch (error) { + console.error("Error fetching nonce:", error); + } +} + +// Example usage +getLatestNonce("0xYourWalletAddress"); +``` +**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: +```javascript +const { Network, Alchemy } = require("alchemy-sdk"); + +const settings = { + apiKey: "YOUR_API_KEY", + network: Network.ETH_MAINNET, +}; +const alchemy = new Alchemy(settings); + +async function batchRequests() { + try { + const batch = [ + { method: "eth_blockNumber", params: [] }, + { method: "eth_getBalance", params: ["0xYourWalletAddress", "latest"] }, + ]; + const responses = await alchemy.core.send("batch", batch); + console.log("Batch responses:", responses); + } catch (error) { + console.error("Batch request failed:", error); + } +} + +batchRequests(); +``` +**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. +**Screenshot Example:**Caption: Detailed view of a request showing payload and response, useful for verifying code sample results. + +### 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. +* **Combine with Other Tools**: Pair Request Logs with Alchemy's Mempool Watcher to diagnose transaction delays or gas 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. \ No newline at end of file diff --git a/fern/docs.yml b/fern/docs.yml index 8890ca54..b1206d79 100644 --- a/fern/docs.yml +++ b/fern/docs.yml @@ -1957,6 +1957,11 @@ navigation: api-reference/alchemy-sdk/sdk-v2-methods/sdk-getnftsforcontract.mdx slug: sdk-v2-methods slug: alchemy-sdk + - section: Dashboard Tools + contents: + - page: Request Logs + path: fern/api-reference/dashboard-tools/request-logs.mdx + slug: request-logs - section: Blast RPC API contents: - page: Introduction to Blast @@ -4784,10 +4789,6 @@ redirects: destination: /docs/alchemy-notify - source: /introduction/core-products/alchemy-supernode destination: /docs/alchemy-supernode - - source: /guides/eip-1559 - destination: /docs/eip-1559-resource-and-tutorial-hub - - source: /guides/eip-1559/gas-estimator - destination: /docs/how-to-build-a-gas-fee-estimator-using-eip-1559 - source: /guides/eip-1559/maxpriorityfeepergas-vs-maxfeepergas destination: /docs/maxpriorityfeepergas-vs-maxfeepergas - source: /guides/eip-1559/retry-eip-1559-tx @@ -5284,10 +5285,6 @@ redirects: destination: /docs/reference/getinflationreward - source: /apis/solana-api/getlargestaccounts destination: /docs/reference/getlargestaccounts - - source: /apis/solana-api/getmaxretransmitslot - destination: /docs/reference/getmaxretransmitslot - - source: /apis/solana-api/getmaxshredinsertslot - destination: /docs/reference/getmaxshredinsertslot - source: /apis/solana-api/getminimumbalanceforrentexemption destination: /docs/reference/getminimumbalanceforrentexemption - source: /apis/solana-api/getmultipleaccounts