vm_label_values
Retrieve all unique values for a specified label in VictoriaMetrics-mcp-server to streamline data analysis and monitoring tasks.
Instructions
Get all unique values for a specific label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Label name to retrieve values for |
Implementation Reference
- src/index.js:300-326 (handler)The handler function for the vm_label_values tool. It constructs a URL to the VictoriaMetrics API endpoint /api/v1/label/{label}/values, fetches the data, and returns the JSON response or an error.async function vmLabelValues(label) { let urlStr = VM_URL if (urlStr === "") { urlStr = VM_SELECT_URL } const url = new URL(urlStr + "/api/v1/label/"+ label +"/values"); 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:111-124 (schema)The tool schema definition, including name, description, and inputSchema that requires a 'label' string parameter.const VM_LABEL_VALUES_TOOL = { name: "vm_label_values", description: "Get all unique values for a specific label", inputSchema: { type: "object", properties: { label: { type: "string", description: "Label name to retrieve values for", } }, required: ["label"], } };
- src/index.js:127-134 (registration)Registration of the vm_label_values tool (as VM_LABEL_VALUES_TOOL) in the VM_TOOLS array used for ListToolsRequest response.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:359-362 (registration)Registration/dispatch of the vm_label_values tool in the CallToolRequest handler switch statement.case "vm_label_values": { const {label} = request.params.arguments; return await vmLabelValues(label); }