grafana / k6

A modern load testing tool, using Go and JavaScript - https://k6.io
GNU Affero General Public License v3.0
24.92k stars 1.23k forks source link

Abort test on reaching metric limit #3861

Closed ameetpal closed 1 month ago

ameetpal commented 1 month ago

Feature Description

As of now following warning pops up when there are large number of urls in test oi.logger.Warnf( "The test has generated metrics with %d unique time series, "+ "which is higher than the suggested limit of %d "+ "and could cause high memory usage. "+ "Consider not using high-cardinality values like unique IDs as metric tags "+ "or, if you need them in the URL, use the name metric tag or URL grouping. "+ "See https://grafana.com/docs/k6/latest/using-k6/tags-and-groups/ for details.", oi.cardinality.Count(), timeSeriesFirstLimit, )

Other than warning there should be an option to abort test when we see this warning, As this is causing high memory usage.

Suggested Solution (optional)

An K6 environment variable to stop test when this limit is reached

Already existing or connected issues / PRs (optional)

No response

codebien commented 1 month ago

This mostly leads to #3198, where you can send the metrics to external metric storages, and you can set a threshold on a specific query. When the query crosses the threshold then the test is stopped by aborted by threshold if abort-on-failure option is set.

We don't have it in our short-term roadmap, so if you need it immediately then you can do it autonomously reproducing the same concept by building an Output extension.

ameetpal commented 1 month ago

@codebien Will i able to abort test from output extension ? i am not able to find any reference for it

codebien commented 1 month ago

@ameetpal Yes, you can. Your output has to implement WithTestRunStop interface, then k6 passes on startup will call this function to pass the function to call when you want to abort.

Let we know if something isn't clear.