vm_labels
Extract all unique label names from VictoriaMetrics data for enhanced metadata analysis and query optimization.
Instructions
Get all unique label names
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:272-298 (handler)Implements the core logic for the vm_labels tool by querying the VictoriaMetrics API endpoint /api/v1/labels to retrieve all unique label names and returns the JSON data.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)Defines the tool metadata, description, and input schema (empty object since no input parameters are 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)Registers VM_LABELS_TOOL in the array of tools returned by the ListToolsRequest 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)Registers the vmLabels handler function in the switch statement for CallToolRequest.case "vm_labels": { return await vmLabels(); }