{"record":{"id":"272a090281680cf9","repo":"grafana/k6","slug":"k6-cloud-logs-push-url-requires-k6-cloud-test-run","errorCode":null,"errorMessage":"K6_CLOUD_LOGS_PUSH_URL requires K6_CLOUD_TEST_RUN_TOKEN","messagePattern":"K6_CLOUD_LOGS_PUSH_URL requires K6_CLOUD_TEST_RUN_TOKEN","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/outputs_cloud.go","lineNumber":231,"sourceCode":"func applyExternalProvisioningCreds(\n\tgs *state.GlobalState, test *loadedAndConfiguredTest, conf *cloudapi.Config,\n) error {\n\t// The log-push config is env-supplied for an external run and likewise not\n\t// env-bound on the Config, so read it explicitly here (before the checks\n\t// below, which require the token when a logs URL is set).\n\tif err := applyExternalLogsConfig(gs, conf); err != nil {\n\t\treturn err\n\t}\n\tpushURL := gs.Env[\"K6_CLOUD_METRICS_PUSH_URL\"]\n\ttoken := gs.Env[\"K6_CLOUD_TEST_RUN_TOKEN\"]\n\tif (pushURL == \"\") != (token == \"\") {\n\t\treturn errors.New(\"both K6_CLOUD_METRICS_PUSH_URL and \" +\n\t\t\t\"K6_CLOUD_TEST_RUN_TOKEN must be set together\")\n\t}\n\t// A logs push URL is authenticated with the same scoped token, so reject a\n\t// logs URL supplied without it rather than silently streaming nothing.\n\tif token == \"\" && conf.LogsPushURL.Valid && conf.LogsPushURL.String != \"\" {\n\t\treturn errors.New(\"K6_CLOUD_LOGS_PUSH_URL requires K6_CLOUD_TEST_RUN_TOKEN\")\n\t}\n\tif pushURL == \"\" {\n\t\treturn nil\n\t}\n\n\tconf.MetricsPushURL = null.StringFrom(pushURL)\n\tconf.TestRunToken = null.StringFrom(token)\n\traw, err := cloudConfToRawMessage(*conf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not serialize cloud configuration: %w\", err)\n\t}\n\tif test.derivedConfig.Collectors == nil {\n\t\ttest.derivedConfig.Collectors = make(map[string]json.RawMessage)\n\t}\n\ttest.derivedConfig.Collectors[builtinOutputCloud.String()] = raw\n\treturn nil\n}\n","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/outputs_cloud.go#L213-L249","documentation":"In applyExternalProvisioningCreds (internal/cmd/outputs_cloud.go:231), a configured logs push URL (conf.LogsPushURL, sourced from K6_CLOUD_LOGS_PUSH_URL) is authenticated with the same scoped token as metrics. If the token is empty, k6 refuses to start rather than silently streaming nothing to an endpoint that will reject it.","triggerScenarios":"Setting K6_CLOUD_LOGS_PUSH_URL (or a LogsPushURL via config) without K6_CLOUD_TEST_RUN_TOKEN; commonly when enabling cloud log shipping in env-only provisioning setups.","commonSituations":"Enabling the logs-push feature flag/URL in CI but keeping the token in a different, unexported secret store; docs walkthroughs that show the URL variable but omit token provisioning.","solutions":["Export K6_CLOUD_TEST_RUN_TOKEN alongside K6_CLOUD_LOGS_PUSH_URL (and typically K6_CLOUD_METRICS_PUSH_URL, since URL and token must pair per error 44).","If you did not intend log shipping, unset K6_CLOUD_LOGS_PUSH_URL / remove logsPushURL from the cloud config."],"exampleFix":"# before\nexport K6_CLOUD_LOGS_PUSH_URL=\"https://ingest.../logs\"\nk6 run -o cloud script.js\n# after\nexport K6_CLOUD_LOGS_PUSH_URL=\"https://ingest.../logs\"\nexport K6_CLOUD_METRICS_PUSH_URL=\"https://ingest.../metrics\"\nexport K6_CLOUD_TEST_RUN_TOKEN=\"<token>\"\nk6 run -o cloud script.js","handlingStrategy":"validation","validationCode":"# logs push URL implies token\n[ -n \"$K6_CLOUD_LOGS_PUSH_URL\" ] && [ -z \"$K6_CLOUD_TEST_RUN_TOKEN\" ] && { echo 'K6_CLOUD_LOGS_PUSH_URL requires K6_CLOUD_TEST_RUN_TOKEN'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat K6_CLOUD_LOGS_PUSH_URL as part of the external-provisioning secret set, never a standalone env var.","Dry-run cloud provisioning in CI with all three variables echoed as present/absent flags (names only, never values)."],"tags":["cloud","logging","environment-variables","authentication"],"backgroundTag":"missing-env-var","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}