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: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:Group Duration Metrics
k6 automatically tracks group duration:Combining Tags and Groups
Tag and Group Best Practices
- Use consistent naming - Establish naming conventions for tags and groups
- Avoid high cardinality - Don’t use unique values (like user IDs) as tags
- Tag strategically - Add tags that help with analysis and debugging
- Group logically - Organize by user flow, API endpoint type, or feature
- Limit nesting depth - Keep group hierarchies shallow (2-3 levels max)
- 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
- Review Test Options for configuration
- Learn about HTTP Requests for making API calls
- Explore Scenarios for advanced test patterns