Skip to main content

Tags and Groups

Tags and groups help you organize, filter, and analyze your k6 test metrics. They allow you to segment results by request type, scenario, user flow, or any custom dimension.

Tags

Tags are key-value pairs attached to metrics. They enable filtering and aggregation of test results.

Why Use Tags?

  • Filter metrics - Create thresholds for specific requests or scenarios
  • Organize results - Group related requests together
  • Track metadata - Add context like environment, version, or team
  • Analyze patterns - Identify performance issues by tag dimensions

System Tags

k6 automatically adds system tags to all metrics:

Controlling System Tags

Enable or disable system tags:
Disabling system tags reduces memory usage and metrics cardinality, but limits filtering options.

Custom Tags

Global Tags

Apply tags to all metrics in the test:

Request Tags

Add tags to specific HTTP requests:

Scenario Tags

Tag all metrics from a scenario:

Using Tags in Thresholds

Filter metrics by tags when defining thresholds:
Tag values in threshold expressions are case-sensitive and must match exactly.

Groups

Groups organize requests into logical sections, similar to folders. They help structure test logic and create hierarchical metrics.

Basic Groups

Nested Groups

Create hierarchical organization:
This creates a hierarchy like:

Group Duration Metrics

k6 automatically tracks group duration:

Combining Tags and Groups

Tag and Group Best Practices

  1. Use consistent naming - Establish naming conventions for tags and groups
  2. Avoid high cardinality - Don’t use unique values (like user IDs) as tags
  3. Tag strategically - Add tags that help with analysis and debugging
  4. Group logically - Organize by user flow, API endpoint type, or feature
  5. Limit nesting depth - Keep group hierarchies shallow (2-3 levels max)
  6. Use scenario tags - Tag entire scenarios for easy filtering

Real-World Example

Here’s a complete example combining tags and groups:

Metrics Explorer Integration

Tags enable powerful filtering in metrics backends:

Next Steps