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

# Retrieve VM metrics

> Retrieve a time series for a single metric of a Virtual Machine.



## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples get /virtual_machines/{virtual_machine_id}/metrics
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: IP Addresses
  - name: Kubernetes Clusters
  - name: Operating Systems
  - name: Plans
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Block Storage
  - name: Filesystem Storage
  - name: Object Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
  - name: Virtual machine backups
  - name: Virtual machine restores
paths:
  /virtual_machines/{virtual_machine_id}/metrics:
    get:
      tags:
        - Virtual machines
      summary: Retrieve VM metrics
      description: Retrieve a time series for a single metric of a Virtual Machine.
      operationId: show-virtual-machine-metrics
      parameters:
        - name: virtual_machine_id
          in: path
          required: true
          schema:
            type: string
        - name: metric
          in: query
          required: true
          schema:
            type: string
            enum:
              - cpu
              - memory
              - network
              - disk
        - name: range
          in: query
          required: false
          schema:
            type: string
            enum:
              - 5m
              - 15m
              - 1h
              - 24h
        - name: force_refresh
          in: query
          required: false
          schema:
            type: boolean
      responses:
        '200':
          description: Success
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/virtual_machine_metrics'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tlatitudeshgosdk \"github.com/latitudesh/latitudesh-go-sdk\"\n\t\"github.com/latitudesh/latitudesh-go-sdk/models/operations\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := latitudeshgosdk.New(\n        latitudeshgosdk.WithSecurity(os.Getenv(\"LATITUDESH_BEARER\")),\n    )\n\n    res, err := s.VirtualMachines.ShowVirtualMachineMetrics(ctx, \"<id>\", operations.MetricMemory, nil, nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.VirtualMachineMetrics != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Latitudesh } from "latitudesh-typescript-sdk";

            const latitudesh = new Latitudesh({
              bearer: process.env["LATITUDESH_BEARER"] ?? "",
            });

            async function run() {
              const result = await latitudesh.virtualMachines.showVirtualMachineMetrics({
                virtualMachineId: "<id>",
                metric: "memory",
              });

              console.log(result);
            }

            run();
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.virtual_machines.show_virtual_machine_metrics(virtual_machine_id="<id>", metric=latitudesh_python_sdk.QueryParamMetric.MEMORY)

                # Handle response
                print(res)
components:
  schemas:
    virtual_machine_metrics:
      type: object
      properties:
        metric:
          type: string
          enum:
            - cpu
            - memory
            - network
            - disk
        range:
          type: string
          enum:
            - 5m
            - 15m
            - 1h
            - 24h
        step:
          type: string
          description: Sampling interval between adjacent points (e.g. "15s", "1m")
        unit:
          type: string
          enum:
            - percent
            - bytes_per_second
          description: Unit applied to every point value
        points:
          type: array
          items:
            type: object
            properties:
              timestamp:
                type: string
                format: date-time
                description: ISO 8601 UTC timestamp (seconds precision)
              value:
                type: number
                description: Sampled value, rounded to 2 decimal places
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````