---
title: "Verify your thresholds are CI-ready | Grafana Labs"
description: "Confirm your k6 script has meaningful thresholds that produce the correct exit codes for pipeline automation."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Verify your thresholds are CI-ready

Before you connect k6 to a pipeline, confirm that your thresholds behave as gates. A threshold that passes means the deploy is acceptable. A threshold that fails means k6 returns a non-zero exit code, which the pipeline interprets as a failure. If your thresholds are too loose, every deploy passes regardless of performance. If you have no thresholds at all, k6 always exits with code `0` and the gate is meaningless.

To verify your thresholds are CI-ready, complete the following steps:

1. Open your k6 test script in your code editor and check the `thresholds` section in the `options` block. You should have at least one threshold defined. For example:
   
   JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```javascript
   export const options = {
     thresholds: {
       http_req_duration: ['p(95)<500'],
       http_req_failed: ['rate<0.01'],
     },
   };
   ```
   
   If your script doesn’t have thresholds, add them now. At minimum, include a latency threshold (`http_req_duration`) and an error rate threshold (`http_req_failed`).
2. Run your test and confirm it passes with exit code `0`:
   
   Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```bash
   k6 run test.js
   echo $?
   ```
   
   The output of `echo $?` should be `0`, meaning all thresholds passed. If the thresholds failed, adjust either your thresholds or your test target so you have a known-passing state.
3. Temporarily tighten a threshold to force a failure. For example, change the latency threshold to an impossibly low value:
   
   JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```javascript
   thresholds: {
     http_req_duration: ['p(95)<1'],
     http_req_failed: ['rate<0.01'],
   },
   ```
4. Run the test again and confirm it fails with a non-zero exit code:
   
   Bash ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```bash
   k6 run test.js
   echo $?
   ```
   
   The exit code should be non-zero (for threshold failures, k6 commonly returns `99`). k6 prints which thresholds were breached in the end-of-test summary. This is the signal your pipeline uses to block a deploy.
5. Revert the threshold to its original value so the test passes again.

> **Tip:** Good CI thresholds are based on your actual performance baseline, not arbitrary numbers. If you’ve established a performance baseline, use the p95 latency and error rate from your baseline runs as starting points. To learn more, refer to [Establish a performance baseline with k6](/docs/learning-paths/establish-k6-baseline/) and [Load test types](/docs/k6/latest/testing-guides/test-types/).

In the next milestone, you parameterize your script so it can run against any environment without code changes.
