有什么方法可以将令牌传递到标头中的 K6_PROMETHEUS_RW_SERVER_URL 吗? 在没有令牌的情况下运行,例如有关 k6 的工作使用正确的 rw 服务器:
K6_PROMETHEUS_RW_SERVER_URL=https://uat.org/api/v1/write \
k6 run -o experimental-prometheus-rw dist/get-all-node-requests-test.js
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
execution: local
script: dist/get-all-node-requests-test.js
output: Prometheus remote write (https://uat.org/api/v1/write)
scenarios: (100.00%) 1 scenario, 3 max VUs, 4h22m30s max duration (incl. graceful stop):
* default: Up to 3 looping VUs for 4h22m0s over 3 stages (gracefulRampDown: 30s, gracefulStop: 30s)
INFO[0000] Wed Mar 13 2024 20:56:58 GMT+0000 (GMT): Response status: 200. Request duration: 137.847 source=console
INFO[0004] Wed Mar 13 2024 20:57:02 GMT+0000 (GMT): Response status: 200. Request duration: 118.392 source=console
ERRO[0006] Failed to send the time series data to the endpoint error="got status code: 401 instead expected a 2xx successful status code" output="Prometheus remote write"
但是我需要在标头中提供令牌。
我尝试通过curl 来实现它,但没有成功。有什么办法可以将令牌传递到 rw 服务器吗?
提前致谢!
**************************** 已解决 ******************** ******
K6_PROMETHEUS_RW_BEARER_TOKEN=<TOKEN> \
K6_PROMETHEUS_RW_SERVER_URL=https://uat.org/api/v1/write \
k6 run -o experimental-prometheus-rw dist/get-all-node-requests-test.js
To pass a token to RW endpoint works in this way:
K6_PROMETHEUS_RW_BEARER_TOKEN=<TOKEN> \
K6_PROMETHEUS_RW_SERVER_URL=https://uat.org/api/v1/write \
k6 run -o experimental-prometheus-rw dist/get-all-node-requests-test.js