Skip to main content
Glama

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
NameRequiredDescriptionDefault
startTimeNoStart time (Unix timestamp ms)
endTimeNoEnd time (Unix timestamp ms)
limitNoMax entries to analyze
instanceIdNoOptional instance ID override

Implementation Reference

  • 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));
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BetterDB-inc/monitor'

If you have feedback or need assistance with the MCP directory API, please join our Discord server