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
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "vm_labels"
}
}Input 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(); }