Traffic Processing with Plugins
Understanding Stacks and Plugins
In Qtap's configuration, traffic processing is organized using two key concepts:
Stacks: Named collections of plugins that work together to process traffic
Plugins: Individual components that perform specific functions on captured traffic
This structure allows you to create different processing configurations for different types of traffic.
Stack Configuration
Stacks are defined in the stacks
section of your qpoint.yaml
file. Each stack has a unique name and contains one or more plugins:
You can create multiple stacks for different purposes, each with its own set of plugins and configurations.
Available Plugins
Qtap includes several plugins that provide different processing capabilities.
Access Logs Plugin
The access_logs
plugin provides formatted logging of HTTP traffic. This is the preferred plugin for most use cases and replaces the older debug plugin.
Basic Configuration
Mode Options
summary
: Basic information (method, path, status code)details
: Includes headers and timing informationfull
: Complete information including request/response bodies
Example with Rules
This configuration:
Uses summary mode by default
Applies details mode to
api.example.com
trafficCaptures full details for any response with a status code ≥ 400
Error Detection Plugin
Note: While still supported, this plugin is being phased out in favor of the more flexible access_logs plugin with rules.
The detect_errors
plugin captures detailed information when responses meet specific error criteria.
Status codes can be specified as:
Individual codes:
'404'
,'500'
Code ranges:
'4xx'
,'5xx'
Debug Plugin
Note: This plugin is deprecated. Consider using the access_logs plugin instead.
The debug
plugin provides basic logging of HTTP traffic:
Rule Expressions in the Access Logs Plugin
The access_logs
plugin is the only plugin that supports rule expressions, allowing you to selectively apply different logging modes based on request and response characteristics.
Expression Syntax
Rule expressions follow a straightforward pattern:
Multiple conditions can be combined using logical operators:
Available Fields for Rule Expressions
Based on the HeaderMap RulePairs, the following fields are available:
Request Fields
request.method
request.method == "POST"
request.path
request.path contains "/api/"
request.host
request.host == "api.example.com"
request.url
request.url contains "search"
request.header.<name>
request.header.content-type == "application/json"
Response Fields
response.status
response.status >= 400
response.host
response.host != "api.example.com"
response.url
response.url contains "redirect"
response.header.<name>
response.header.content-type contains "json"
Operators for Rule Expressions
The expressions support various operators based on the rulekit implementation:
Comparison Operators
==
eq
Equal to
request.method == "GET"
!=
ne
Not equal to
request.host != "internal.example.com"
>
gt
Greater than
response.status > 200
>=
ge
Greater than or equal to
response.status >= 400
<
lt
Less than
response.status < 300
<=
le
Less than or equal to
response.status <= 399
=~
matches
Matches regex pattern
request.path matches /^\/api\/v\d+\//
contains
Contains substring
request.url contains "search"
in
Is contained in array
request.method in ["GET", "HEAD"]
Logical Operators
and
&&
Logical AND
request.method == "POST" and response.status >= 400
or
||
Logical OR
request.path contains "/admin" or request.path contains "/auth"
not
!
Logical NOT
not request.host == "public.example.com"
Value Types
The expressions support various value types:
Boolean:
true
,false
Number: Integer or floating-point values
String: Text enclosed in quotes
Regex Pattern: Patterns enclosed in slashes
/pattern/
or vertical bars|pattern|
Array: Values in square brackets, e.g.,
[value1, value2, value3]
Common Plugin Configurations
Basic Monitoring
Detailed Error Tracking
API-Specific Monitoring
This configuration:
Uses the default_stack for most traffic
Applies the api_stack to traffic matching
api.example.com
Captures detailed information for all API traffic
Records full details for authentication issues
Creating Multiple Stacks
You can create multiple stacks for different traffic types and apply them selectively:
The endpoints
section in the tap
configuration determines which stack is used for which traffic.
Combining Plugins
You can combine multiple plugins in a single stack:
Plugins are processed in the order they appear in the configuration.
Complete Example
This configuration provides:
Basic summary logging for most traffic
Detailed logging for all errors
Specialized handling for
api.example.com
trafficFull logging of API errors
Privacy protection for authentication endpoints
By understanding and utilizing plugins effectively, you can create a configuration that provides the visibility you need while respecting performance and privacy considerations.
Last updated