> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camposcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /v1/databases/{databaseId}/metrics

> This endpoint returns the use of a database over time.



## OpenAPI

````yaml GET /v1/databases/{databaseId}/metrics
openapi: 3.1.0
info:
  title: CamposCloud API Documentation
  description: >-
    This documentation provides an overview of the CamposCloud API, including
    authentication, endpoints, and data structures. It is designed to help
    developers integrate with the CamposCloud platform effectively.
  version: 1.0.0
servers:
  - url: https://api.camposcloud.com
security:
  - bearerAuth: []
paths:
  /v1/databases/{databaseId}/metrics:
    get:
      tags:
        - Databases
      description: >-
        Memory, CPU, whether it was up and the database's own counters
        (connections, queries, size), over the last `hours`.
      parameters:
        - name: databaseId
          in: path
          required: true
          description: ID of the database.
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
        - name: hours
          in: query
          description: >-
            How many hours back, from 1 to 720 (30 days). The series is averaged
            into steps so that it never has more than 288 points.
          schema:
            type: integer
            minimum: 1
            maximum: 720
            default: 24
      responses:
        '200':
          description: The series.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricSeries'
        '400':
          description: Invalid input.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Not found, or you do not have access to it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    MetricSeries:
      type: object
      required:
        - stepMs
        - points
      properties:
        stepMs:
          type: integer
          description: Length of each step, in milliseconds.
        points:
          type: array
          items:
            $ref: '#/components/schemas/MetricPoint'
    Error:
      type: object
      description: >-
        Every error returned by the API has this shape. `error` is a human
        readable message (in English or in Portuguese, depending on the
        endpoint). Many errors also carry `code`, a stable identifier to rely on
        in your code, and sometimes extra fields with details (for example
        `requestedMB` and `availableMB` with `PLAN_MEMORY_LIMIT`). Resources you
        have no relation to answer `404`, not `403`.
      required:
        - error
      properties:
        error:
          type: string
          description: Human readable description of the error.
          example: Application not found.
        code:
          type: string
          description: >-
            Stable, machine-readable identifier of the error. Present on many
            errors; compare against it instead of the message. Examples:
            `PLAN_MEMORY_LIMIT`, `APPLICATION_NOT_FOUND`, `DATABASE_NOT_FOUND`,
            `MAIN_FILE_INVALID`, `ENV_DUPLICATE_KEY`, `CUSTOM_DOMAIN_IN_USE`,
            `CUSTOM_DOMAIN_RESERVED`, `CUSTOM_DOMAIN_NOT_CLOUDFLARE`,
            `CUSTOM_DOMAIN_NO_PENDING`, `CUSTOM_DOMAIN_TXT_NOT_FOUND`.
          example: PLAN_MEMORY_LIMIT
    MetricPoint:
      type: object
      description: >-
        One step of a series: averages and peaks of the readings taken in it.
        Fields a resource does not have (database counters on an application)
        are absent.
      properties:
        at:
          type: string
          format: date-time
          description: Start of the step.
        memoryBytes:
          type: number
          description: Average memory in use.
        reservedBytes:
          type: number
          description: Memory reserved for it (its limit).
        cpuPercent:
          type: number
          description: Average CPU use, in percent.
        online:
          type: boolean
          description: Whether it was up in any reading of the step.
        upShare:
          type: number
          description: Share of the readings in which it was up, 0 to 1.
        networkRxBytes:
          type: number
        networkTxBytes:
          type: number
        diskBytes:
          type: number
        connections:
          type: number
          description: 'Databases: open connections.'
        maxConnections:
          type: number
          description: 'Databases: connection limit.'
        queries:
          type: number
          description: 'Databases: queries counted since it started.'
        dataBytes:
          type: number
          description: 'Databases: size of the data.'
        queryMs:
          type: number
        queryCount:
          type: number
  responses:
    Unauthorized:
      description: >-
        The `Authorization` header is missing or malformed, or the API token is
        invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Invalid developer token
    TooManyRequests:
      description: >-
        A rate limit was exceeded. See the `RateLimit-*` and `Retry-After`
        response headers.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Too many requests, please try again later
    InternalError:
      description: >-
        Unexpected error. On endpoints that do not document a `400` for it, this
        is also returned when an ID in the URL is not a valid identifier.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Internal server error. Please try again later.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your CamposCloud API token, sent as `Authorization: Bearer <token>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.