Gateway Metrics¶
This guide explains how to implement and configure metrics collection for the API Platform Gateway components.
Overview¶
The default metrics services included in the Docker Compose configuration are demonstration services designed to showcase how you can observe component metrics in a centralized setup. These services provide a reference implementation that you can use out-of-the-box for development, testing, or as a starting point for your production metrics strategy.
Important: You are free to choose any metrics or observability strategy that suits your environment and requirements. The provided setup is just one of many possible configurations.
Metrics Architecture¶
The default metrics stack consists of:
- Prometheus: Scrapes, stores, and queries metrics from gateway components
- Grafana: Visualizes metrics through dashboards with alerts and notifications
How It Works¶
- Gateway components (gateway-controller, policy-engine, router) expose metrics via Prometheus HTTP endpoints
- Prometheus scrapes these endpoints at regular intervals (default: 15s)
- Metrics are stored in Prometheus's time-series database
- Grafana queries Prometheus to visualize metrics through pre-built dashboards
- Users can view real-time metrics, historical trends, and set up alerts
What are Metrics?¶
Metrics are numerical measurements tracked over time:
- Counters: Cumulative values that only increase (e.g., total requests, total errors)
- Gauges: Current values that can go up or down (e.g., active connections, memory usage)
- Histograms: Sample observations with configurable buckets (e.g., request duration)
In This Section¶
- Enabling and Disabling Metrics — Turn metrics on or off and run the demonstration metrics services
- Viewing Metrics in Grafana — Explore pre-built dashboards, create custom dashboards, and set up alerts
- Prometheus Queries — Useful PromQL queries for gateway controller, policy engine, and router
- Configuration Options — Scrape interval, custom endpoints, retention, and histogram buckets
- Alternative Metrics Backends — Export metrics to CloudWatch, Datadog, New Relic, and other systems
- Metric Reference — Full list of metrics exposed by each gateway component
- Best Practices and Troubleshooting — Recommendations, common issues, and integration with logging and tracing