{"record":{"id":"bd5a2e9effeecf89","repo":"VictoriaMetrics/VictoriaMetrics","slug":"missing-put-prefix-in-q","errorCode":null,"errorMessage":"missing `put ` prefix in %q","messagePattern":"missing `put ` prefix in %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/protoparser/opentsdb/parser.go","lineNumber":62,"sourceCode":"type Row struct {\n\tMetric    string\n\tTags      []Tag\n\tValue     float64\n\tTimestamp int64\n}\n\nfunc (r *Row) reset() {\n\tr.Metric = \"\"\n\tr.Tags = nil\n\tr.Value = 0\n\tr.Timestamp = 0\n}\n\nfunc (r *Row) unmarshal(s string, tagsPool []Tag) ([]Tag, error) {\n\tr.reset()\n\ts = trimLeadingSpaces(s)\n\tif !strings.HasPrefix(s, \"put \") {\n\t\treturn tagsPool, fmt.Errorf(\"missing `put ` prefix in %q\", s)\n\t}\n\ts = s[len(\"put \"):]\n\ts = trimLeadingSpaces(s)\n\tn := strings.IndexByte(s, ' ')\n\tif n < 0 {\n\t\treturn tagsPool, fmt.Errorf(\"cannot find whitespace between metric and timestamp in %q\", s)\n\t}\n\tr.Metric = s[:n]\n\tif len(r.Metric) == 0 {\n\t\treturn tagsPool, fmt.Errorf(\"metric cannot be empty\")\n\t}\n\ttail := trimLeadingSpaces(s[n+1:])\n\tn = strings.IndexByte(tail, ' ')\n\tif n < 0 {\n\t\treturn tagsPool, fmt.Errorf(\"cannot find whitespace between timestamp and value in %q\", s)\n\t}\n\ttimestamp, err := fastfloat.Parse(tail[:n])\n\tif err != nil {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/protoparser/opentsdb/parser.go#L44-L80","documentation":"The OpenTSDB parser (lib/protoparser/opentsdb) expects each line of a telnet-style put request to start with the literal prefix 'put '. Row.unmarshal returns this error when a line does not. It is a line-format validation error for the OpenTSDB text protocol.","triggerScenarios":"POSTing lines to the OpenTSDB API insert handler that lack the leading 'put ' keyword, e.g. 'sys.cpu.user 1234567890 1 host=web01' without the prefix.","commonSituations":"Scripts written against a different text format; missing prefix after naive trimming of whitespace; sending OpenTSDB JSON API payloads to the telnet-style endpoint.","solutions":["Prefix each line with 'put ' followed by metric timestamp value tag=k=v pairs.","Verify you are not sending extra leading content; note trimLeadingSpaces strips spaces but the 'put ' keyword itself is required.","Use the OpenTSDB JSON API endpoint instead if your payload is JSON.","Test one line with curl against the OpenTSDB insert endpoint before batching."],"exampleFix":"// before\n\"sys.cpu.user 1496412345 42 host=web01\"\n// after\n\"put sys.cpu.user 1496412345 42 host=web01\"","handlingStrategy":"validation","validationCode":"// validate line before sending to OpenTSDB telnet-style endpoint\nre := regexp.MustCompile(`^put \\S+ \\d+ \\S+`)\nif !re.MatchString(line) {\n    return fmt.Errorf(\"invalid opentsdb line: %q\", line)\n}","typeGuard":null,"tryCatchPattern":"if err := parser.Parse(body, cb); err != nil {\n    if strings.Contains(err.Error(), \"missing `put ` prefix\") {\n        // offending line is quoted in the error; fix its format\n    }\n}","preventionTips":["Always prefix lines with literal 'put '","Use the OpenTSDB JSON API if your data is JSON","Regex-validate generated lines before batching"],"tags":["opentsdb","line-protocol","validation"],"backgroundTag":"missing-put-prefix","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}