get_logs_stats
Retrieve aggregated statistics of API request logs from PocketBase, with optional filtering by fields such as method or status.
Instructions
Get API request logs statistics with optional filtering.
Input 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 handler function for 'get_logs_stats'. It accepts a 'filter' parameter, calls PocketBase's logs.getStats() API, and returns the result as JSON text. Includes error handling for API failures.
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/types/tool-types.ts:87-89 (schema)TypeScript interface for the 'get_logs_stats' tool arguments. Defines an optional 'filter' string parameter.
export interface GetLogsStatsArgs { filter?: string; } - src/tools/log-tools.ts:35-45 (registration)Registers 'get_logs_stats' in the logToolInfo array with its name, description, and inputSchema (accepting an optional filter string).
{ 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/tools/index.ts:53-54 (registration)Routes the tool name 'get_logs_stats' to the handleLogToolCall function in log-tools.ts.
} else if (name === 'list_logs' || name === 'get_log' || name === 'get_logs_stats') { return handleLogToolCall(name, toolArgs, pb); - src/types/index.ts:14-16 (helper)Re-exports the GetLogsStatsArgs interface from tool-types.ts for use by other modules.
ListLogsArgs, GetLogArgs, GetLogsStatsArgs,