Skip to content

Running Jaeger Query in AWS Lambda and API Gateway

1

I am trying to deploy the Jaeger query in AWS Lambda so I pulled the latest Jaeger Query image from Docker Hub and pushed the same to AWS ECR. After pushing the image to AWS ECR I created the AWS Lambda function using the same. Created an AWS API gateway and completed the integration of API gateway with Lambda function and deployed the API gateway with the new stage "prod" but once I hit the URL of API gateway Jaeger UI is not showing and gave the below error

Output in Browser

CORS policy in API Gateway

CORS policy

Can I help me identify the issue if I am missing anything here.

asked 2 years ago804 views

1 Answer
0

Hi Atif!

I see you're working on setting up Jaeger Query with AWS Lambda and API Gateway but encountering issues with the UI not appearing and a CORS-related configuration. Let’s break this down and address the key challenges. 😊


Clarifying the Issue

From your description and screenshots, the key issues seem to be:

  1. The Jaeger UI not showing and responding with a {"message":"Not Found"} error.
  2. Potential misconfiguration in the API Gateway's CORS policy, which might block requests from other origins or fail to forward headers properly.

Both problems could stem from how the Lambda integration is set up, how the Jaeger Query Docker image is configured, and how CORS is defined in API Gateway. Let’s dive deeper into solving this step by step.


Key Terms

  • Jaeger Query: A component of the Jaeger distributed tracing system that serves the query and UI for trace data.
  • CORS (Cross-Origin Resource Sharing): A browser mechanism that controls how resources on a web page can be requested from another domain.
  • API Gateway and Lambda Integration: The configuration connecting your AWS Lambda function to API Gateway, enabling it to handle HTTP requests.
  • CloudWatch Logs: A service that collects and monitors logs generated by AWS resources, such as Lambda. Useful for debugging runtime issues.
  • Preflight Request: An HTTP OPTIONS request sent by browsers to verify CORS policies before a main request (e.g., GET or POST).

The Solution (Our Recipe)

Steps at a Glance:

  1. Check the Lambda Function Configuration.
  2. Use CloudWatch Logs for Debugging.
  3. Verify the API Gateway Integration.
  4. Update the CORS Configuration
  5. Test the Preflight Requests.
  6. Debug with Postman.
  7. Fine-Tune the Jaeger Query Docker Image.

Step-by-Step Guide:

  1. Check the Lambda Function Configuration:
    • Verify the Lambda handler and the Jaeger Query Docker image. If the image expects requests on a specific port (e.g., 16686), make sure it’s exposed in the Dockerfile and that Lambda routes traffic correctly.
    • Ensure your Lambda function is not stripping or modifying paths before forwarding them to the Jaeger container.

  1. Use CloudWatch Logs for Debugging:
    • Open the AWS Lambda console and navigate to Monitor > Logs.
    • Look for specific errors or unexpected behavior, such as missing routes, incorrect paths, or network connectivity issues.
    • For example, verify that Lambda is forwarding requests properly and the Jaeger Query application is responding.

  1. Verify the API Gateway Integration:
    • Ensure that Lambda Proxy Integration is enabled in API Gateway, which allows the Lambda function to handle HTTP requests and responses dynamically.
    • Double-check that the resource paths and methods (e.g., /, /ui) are correctly mapped to your Lambda function.

  1. Update the CORS Configuration:
    • In the API Gateway CORS settings, make sure the following are correctly configured:
      • Access-Control-Allow-Origin: Set to * or a specific domain.
      • Access-Control-Allow-Methods: Include GET, POST, OPTIONS, etc., based on your API usage.
      • Access-Control-Allow-Headers: Include headers like Content-Type, Authorization, or any custom headers your app uses.
      • Access-Control-Allow-Credentials: Set to true if cookies or authorization headers are required.
    • Don’t forget to deploy the changes to the API Gateway stage after updating CORS.

  1. Test the Preflight Requests:
    • Use curl to test preflight behavior. For example:
      curl -X OPTIONS \
      -H "Access-Control-Request-Method: GET" \
      -H "Access-Control-Request-Headers: Authorization" \
      -H "Origin: http://example.com" \
      https://your-api-gateway-endpoint
    • Verify that the response includes the necessary CORS headers (Access-Control-Allow-Origin, etc.).

  1. Debug with Postman:
    • Test API Gateway directly by sending GET or POST requests to specific resource paths. For example:
      • URL: https://your-api-gateway-endpoint/ui
      • Headers: Include Origin and any necessary custom headers.
    • Check the returned status codes and headers. A missing CORS header suggests a misconfiguration.

  1. Fine-Tune the Jaeger Query Docker Image:
    • Confirm the Jaeger Query container is healthy by testing locally or in a different environment.
    • Ensure that the UI is accessible at the expected path (/ui) and verify compatibility with Lambda's behavior.

Closing Thoughts

This approach addresses both the Lambda setup and CORS configuration challenges. Debugging with CloudWatch Logs and tools like curl and Postman will help pinpoint issues more effectively. If the Jaeger Query Docker image has configuration options, explore them to ensure it aligns with AWS Lambda’s networking and routing.


Let me know how it goes. I'm sure you'll get Jaeger up and running very soon! 🚀😊


Cheers, Aaron 😊✨

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.