### Install Akamai CLI Diagnostics Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/README.md Install the Akamai CLI Diagnostics tool using the Akamai CLI or by manually downloading and installing the binary. ```bash # Install via Akamai CLI (recommended) akamai install diagnostics # Or download binary and install manually chmod +x akamai-diagnostics-* sudo mv akamai-diagnostics-* /usr/local/bin/akamai-diagnostics ``` -------------------------------- ### Example MTR Command (CLI) Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md An example of how to run an MTR (My Traceroute) command directly via the CLI with all parameters specified. ```bash akamai diagnostics mtr --source bangalore-india --destination www.akamai.com --ip-version IPv4 --port 443 --packet-type ICMP ``` -------------------------------- ### ContentProblems Request Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Example of how to construct and use the ContentProblems function with a specific request, including URL and edge location. ```go request := internal.ContentProblemsRequest{ Url: "http://www.example.com", EdgeLocationId: "bangalore-india", } svc.ContentProblems(request) ``` -------------------------------- ### Single Account CLI Command Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/configuration.md Demonstrates running diagnostic commands after setting up a single account in the .edgerc file. ```bash # Create/edit ~/.edgerc [diagnostics] client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx host = akaa-baseurl-xxxxxxxxxxxxxxxxxxxxxxxx.luna.akamaiapis.net/ access_token = akab-access-token-xxx-xxxxxxxxxxxxxxxx # Run commands akamai diagnostics verify-ip 123.123.123.123 akamai diagnostics edge-locations ``` -------------------------------- ### Start an animated spinner Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/output-utilities.md Starts an animated spinner with a given message. Returns a spinner instance that can be used to stop the spinner later. ```go func StartSpinner(message string) *spinner.Spinner ``` ```go spinner := internal.StartSpinner("Verifying IP addresses...") // Perform async operation response, err := api.VerifyIp(request) internal.StopSpinner(spinner, err == nil) ``` -------------------------------- ### Run Connectivity Problem Scenario with Basic Options Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Execute the connectivity-problem command with a URL and a client location. This is a basic usage example. ```bash akamai diagnostics connectivity-problem http://www.example.com --client-location bangalore-india ``` -------------------------------- ### Multi-Account CLI Command Examples Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/configuration.md Shows how to execute diagnostic commands targeting specific accounts using the --section flag. ```bash # Create/edit ~/.edgerc with multiple sections [diagnostics-prod] client_secret = xxxxxxxxxxxxxxxxxxxxx1 host = akaa-prod-baseurl-xxxxxxxxxxxxxxxxxxxxxx.luna.akamaiapis.net/ access_token = akab-access-token-prod-xxxxxxxxxxxxxx [diagnostics-staging] client_secret = xxxxxxxxxxxxxxxxxxxxx2 host = akaa-staging-baseurl-xxxxxxxxxxxxxxxxxx.luna.akamaiapis.net/ access_token = akab-access-token-staging-xxxxxxxxxx # Run commands with different sections akamai diagnostics --section diagnostics-prod verify-ip 123.123.123.123 akamai diagnostics --section diagnostics-staging verify-ip 123.123.123.123 ``` -------------------------------- ### List Diagnostic Links Request Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Example of a GET request to list diagnostic groups, with optional filtering by URL and active status. ```http GET /edge-diagnostics/v1/user-diagnostic-data/groups?url=https://www.example.com&activeOnly=true ``` -------------------------------- ### GtmTestTargetIp Go Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Retrieves and displays test target IPs for a GTM property and domain. Use this to verify GTM configurations. ```go svc.GtmTestTargetIp("www-origin", "example.20000puzzles.akadns.net") ``` -------------------------------- ### ConnectivityProblems Go Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Runs a connectivity problem diagnosis scenario and displays results. Use this to identify and troubleshoot network connectivity issues. ```go request := internal.ConnectivityProblemsRequest{ Url: "http://www.example.com", EdgeLocationId: "bangalore-india", } svc.ConnectivityProblems(request) ``` -------------------------------- ### StartSpinner Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/output-utilities.md Starts an animated spinner with a message to indicate ongoing processes. ```APIDOC ## Spinner Display ### StartSpinner Starts an animated spinner with a message while waiting for async operations. #### Parameters - **message** (string) - Required - Message to display next to spinner #### Returns - **`*spinner.Spinner`** - Spinner instance to stop later #### Example ```go spinner := internal.StartSpinner("Verifying IP addresses...") // Perform async operation response, err := api.VerifyIp(request) internal.StopSpinner(spinner, err == nil) ``` ``` -------------------------------- ### Mtr Go Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Performs My Traceroute analysis and displays hop-by-hop routing data. Useful for diagnosing network path issues. ```go request := internal.MtrRequest{ Source: "bangalore-india", Destination: "www.example.com", PacketType: "TCP", } svc.Mtr(request) ``` -------------------------------- ### Grep Go Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Searches edge logs and displays matching log entries. Useful for debugging specific requests or traffic patterns. ```go request := internal.GrepRequest{ EdgeIp: "123.123.123.123", LogType: "EDGE", Start: "2021-01-01T01:00:00.000Z", End: "2021-01-01T01:30:00.000Z", Hostnames: []string{"www.akamai.com"}, } svc.Grep(request) ``` -------------------------------- ### Install Edge Diagnostics CLI using Akamai CLI Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Installs the Edge Diagnostics CLI using the Akamai CLI package manager. Ensure you have the Akamai CLI installed first. ```bash akamai install diagnostics ``` -------------------------------- ### Example: Verify IP Address Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Verifies the reachability and configuration of a specific IP address using the Edge Diagnostics CLI. ```bash akamai-diagnostics verify-ip 123.123.123.123 ``` -------------------------------- ### Example: Perform a Dig Query Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Performs a DNS lookup (dig) for a given hostname using the Edge Diagnostics CLI. ```bash akamai-diagnostics dig --hostname www.example.com ``` -------------------------------- ### Get Diagnostic Records Request Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Example GET request to retrieve diagnostic records for a specific link. Query parameters can be used to include MTR, dig, and curl data. ```http GET /edge-diagnostics/v1/user-diagnostic-data/groups/abc123def456/records?includeMtr=true&includeDig=true&includeCurl=true ``` -------------------------------- ### Get Help for a Command Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Use the --help flag to display help information for any Akamai CLI diagnostics command. ```bash $akamai diagnostics --help [command] ``` -------------------------------- ### Custom Credentials Location CLI Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/configuration.md Demonstrates using a custom path for the .edgerc file via the --edgerc flag or the AKAMAI_EDGERC environment variable. ```bash # Store credentials in custom location mkdir -p /etc/akamai cp ~/.edgerc /etc/akamai/.edgerc chmod 600 /etc/akamai/.edgerc # Use with CLI akamai diagnostics --edgerc /etc/akamai/.edgerc verify-ip 123.123.123.123 # Or set environment variable export AKAMAI_EDGERC=/etc/akamai/.edgerc akamai diagnostics verify-ip 123.123.123.123 ``` -------------------------------- ### Get CLI Version Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Use the --version flag to retrieve the current version of the Akamai CLI. ```bash $akamai --version ``` -------------------------------- ### Curl Go Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Executes a curl request from an edge server and displays response details. Use this to test HTTP requests to your endpoints. ```go request := internal.CurlRequest{ Url: "http://www.example.com", EdgeLocationId: "bangalore-india", } svc.Curl(request) ``` -------------------------------- ### Build Akamai CLI Diagnostics from Source Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/README.md Instructions for building the Akamai CLI Diagnostics tool from its source code using Go. This involves getting the package and running the build command. ```bash go get github.com/akamai/cli-diagnostics cd $GOPATH/src/github.com/akamai/cli-diagnostics go build -o akamai-diagnostics ``` -------------------------------- ### Estats Go Example Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Retrieves error statistics and displays aggregated performance data. Use this to identify and analyze errors on your Akamai delivery. ```go request := internal.EstatsRequest{ Url: "https://www.example.com", ErrorType: "EDGE", } svc.Estats(request) ``` -------------------------------- ### Handle Network Connection Errors in Go Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md This example demonstrates how to catch and handle general network connectivity failures, such as unreachable networks or DNS issues. It uses the client's Do method and ensures the CLI exits with a standard error code. ```go resp, err := client.Do(req) if err != nil { Abort(err.Error(), CliErrExitCode) } ``` -------------------------------- ### Example 404 Not Found Error JSON Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Presents the JSON format for a 404 Not Found error, typically indicating that a requested resource does not exist. ```json { "type": "https://api.akamai.com/docs/errors/not-found", "title": "Not Found", "status": 404, "detail": "Diagnostic link 'abc123' not found" } ``` -------------------------------- ### Run Dig for GTM Hostname Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Diagnose GTM hostnames using the 'dig' command. This example specifies the query type and marks the hostname as GTM. ```bash diagnostics dig --hostname www.akamai.com --client-location bangalore-india --query-type NS --gtm ``` -------------------------------- ### Retrieve Connectivity Problems Results (GET) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves the detailed analysis results for an asynchronous connectivity problem diagnosis. Use the link obtained from ConnectivityProblemsPost. ```go response, err := api.ConnectivityProblemsGet("https://api.akamai.com/edge-diagnostics/v1/connectivity-problems/1111") ``` -------------------------------- ### Run grep for hostname with filters Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Use this command to fetch log lines for a specific hostname, filtering by client IP and HTTP status codes. Ensure the `akamai-cli` is installed and configured. ```bash akamai diagnostics grep 123.123.123.123 "2021-04-13T14:27:06.000Z" "2021-04-13T14:59:06.000Z" --hostname "www.akamai.com" --client-ip "123.123.123.123" --http-status-code "400, 401" -rf ``` -------------------------------- ### Run Connectivity Problem Scenario with Advanced Options Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Execute the connectivity-problem command with a URL and multiple advanced options including client location, edge server IP, client IP, request header, port, packet type, and IP version. This provides a more comprehensive diagnostic setup. ```bash akamai diagnostics connectivity-problem http://www.example.com --client-location bangalore-india --edge-server-ip 123.123.123.123 --client-ip 123.123.123.122 --request-header accept:text/html --port 80 --packet-type TCP --ip-version IPV4 ``` -------------------------------- ### Get Diagnostic Records Response Body (200 OK) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Example response for retrieving diagnostic records. It includes the groupId and an array of record objects, each containing details about the collected data. ```json { "groupId": "abc123def456", "records": [ { "endUserDataId": "record001", "protocol": "HTTP", "userAgent": "Mozilla/5.0...", "createdDate": "2021-01-01T12:00:30Z", "uniqueId": 1, "clientIpv4": { "ip": "203.0.113.1", "ipType": "IPV4" } } ] } ``` -------------------------------- ### List Diagnostic Links Response Body (200 OK) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Example response for listing diagnostic groups. It returns an array of group objects, each containing diagnostic link details. ```json { "groups": [ { "groupId": "abc123def456", "url": "https://www.example.com", "note": "Production test", "createdTime": "2021-01-01T12:00:00Z", "diagnosticLink": "https://diagnostic.akamai.com/abc123def456", "diagnosticLinkStatus": "ACTIVE", "recordCount": 5, "createdBy": "user@example.com" } ] } ``` -------------------------------- ### Chaining Akamai CLI Operations Programmatically Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/README.md Demonstrates chaining Akamai CLI commands to extract specific data programmatically. This example retrieves the ID of the first edge location using JSON output and jq. ```bash # Chain operations akamai diagnostics edge-locations --json | jq '.edgeLocations[0].id' ``` -------------------------------- ### Retrieve Log Search Results Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Example response body when retrieving log search results. It contains a list of logs with details like timestamp, client IP, and HTTP status, along with a legend for log types. ```json { "result": { "logs": [ { "timestamp": "2021-01-01T01:15:30Z", "client_ip": "203.0.113.100", "http_status": "200", "bytes": "1234" } ], "legend": { "logType": { "EDGE": "Edge server log" } } } } ``` -------------------------------- ### Run grep for CP code with filters Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Use this command to fetch log lines for a specific CP code, filtering by client IP and HTTP status codes. Ensure the `akamai-cli` is installed and configured. ```bash akamai diagnostics grep 123.123.123.123 "2021-04-13T14:27:06.000Z" "2021-04-13T14:59:06.000Z" --cp-code 12345 --client-ip "123.123.123.123" --http-status-code "400, 401" -rf ``` -------------------------------- ### Example API Error Response Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Provides an example of a JSON response conforming to the RFC 7807 Problem Statement format. This illustrates the structure and fields expected for API errors, including specific sub-error details. ```json { "type": "https://api.akamai.com/docs/errors/invalid-request", "title": "Invalid Request", "status": 400, "instance": "/edge-diagnostics/v1/verify-edge-ip", "detail": "IP address 'invalid-ip' is not a valid IPv4 or IPv6 address", "errors": [ { "type": "invalid_ipaddress", "title": "Invalid IP Address", "requestField": "ipAddresses", "requestValues": ["invalid-ip"], "detail": "IP address 'invalid-ip' is not a valid IPv4 or IPv6 address" } ] } ``` -------------------------------- ### Validate Grep Command Fields Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/validator.md Validates parameters for the grep (log search) command, including edge IP, start time, and end time. Ensure edge IP is a valid IPv4 or IPv6 address and timestamps are in ISO 8601 format with start time preceding end time. ```go func (v *Validator) ValidateGrepFields(edgeIp, startTime, endTime string, request *GrepRequest) *CliError ``` ```go var request internal.GrepRequest request.LogType = "EDGE" err := validator.ValidateGrepFields( "203.0.113.1", "2021-01-01T01:00:00.000Z", "2021-01-01T01:30:00.000Z", &request, ) ``` -------------------------------- ### Create New Service Instance Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Instantiates a new Service object. Requires an ApiClient, a cobra.Command for localization, and a boolean to determine JSON output format. ```go api := internal.NewApiClient(*eghc) svc := internal.NewService(*api, cmd, false) ``` -------------------------------- ### Get Log Search Results Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves results from a log search request. ```APIDOC ## GET {link} ### Description Retrieves results from a log search request. ### Method GET ### Endpoint {link} ### Response #### Success Response (200 OK) - **result** (object) - - **logs** (array) - - **timestamp** (string) - - **client_ip** (string) - - **http_status** (string) - - **bytes** (string) - - **legend** (object) - - **logType** (object) - - **EDGE** (string) - #### Response Example { "result": { "logs": [ { "timestamp": "2021-01-01T01:15:30Z", "client_ip": "203.0.113.100", "http_status": "200", "bytes": "1234" } ], "legend": { "logType": { "EDGE": "Edge server log" } } } } #### Status Codes - 200 OK - Results available - 202 Accepted - Still processing - 404 Not Found - Request not found ``` -------------------------------- ### Get Error Translation Results Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves results from an asynchronous error translation request. ```APIDOC ## GET {link} ### Description Retrieves results from an asynchronous error translation request (full URL from response above). ### Method GET ### Endpoint {link} ### Response #### Success Response (200 OK) - **executionStatus** (string) - SUCCESS, PENDING, or FAILURE - **result** (object) - The translation result details. - **url** (string) - The original URL. - **httpResponseCode** (int) - The HTTP response code. - **clientIp** (string) - The client IP address. - **connectingIp** (string) - The connecting IP address. - **cpCode** (string) - The CP code. - **epochTime** (int) - The epoch timestamp. - **logs** (array) - An array of log entries. - **description** (string) - Description of the log entry. - **fields** (object) - Additional fields for the log entry. - **rule_id** (string) - The ID of the triggered rule. #### Response Example ```json { "executionStatus": "SUCCESS", "result": { "url": "https://www.example.com/path", "httpResponseCode": 403, "clientIp": "203.0.113.1", "connectingIp": "10.0.0.5", "cpCode": "12345", "epochTime": 1609502400, "logs": [ { "description": "WAF rule triggered", "fields": { "rule_id": "1000001" } } ] } } ``` ### Status Codes - `200 OK` - Results available - `202 Accepted` - Still processing, retry after specified interval - `404 Not Found` - Request not found - `401 Unauthorized` - Invalid credentials ``` -------------------------------- ### Get Error Statistics Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves error statistics and performance metrics for a URL or CP code. ```APIDOC ## POST /edge-diagnostics/v1/estats ### Description Retrieves error statistics and performance metrics for a URL or CP code. ### Method POST ### Endpoint /edge-diagnostics/v1/estats ### Parameters #### Request Body - **url** (string) - No* - URL to get stats for (*one of url or cpCode required) - **cpCode** (int) - No* - CP code to get stats for (*one of url or cpCode required) - **delivery** (string) - No - STANDARD_TLS or ENHANCED_TLS - **errorType** (string) - No - EDGE or ORIGIN ### Request Example { "url": "https://www.example.com", "cpCode": null, "delivery": "STANDARD_TLS", "errorType": "EDGE" } ### Response #### Success Response (200 OK) - **result** (object) - - **edgeHits** (int) - - **edgeErrors** (int) - - **edgeFailurePercentage** (int) - - **edgeStatusCodeDistribution** (array) - - **httpStatus** (int) - - **hits** (int) - - **percentage** (int) - - **topEdgeIpsWithError** (array) - - **edgeIp** (string) - - **httpStatus** (int) - - **hits** (int) - #### Response Example { "result": { "edgeHits": 1000, "edgeErrors": 50, "edgeFailurePercentage": 5, "edgeStatusCodeDistribution": [ { "httpStatus": 200, "hits": 950, "percentage": 95 } ], "topEdgeIpsWithError": [ { "edgeIp": "203.0.113.1", "httpStatus": 500, "hits": 25 } ] } } #### Status Codes - 200 OK - Statistics retrieved successfully - 400 Bad Request - Invalid parameters - 401 Unauthorized - Invalid credentials ``` -------------------------------- ### Get GTM Property Test IPs Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves test target IPs for a specific GTM property. ```APIDOC ## GET /edge-diagnostics/v1/gtm/{property}/{domain}/gtm-property-ips ### Description Retrieves test target IPs for a specific GTM property. ### Method GET ### Endpoint /edge-diagnostics/v1/gtm/{property}/{domain}/gtm-property-ips ### Parameters #### Path Parameters - **property** (string) - Required - GTM property name - **domain** (string) - Required - GTM domain name ### Response #### Success Response (200 OK) - **gtmPropertyIps** (object) - **property** (string) - **domain** (string) - **testIps** ([]string) - Test target IPs - **targets** ([]string) #### Response Example ```json { "gtmPropertyIps": { "property": "www-origin", "domain": "example.20000puzzles.akadns.net", "testIps": ["203.0.113.1", "203.0.113.2"], "targets": ["origin1.example.com", "origin2.example.com"] } } ``` ### Status Codes - `200 OK` - IPs retrieved successfully - `404 Not Found` - Property or domain not found - `401 Unauthorized` - Invalid credentials ``` -------------------------------- ### Initiate Grep Search (POST) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Initiates an asynchronous log search. This is useful for searching logs across specified edge IPs and time ranges. ```go request := internal.GrepRequest{ EdgeIp: "123.123.123.123", LogType: "EDGE", Start: "2021-01-01T01:00:00.000Z", End: "2021-01-01T01:30:00.000Z", Hostnames: []string{"www.akamai.com"}, } response, err := api.GrepPost(request) ``` -------------------------------- ### Initiate Content Problems Diagnosis (POST) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Initiates an asynchronous diagnosis for content-related problems. This is useful for identifying issues with content delivery and accessibility. ```go request := internal.ContentProblemsRequest{ Url: "http://www.example.com", EdgeLocationId: "bangalore-india", IpVersion: "IPV4", } response, err := api.ContentProblemsPost(request) ``` -------------------------------- ### ConnectivityProblemsGet Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves results from an asynchronous connectivity problem diagnosis. This method sends a GET request to a provided link. ```APIDOC ## GET {link}?includeContentResponseBody=true ### Description Retrieves results from an asynchronous connectivity problem diagnosis. ### Method GET ### Endpoint {link}?includeContentResponseBody=true ### Parameters #### Path Parameters - **link** (string) - Required - Full URL link returned by ConnectivityProblemsPost ### Response #### Success Response (200 OK) - **[]byte** - JSON response with detailed connectivity analysis ### Request Example ```go response, err := api.ConnectivityProblemsGet("https://api.akamai.com/edge-diagnostics/v1/connectivity-problems/1111") ``` ``` -------------------------------- ### Compile Binary (Windows) Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Compiles the Edge Diagnostics CLI from source code on Windows. Requires Go 1.17 or later. ```bash go build -o akamai-diagnostics.exe ``` -------------------------------- ### GrepGet Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves results from an asynchronous log search request. This method sends a GET request to a provided link. ```APIDOC ## GET {link} ### Description Retrieves results from an asynchronous log search request. ### Method GET ### Endpoint {link} ### Parameters #### Path Parameters - **link** (string) - Required - Full URL link returned by GrepPost ### Response #### Success Response (200 OK) - **[]byte** - JSON response with log lines and legend ### Request Example ```go response, err := api.GrepGet("https://api.akamai.com/edge-diagnostics/v1/grep/9999") ``` ``` -------------------------------- ### Translate Error (GET) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves results from an asynchronous error translation request using the link provided by TranslateErrorPost. ```go response, err := api.TranslateErrorGet("https://api.akamai.com/edge-diagnostics/v1/error-translator/1234") ``` -------------------------------- ### Initialize EdgeGrid Configuration Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Handles errors during the initialization of EdgeGrid configuration, such as file not found or invalid format. Use this when setting up authentication. ```go config, err := edgegrid.Init(filepath, section) if err != nil { Abort(GetGlobalErrorMessage("initEdgeRc"), CliErrExitCode) } ``` -------------------------------- ### Compile Binary (Unix-based) Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Compiles the Edge Diagnostics CLI from source code on Linux, macOS, and other Unix-like systems. Requires Go 1.17 or later. ```bash go build -o akamai-diagnostics ``` -------------------------------- ### NewService Constructor Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Creates a new Service instance. It takes an ApiClient, a cobra.Command for localization, and a boolean to determine JSON output format. ```APIDOC ## NewService Constructor ### Description Creates a new Service instance. It takes an ApiClient, a cobra.Command for localization, and a boolean to determine JSON output format. ### Signature ```go func NewService(api ApiClient, cmd *cobra.Command, outputAsJson bool) *Service ``` ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters Table | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | api | ApiClient | Yes | API client for making requests | | cmd | *cobra.Command | Yes | Cobra command for message localization | | outputAsJson | bool | Yes | If true, output raw JSON; otherwise format as tables | ### Returns - ** *Service** - A pointer to a new Service instance ### Example ```go api := internal.NewApiClient(*eghc) svc := internal.NewService(*api, cmd, false) ``` ``` -------------------------------- ### Initiate Connectivity Problems Diagnosis (POST) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Initiates an asynchronous diagnosis for connectivity problems. This method is suitable for diagnosing issues related to URL accessibility and network paths. ```go request := internal.ConnectivityProblemsRequest{ Url: "http://www.example.com", EdgeLocationId: "bangalore-india", PacketType: "TCP", Port: 443, } response, err := api.ConnectivityProblemsPost(request) ``` -------------------------------- ### Call Estats API Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves error statistics and performance metrics. Use this method to get insights into edge and origin performance. ```go request := internal.EstatsRequest{ Url: "https://www.example.com", ErrorType: "EDGE", } response, err := api.Estats(request) ``` -------------------------------- ### Create New ApiClient Instance Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Instantiates a new ApiClient using an existing EdgeGridHttpClient. Ensure the HTTP client is configured with EdgeGrid authentication before creating the ApiClient. ```Go eghc := internal.NewEdgeGridHttpClient(edgercPath, section, accountKey) api := internal.NewApiClient(*eghc) ``` -------------------------------- ### CI/CD Pipeline Environment Configuration Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/configuration.md Sets up environment variables for AKAMAI_EDGERC, AKAMAI_EDGERC_SECTION, LOG_LEVEL, and AKAMAI_OUTPUT_JSON for CI/CD integration. ```bash # In CI/CD environment, set credentials via environment export AKAMAI_EDGERC=$CI_HOME/.edgerc export AKAMAI_EDGERC_SECTION=ci export LOG_LEVEL=debug export AKAMAI_OUTPUT_JSON=true # Run diagnostic command akamai diagnostics verify-ip $TEST_IP ``` -------------------------------- ### Capture full request/response with trace logging Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/configuration.md Capture full request and response details by setting LOG_LEVEL to 'trace' and teeing the output to a log file. ```bash LOG_LEVEL=trace akamai diagnostics verify-ip 123.123.123.123 2>&1 | tee diagnostics.log ``` -------------------------------- ### Support JSON Output or Table Formatting Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/output-utilities.md Provides logic to conditionally print output as JSON or format it as a table based on a flag. Use `PrintJsonOutput` for raw JSON and `PrintVerifyIpsResponse` for table-based responses. ```go if outputAsJson { internal.PrintJsonOutput(responseBytes) return } // Otherwise format as table internal.PrintVerifyIpsResponse(parsedResponse, "Failed IPs") ``` -------------------------------- ### List IP Acceleration Hostnames Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Lists all IP Acceleration (IPA) hostnames you have access to, which can be used to generate diagnostic links. ```bash akamai diagnostics ipa-hostnames ``` -------------------------------- ### Make Binary Executable (Linux/macOS) Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Makes the downloaded Edge Diagnostics CLI binary executable on Linux and macOS systems. This is a required step before moving the binary to your PATH. ```bash $chmod +x ~/Downloads/akamai-diagnostics-- ``` -------------------------------- ### Example 401 Unauthorized Error JSON Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Shows the JSON format for a 401 Unauthorized error, indicating invalid or expired authentication credentials. ```json { "type": "https://api.akamai.com/docs/errors/unauthorized", "title": "Unauthorized", "status": 401, "detail": "Authentication credentials are invalid or expired" } ``` -------------------------------- ### Print Success, Error, Warning, and Table Output Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/output-utilities.md Demonstrates the use of utility functions for printing different types of messages and structured data. Use `PrintSuccess` for completion messages, `Abort` for errors, `PrintWarning` for cautionary notes, and `ShowTable` for tabular data. ```go // For success states internal.PrintSuccess("✓ Operation completed\n") // For errors (and exit) internal.Abort("Operation failed", CliErrExitCode) // For warnings internal.PrintWarning("This may take a while...") // For structured data headers := []string{"Field", "Value"} rows := [][]string{ {"Status", "Active"}, } internal.ShowTable(headers, rows) ``` -------------------------------- ### Get URL Health Check Results Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves results from an asynchronous URL health check request. Use the link returned by UrlHealthCheckPost. ```go response, err := api.UrlHealthCheckGet("https://api.akamai.com/edge-diagnostics/v1/url-health-check/5678") ``` -------------------------------- ### Clone Edge Diagnostics CLI Source Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Clones the Edge Diagnostics CLI source code repository from GitHub. Ensure Git is installed and configured. ```bash $git clone https://github.com/akamai/cli-diagnostics.git ``` -------------------------------- ### Create New Validator Instance Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/validator.md Instantiates a new Validator. Use this to prepare for subsequent validation calls. Requires the Cobra command and JSON input data. ```go validator := internal.NewValidator(cmd, jsonData) ``` -------------------------------- ### Create Diagnostic Link Response Body (201 Created) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md This is an example of a successful response when creating a diagnostic link. It includes the groupId and the generated diagnosticLink. ```json { "groupId": "abc123def456", "url": "https://www.example.com", "note": "Testing production deployment", "createdTime": "2021-01-01T12:00:00Z", "diagnosticLink": "https://diagnostic.akamai.com/abc123def456", "diagnosticLinkStatus": "ACTIVE", "recordCount": 0, "createdBy": "user@example.com" } ``` -------------------------------- ### Check .edgerc Configuration (Bash) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Displays the content of the .edgerc file to verify the presence of the correct section, client_secret, host, and access_token. ```bash cat ~/.edgerc # Verify: # - [section] exists (default: diagnostics) # - client_secret is set # - host is set # - access_token is set ``` -------------------------------- ### Example 403 Forbidden Error JSON Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Displays the JSON structure for a 403 Forbidden error, which occurs when authenticated users lack sufficient permissions. ```json { "type": "https://api.akamai.com/docs/errors/forbidden", "title": "Forbidden", "status": 403, "detail": "You do not have permission to access this resource" } ``` -------------------------------- ### Get Diagnostic Records Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves collected diagnostic records for a specific diagnostic link, with options to include MTR, DNS (dig), and curl data. ```APIDOC ## GET /edge-diagnostics/v1/user-diagnostic-data/groups/{linkId}/records ### Description Retrieves collected diagnostic records for a specific diagnostic link. ### Method GET ### Endpoint /edge-diagnostics/v1/user-diagnostic-data/groups/{linkId}/records ### Parameters #### Path Parameters - **linkId** (string) - Required - The diagnostic link ID #### Query Parameters - **includeMtr** (boolean) - Optional - Include MTR data - **includeDig** (boolean) - Optional - Include DNS (dig) data - **includeCurl** (boolean) - Optional - Include curl request data ### Request Example ``` GET /edge-diagnostics/v1/user-diagnostic-data/groups/abc123def456/records?includeMtr=true&includeDig=true&includeCurl=true ``` ### Response #### Success Response (200 OK) - **groupId** (string) - Unique group identifier - **records** (array) - List of diagnostic records. Each record contains: - **endUserDataId** (string) - Unique identifier for the end user data record - **protocol** (string) - Protocol used (e.g., HTTP) - **userAgent** (string) - User agent string - **createdDate** (string) - Timestamp of record creation - **uniqueId** (int) - Unique identifier for the record within the group - **clientIpv4** (object) - Client IPv4 address information: - **ip** (string) - The IPv4 address - **ipType** (string) - Type of IP address (e.g., IPV4) #### Response Example ```json { "groupId": "abc123def456", "records": [ { "endUserDataId": "record001", "protocol": "HTTP", "userAgent": "Mozilla/5.0...", "createdDate": "2021-01-01T12:00:30Z", "uniqueId": 1, "clientIpv4": { "ip": "203.0.113.1", "ipType": "IPV4" } } ] } ``` ### Status Codes - `200 OK` - Records retrieved successfully - `404 Not Found` - Diagnostic link not found - `401 Unauthorized` - Invalid credentials ``` -------------------------------- ### Run estats for a specific URL Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Use this command to get error statistics for a given URL. Optional flags can include logs and TLS type. ```bash akamai diagnostics estats --url https://www.akamai.com ``` -------------------------------- ### Enable Trace Logging (Bash) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/errors.md Sets the LOG_LEVEL environment variable to trace for exhaustive output, including full request payloads and response bodies. ```bash LOG_LEVEL=trace akamai diagnostics verify-ip 123.123.123.123 ``` -------------------------------- ### List IPA Hostnames Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves a list of IP Acceleration hostnames. ```APIDOC ## GET /edge-diagnostics/v1/ipa/hostnames ### Description Retrieves list of IP Acceleration hostnames. ### Method GET ### Endpoint /edge-diagnostics/v1/ipa/hostnames ### Response #### Success Response (200 OK) - **hostnames** ([]string) - List of IP Acceleration hostnames #### Response Example ```json { "hostnames": [ "ipa1.example.com", "ipa2.example.com" ] } ``` ### Status Codes - `200 OK` - List retrieved successfully - `401 Unauthorized` - Invalid credentials ``` -------------------------------- ### List GTM Hostnames Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Lists all GTM properties you have access to. Use the optional --test-target-ip flag to request test and target IPs or hostnames for a specific GTM hostname. ```bash akamai diagnostics gtm-hostnames ``` ```bash akamai diagnostics gtm-hostnames --test-target-ip www-origin.20000puzzles.akadns.net ``` -------------------------------- ### Get User Diagnostics Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves collected diagnostic data for a specific diagnostic link. Specify which data types (MTR, dig, curl) to include. ```go response, err := api.UserDiagnosticsGet("ab123c", true, true, true) ``` -------------------------------- ### Response Error Statistics Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md This is an example of a successful response when retrieving error statistics. It includes metrics like edge hits, errors, and status code distribution. ```json { "result": { "edgeHits": 1000, "edgeErrors": 50, "edgeFailurePercentage": 5, "edgeStatusCodeDistribution": [ { "httpStatus": 200, "hits": 950, "percentage": 95 } ], "topEdgeIpsWithError": [ { "edgeIp": "203.0.113.1", "httpStatus": 500, "hits": 25 } ] } } ``` -------------------------------- ### Run Content Problems Scenario with Client Location and Site Shield Map Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Use this command to run the content problems scenario for a specific URL, specifying the client location and enabling the Site Shield map. ```bash akamai diagnostics content-problem http://www.example.com --client-location bangalore-india --run-from-site-shield-map ``` -------------------------------- ### MTR Response Body Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md This is an example of a successful MTR analysis response. It includes details about each hop, such as IP address, host, packet loss, and latency metrics. ```json { "result": { "host": "www.example.com", "hops": [ { "number": 1, "ip": "10.0.0.1", "host": "edge1.akamai.com", "packetLoss": 0, "sentPackets": 60, "lastPacketLatency": 2.5, "averageLatency": 2.4, "bestRtt": 2.1, "worstRtt": 3.2, "standardDeviation": 0.3 } ] } } ``` -------------------------------- ### NewEdgeGridHttpClient Constructor Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/edge-grid-http-client.md Creates a new EdgeGrid HTTP client. It loads authentication credentials from a specified .edgerc file section or environment variables. The accountSwitchKey is optional and used for multi-account operations. ```APIDOC ## NewEdgeGridHttpClient ### Description Creates a new EdgeGrid HTTP client with authentication credentials from .edgerc file or environment variables. ### Signature ```go func NewEdgeGridHttpClient(filepath, section, accountSwitchKey string) *EdgeGridHttpClient ``` ### Parameters #### Path Parameters - **filepath** (string) - Required - Path to .edgerc credentials file (checked via AKAMAI_EDGERC env var first) - **section** (string) - Required - Section name in .edgerc file (defaults to "diagnostics") - **accountSwitchKey** (string) - Optional - Optional account switch key for multi-account operations (empty string if not used) ### Returns - **`*EdgeGridHttpClient`** - A pointer to a new HTTP client instance ### Error Behavior Aborts with error code 1 if .edgerc file cannot be read or is malformed. ### Example ```go client := internal.NewEdgeGridHttpClient("~/.edgerc", "diagnostics", "") ``` ``` -------------------------------- ### DNS Lookup Response Body (200 OK) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md This is an example of a successful DNS lookup response. It includes details about the request, execution status, and the lookup result. ```json { "request": { "hostname": "www.example.com", "queryType": "A", "edgeLocationId": "singapore", "isGtmHostname": false }, "createdTime": "2021-01-01T12:00:00Z", "createdBy": "user@example.com", "completedTime": "2021-01-01T12:00:05Z", "executionStatus": "SUCCESS", "edgeIpLocation": { "city": "Singapore", "countryCode": "SG" }, "internalIp": "10.0.0.1", "result": { "result": "success" } } ``` -------------------------------- ### Retrieve Content Problems Results Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Use this endpoint to get the results of a content problem diagnosis. The 'includeContentResponseBody' parameter can be used to include the response body in the results. ```json { "result": { "content_status": "MISSING", "response_body": "" } } ``` -------------------------------- ### List IP Acceleration Hostnames Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Retrieves and displays a list of IP Acceleration hostnames. Use to fetch and display IPA hostnames from the API. ```go func (svc Service) IpaHostnames() ``` ```go svc.IpaHostnames() ``` -------------------------------- ### Create New EdgeGridHttpClient Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/edge-grid-http-client.md Initializes a new HTTP client for Akamai API requests. It reads credentials from a specified .edgerc file and section, or environment variables. An optional account switch key can be provided for multi-account operations. ```Go client := internal.NewEdgeGridHttpClient("~/.edgerc", "diagnostics", "") ``` -------------------------------- ### List IP Acceleration Hostnames Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves a list of IP Acceleration hostnames. This endpoint is used to get a collection of hostnames associated with IP Acceleration services. ```json { "hostnames": [ "ipa1.example.com", "ipa2.example.com" ] } ``` -------------------------------- ### Run Content Problems Scenario with Edge IP and Request Headers Source: https://github.com/akamai/cli-diagnostics/blob/master/README.md Execute the content problems scenario with detailed options including client location, specific edge server IP, custom request headers, and IP version. ```bash akamai diagnostics content-problem http://www.example.com --client-location bangalore-india --edge-ip 123.123.123.123 --request-header accept:text/html --ip-version IPV4 ``` -------------------------------- ### Retrieve Grep Results (GET) Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves the results of an asynchronous log search initiated by GrepPost. Requires the full URL link provided in the GrepPost response. ```go response, err := api.GrepGet("https://api.akamai.com/edge-diagnostics/v1/grep/9999") ``` -------------------------------- ### Configure EdgeGridHttpClient with Account Switch Key Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/edge-grid-http-client.md Creates a new EdgeGrid HTTP client instance configured for multi-account operations by providing an account switch key. This key is appended as a query parameter to all subsequent API requests. ```Go client := internal.NewEdgeGridHttpClient("~/.edgerc", "diagnostics", "account-key-123") ``` -------------------------------- ### Get GTM Test Target IPs Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves test target IPs for a specific GTM property and domain. Requires the property and domain names as parameters. ```go response, err := api.GtmTestTargetIp("www-origin", "example.20000puzzles.akadns.net") ``` -------------------------------- ### Get GTM Property Test IPs Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/endpoints.md Retrieves test target IPs for a specific GTM property. Requires the property name and domain name as path parameters. ```json { "gtmPropertyIps": { "property": "www-origin", "domain": "example.20000puzzles.akadns.net", "testIps": ["203.0.113.1", "203.0.113.2"], "targets": ["origin1.example.com", "origin2.example.com"] } } ``` -------------------------------- ### Configure CLI with Command-Line Flags Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/configuration.md Use command-line flags to override default settings for credential files, sections, account keys, and output format. Flags can be combined for complex configurations. ```bash # Use custom .edgerc file akamai diagnostics --edgerc /etc/akamai/.edgerc verify-ip 123.123.123.123 ``` ```bash # Use alternate section akamai diagnostics --section production verify-ip 123.123.123.123 ``` ```bash # Use alternate account akamai diagnostics --account-key account-12345 edge-locations ``` ```bash # Output as JSON akamai diagnostics --json verify-ip 123.123.123.123 ``` ```bash # Combine flags akamai diagnostics --edgerc ~/.edgerc_prod --section prod --json edge-locations ``` -------------------------------- ### Get User Diagnostic Data Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/service.md Retrieves and displays collected diagnostic data for a specific diagnostic link. Use to include MTR, DNS, and curl data in the output. ```go func (svc Service) UserDiagnosticsGet(linkId string, mtr, dig, curl bool) ``` ```go svc.UserDiagnosticsGet("ab123c", true, true, true) ``` -------------------------------- ### Retrieve IPA Hostnames Source: https://github.com/akamai/cli-diagnostics/blob/master/_autodocs/api-reference/api-client.md Retrieves a list of IP Acceleration hostnames. The response is a JSON array of IPA hostnames. ```go response, err := api.IpaHostnames() ```