get_slowlog_patterns
Analyzes slowlog patterns from Valkey/Redis instances to identify recurring performance issues by grouping commands by normalized pattern, showing frequency, average duration, and examples.
Instructions
Get analyzed slowlog patterns from persisted storage. Groups slow commands by normalized pattern, showing frequency, average duration, and example commands. Survives slowlog buffer rotation — data goes back as far as BetterDB has been running.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max entries to analyze | |
| instanceId | No | Optional instance ID override |
Implementation Reference
- Implementation of the get_slowlog_patterns tool, which calls metricsService to get slow log pattern analysis and returns formatted data.
const getSlowlogPatterns = tool( async ({ connectionId }: { connectionId?: string }) => { const analysis = await metricsService.getSlowLogPatternAnalysis(undefined, connectionId); return JSON.stringify({ total_entries: analysis.totalEntries, patterns: analysis.patterns.slice(0, 5).map((p) => ({ pattern: p.pattern, count: p.count, percentage: p.percentage.toFixed(1), avg_duration_ms: (p.avgDuration / 1000).toFixed(2), })), }); }, { name: 'get_slowlog_patterns', description: 'Analyze slow command patterns to identify common slow queries', schema: z.object({}).passthrough(), } );