Skip to main content
Tags and groups help you organize k6 test results for better analysis. They let you categorize metrics, filter results, and structure your tests logically.

What are tags?

Tags are key-value pairs attached to metrics, checks, and requests. They enable you to:
  • Filter metrics by request type, endpoint, or custom criteria
  • Set thresholds for specific tagged metrics
  • Analyze results by different dimensions
  • Compare performance across different parts of your test
k6 provides two types of tags:

System tags

Automatically added by k6Examples: status, method, url

User-defined tags

Custom tags you add to your testExamples: endpoint, type, priority

System tags

k6 automatically tags metrics with system-defined metadata:

Optional system tags

These tags are disabled by default but can be enabled: Enable them using the systemTags option:

User-defined tags

Add custom tags to requests, checks, and metrics:

Tag HTTP requests

Tag checks

Tag custom metrics

Test-wide tags

Set tags that apply to all metrics in your test:
Test-wide tags are useful for:
  • Comparing results across test runs
  • Filtering results in monitoring systems
  • Organizing tests by environment or team

Thresholds on tagged metrics

Set different thresholds for different tagged requests:
This allows different performance requirements for different request types.

Groups

Groups organize test code into logical sections and automatically tag all operations within them.

Basic groups

All requests within a group are automatically tagged with group tag.

Nested groups

Groups can be nested for hierarchical organization:
The group tag shows the full path: ::user workflow::login

Group duration metric

k6 automatically creates a group_duration metric for each group:

Dynamic tags from code

Set tags dynamically during test execution:

Tagging stages

Use helper functions to tag operations by their test stage:

Complete example

Here’s a comprehensive example using tags and groups:

Best practices

Use descriptive tag names

Make tag names clear and consistent across your tests.

Tag by request type

Separate API, static content, and other request types with tags.

Group logical workflows

Use groups to organize user journeys and workflows.

Set thresholds per tag

Define different performance requirements for different request types.
Avoid one group per request. Wrapping every request in a group adds unnecessary complexity. Use groups for logical sections, not individual requests.