get_commandlog_patterns
Analyze COMMANDLOG patterns from Valkey 8+ storage to identify slow commands, large requests, and large replies for performance optimization.
Instructions
Get analyzed COMMANDLOG patterns from persisted storage (Valkey 8+ only). Like get_slowlog_patterns but includes large-request and large-reply patterns in addition to slow commands.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startTime | No | Start time (Unix timestamp ms) | |
| endTime | No | End time (Unix timestamp ms) | |
| limit | No | Max entries to analyze | |
| instanceId | No | Optional instance ID override |
Implementation Reference
- packages/mcp/src/index.ts:478-497 (handler)Registration and handler for the MCP tool 'get_commandlog_patterns', which fetches analysis from the API.
server.tool( 'get_commandlog_patterns', 'Get analyzed COMMANDLOG patterns from persisted storage (Valkey 8+ only). Like get_slowlog_patterns but includes large-request and large-reply patterns in addition to slow commands.', { startTime: z.number().optional().describe('Start time (Unix timestamp ms)'), endTime: z.number().optional().describe('End time (Unix timestamp ms)'), limit: z.number().optional().describe('Max entries to analyze'), instanceId: z.string().optional().describe('Optional instance ID override'), }, async ({ startTime, endTime, limit, instanceId }) => { const id = resolveInstanceId(instanceId); const qs = buildQuery({ startTime, endTime, limit }); const data = await apiFetch(`/mcp/instance/${id}/history/commandlog-patterns${qs}`); if (isLicenseError(data)) { return { content: [{ type: 'text' as const, text: licenseErrorResult(data) }] }; } return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, - API controller handler for the getCommandlogPatterns endpoint.
async getCommandlogPatterns( @Param('id', ValidateInstanceIdPipe) id: string, @Query('startTime') startTime?: string, @Query('endTime') endTime?: string, @Query('limit') limit?: string, ) { try { return await this.commandLogAnalyticsService.getStoredCommandLogPatternAnalysis({ startTime: msToSeconds(startTime), endTime: msToSeconds(endTime), limit: safeLimit(limit, 500), connectionId: id, }); - Service method responsible for retrieving and analyzing command log patterns.
async getStoredCommandLogPatternAnalysis(options?: CommandLogQueryOptions): Promise<SlowLogPatternAnalysis> { // Fetch stored entries with the given filters const entries = await this.storage.getCommandLogEntries({ ...options, limit: options?.limit || 500, // Higher limit for pattern analysis }); return analyzeSlowLogPatterns(entries.map(toSlowLogEntry)); }