get_cluster_slowlog
Retrieve aggregated slowlog data across all cluster nodes to identify slow commands in cluster mode, as per-node logs are incomplete. Returns error if not in cluster mode.
Instructions
Get the aggregated slowlog across ALL nodes in the cluster. This is the primary tool for finding slow commands in cluster mode — per-node slowlogs are incomplete. Returns an error message if not in cluster mode.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max entries to return (default 100) | |
| instanceId | No | Optional instance ID override |
Implementation Reference
- The actual implementation of the logic that aggregates slowlogs from all cluster nodes.
async getClusterSlowlog(limit: number = 100, connectionId?: string): Promise<ClusterSlowlogEntry[]> { const nodes = await this.discoveryService.discoverNodes(connectionId); const slowlogPromises = nodes.map((node) => this.getNodeSlowlog(node, limit, connectionId)); const results = await Promise.allSettled(slowlogPromises); const allEntries: ClusterSlowlogEntry[] = []; for (const result of results) { if (result.status === 'fulfilled') { allEntries.push(...result.value); } else { this.logger.warn(`Failed to fetch slowlog from a node: ${result.reason}`); } } allEntries.sort((a, b) => b.timestamp - a.timestamp); return allEntries.slice(0, limit); } - packages/mcp/src/index.ts:596-611 (registration)The MCP tool registration for 'get_cluster_slowlog', which calls the API endpoint.
server.tool( 'get_cluster_slowlog', 'Get the aggregated slowlog across ALL nodes in the cluster. This is the primary tool for finding slow commands in cluster mode — per-node slowlogs are incomplete. Returns an error message if not in cluster mode.', { limit: z.number().optional().describe('Max entries to return (default 100)'), instanceId: z.string().optional().describe('Optional instance ID override'), }, async ({ limit, instanceId }) => { const id = resolveInstanceId(instanceId); const qs = buildQuery({ limit }); const data = await apiFetch(`/mcp/instance/${id}/cluster/slowlog${qs}`); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - The API controller endpoint that handles the request for the cluster slowlog and calls the service.
async getClusterSlowlog( @Param('id', ValidateInstanceIdPipe) id: string, @Query('limit') limit?: string, ) { try { const parsedLimit = safeLimit(limit, 100); return await this.clusterMetricsService.getClusterSlowlog(parsedLimit, id); } catch (error) { const msg = error instanceof Error ? error.message : ''; if (msg.includes('CLUSTERDOWN') || msg.includes('cluster mode')) { return { error: 'not_cluster', message: 'This instance is not running in cluster mode.' }; } this.logger.error(`Failed to get cluster slowlog for ${id}`, error instanceof Error ? error.stack : error); throw new HttpException('Failed to get cluster slowlog', HttpStatus.INTERNAL_SERVER_ERROR);