如果“xk6-output-prometheus-remote”扩展与另一个扩展一起添加,则 xk6 无法构建

问题描述 投票:0回答:1

我正在尝试使用 xk6 构建 k6 二进制文件来添加我需要的扩展。首先,我下载了最新版本的xk6:

go install go.k6.io/xk6/cmd/xk6@latest

之后,我有了 xk6 可执行文件,因此我将仅添加“xk6-output-prometheus-remote”扩展名:

./xk6 build --with github.com/grafana/xk6-output-prometheus-remote@latest
xk6 has now produced a new k6 binary which may be different than the command on your system path!

如您所见,如果我仅添加该扩展名,一切都很好。但现在,我将添加 xk6-kafka 扩展,因此我输入下一个:

./xk6 build --with github.com/grafana/xk6-output-prometheus-remote@latest --with github.com/mostafa/xk6-kafka@latest

我收到下一个错误,抱怨 xk6-output-prometheus-remote:

# github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite
../../pkg/mod/github.com/grafana/[email protected]/pkg/remotewrite/remotewrite.go:173:13: t.Total undefined (type *"go.k6.io/k6/metrics".TrendSink has no field or method Total)
../../pkg/mod/github.com/grafana/[email protected]/pkg/remotewrite/trend.go:28:23: undefined: metrics.NewTrendSink
2023/08/30 10:45:35 [INFO] Cleaning up temporary folder: .../go/bin/buildenv_2023-08-30-1045.725323668
2023/08/30 10:45:35 [FATAL] exit status 1

如果尝试使用其他扩展执行正常的 xk6 构建,我没有问题:

./xk6 build --with github.com/mostafa/xk6-kafka@latest --with github.com/mostafa/xk6-sql@latest --with github.com/mostafa/xk6-output-influxdb@latest

再说一次,一切都很好。

我试图查看它的扩展是否有特殊的东西可以安装它,但我找不到任何东西。

我还尝试使用容器作为官方文档构建 k6 二进制文件,但使用容器的输出是相同的。

请问你能帮我吗?

prometheus grafana performance-testing k6
1个回答
0
投票

从 v0.42.0 开始,您不再需要在 xk6-output-prometheus-remote 扩展中进行编译。默认情况下,它作为实验模块包含在 k6 版本二进制文件中。因此,在您的示例中,排除

--with github.com/grafana/xk6-output-prometheus-remote@latest
,您仍然拥有 Prometheus 远程写入功能。

请参阅 https://k6.io/docs/results-output/real-time/prometheus-remote-write/ 了解最新用法。

© www.soinside.com 2019 - 2024. All rights reserved.