get-pod-metrics
Retrieve detailed performance metrics for a specific Kubernetes pod to monitor resource usage and analyze pod behavior within your cluster.
Instructions
Get detailed metrics for a pod
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pod | Yes | The name of the pod | |
| namespace | No | The namespace of the pod (optional, defaults to current context namespace) |
Implementation Reference
- server.js:2081-2089 (handler)The handler function for the 'get-pod-metrics' tool. It extracts the pod name and optional namespace from arguments, constructs a kubectl command to retrieve the resource specifications (requests/limits) for all containers in the pod using jsonpath and pipes to jq for formatting, executes it via execAsync, and returns the stdout as text content or an error message.case "get-pod-metrics": { const { pod, namespace } = args; const nsArg = namespace ? `-n ${namespace}` : ""; const cmd = `kubectl get pod ${pod} ${nsArg} -o jsonpath='{.spec.containers[*].resources}' | jq .`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || "Unable to get pod metrics" }] }; }
- server.js:1097-1110 (schema)Input schema for the 'get-pod-metrics' tool, defining required 'pod' string parameter and optional 'namespace' string.inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" } }, required: ["pod"] }
- server.js:1095-1111 (registration)Registration of the 'get-pod-metrics' tool in the tools array used by ListToolsRequestHandler. Includes name, description, and input schema.name: "get-pod-metrics", description: "Get detailed metrics for a pod", inputSchema: { type: "object", properties: { pod: { type: "string", description: "The name of the pod" }, namespace: { type: "string", description: "The namespace of the pod (optional, defaults to current context namespace)" } }, required: ["pod"] } },