{"record":{"id":"d938b19016ca11f9","repo":"grafana/k6","slug":"error-while-parsing-loki-configuration-w","errorCode":null,"errorMessage":"error while parsing loki configuration %w","messagePattern":"error while parsing loki configuration %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/log/loki.go","lineNumber":146,"sourceCode":"\n\tif line != \"loki\" {\n\t\tlogOutput, _, _ := strings.Cut(line, \"=\")\n\t\tif logOutput != \"loki\" {\n\t\t\treturn nil, fmt.Errorf(\"loki configuration should be in the form `loki=url-to-push` but is `%s`\", line)\n\t\t}\n\n\t\tif err := opts.parseArgs(line); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn NewLokiHook(fallbackLogger, opts)\n}\n\nfunc (opts *LokiHookOptions) parseArgs(line string) error {\n\ttokens, err := strvals.Parse(line)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error while parsing loki configuration %w\", err)\n\t}\n\n\tfor _, token := range tokens {\n\t\tkey := token.Key\n\t\tvalue := token.Value\n\n\t\tvar err error\n\t\tswitch key {\n\t\tcase \"loki\":\n\t\t\topts.Addr = value\n\t\tcase \"pushPeriod\":\n\t\t\topts.PushPeriod, err = time.ParseDuration(value)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"couldn't parse the loki pushPeriod %w\", err)\n\t\t\t}\n\t\tcase \"profile\":\n\t\t\topts.Profile = true\n\t\tcase \"limit\":","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/log/loki.go#L128-L164","documentation":"Wraps a strvals.Parse failure in LokiHookOptions.parseArgs. It fires when the `loki=...` configuration line is not valid key=value token syntax (bad quoting/separators). The at-fault input is the malformed loki config line; the strvals error is wrapped with %w.","triggerScenarios":"Thrown at internal/log/loki.go:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure valid key=value syntax, e.g. loki=http://localhost:3100/loki/api/v1/push","Correctly quote URLs or values containing special characters","Inspect the wrapped strvals error for the exact syntax problem"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}