vm_labels
Retrieve all unique label names from VictoriaMetrics to organize and filter time series data for monitoring and analysis.
Instructions
Get all unique label names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:272-298 (handler)The handler function that executes the vm_labels tool by querying the VictoriaMetrics /api/v1/labels endpoint and returning the list of unique label names.async function vmLabels() { let urlStr = VM_URL if (urlStr === "") { urlStr = VM_SELECT_URL } const url = new URL(urlStr + "/api/v1/labels"); const response = await fetch(url.toString()); const data = await response.json(); if (data.status === "success") { return { content: [{ type: "text", text: JSON.stringify(data.data), }], isError: false }; } else { return { content: [{ type: "text", text: "range query fail:" + await response.text(), }], isError: true }; } }
- src/index.js:101-109 (schema)Tool schema definition for vm_labels, including name, description, and empty input schema (no parameters required).const VM_LABELS_TOOL = { name: "vm_labels", description: "Get all unique label names", inputSchema: { type: "object", properties: {}, required: [], } };
- src/index.js:127-134 (registration)Registration of the vm_labels tool (VM_LABELS_TOOL) in the VM_TOOLS array, which is provided to the listTools request handler.const VM_TOOLS = [ VM_DATA_WRITE_TOOL, VM_QUERY_RANGE_TOOL, VM_QUERY_TOOL, VM_LABELS_TOOL, VM_LABEL_VALUES_TOOL, VM_PROMETHEUS_WRITE_TOOL ];
- src/index.js:356-358 (registration)Dispatch/registration in the callTool request handler switch statement that maps 'vm_labels' to the vmLabels function.case "vm_labels": { return await vmLabels(); }