Skip to main content
Glama

get_error_analytics

Read-onlyIdempotent

Retrieve error-count time-series data with total errors and per-bucket counts to monitor high-level error trends.

Instructions

Get error-count time-series data with summary.total_errors and per-bucket counts. Use this for high-level error trends; use get_error_rate_analytics for percentages, or get_error_status_codes_analytics and get_error_stacks_analytics for breakdowns. Enterprise-gated. Returns 403 on non-Enterprise Portkey plans.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
time_of_generation_minYesStart time for the analytics period (ISO8601 format, e.g., '2024-01-01T00:00:00Z')
time_of_generation_maxYesEnd time for the analytics period (ISO8601 format, e.g., '2024-02-01T00:00:00Z')
total_units_minNoMinimum number of total tokens to filter by
total_units_maxNoMaximum number of total tokens to filter by
cost_minNoMinimum cost in cents to filter by
cost_maxNoMaximum cost in cents to filter by
prompt_token_minNoMinimum number of prompt tokens
prompt_token_maxNoMaximum number of prompt tokens
completion_token_minNoMinimum number of completion tokens
completion_token_maxNoMaximum number of completion tokens
status_codeNoLegacy Portkey query param for HTTP status codes. Comma-separated string; prefer status_codes for structured inputs.
weighted_feedback_minNoMinimum weighted feedback score (-10 to 10)
weighted_feedback_maxNoMaximum weighted feedback score (-10 to 10)
virtual_keysNoLegacy Portkey query param for virtual key slugs. Comma-separated string; prefer virtual_key_slugs for structured inputs.
configsNoLegacy Portkey query param for config slugs. Comma-separated string; prefer config_slugs for structured inputs.
status_codesNoStructured alias for status_code. Use an array of HTTP status codes; normalized to the legacy comma-separated Portkey query param.
virtual_key_slugsNoStructured alias for virtual_keys. Use an array of virtual key slugs; normalized to the legacy comma-separated Portkey query param.
config_slugsNoStructured alias for configs. Use an array of config slugs; normalized to the legacy comma-separated Portkey query param.
workspace_slugNoFilter by specific workspace
api_key_idsYesLegacy Portkey query param for API key UUIDs. Comma-separated string; request_analytics also accepts an array and normalizes it to this form.
metadataNoLegacy Portkey query param for metadata filtering. Stringified JSON object, e.g. '{"env":"prod","app":"myapp"}'; prefer metadata_filter for structured inputs.
ai_org_modelNoLegacy Portkey query param for provider/model pairs. Format: 'provider__model' with double underscore, e.g. 'openai__gpt-4' or 'anthropic__claude-3-opus'. Comma-separated string; prefer provider_models for structured inputs.
provider_modelsNoStructured alias for ai_org_model. Use provider__model strings in an array; normalized to the legacy comma-separated Portkey query param.
trace_idNoLegacy Portkey query param for trace IDs. Comma-separated string; prefer trace_ids for structured inputs.
trace_idsNoStructured alias for trace_id. Use an array of trace IDs; normalized to the legacy comma-separated Portkey query param.
span_idNoLegacy Portkey query param for span IDs. Comma-separated string; prefer span_ids for structured inputs.
span_idsNoStructured alias for span_id. Use an array of span IDs; normalized to the legacy comma-separated Portkey query param.
metadata_filterNoStructured alias for metadata. Use an object such as { env: 'prod' }; normalized to a JSON string before the request is sent.
prompt_slugNoFilter by prompt slug

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYesWhether the tool call succeeded and returned structured data
dataNoStructured success payload when ok is true
errorNoStructured error payload when ok is false

Implementation Reference

  • The MCP tool handler for 'get_error_analytics'. It registers a tool with the MCP server, calls service.analytics.getErrorAnalytics with normalized params, maps data_points to {timestamp, total_errors}, and formats the response using formatGraphAnalytics.
    server.tool(
    	"get_error_analytics",
    	"Get error-count time-series data with summary.total_errors and per-bucket counts. Use this for high-level error trends; use get_error_rate_analytics for percentages, or get_error_status_codes_analytics and get_error_stacks_analytics for breakdowns.",
    	baseAnalyticsSchema,
    	async (params) => {
    		const analytics = await service.analytics.getErrorAnalytics(
    			normalizeAnalyticsParams(params as Record<string, unknown>),
    		);
    		const dataPoints = analytics.data_points.map((point) => ({
    			timestamp: point.timestamp,
    			total_errors: point.total,
    		}));
    		return {
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify(
    						formatGraphAnalytics(
    							{
    								total_errors: analytics.summary.total,
    							},
    							dataPoints,
    						),
    						null,
    						2,
    					),
    				},
    			],
    		};
    	},
    );
  • Type definitions for ErrorAnalyticsResponse, ErrorDataPoint, and ErrorSummary used in the handler.
    export interface ErrorDataPoint {
    	timestamp: string;
    	total: number;
    }
    
    export interface ErrorSummary {
    	total: number;
    }
    
    export interface ErrorAnalyticsResponse {
    	object: "analytics-graph";
    	data_points: ErrorDataPoint[];
    	summary: ErrorSummary;
    }
  • Helper function formatGraphAnalytics used to structure the response with summary, point_count, and data_points.
    function formatGraphAnalytics(
    	summary: Record<string, unknown>,
    	dataPoints: Record<string, unknown>[],
    ): {
    	summary: Record<string, unknown>;
    	point_count: number;
    	data_points: Record<string, unknown>[];
    } {
    	return {
    		summary,
    		point_count: dataPoints.length,
    		data_points: dataPoints,
    	};
    }
  • The baseAnalyticsSchema Zod schema (fragment shown) used for input validation across all analytics tools including get_error_analytics.
    const baseAnalyticsSchema = {
    	time_of_generation_min: z
    		.string()
    		.describe(
    			"Start time for the analytics period (ISO8601 format, e.g., '2024-01-01T00:00:00Z')",
    		),
    	time_of_generation_max: z
    		.string()
    		.describe(
    			"End time for the analytics period (ISO8601 format, e.g., '2024-02-01T00:00:00Z')",
    		),
    	total_units_min: z.coerce
    		.number()
    		.positive()
    		.optional()
    		.describe("Minimum number of total tokens to filter by"),
    	total_units_max: z.coerce
    		.number()
    		.positive()
    		.optional()
    		.describe("Maximum number of total tokens to filter by"),
  • Registration of 'get_error_analytics' in the ENTERPRISE_GATED_TOOL_NAMES set, marking it as an enterprise-only tool.
    const ENTERPRISE_GATED_TOOL_NAMES = new Set([
    	"get_cost_analytics",
    	"get_request_analytics",
    	"get_token_analytics",
    	"get_latency_analytics",
    	"get_error_analytics",
    	"get_error_rate_analytics",
    	"get_cache_hit_latency",
    	"get_cache_hit_rate",
    	"get_users_analytics",
    	"get_error_stacks_analytics",
    	"get_error_status_codes_analytics",
    	"get_user_requests_analytics",
    	"get_rescued_requests_analytics",
    	"get_feedback_analytics",
    	"get_feedback_models_analytics",
Behavior4/5

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

Annotations already declare readOnly, non-destructive, idempotent, and open world. The description adds the enterprise restriction and 403 behavior. No contradictions.

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?

Very concise: two sentences plus a note about enterprise gating. Front-loaded with main purpose and usage guidance. No filler.

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

Completeness4/5

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

Given the tool's complexity (29 parameters, many nested), the description covers purpose, usage guidance, and an important behavioral constraint. Output schema exists for return values. Could mention required parameters explicitly, but schema already lists them.

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?

Schema coverage is 100% with detailed descriptions for all 29 parameters. The description does not add parameter-specific details beyond the schema, so baseline score of 3 is appropriate.

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 the tool retrieves error-count time-series data with summary.total_errors and per-bucket counts. It distinguishes itself from sibling analytics tools by naming specific alternatives for different use cases.

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

Usage Guidelines5/5

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

Explicitly advises when to use this tool ('high-level error trends') and when to use alternatives (percentages, status codes, stacks). Also mentions enterprise gating and 403 response for non-Enterprise plans.

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/s-b-e-n-s-o-n/portkey-admin-mcp'

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