Skip to content

Add Prometheus Metrics Exporter #9

@naji247

Description

@naji247

Overview

MCPcat currently supports OTLP, Datadog, and Sentry exporters for telemetry. Adding a Prometheus exporter would allow users to integrate with one of the most popular open-source monitoring systems.

Current State

The telemetry system has a clean exporter interface that makes it easy to add new exporters. Existing exporters (OTLP, Datadog, Sentry) provide good examples of the implementation pattern.

Requirements

Create a new Prometheus exporter that:

  1. Converts MCP events to Prometheus metrics

    • Counter for total events
    • Histogram for event duration
    • Labels for event type, tool name, error status
  2. Exposes metrics endpoint

    • HTTP endpoint for Prometheus scraping
    • Configurable port and path
  3. Follows existing patterns

    • Extends the base Exporter class
    • Integrates with TelemetryManager
    • Handles errors gracefully

Why This Matters

  • Prometheus is widely adopted in the industry
  • Many organizations already have Prometheus infrastructure
  • Enables integration with Grafana for visualization
  • Provides an open-source alternative to commercial solutions
  • Complements existing exporters

Acceptance Criteria

  • New PrometheusExporter class in exporters module
  • Converts events to appropriate metric types
  • Exposes metrics on configurable HTTP endpoint
  • Includes proper labels and metadata
  • Handles high-cardinality data appropriately
  • Includes unit tests
  • Updates documentation with configuration examples

Getting Started

  1. Review the base Exporter interface
  2. Look at existing exporters for patterns
  3. Research Prometheus Python client library
  4. Start with basic counter metrics
  5. Add histogram for duration tracking
  6. Implement HTTP server for metrics endpoint

Configuration Example

The exporter should support configuration like:

exporters:
  prometheus:
    type: prometheus
    port: 9090
    path: /metrics
    prefix: mcpcat_

Notes

  • Consider metric cardinality to avoid performance issues
  • Use standard Prometheus naming conventions
  • Think about which event fields make good labels
  • Keep the implementation simple initially
  • This could later be extended with custom metrics

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions