---
title: "Handler for the `/metrics` endpoint."
url: "https://developer.rucho.org/apis/rucho/versions/5bdf1bcb-8db4-40f1-a293-72c7198e26c8/operations/get_metrics"
---

> Full API specification: https://developer.rucho.org/apis/rucho/versions/5bdf1bcb-8db4-40f1-a293-72c7198e26c8.md

# Handler for the `/metrics` endpoint.

`GET` `/metrics`

Operation ID: `get_metrics`

Returns a JSON object containing: - `all_time`: Total requests, successes, failures, and per-endpoint hits since server start - `last_hour`: Same metrics but only for the last 60 minutes (rolling window) # Example Response ```json { "all_time": { "total_requests": 1000, "successes": 950, "failures": 50, "endpoint_hits": { "/get": 500, "/post": 300, "/status/:code": 200 } }, "last_hour": { "total_requests": 100, "successes": 95, "failures": 5, "endpoint_hits": { "/get": 50, "/post": 30, "/status/:code": 20 } } } ```

## Responses

- `200` - Request statistics as JSON: `all_time` totals plus a rolling `last_hour` window, each with total/success/failure counts and per-endpoint hits. Only mounted when `metrics_enabled` is set — otherwise the route returns 404.

## OpenAPI definition

````yaml
openapi: 3.0.3
info:
  title: rucho
  version: 1.6.0
servers:
  - url: https://rucho.org
    description: Production (EKS us-east-2, behind Kong)
paths:
  /metrics:
    get:
      tags:
        - crate::routes::metrics
      summary: Handler for the `/metrics` endpoint.
      description: >-
        Returns a JSON object containing:

        - `all_time`: Total requests, successes, failures, and per-endpoint hits
        since server start

        - `last_hour`: Same metrics but only for the last 60 minutes (rolling
        window)


        # Example Response


        ```json

        {

        "all_time": {

        "total_requests": 1000,

        "successes": 950,

        "failures": 50,

        "endpoint_hits": {

        "/get": 500,

        "/post": 300,

        "/status/:code": 200

        }

        },

        "last_hour": {

        "total_requests": 100,

        "successes": 95,

        "failures": 5,

        "endpoint_hits": {

        "/get": 50,

        "/post": 30,

        "/status/:code": 20

        }

        }

        }

        ```
      operationId: get_metrics
      responses:
        "200":
          description: "Request statistics as JSON: `all_time` totals plus a rolling
            `last_hour` window, each with total/success/failure counts and
            per-endpoint hits. Only mounted when `metrics_enabled` is set —
            otherwise the route returns 404."
          content:
            application/json:
              schema: {}
````
