{"record":{"id":"81ba8677ced2af3c","repo":"grafana/k6","slug":"marking-time-series-as-stale-failed-w","errorCode":null,"errorMessage":"marking time series as stale failed: %w","messagePattern":"marking time series as stale failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/prometheusrw/remotewrite/remotewrite.go","lineNumber":117,"sourceCode":"// Stop stops the output.\nfunc (o *Output) Stop() error {\n\to.logger.Debug(\"Stopping the output\")\n\tdefer o.logger.Debug(\"Output stopped\")\n\to.periodicFlusher.Stop()\n\n\tif !o.config.StaleMarkers.Bool {\n\t\treturn nil\n\t}\n\tstaleMarkers := o.staleMarkers()\n\tif len(staleMarkers) < 1 {\n\t\to.logger.Debug(\"No time series to mark as stale\")\n\t\treturn nil\n\t}\n\to.logger.WithField(\"staleMarkers\", len(staleMarkers)).Debug(\"Marking time series as stale\")\n\n\terr := o.client.Store(context.Background(), staleMarkers)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marking time series as stale failed: %w\", err)\n\t}\n\treturn nil\n}\n\n// staleMarkers maps all the seen time series with a stale marker.\nfunc (o *Output) staleMarkers() []*prompb.TimeSeries {\n\t// Add 1ms so in the extreme case that the time frame\n\t// between the last and the next flush operation is under-millisecond,\n\t// we can avoid the sample being seen as a duplicate,\n\t// if we force it in the future.\n\t// It is essential because if it overlaps, the remote write discards the last sample,\n\t// so the stale marker and the metric will remain active for the next 5 min\n\t// as the default logic without stale markers.\n\ttimestamp := o.now().\n\t\tTruncate(time.Millisecond).Add(1 * time.Millisecond).UnixMilli()\n\n\tstaleMarkers := make([]*prompb.TimeSeries, 0, len(o.tsdb))\n\tfor _, swm := range o.tsdb {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/output/prometheusrw/remotewrite/remotewrite.go#L99-L135","documentation":"On test completion, the remote-write output tried to send stale markers for all seen time series (K6_PROMETHEUS_RW_STALE_MARKERS=true) and the Store POST to Prometheus failed; Stop wraps the transport error.","triggerScenarios":"Thrown at internal/output/prometheusrw/remotewrite/remotewrite.go:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error: connectivity, TLS, or server rejection of the stale-marker write","Ensure the remote write endpoint is still reachable when the test ends","Disable stale markers if not needed (K6_PROMETHEUS_RW_STALE_MARKERS=false)"],"exampleFix":null,"handlingStrategy":"retry","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"}