APM Gateway
apm-gateway is a stateless Prometheus façade for application performance monitoring. It executes PromQL queries for request rates, latency percentiles, and error rates and returns structured JSON. No database — all metrics live in Prometheus.
Prometheus Queries
| Endpoint | PromQL |
|---|---|
GET /api/v1/services/metrics | sum by (app, namespace) (rate(http_requests_total[5m])) |
GET /api/v1/endpoints/slowest | topk(10, histogram_quantile(0.99, sum by (le, handler, method) (rate(http_request_duration_seconds_bucket[5m])))) |
GET /api/v1/endpoints/erroring | topk(10, sum by (handler, method) (rate(http_requests_total{status=~"5.."}[5m]))) |
These queries follow the OpenMetrics conventions used by Prometheus client libraries, Istio service mesh metrics, and most Kubernetes-native application frameworks.
REST API
| Method | Path | Description |
|---|---|---|
GET | /api/v1/services/metrics | Request rate per service (?namespace=) |
GET | /api/v1/endpoints/slowest | Top 10 endpoints by p99 latency |
GET | /api/v1/endpoints/erroring | Top 10 endpoints by 5xx error rate |
GET | /healthz | Health check |
Metric Labels
The queries expect these standard labels on http_requests_total and http_request_duration_seconds:
apporservice— workload namenamespace— Kubernetes namespacehandler— route or endpoint pathmethod— HTTP methodstatus— HTTP status code
If your workloads use non-standard label names (e.g. Istio uses destination_service_name), update the PromQL in the handler or proxy the queries through a Prometheus recording rule.
Environment Variables
| Variable | Default | Description |
|---|---|---|
PROMETHEUS_URL | http://localhost:9090 | Prometheus endpoint |
PORT | 8101 | HTTP port |