get_logs_stats
Analyze API request logs by retrieving statistics, with optional filtering to focus on specific criteria like methods or endpoints, for effective monitoring and debugging.
Instructions
Get API request logs statistics with optional filtering.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | PocketBase filter string (e.g., "method='GET'"). |
Implementation Reference
- src/tools/log-tools.ts:97-119 (handler)The main execution logic for the 'get_logs_stats' tool. It extracts the optional filter from args, calls pb.logs.getStats(), formats the result as JSON, and handles errors appropriately.async function getLogsStats(args: GetLogsStatsArgs, pb: PocketBase): Promise<ToolResult> { const { filter } = args; try { // Make the API request to get logs statistics const result = await pb.logs.getStats({ filter }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { // If there's an error, return a more descriptive error if (error instanceof Error) { return { content: [{ type: 'text', text: `Error fetching log stats: ${error.message}` }], isError: true }; } throw error; } }
- src/tools/log-tools.ts:38-44 (schema)JSON schema definition for input validation of the 'get_logs_stats' tool, specifying an optional 'filter' string property.inputSchema: { type: 'object', properties: { filter: { type: 'string', description: 'PocketBase filter string (e.g., "method=\'GET\'").' }, }, required: [], },
- src/tools/log-tools.ts:35-46 (registration)ToolInfo registration for 'get_logs_stats' including name, description, and inputSchema, part of logToolInfo array returned by listLogTools().{ name: 'get_logs_stats', description: 'Get API request logs statistics with optional filtering.', inputSchema: { type: 'object', properties: { filter: { type: 'string', description: 'PocketBase filter string (e.g., "method=\'GET\'").' }, }, required: [], }, }, ];
- src/types/tool-types.ts:87-89 (schema)TypeScript interface defining the input arguments for the 'get_logs_stats' tool.export interface GetLogsStatsArgs { filter?: string; }
- src/tools/index.ts:53-54 (registration)Routing logic in central handleToolCall that directs 'get_logs_stats' calls to the log-tools handler.} else if (name === 'list_logs' || name === 'get_log' || name === 'get_logs_stats') { return handleLogToolCall(name, toolArgs, pb);