Description

Capture and store a sequence of requests/responses to a service by observing
network traffic.

Examples

akita apidump --service my-api

Capture all traffic for the service "my-api". The traffic will automatically be assigned to the "default" deployment.

akita apidump --filter "port 80" --out mytracedir

Capture requests/responses going to or coming from port 80 and store them into a directory called mytracedir.

akita apidump --filter "port 80" --out akita://my-service:trace:mytrace

Capture requests/responses going to or coming from port 80 and store them into a trace on the Akita cloud called mytrace.

akita apidump --filter "port 80" -c ./my_tests.sh -u ${USER}

Run my_tests.sh as ${USER} and capture requests/responses going to or coming from port 80. Akita will automatically terminate once the script finishes.

Required Flags

--out location or --service name

The location to store the trace. Can be an AkitaURI or a local directory.

When specifying a local directory, Akita writes HAR files to the directory.

When specifying an AkitaURI, the format is akita://{SERVICE}:trace:{NAME}, where SERVICE is the name of your service and NAME is the name of the trace on Akita Cloud where the collected data is stored.

If you provide a service name, a trace is automatically created.

Optional Flags

--deployment string

Specify a deployment name such as "production" or "staging" that distinguishes this trace from others within the same Akita project. If you do not specify a deployment name, "default" will be used.

--filter string

Used to match packets going to and coming from your API service.

For example, to match packets destined/originated from port 80, you would set --filter="port 80".

The syntax follows BPF syntax (man 7 pcap-filter). See Packet Filters for Customizing Capture

This filter is applied uniformly across all network interfaces, as set by --interfaces flag.

--interfaces []string

List of network interfaces to listen on (e.g. "lo" or "eth0").

You may specify a comma separated string (e.g. --interfaces lo,eth0) or multiple separate flags (e.g. --interfaces lo --interfaces eth0).

If not set, defaults to all interfaces on the host.

--rate-limit number

Set the maximum number of HTTP request/response pairs to collect per minute. If the number of samples exceeds this amount, the CLI will randomly sample events, and send only the specified number to the Akita cloud.

--sample-rate number

A number between [0.0, 1.0] to control sampling. Deprecated; use --rate-limit instead.

--tags []string

Adds tags to the dump.

You may specify a comma separated list of "key=value" pairs (e.g. --tags a=b,c=d) or multiple separate flags (e.g. --tags a=b --tags c=d)

--command, -c string

A command that generates requests and responses for Akita to observe. Akita will execute the command (similar to bash -c) and automatically terminate when the command finishes, without needing to receive a SIGINT.

By default, the command runs as the current user. As a safety precaution, if the current user is root, you must use the -u flag to explicitly indicate that you want to run as root.

--user, -u string

Username of the user to use when running the command specified in -c

--path-exclusions []string

Removes HTTP paths matching regular expressions.

For example, to filter out requests fetching files with png or jpg extensions, you can specify --path-exclusions ".*\.png" --path-exclusions ".*\.jpg"

--host-exclusions []string

Removes HTTP requests whose host URL matches any one of the given regular expressions.

--path-allow []string

Only capture HTTP requests whose whose URL path matches any one of the given regular expressions.

--host-allow []string

Only capture HTTP requests whose whose URL host matches any one of the given regular expressions.

--append-by-tag

Append the captured network traffic to the most recent trace matching the tag given in the --tags argument. Only one tag is currently supported. If no trace matches the given tag, one will be created.

Diagnostic output (version 0.12.1 and later)

If the packet capture fails to see any HTTP requests or responses, the CLI will emit one of the following warning messages:

Did not capture any TCP packets matching the filter: There were TCP packets observed, but not matching the filter that you specified. This may mean that you used an incorrect port number, or other mistake in the --filter argument.

Did not capture any TCP packets during the trace: No TCP packets were observed at all. This could occur if you specify an --interface argument other than the one that has API traffic, or if the test did not generate any network traffic.

Captured MMM TCP packets total; NNN unparsed TCP segments: The capture contains TCP streams matching the filter, but they could not be recognized as HTTP. A common reason is that they were encrypted HTTPS instead, and must be captured using a proxy or browser instead. Or, it could be that the traffic is another protocol not yet supported.

To see more details about the packet capture process, and accumulated counters, run akita with the --debug flag.


Did this page help you?