Skip to main content
Glama

cribl_getSystemMetrics

Retrieve system metrics from Cribl deployment with optional filters for time range, metric names, and worker processes to narrow results and maintain performance.

Instructions

Retrieves system metrics from the Cribl deployment. IMPORTANT: To avoid excessively large responses, please use the optional parameters (filterExpr, metricNameFilter, earliest, latest, numBuckets, wp) to narrow down your query whenever possible. If no parameters are provided, the server will default to fetching only the most recent data bucket (numBuckets=1) to prevent performance issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterExprNoOptional: A JS expression to filter metrics (e.g., "model.pipeline === 'test'" or "host == 'myhost'").
metricNameFilterNoOptional: Regex or array of metric names (e.g.,limit to "pipe.*" , "total.in_bytes", or "os.cpu.perc,os.mem.*").
earliestNoOptional: Start time for the query (e.g., '-15m', '2023-10-26T10:00:00Z').
latestNoOptional: End time for the query (e.g., 'now', '2023-10-26T10:15:00Z').
numBucketsNoOptional: The number of time buckets for aggregation.
wpNoOptional: Worker process filter.

Implementation Reference

  • src/server.ts:342-365 (registration)
    Registers the 'cribl_getSystemMetrics' MCP tool with the server, including description, schema, and handler callback.
    server.tool(
        'cribl_getSystemMetrics',
        'Retrieves system metrics from the Cribl deployment. \nIMPORTANT: To avoid excessively large responses, please use the optional parameters (filterExpr, metricNameFilter, earliest, latest, numBuckets, wp) to narrow down your query whenever possible. \nIf no parameters are provided, the server will default to fetching only the most recent data bucket (numBuckets=1) to prevent performance issues.',
        GetSystemMetricsArgsShape,
        async (args: ValidatedArgs<typeof GetSystemMetricsArgsShape>) => {
            console.error(`[Tool Call] cribl_getSystemMetrics with args:`, args)
    
            // Pass the validated args to the API client function
            const result = await getSystemMetrics(args)
    
            if (!result.success || typeof result.data !== 'string') {
                console.error(`[Tool Error] cribl_getSystemMetrics for args ${JSON.stringify(args)}:`, result.error || 'Invalid data received')
                return {
                    isError: true,
                    content: [{ type: 'text', text: `Error fetching system metrics: ${result.error || 'Unknown error'}` }],
                }
            }
    
            console.error(`[Tool Success] cribl_getSystemMetrics: Fetched ${result.data.length} characters of metrics for args:`, args)
            return {
                content: [{ type: 'text', text: result.data }],
            }
        }
    )
  • Defines the Zod schema for input validation of the 'cribl_getSystemMetrics' tool arguments.
    const GetSystemMetricsArgsShape = {
        filterExpr: z.string().optional().nullable().describe('Optional: A JS expression to filter metrics (e.g., "model.pipeline === \'test\'" or "host == \'myhost\'").'),
        metricNameFilter: z.string().optional().nullable().describe('Optional: Regex or array of metric names (e.g.,limit to "pipe.*" , "total.in_bytes", or "os.cpu.perc,os.mem.*").'),
        earliest: z.string().optional().nullable().describe('Optional: Start time for the query (e.g., \'-15m\', \'2023-10-26T10:00:00Z\').'),
        latest: z.string().optional().nullable().describe('Optional: End time for the query (e.g., \'now\', \'2023-10-26T10:15:00Z\').'),
        numBuckets: z.number().int().optional().nullable().describe('Optional: The number of time buckets for aggregation.'),
        wp: z.string().optional().nullable().describe('Optional: Worker process filter.'),
    }
  • Handler function that validates args, calls getSystemMetrics API, and returns the result or error.
        async (args: ValidatedArgs<typeof GetSystemMetricsArgsShape>) => {
            console.error(`[Tool Call] cribl_getSystemMetrics with args:`, args)
    
            // Pass the validated args to the API client function
            const result = await getSystemMetrics(args)
    
            if (!result.success || typeof result.data !== 'string') {
                console.error(`[Tool Error] cribl_getSystemMetrics for args ${JSON.stringify(args)}:`, result.error || 'Invalid data received')
                return {
                    isError: true,
                    content: [{ type: 'text', text: `Error fetching system metrics: ${result.error || 'Unknown error'}` }],
                }
            }
    
            console.error(`[Tool Success] cribl_getSystemMetrics: Fetched ${result.data.length} characters of metrics for args:`, args)
            return {
                content: [{ type: 'text', text: result.data }],
            }
        }
    )
  • Actual API client implementation that calls GET /api/v1/system/metrics with optional query parameters, defaulting to numBuckets=1 when no params provided.
    export async function getSystemMetrics(
        params?: {
            filterExpr?: string | null;
            metricNameFilter?: string | null;
            earliest?: string | null;
            latest?: string | null;
            numBuckets?: number | null;
            wp?: string | null;
        }
    ): Promise<ClientResult<string>> {
        const context = `getSystemMetrics`;
        const url = `/api/v1/system/metrics`;
        console.error(`[stderr] Attempting API call: GET ${url} with params: ${JSON.stringify(params)}`);
    
        // Prepare query parameters
        const queryParams: Record<string, any> = {};
        if (params?.filterExpr != null) queryParams.filterExpr = params.filterExpr;
        if (params?.metricNameFilter != null) queryParams.metricNameFilter = params.metricNameFilter;
        if (params?.earliest != null) queryParams.earliest = params.earliest;
        if (params?.latest != null) queryParams.latest = params.latest;
        if (params?.wp != null) queryParams.wp = params.wp;
    
        // Default to 1 bucket if no parameters are provided to limit response size
        const providedParamKeys = Object.keys(params || {}).filter(k => params?.[k as keyof typeof params] !== undefined && params?.[k as keyof typeof params] !== null);
        if (providedParamKeys.length === 0) {
            queryParams.numBuckets = 1;
            console.error(`[stderr] No specific metrics parameters provided, defaulting to numBuckets=1`);
        } else if (params?.numBuckets != null) {
            queryParams.numBuckets = params.numBuckets;
        }
    
        try {
            const response = await apiClient.get<string>(url, {
                params: queryParams,
                headers: {
                    ...apiClient.defaults.headers.common,
                    'Accept': 'text/plain' // Keep requesting plain text for now
                },
                responseType: 'text',
            });
            const responseDataString = typeof response.data === 'string' ? response.data : String(response.data);
            return { success: true, data: responseDataString };
        } catch (error) {
            const errorMessage = handleApiError(error, context);
            if (axios.isAxiosError(error) && error.response?.headers?.['content-type']?.includes('text/html')) {
                try {
                    const htmlError = error.response.data as string;
                    const preMatch = htmlError.match(/<pre>([\s\S]*?)<\/pre>/i);
                    if (preMatch && preMatch[1]) {
                        console.error(`[stderr] Extracted HTML error detail for ${context}: ${preMatch[1]}`);
                    }
                } catch (htmlParseError) {
                    console.error(`[stderr] Failed to parse potential HTML error for ${context}: ${htmlParseError}`);
                }
            }
            return { success: false, error: errorMessage };
        }
    }
  • Import statement that brings the getSystemMetrics API client function into server.ts.
    import {
        getPipelines,
        getSources,
        setPipelineConfig,
        getPipelineConfig,
        listWorkerGroups,
        restartWorkerGroup,
        getSystemMetrics,
        versionControl,
        commitPipeline,
        deployPipeline
    } from './api/criblClient.js';
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries the full burden. It discloses the default behavior (fetches only most recent bucket if no params) and warns about large responses, adding behavioral context beyond the input schema. It doesn't cover all traits (e.g., rate limits) but is sufficient for a simple read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact with two short paragraphs. The first sentence states the purpose, followed by a highlighted IMPORTANT note and a default behavior explanation. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description is adequate but incomplete. It covers the critical performance warning and default behavior, but doesn't describe the return format, data structure, or how to interpret metrics, leaving some gaps for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% parameter description coverage, providing detailed explanations for each parameter. The description only lists the parameter names without adding new meaning, so it meets the baseline of 3 without exceeding schema contributions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Retrieves system metrics from the Cribl deployment' with a specific verb and resource. It distinguishes itself from sibling tools, which are about pipeline configuration, worker groups, etc., by being the only metrics retrieval tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly advises using optional parameters to narrow queries and explains the default behavior (numBuckets=1) to prevent performance issues. This provides clear context for when to use the tool, though it doesn't compare with sibling tools explicitly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/pebbletek/cribl-mcp'

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