Skip to content

feat: Add Prometheus metrics endpoint #3

@gouravjshah

Description

@gouravjshah

Summary

Add a /metrics endpoint that exposes gateway metrics in Prometheus format for production observability.

Parent Epic

Part of #1 - Production Kubernetes & Container Support

Proposed Metrics

Gateway Metrics

Metric Type Description
mcp_gateway_requests_total Counter Total MCP requests by server_id, method
mcp_gateway_request_duration_seconds Histogram Request latency histogram
mcp_gateway_active_servers Gauge Currently running server instances
mcp_gateway_server_starts_total Counter Server startup count by server_id
mcp_gateway_server_stops_total Counter Server shutdown count by server_id, reason
mcp_gateway_errors_total Counter Error count by server_id, error_type

Server-Level Metrics

Metric Type Description
mcp_server_tools_called_total Counter Tool invocations by server_id, tool_name
mcp_server_uptime_seconds Gauge Time since server started
mcp_server_memory_bytes Gauge Memory usage (if available)

Implementation

Dependencies

[dependencies]
prometheus = "0.13"

Endpoint

GET /metrics
Content-Type: text/plain; version=0.0.4

Example Output

# HELP mcp_gateway_requests_total Total MCP requests
# TYPE mcp_gateway_requests_total counter
mcp_gateway_requests_total{server_id="postgres",method="tools/call"} 142

# HELP mcp_gateway_active_servers Currently running servers
# TYPE mcp_gateway_active_servers gauge
mcp_gateway_active_servers 3

Acceptance Criteria

  • /metrics endpoint returns Prometheus-format metrics
  • Request count and latency tracked per server
  • Active server count gauge
  • Error rate tracking
  • Compatible with Prometheus scraping
  • Optional: ServiceMonitor CRD for K8s

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestobservabilityMetrics, logging, tracingv0.2Version 0.2 features

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions