Record HTTP traffic
The Envoy Tap filter allows to interpose on and record HTTP traffic that the Microgateway receives. For further details, see official Envoy Tap filter documentation.
Airlock Microgateway allows adding additional Envoy filters in the CR EnvoyHTTPFilter.
Steps for SidecarGateway
Tap filter configuration
- Create a CR EnvoyHTTPFilter with a Tap filter configuration.
- Reference the CR EnvoyHTTPFilter in the CR SidecarGateway.
Example SidecarGateway:
- Example
apiVersion: microgateway.airlock.com/v1alpha1 kind: SidecarGateway metadata: name: sidecar-gateway-example spec: ... applications: - containerPort: 8080 ... envoyHTTPFilterRefs: prepend: - name: tap-filter
- Configure a port forwarding for the Envoy Administration interface as described in Envoy Administration interface. The standard port of the interface is port
19000
. - Run the following CURL command to tap into the traffic.
- Notice
- The
config_id
value in the CURL command must match theconfig_id
value configured in the CR EnvoyHTTPFilter. - With this config, all requests up to a size of
100000
bytes are recorded in JSON format. - The documented CURL command uses a configuration to record all requests. To record specific requests, create your
match_config
. For more information refer to official Envoy Tap filter documentation.
- The
- The tapped traffic arriving at the Microgateway is output to the console. Consider writing the output to a file, as the output can generate a considerable amount of data.
Steps for K8s Gateway API
Tap filter configuration
- Create a CR EnvoyHTTPFilter with a Tap filter configuration.
- Create a CR EnvoyExtensionPolicy and refer to the desired HTTPRoute. Reference the CR EnvoyHTTPFilter.
Example EnvoyExtensionPolicy:
- Notice
The Gateway of the targeted HTTPRoutes must be configured to allow EnvoyExtensionPolicy in its GatewayParameters or this Policy will have no effect.
Set
spec.features.envoyExtensionPolicyEnabled: true
in the CR GatewayParameters of the Gateway of the targeted HTTPRoute. - Configure a port forwarding for the Envoy Administration interface as described in Envoy Administration interface. The standard port of the interface is port
19000
. - Run the following CURL command to tap into the traffic.
- Notice
- The
config_id
value in the CURL command must match theconfig_id
value configured in the CR EnvoyHTTPFilter. - With this config, all requests up to a size of
100000
bytes are recorded in JSON format. - The documented CURL command uses a configuration to record all requests. To record specific requests, create your
match_config
. For more information refer to official Envoy Tap filter documentation.
- The
- The tapped traffic arriving at the Microgateway is output to the console. Consider writing the output to a file, as the output can generate a considerable amount of data.
Analyze the tapped traffic
- Run the CURL command and write the output to a file.
Example to save the tapped traffic in a file:
- Analyze the JSON file with jq
Example to analyze with jq:
Example output
- Example
{"method":"GET","host":"nextcloud-127-0-0-1.nip.io","path":"/status.php","status":200,"req_bytes":4,"resp_bytes":170} {"method":"PUT","host":"nextcloud-127-0-0-1.nip.io","path":"/ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json","status":200,"req_bytes":19,"resp_bytes":223} {"method":"GET","host":"nextcloud-127-0-0-1.nip.io","path":"/apps/dashboard/","status":200,"req_bytes":4,"resp_bytes":1024} {"method":"GET","host":"nextcloud-127-0-0-1.nip.io","path":"/ocs/v2.php/apps/dashboard/api/v1/widgets","status":200,"req_bytes":4,"resp_bytes":1024} {"method":"PROPFIND","host":"nextcloud-127-0-0-1.nip.io","path":"/remote.php/dav/files/admin/","status":207,"req_bytes":566,"resp_bytes":1024} {"method":"GET","host":"nextcloud-127-0-0-1.nip.io","path":"/ocs/v2.php/apps/recommendations/api/v1/recommendations/always","status":200,"req_bytes":4,"resp_bytes":1024}
Further information and links
External links: