How do I trace an Application Load Balancer request using X-Amzn-Trace-Id?
How do I log X-Amzn-Trace-Id to trace requests through my Application Load Balancer and web servers?
"How do I log X-Amzn-Trace-Id to trace requests through my Application Load Balancer and web servers?Short descriptionIn Elastic Load Balancing (ELB), when an Application Load Balancer handles a request, the trace information is added to the X-Amzn-Trace-Id header. For example:X-Amzn-Trace-Id: Root=1-67891233-abcdef012345678912345678Log the identifier and then use it to troubleshoot issues with your load balancer. For example, use the X-Amzn-Trace-Id header to identify when many similar requests are received from the same client within a short time. If you have many layers in your stack, then you can also use the X-Amzn-Trace-Id header to track a request across all the layers.ResolutionUse the following steps for common web server configurations (Apache, Tomcat, NGINX, or IIS) to log the X-Amzn-Trace-Id header:Apache1.    Open the Apache configuration file (/etc/httpd/conf/httpd.conf in Amazon Linux) in your preferred text editor.2.    In the LogFormat section, add the option  %{X-Amzn-Trace-Id}i as follows:LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Amzn-Trace-Id}i\"" combined3.    Restart the Apache service to apply your changes as follows:sudo service apache restartTomcat1.    Open the Tomcat configuration file (/etc/tomcat7/server.xml in Amazon Linux) in your preferred text editor.    2.    In the org.apache.catalina.valves.AccessLogValve class, add the option %{X-Amzn-Trace-Id}i as follows:<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"      prefix="localhost_access_log." suffix=".txt"      pattern="%h %l %u %t &quot;%r&quot; %s %b %{X-Amzn-Trace-Id}i" />3.    Restart the Tomcat service to apply your changes as follows:sudo service tomcat7 restartNGINX1.    Open the NGINX configuration file ( /etc/nginx/nginx.conf in Amazon Linux) in your preferred text editor.2.    In the log_format section, add the option $http_x_amzn_trace_id as follows:log_format  main  '"$http_x_forwarded_for" $remote_addr - $remote_user [$time_local] "$request" '    '$status $body_bytes_sent "$http_referer" '    '"$http_user_agent" "$http_x_amzn_trace_id"';3.    Restart the NGINX service to apply your changes as follows:sudo service nginx restartInternet Information Services (IIS)1.    Open the IIS Manager.2.    Select your server’s name.3.    Choose Logging.4.    Choose Select Fields.5.    Choose Add Field.6.    In the dialog box, for Field Name, enter X-Amzn-Trace-Id. For Source Type, enter Request Header. For Source, enter X-Amzn-Trace-Id.7.    Choose Apply to apply your changes.Related informationRequest tracing for your Application Load BalancerAccess logs for your Application Load BalancerFollow"