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

# Query Kubernetes pod metrics

For authentication and the other Kubernetes endpoints, see the [Public API (V2) overview](https://docs.appsignal.com/api/v2/overview.md#kubernetes).

```yaml POST /api/v2/kubernetes/pods theme={null}
openapi: 3.1.0
info:
  title: AppSignal V2 API
  description: >-
    REST API for metrics, traces, logs, Kubernetes monitoring, and deployment
    tracking.
  license:
    name: ''
  version: 0.1.0
paths:
  /api/v2/kubernetes/pods:
    post:
      tags:
        - Kubernetes
      summary: Query Kubernetes pod metrics
      operationId: pods
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PodsQuery'
            example:
              site_id: abc123
              from: '2024-01-01T00:00:00Z'
              to: '2024-01-01T01:00:00Z'
              namespaces:
                - default
                - kube-system
              state: Running
        required: true
      responses:
        '200':
          description: One row per pod, ordered by namespace and pod name.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PodsRow'
        '400':
          description: Malformed request, or input the server cannot process.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Missing or invalid authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Route or resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: External query concurrency limit exceeded; retry shortly.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsResponse'
        '500':
          description: Unhandled server-side failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer_auth: []
        - token_query: []
components:
  schemas:
    BadRequestResponse:
      type: object
      description: >-
        Standard body for HTTP 400 Bad Request responses. Branch on the stable
        `error` slug, display `message` as-is, and read per-error structured
        data from `details`.
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Stable, machine-readable slug identifying the specific error case.
        message:
          type: string
          description: Human-readable message. Safe to log or display to end users.
        details:
          description: >-
            Per-error structured payload. Shape varies by
            [`error`](Self::error).
    Container:
      type: object
      description: A container within a Kubernetes pod.
      required:
        - name
        - status
        - exit_code
        - reason
      properties:
        name:
          type: string
          description: Name of the container.
        status:
          $ref: '#/components/schemas/ContainerStatus'
          description: Current status of the container.
        exit_code:
          type: integer
          format: int32
          description: Exit code of the container process (0 means success).
        reason:
          type: string
          description: Human-readable reason for the container's current status.
    ContainerStatus:
      type: string
      description: Status of a container within a pod.
      enum:
        - Running
        - Terminated
        - Waiting
        - Unknown
    ErrorResponse:
      type: object
      description: Error body returned for 401, 404 and 500 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
    PodPhase:
      type: string
      description: Kubernetes pod lifecycle phase.
      enum:
        - Running
        - Succeeded
        - Pending
        - Failed
        - Unknown
    PodState:
      type: string
      description: Derived state of a pod, combining phase and container statuses.
      enum:
        - Unknown
        - Pending
        - Running
        - Succeeded
        - Failed
    PodsQuery:
      type: object
      description: Query for fetching detailed Kubernetes pod metrics.
      required:
        - site_id
        - from
        - to
      properties:
        site_id:
          type: string
          description: Site identifier to query pods for.
        from:
          type: string
          format: date-time
          description: Start of the time range (inclusive).
        to:
          type: string
          format: date-time
          description: End of the time range (exclusive).
        namespaces:
          type: array
          items:
            type: string
          description: Optional namespace filter. Empty means all namespaces.
        pod_name:
          type: string
          description: Optional substring of the pod name to match. Empty means all pods.
        node_names:
          type: array
          items:
            type: string
          description: Optional node name filter. Empty means all nodes.
        state:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/PodState'
              description: >-
                Optional pod state filter, applied to every snapshot in the time
                range rather than only the latest.
    PodsRow:
      type: object
      description: >-
        The latest detailed Kubernetes pod metrics within the requested time
        range.
      required:
        - timestamp
        - pod_name
        - pod_namespace
        - node_name
        - cpu_usage_nano_cores
        - cpu_usage_core_nano_seconds
        - memory_rss_bytes
        - memory_usage_bytes
        - memory_working_set_bytes
        - memory_page_faults
        - memory_major_page_faults
        - ephemeral_storage_used_bytes
        - ephemeral_storage_capacity_bytes
        - network_rx_bytes
        - network_tx_bytes
        - process_count
        - phase
        - state
        - containers
        - pod_restart_count
        - pod_uptime_seconds
      properties:
        timestamp:
          type: string
          format: date-time
          description: Timestamp of the metrics snapshot.
        pod_name:
          type: string
          description: Name of the pod.
        pod_namespace:
          type: string
          description: Kubernetes namespace the pod belongs to.
        node_name:
          type: string
          description: Name of the node this pod is running on.
        cpu_usage_nano_cores:
          type: number
          format: double
          description: CPU usage in nanocores.
        cpu_usage_core_nano_seconds:
          type: number
          format: double
          description: Cumulative CPU usage in core-nanoseconds.
        memory_rss_bytes:
          type: number
          format: double
          description: Resident set size (RSS) memory in bytes.
        memory_usage_bytes:
          type: number
          format: double
          description: Total memory usage in bytes.
        memory_working_set_bytes:
          type: number
          format: double
          description: Working set memory in bytes.
        memory_page_faults:
          type: number
          format: double
          description: Number of page faults.
        memory_major_page_faults:
          type: number
          format: double
          description: Number of major page faults.
        ephemeral_storage_used_bytes:
          type: number
          format: double
          description: Ephemeral storage used in bytes.
        ephemeral_storage_capacity_bytes:
          type: number
          format: double
          description: Ephemeral storage capacity in bytes.
        network_rx_bytes:
          type: number
          format: double
          description: Network bytes received.
        network_tx_bytes:
          type: number
          format: double
          description: Network bytes transmitted.
        process_count:
          type: number
          format: double
          description: Number of running processes.
        phase:
          $ref: '#/components/schemas/PodPhase'
          description: Current phase of the pod lifecycle.
        state:
          $ref: '#/components/schemas/PodState'
          description: Derived pod state based on phase and container statuses.
        containers:
          type: array
          items:
            $ref: '#/components/schemas/Container'
          description: Containers running in this pod.
        pod_restart_count:
          type: integer
          format: u-int32
          description: Total number of container restarts for this pod.
          minimum: 0
        pod_uptime_seconds:
          type: integer
          format: u-int64
          description: Pod uptime in seconds.
          minimum: 0
    TooManyRequestsResponse:
      type: object
      description: Error body returned for 429 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
        suggestion:
          type:
            - string
            - 'null'
          description: >-
            A cheaper way to write the request's filter. Only the trace list

            endpoints set it, and only for a filter with a known indexed
            rewrite.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: '`Authorization: Bearer <token>`'
    token_query:
      type: apiKey
      in: query
      name: token
      description: >-
        Alternative to the Authorization header: pass the token as a
        `?token=<token>` query parameter.
```


## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.appsignal.com/llms.txt).


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