cli-diagnostics

Edge Diagnostics CLI (Beta)

Get started with the Edge Diagnostics CLI

Use the Edge Diagnostics CLI to identify, analyze, and troubleshoot common content delivery network issues that your users may encounter.

NOTE: This CLI is based on the Edge Diagnostics API. The previous version, the Diagnostic Tools CLI, is now deprecated and will be discontinued on September 30, 2022. We encourage you to migrate to this new Edge Diagnostics CLI to avoid any inconvenience after the discontinuation of the Diagnostic Tools CLI.

Install Edge Diagnostics CLI

There are three ways in which you can install the CLI.

To install this CLI, you need the Akamai CLI package manager. Once you install the Akamai CLI, run this command:

akamai install diagnostics

Stay up to date

To make sure you always use the latest version of the CLI, run this command:

akamai update diagnostics

Install and execute from binaries

Follow the instructions for your operating system.

Linux and macOS

Once you download the appropriate binary for your system, make it executable, and make it available in your $PATH. Run the following commands:

$ chmod +x ~/Downloads/akamai-diagnostics-<VERSION>-<PLATFORM>
$ mv ~/Downloads/akamai-diagnostics-<VERSION>-<PLATFORM> /usr/local/bin/akamai-diagnostics

Windows

Once you download the appropriate binary for your system, rename the binary to akamai-diagnostics.exe, and add the binary location to the PATH variable.

Execute the binaries To execute the binaries, run akamai-diagnostics [COMMAND] where COMMAND is any command from the list of available commands.

Examples:

Compile from Source

Prerequisite: Make sure you install Go 1.17 or later.

To compile Edge Diagnostics CLI from source:

  1. Change the working directory:

     $ cd $GOPATH
    
  2. Fetch the package:

     $ git clone https://github.com/akamai/cli-diagnostics.git
    
  3. Go to the package directory:

    $ cd cli-diagnostics
    
  4. Compile the binary:

  1. Move the akamai-diagnostics or akamai-diagnostics.exe binary so that it’s available in your $PATH.

  2. To run any command

     $ akamai-diagnostics [COMMAND]
    

Work with multiple accounts

To diagnose an issue, you may need to switch between different accounts. To do this, run the required operation with the --account-key flag followed by the account ID of your choice.

For example: akamai diagnostics --account-key 1-1TJZFB ipa-hostnames

API credentials

The Edge Diagnostics CLI requires your authentication credentials to execute any command. To create your credentials, see Create a quick API client. You can provide these API credentials to the CLI in two ways, either through the .edgerc file or by setting the environment variables.

Using the .edgerc file

Akamai-branded packages use an .edgerc file for standard EdgeGrid authentication. To set up your .edgerc file, see Add credential to .edgerc file. We recommend to change the default header name in the .edgerc file to diagnostics.

Setting environment variables

You can set these environment variables to provide your API credentials:

Make sure that the environment variable AKAMAI_EDGERC_SECTION is set to diagnostics.

JSON support

Instead of creating requests directly in CLI, you can request to run a command on a specific JSON file.

For example, instead of such MTR command: akamai diagnostics mtr --source bangalore-india --destination www.akamai.com --ip-version IPv4 --port 443 --packet-type ICMP

You can run akamai diagnostics mtr < mtr_data_file.json command. Where the JSON file has all the required data for the MTR request.

To create a valid JSON file, refer to the example JSON file for an operation.

Operation categories

Check these descriptions to learn more about the available categories of tools and tools they include.

Available operations and commands

Check available commands and options

The help command returns a list of available commands and flags with their descriptions.

Command: help [COMMAND] where COMMAND is the command you need help with.

Examples:

List edge server locations

The edge-locations command lists active edge server locations you can use to run Request content with cURL, Get domain details with dig, Test network connectivity with MTR,Run the URL health check, Run the Connectivity problems scenario and Run the Content problems scenario operations.

Command: edge-locations [--search REGION] where the --search flag filters edge server locations for a particular REGION. This flag is optional.

Examples:

Expected output: The response includes locations of active edge servers you can run curl, dig, mtr, url-health-check, connectivity-problem and content-problem commands. For more details, you can check the API response description.

List GTM hostnames

The gtm-hostnames command lists GTM properties you have access to. You can also request their test IPs and target IPs or hostnames. The returned values can be used to run Get domain details with dig and Test network connectivity with MTR operations for a GTM hostname.

Command: gtm-hostnames [--test-target-ip GTM_HOSTNAME] where the --test-target-ip flag requests the test IPs and target IPs or hostnames for a GTM_HOSTNAME. This flag is optional.

Examples:

Expected output: The response includes all GTM properties you have access to and can run dig and mtr commands for. For more details, you can check the API response description.

List IP Acceleration hostnames

The ipa-hostnames command lists IP Acceleration (IPA) hostnames you have access to and can generate a diagnostic link to collect diagnostic data for.

Command: ipa-hostnames

Examples: akamai diagnostics ipa-hostnames

Expected output: The response includes all IPA hostnames you can gather diagnostic data for.

The user-diagnostics create command generates a diagnostic link for you to share with users of a particular URL or IP Acceleration (IPA) hostname experiencing similar issues. Each link is valid for 7 days or 50 submissions. After a user clicks the link, Edge Diagnostics gathers necessary diagnostic data and asks the user to submit them. Once submitted, you can check the collected data with the Get collected diagnostic data operation. To get the list of IPA hostnames you can create the diagnostic link for, run the List IP Acceleration hostnames operation.

Command:

Where:

Examples:

Expected output: The response includes the link you can send to users experiencing issues with the hostname. When a user clicks the link, Edge Diagnostics gathers necessary data and asks the user to submit them. The response includes also link_id you can use to get collected diagnostic data.

The user-diagnostics list command lists generated diagnostic links used to collect user diagnostic data for hostnames experiencing issues. It also lists the number of data submitted with each link.

Command: user-diagnostics list [--url URL] [--user USER] [--active], where:

All three filters are optional and can be used together.

Examples:

Expected output: The response is the list with an overview of created diagnostic links. To get the details of a specific link and collected data, run the Get collected diagnostic data operation using the returned link_id.

Get collected diagnostic data

The user-diagnostics get command returns diagnostic data submitted by users using a diagnostic link with a specific ID.

Command: user-diagnostics get LINK_ID [--mtr] [--dig] [--curl], where:

The --mtr, --dig, and curl flags are optional and can be used together.

Examples:

Expected output: The response includes a table with the collected data. For more details, you can check the API response description.

Translate an error string

The translate-error-string command fetches summary and logs for an error with a specific reference code. You can also translate any Global Request Number (GRN) generated by Property Manager’s Global Request Number behavior. Data is available from either the last 6 or 24 hours depending on the server and traffic conditions.

Command: translate-error-string ERROR_STRING [--trace-forward-logs], where :

Examples:

Expected outcome: The response includes the error translation in the JSON format. For more details, you can check the API response description.

Verify an IP

The verify-ip command checks whether a specific IP address belongs to an edge server.

Command: verify-ip IP_ADDRESS ... where IP_ADDRESS is the IP address you want to verify. You can enter up to 10 values.

Examples:

Expected output: The response notes whether the IP address is for an edge server.

Locate an IP network

The locate-ip command provides network geolocation and details for an edge server IP address.

Command: locate-ip IP_ADDRESS ... where IP_ADDRESS is the IP address you want to get the data for. You can enter up to 10 values.

Examples:

Expected output: The response includes network geolocation data for a network of the IP address. For more details, you can check the API response description.

Verify an IP and locate its network

The verify-locate-ip command verifies if an IP address belongs to an edge server and gets geolocation data for its network.

Command: verify-locate-ip IP_ADDRESS where IP_ADDRESS is the IP address you want to get the data for.

Examples:

Expected output: The response includes the IP’s geographic and network location data. For more details, you can check the API response description.

Translate an Akamaized URL

The translate-url command provides basic information about an Akamaized URL, such as typecode, cache key hostname, CP code, serial number, and TTL. A URL becomes an Akamaized URL (ARL) once it’s on an edge server.

Command: translate-url URL, where URL is the fully qualified, Akamaized URL you want to get the details of.

Examples:

Expected outcome: The response includes details about the requested ARL. For more details, you can check the API response description.

Get error statistics

The estats command provides statistics of errors happening for a URL or a content provider (CP) code’s traffic. The tool also returns logs for the edge server response to a client and the edge server forward request to an origin server, and error details. Error data returned is based on a nine-second traffic sample from the last two minutes.

Command:

Where:

The --logs, --edge-errors, and --origin-errors flags are optional and can be used together.

Examples:

Expected outcome: The response includes error statistics in the JSON format. For more details, you can check the API response description.

Get logs

The grep command uses GREP to fetch log lines from an IP address within the Akamai network. You can use parameters to filter the data. Logs provide low-level details on how each request was handled. You can use this information to troubleshoot caching and performance issues, and to ensure the correct Akamai features were applied to the traffic. Data is available from either the last 6 or 24 hours depending on the server and traffic conditions.

Command:

Where:

Examples:

Expected outcome: The response includes a standard grep response in the JSON format. For more details, you can check the API response description.

Request content with cURL

The curl command requests content to provide the raw HTML for a URL, including response headers. You can run this operation either for a specific location or an edge IP.

Command:

Where:

If you don’t provide neither --client-location nor --edge-server-ip, Edge Diagnostics will run the curl command using a random location.

Examples:

Expected outcome: The response includes the curl response. For more details, you can check the API response description.

Get domain details with dig

The dig command provides DNS details for a hostname or a domain name, or a GTM hostname. The results may help you diagnose issues with domain name resolutions. You can run this operation either for a specific location or an edge IP.

Command:

Where:

If you don’t provide neither --client-location nor --edge-server-ip, Edge Diagnostics will run the dig command using a random location.

Examples:

Expected outcome: The response includes a standard dig response. For more details, you can check the API response description.

Test network connectivity with MTR

The mtr command provides information about the packets loss and latency between an edge server IP address or location and a remote destination. You can run this operation also for a GTM hostname.

Command:

Where:

Examples:

Expected outcome: The response includes a standard mtr response. For more details, you can check the API response description.

Run the URL health check

The url-health-check command simultaneously runs Translate an Akamaized URL, Request content with cURL, Get domain details with dig, Test network connectivity with MTR, and Get logs operations for a URL.

Command: url-health-check URL [--client-location LOCATION] [--edge-server-ip EDGE_SERVER_IP] [--ip-version IPv4|IPv6] [--port 80|443] [--packet-type TCP|ICMP] [--request-header REQUEST_HEADER...] [-q QUERY_TYPE] [--run-from-site-shield-map] [--logs] [--network-connectivity], where:

The --edge-server-ip, --ip-version, --port, --packet-type, --request-header, --query-type, --logs, and --network-connectivity flags are optional.

Examples:

Expected outcome: The response includes grep, dig, curl, mtr, and translate-url details for the URL in the JSON format. For more details, you can check the API response description.

Run the Connectivity problems scenario

The connectivity-problem command simultaneously runs Request content with cURL, Test network connectivity with MTR, and Get logs operations for a URL.

Command: connectivity-problem URL [--client-location LOCATION] [--edge-server-ip EDGE_SERVER_IP] [--client-ip CLIENT_IP] [--request-header REQUEST_HEADER...] [--ip-version IPv4|IPv6] [--port 80|443] [--packet-type TCP|ICMP] [--run-from-site-shield-map], where:

The --edge-server-ip, --client-ip, --ip-version, --port, --packet-type, --request-header, and --run-from-site-shield-map flags are optional.

Examples:

Expected outcome: The response includes grep, curl, and mtr details for the URL in the JSON format. For more details, you can check the API response description.

Run the Content problems scenario

The content-problem command simultaneously runs Request content with cURL and Get logs operations for a URL.

Command: content-problem URL [--client-location LOCATION] [--edge-server-ip EDGE_SERVER_IP] [--request-header REQUEST_HEADER...] [--ip-version IP_VERSION] [--run-from-site-shield-map], where:

The --edge-server-ip, --request-header, and --run-from-site-shield-map flags are optional.

Examples:

Expected outcome: The response includes grep and curl details for the URL in the JSON format. For more details, you can check the API response description.

Available flags

You can use the following flags with all the listed commands.

edgerc

Use the --edgerc flag to provide a new location of .edgerc file. This file contains the API credentials required to run all commands.

The CLI takes the default value of the --edgerc flag from the AKAMAI_EDGERC environment variable. If the variable is not set, then the CLI uses your home directory:

Command: To add the --edgerc flag to a specific command: $akamai diagnostics --edgerc EDGERC_PATH [command], where EDGERC_PATH is the new path to the file.

Example: $akamai diagnostics --edgerc "/Users/new_user/Downloads/.edgerc" edge-locations

section

Use the --section flag to provide a new section name. The section name specifies which section of API credentials to read from the .edgerc file. The CLI takes the default value of the --section flag from the AKAMAI_EDGERC_SECTION environment variable. If the variable is not set, then the CLI uses diagnostics as the section name.

Command: To add the --section flag to a specific command:$akamai diagnostics --section SECTION_NAME [command], where SECTION_NAME is the new section name.

Example: $akamai diagnostics --section default gtm-hostnames

help

The --help flag returns help for a command.

version

The --version flag returns the version.

json

The --json flag returns the information in JSON format. You can also set this flag to be true always by setting the environment variable AKAMAI_OUTPUT_JSON to true.

Exit codes

When you complete an operation, the CLI generates one of these exit codes:

Windows 10 2018 version

If you’re using Windows 10, 2018 version and you’re having problems running the Edge Diagnostics CLI, we recommend you try the following work-around. In the downloaded repository, add the .exe suffix to the akamai-diagnostics executable file.

Notice

Copyright © 2022 Akamai Technologies, Inc.

Your use of Akamai’s products and services is subject to the terms and provisions outlined in Akamai’s legal policies.