get_apprun_logs
Retrieve application logs from Sakura Cloud AppRun to monitor performance, troubleshoot issues, and analyze runtime behavior with configurable parameters for offset and limit.
Instructions
Get logs from an AppRun application
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | The ID of the AppRun application to get logs from | |
| offset | No | Offset to start fetching logs from (default: 0) | |
| limit | No | Maximum number of log entries to fetch (default: 100) | |
| zone | No | The zone to use (e.g., "tk1v", "is1a", "tk1a"). Defaults to "tk1v" if not specified. |
Implementation Reference
- src/server.ts:2438-2466 (handler)Handler implementation for the 'get_apprun_logs' tool. Validates credentials, extracts parameters (appId required, offset/limit optional), constructs API path, calls fetchFromAppRunAPI to retrieve logs, and returns JSON-formatted logs.} else if (request.params.name === 'get_apprun_logs') { try { validateCredentials(); const appId = request.params.arguments?.appId as string; if (!appId) { throw new Error('AppRun application ID is required'); } const offset = request.params.arguments?.offset as number || 0; const limit = request.params.arguments?.limit as number || 100; const zone = request.params.arguments?.zone as string || DEFAULT_ZONE; const logsQuery = `/applications/${appId}/logs?offset=${offset}&limit=${limit}`; const logs = await fetchFromAppRunAPI(logsQuery); return { content: [ { type: 'text', text: JSON.stringify(logs, null, 2) } ] }; } catch (error) { console.error('Error calling tool:', error); throw error; } }
- src/server.ts:1397-1421 (registration)Registration of the 'get_apprun_logs' tool in ListToolsRequestSchema, including name, description, and input schema definition.name: 'get_apprun_logs', description: 'Get logs from an AppRun application', inputSchema: { type: 'object', properties: { appId: { type: 'string', description: 'The ID of the AppRun application to get logs from' }, offset: { type: 'number', description: 'Offset to start fetching logs from (default: 0)' }, limit: { type: 'number', description: 'Maximum number of log entries to fetch (default: 100)' }, zone: { type: 'string', description: 'The zone to use (e.g., "tk1v", "is1a", "tk1a"). Defaults to "tk1v" if not specified.' } }, required: ['appId'] } }
- src/server.ts:1399-1420 (schema)Input schema definition for the 'get_apprun_logs' tool, specifying parameters and requirements.inputSchema: { type: 'object', properties: { appId: { type: 'string', description: 'The ID of the AppRun application to get logs from' }, offset: { type: 'number', description: 'Offset to start fetching logs from (default: 0)' }, limit: { type: 'number', description: 'Maximum number of log entries to fetch (default: 100)' }, zone: { type: 'string', description: 'The zone to use (e.g., "tk1v", "is1a", "tk1a"). Defaults to "tk1v" if not specified.' } }, required: ['appId'] }
- src/server.ts:75-122 (helper)Helper function fetchFromAppRunAPI used by the get_apprun_logs handler to make authenticated HTTPS requests to the Sakura Cloud AppRun API.async function fetchFromAppRunAPI(path: string, method: string = 'GET', bodyData?: any): Promise<any> { return new Promise((resolve, reject) => { validateCredentials(); const options = { hostname: 'secure.sakura.ad.jp', port: 443, path: `/cloud/api/apprun/1.0/apprun/api${path}`, method: method, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': `Basic ${Buffer.from(`${SACLOUD_API_TOKEN}:${SACLOUD_API_SECRET}`).toString('base64')}` } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { try { if (data) { const parsedData = JSON.parse(data); resolve(parsedData); } else { resolve({}); } } catch (err) { reject(new Error(`Failed to parse response: ${err}`)); } }); }); req.on('error', (error) => { reject(error); }); if (bodyData && (method === 'POST' || method === 'PUT')) { req.write(JSON.stringify(bodyData)); } req.end(); }); }