APM Gateway
Service: apm-gateway · Port: 8101
apm-gateway serves application performance data: how many requests each service handles, how fast, and how many fail — per service and per endpoint. It runs PromQL against Prometheus and returns structured JSON, so the dashboard, agents and scripts don't need to know PromQL. It stores nothing itself.
What it answers
| Question | Endpoint | PromQL |
|---|---|---|
| How busy is each service? | /api/v1/services/metrics | sum by (app, namespace) (rate(http_requests_total[5m])) |
| Which endpoints are slowest? | /api/v1/endpoints/slowest | topk(10, histogram_quantile(0.99, sum by (le, handler, method) (rate(http_request_duration_seconds_bucket[5m])))) |
| Which endpoints fail most? | /api/v1/endpoints/erroring | topk(10, sum by (handler, method) (rate(http_requests_total{status=~"5.."}[5m]))) |
Metric labels
apm-gateway expects the standard labels used by Prometheus client libraries:
| Label | Meaning |
|---|---|
app or service | The workload. |
namespace | The Kubernetes namespace. |
handler | The route or endpoint. |
method | The HTTP method. |
status | The HTTP status code. |
Using a service mesh or a framework with different label names? Map them in configuration — for example, for Istio:
APM_LABEL_MAP: "app=destination_service_name,status=response_code,handler=request_operation"
APM_REQUESTS_METRIC: "istio_requests_total"
APM_DURATION_METRIC: "istio_request_duration_milliseconds_bucket"
REST API
| Method | Path | Description |
|---|---|---|
GET | /api/v1/services/metrics | Request rate, p50/p95/p99 latency and error rate per service (?namespace=). |
GET | /api/v1/services/{service}/timeseries | A service's metrics over time (?from=&to=&step=). |
GET | /api/v1/endpoints/slowest | The ten slowest endpoints by p99 latency. |
GET | /api/v1/endpoints/erroring | The ten endpoints with the most 5xx errors. |
POST | /api/v1/query | Run a PromQL query (used by the Optimizer and troubleshooter). |
GET | /healthz | Health check. |
Tenant users see only their own services.
Configuration
| Variable | Default | Description |
|---|---|---|
PROMETHEUS_URL | http://kube-prometheus-stack-prometheus.monitoring:9090 | Prometheus. |
APM_LABEL_MAP | — | Label name mappings (standard=yours, comma-separated). |
APM_REQUESTS_METRIC | http_requests_total | Request counter metric. |
APM_DURATION_METRIC | http_request_duration_seconds_bucket | Latency histogram metric. |
AUTH_JWT_ACCESS_SECRET | — | Validates tokens. |
PORT | 8101 | HTTP port. |