---
title: "获取命名空间监控指标"
method: GET
path: "/k8s/cluster/{id}/namespaces/{namespaceName}/metrics"
tags: ["K8s监控"]
---

# 获取命名空间监控指标

`GET /k8s/cluster/{id}/namespaces/{namespaceName}/metrics`

获取指定命名空间下所有Pod的CPU、内存等监控指标汇总

## Path parameters

- `id` integer, required
- `namespaceName` string, required

## Headers

- `Authorization` string, required

## Response `200`

OK

- object
  - `code` integer — 状态码
  - `data` object — 返回的数据
    - `namespace` string — 命名空间名称
    - `podCount` integer — Pod总数
    - `podMetrics` ModelPodMetricsSummary[] — Pod监控列表
      - `namespace` string — 命名空间
      - `podName` string — Pod名称
      - `usage` ModelResourceUsage
        - `cpu` string — CPU使用量 (如: "100m", "1.5")
        - `memory` string — 内存使用量 (如: "128Mi", "1Gi")
      - `usageRate` ModelResourceUsageRate
        - `cpuRate` number — CPU使用率 (百分比: 0-100)
        - `memoryRate` number — 内存使用率 (百分比: 0-100)
    - `resourceQuota` ModelNamespaceResourceQuota
      - `hard` ModelResourceUsage
        - `cpu` string — CPU使用量 (如: "100m", "1.5")
        - `memory` string — 内存使用量 (如: "128Mi", "1Gi")
      - `used` ModelResourceUsage
        - `cpu` string — CPU使用量 (如: "100m", "1.5")
        - `memory` string — 内存使用量 (如: "128Mi", "1Gi")
    - `runningPods` integer — 运行中的Pod数
    - `timestamp` string — 采集时间
    - `totalUsage` ModelResourceUsage
      - `cpu` string — CPU使用量 (如: "100m", "1.5")
      - `memory` string — 内存使用量 (如: "128Mi", "1Gi")
    - `usageRate` ModelResourceUsageRate
      - `cpuRate` number — CPU使用率 (百分比: 0-100)
      - `memoryRate` number — 内存使用率 (百分比: 0-100)
  - `message` string — 提示信息

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `404` — Not Found
- `500` — Internal Server Error

---

[API](https://skmtc.net/opsre/apis/devops.md) · [All operations](https://skmtc.net/opsre/apis/devops/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/opsre/devops/revisions/25cac8835c4c/schema)
