Issue with Prometheus Remote - panic: runtime error: index out of range [1] with length 1

Hello All,

Prometheus is up and running, getting “panic: runtime error: index out of range [1] with length 1”
Following is the error trace

INFO[0000] Prometheus: configuring remote-write with prometheus mapping 
  execution: local
     script: 01_http_get.js
     output: Output k6 metrics to prometheus remote-write endpoint

  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

panic: runtime error: index out of range [1] with length 1
running (00m00.9s), 1/1 VUs, 0 complete and 0 interrupted iterations
goroutine 62 [running]:--------------------------] 1 VUs  00m00.9s/10m0s  0/1 iters, 1 per VU
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite.p(...)
	github.com/grafana/xk6-output-prometheus-remote@v0.0.1/pkg/remotewrite/prometheus.go:216
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite.(*PrometheusMapping).MapTrend(0x104ae14?, 0x300?, {0xc000695290, {0xc09a173d594b3070, 0x4cc3b268, 0x2e0dc00}, 0xc000bba2e0, 0x408207d4fdf3b646}, {0xc000e09200, 0x7, ...})
	github.com/grafana/xk6-output-prometheus-remote@v0.0.1/pkg/remotewrite/prometheus.go:84 +0x1a0d
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite.(*metricsStorage).transform(0xc000040119?, {0x234c558?, 0x2e406d8?}, {0xc000695290, {0xc09a173d594b3070, 0x4cc3b268, 0x2e0dc00}, 0xc000bba2e0, 0x408207d4fdf3b646}, {0xc000e09200, ...})
	github.com/grafana/xk6-output-prometheus-remote@v0.0.1/pkg/remotewrite/metrics.go:64 +0x24c
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite.(*Output).convertToTimeSeries(0xc000d65440, {0xc0029e2260, 0x1, 0xffffffffffffffff?})
	github.com/grafana/xk6-output-prometheus-remote@v0.0.1/pkg/remotewrite/remotewrite.go:149 +0x352
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite.(*Output).flush(0xc000d65440)
	github.com/grafana/xk6-output-prometheus-remote@v0.0.1/pkg/remotewrite/remotewrite.go:112 +0xeb
go.k6.io/k6/output.(*PeriodicFlusher).run(0xc000d674a0)
	go.k6.io/k6@v0.38.0/output/helpers.go:89 +0x88
created by go.k6.io/k6/output.NewPeriodicFlusher
go.k6.io/k6@v0.38.0/output/helpers.go:122 +0x136

Hi @BharathM, welcome to the community forum :tada:

This looks like a serious bug - please report it in the project issue tracker preferably with a sample script that reproduces it :wink:

Hello @mstoykov , Thank you. It got resolved automatically, I was just trying the following commands

K6_PROMETHEUS_REMOTE_URL=http://localhost:9090/api/v1/write \
    /Users/test1/Documents/SF/go/bin/k6 run 02_http_get_options.js -o output-prometheus-remote

K6_PROMETHEUS_REMOTE_URL=http://127.0.0.1:9090/api/v1/write \
    /Users/test1/Documents/SF/go/bin/k6 run 01_http_get.js -o output-prometheus-remote