{"record":{"id":"8084a832b776b88a","repo":"grafana/k6","slug":"failed-to-initialize-the-http-metrics-flush-client","errorCode":null,"errorMessage":"failed to initialize the http metrics flush client: %w","messagePattern":"failed to initialize the http metrics flush client: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/cloud/expv2/output.go","lineNumber":146,"sourceCode":"\t// cloud client. The two must be set together — one without the other is\n\t// a misconfiguration rather than a silent fallback.\n\tswitch {\n\tcase o.metricsHTTPClient != nil && o.metricsURL != \"\":\n\t\t// Both injected (provisioning mode); use as-is.\n\tcase o.metricsHTTPClient == nil && o.metricsURL == \"\":\n\t\to.metricsURL, err = deriveMetricsURL(o.cloudClient.BaseURL(), o.testRunID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to derive the metrics push URL: %w\", err)\n\t\t}\n\t\to.metricsHTTPClient = o.cloudClient\n\tdefault:\n\t\treturn errors.New(\"metrics push client misconfigured: \" +\n\t\t\t\"metricsHTTPClient and metricsURL must be set together\")\n\t}\n\n\tmc, err := newMetricsClientWithURL(o.metricsHTTPClient, o.metricsURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize the http metrics flush client: %w\", err)\n\t}\n\to.flushing = &metricsFlusher{\n\t\ttestRunID:                  o.testRunID,\n\t\tbq:                         &o.collector.bq,\n\t\tclient:                     mc,\n\t\tlogger:                     o.logger,\n\t\tdiscardedLabels:            make(map[string]struct{}),\n\t\taggregationPeriodInSeconds: uint32(o.config.AggregationPeriod.TimeDuration().Seconds()),\n\t\tmaxSeriesInBatch:           int(o.config.MaxTimeSeriesInBatch.Int64),\n\t\t// TODO: when the migration from v1 is over\n\t\t// change the default of cloudapi.MetricPushConcurrency to use GOMAXPROCS(0)\n\t\tbatchPushConcurrency: int(o.config.MetricPushConcurrency.Int64),\n\t}\n\n\tflushCtx, cancelFlush := context.WithCancel(context.Background())\n\to.cancelFlush = cancelFlush\n\n\to.runPeriodicFlush(flushCtx)","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/output/cloud/expv2/output.go#L128-L164","documentation":"During Output.Start, initialization of the HTTP client used to flush metrics to the cloud failed. In the switch that decides between injected (provisioning mode) client/URL and the derived legacy URL, neither a usable cloud client nor a valid configuration could be established, so the flusher cannot be created.","triggerScenarios":"Thrown at output/cloud/expv2/output.go:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the concrete cause","Verify cloud output configuration (host, token, run ID)","Ensure the cloud client was properly initialized before starting the output"],"exampleFix":null,"handlingStrategy":"try-catch","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"}