diff --git a/command/agent_monitor.go b/command/agent_monitor.go index 4d50faf6a..4dc466d2a 100644 --- a/command/agent_monitor.go +++ b/command/agent_monitor.go @@ -89,6 +89,28 @@ func (c *MonitorCommand) Run(args []string) int { return 1 } + // Query the node info and lookup prefix + if len(nodeID) == 1 { + c.Ui.Error(fmt.Sprintf("Node identifier must contain at least two characters.")) + return 1 + } + + if nodeID != "" { + nodeID = sanitizeUUIDPrefix(nodeID) + nodes, _, err := client.Nodes().PrefixList(nodeID) + if err != nil { + c.Ui.Error(fmt.Sprintf("Error querying node: %v", err)) + return 1 + } + + if len(nodes) > 1 { + out := formatNodeStubList(nodes, false) + c.Ui.Output(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", out)) + return 1 + } + nodeID = nodes[0].ID + } + params := map[string]string{ "log_level": logLevel, "node_id": nodeID,