> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/grafana/k6/llms.txt
> Use this file to discover all available pages before exploring further.

# End of Test Summary

> Understanding k6's end-of-test summary output and metrics display

The end-of-test summary provides a comprehensive overview of your test results, displaying key metrics, thresholds, and performance data collected during the test run.

## Overview

When your k6 test completes, a summary is automatically generated and displayed in the console. This summary includes aggregated metrics, threshold results, check failures, and group statistics.

The summary output collects metrics data throughout the test run using a periodic flusher that aggregates samples every 200ms by default.

## Summary Components

### Test Run Duration

The total duration of the test execution, including setup and teardown time.

### Metrics Display

All observed metrics are displayed with their aggregated values:

* **Counter metrics**: Total count and rate per second
* **Gauge metrics**: Current, min, max, and average values
* **Rate metrics**: Percentage of non-zero values
* **Trend metrics**: min, max, avg, med, p(90), p(95), p(99) by default

<Note>
  You can customize which trend statistics are displayed using the `summaryTrendStats` option in your test configuration.
</Note>

### Threshold Results

The summary shows the pass/fail status for each defined threshold:

```javascript theme={null}
export const options = {
  thresholds: {
    'http_req_duration': ['p(95)<500'],
    'http_req_failed': ['rate<0.1'],
  },
};
```

Failed thresholds are highlighted and will cause k6 to exit with a non-zero exit code.

### Check Statistics

For each check in your test, the summary displays:

* Number of passes
* Number of failures
* Pass rate percentage

```javascript theme={null}
import { check } from 'k6';

export default function () {
  const res = http.get('https://test.k6.io');
  check(res, {
    'status is 200': (r) => r.status === 200,
  });
}
```

### Group Metrics

When using groups in your test, the summary can display per-group metrics depending on the summary mode.

## Summary Modes

k6 supports different summary modes that control the level of detail:

### Legacy Mode

The original summary format showing only top-level metrics.

### Compact Mode

A concise summary without group-level details. This is useful for tests with many groups.

### Extended Mode

Displays detailed metrics for each group and scenario, creating a hierarchical view of your test structure.

<Tip>
  Set the summary mode using the `--summary-mode` flag or `K6_SUMMARY_MODE` environment variable.
</Tip>

## Configuration

You can configure summary behavior in your test:

```javascript theme={null}
export const options = {
  summaryTrendStats: ['avg', 'min', 'max', 'p(95)', 'p(99)'],
};
```

## Implementation Details

The summary output (`internal/output/summary/summary.go:22`) implements the `Output` interface and:

1. Collects samples during test execution via `AddMetricSamples()`
2. Stores samples in a data model organized by metrics, groups, and scenarios
3. Tracks check pass/fail counters atomically
4. Generates the final summary structure when `Summary()` is called

<Warning>
  The summary output requires certain system tags to be enabled. Tags like `name`, `method`, `status`, `error`, `check`, and `group` are necessary for full functionality.
</Warning>

## Scenario-Based Summaries

When using multiple scenarios, the summary groups metrics by scenario name, allowing you to analyze performance for each scenario independently.

```javascript theme={null}
export const options = {
  scenarios: {
    smoke: {
      executor: 'constant-vus',
      vus: 10,
      duration: '30s',
    },
    stress: {
      executor: 'ramping-vus',
      startVUs: 0,
      stages: [
        { duration: '2m', target: 100 },
      ],
    },
  },
};
```

Each scenario's metrics are displayed separately in the summary output.
