• You are here:
  • Home »
  • API »

How to get a ‘Request Trace’ in Azure API Management

This blog post is a no-nonsense guide to acquire a Request Trace in Azure API Management. A Request Trace is a JSON document that contains valuable information about a request/response sent to API’s exposed through Azure API Management. You can use the Request Trace for debugging and troubleshooting your APIs.

Note

You need to Allow tracing in your API subscriptions in order to obtain a request trace.

Request traces might contain confidential information (like API keys and tokens), so handle your request traces with care.

Two-Step Quick Guide

You can obtain the Request Trace in two easy steps.

Step 1: In your request…

Add this header to your HTTP request:

Ocp-Apim-Trace: true

Step 2: In your response…

Your HTTP response now contains a response header called Ocp-Apim-Trace-Location:

Ocp-Apim-Trace-Location: https://apimXXXYYYZZZ.blob.core.windows.net/apiinspectorcontainer/XXXYYYZXZZ
The value of this header is the URL to the actual Request Trace.

What is inside a Request Trace?

A request trace is a JSON document that consists of trace-information collected through an API request. This JSON document is divided into ‘request trace sections’ and ‘request trace log entries’.

Request trace sections (sometimes also referred to as policy sections): “inbound”, “backend”, and “output”.

Each ‘request trace section’ contains an array of ‘request trace log entries’.

Each log entry contains:

  • Source: this is the name of the policy that produced the log entry
  • Timestamp: the time when the specific steps started execution
  • Elapsed: the time it takes for a step to be processed
  • Data: various data and information attached to the log entry

 

21