Offload Analytics to a Secondary Service
ngrok and Traffic Policy let you integrate your "front door" gateway with an analytics service you host within your network to capture vital information about your traffic as a part of the request-response lifecycle.
With this gateway setup and the http-request action, you can:
- Host your analytics service in any network, region, or cloud.
- Leave your analytics service completely unexposed to the public internet.
- Simplify your upstream services by removing libraries and code for instrumenting them directly.
- Configure for exactly the timeout and retry conditions your services require.
1. Create endpoints for your services
Start an internal Agent Endpoint, replacing $PORT
based on where your upstream service listens.
You can also use one of our SDKs or the Kubernetes Operator.
Loading…
Start a second endpoint for your analytics service.
Loading…
2. Reserve a domain
Navigate to the Domains section of the ngrok dashboard and click New + to reserve a free static domain like https://your-service.ngrok.app
or a custom domain you already own.
3. Create a Cloud Endpoint
Navigate to the Endpoints section of the ngrok dashboard, then click New + and Cloud Endpoint.
Now you have a Cloud Endpoint with the URL like https://your-service.ngrok.app
.
4. Request customer data from your CRM and apply rate limiting with Traffic Policy
Copy and paste the policy below into your new Cloud Endpoint in the ngrok dashboard.
Loading…
What's happening here?
Traffic Policy sends all requests directly to your upstream service at https://service.internal
.
As part of the response lifecycle, Traffic Policy sends an authenticated request to your analytics service with a body containing attributes, injected with CEL interpolation, about the user's request and your server's response.
The http-request
action is purposely given a short timeout and no retry logic to ensure this analytics request doesn't add unnecessarily slow your service's response time.
5. Try out your endpoint
- In your browser: https://your-service.ngrok.app
- In your terminal:
curl https://your-service.ngrok.app
What's next?
- Read more about Traffic Policy and its core concepts.
- View your traffic in Traffic Inspector.
- Add even more logging flexibility, plus access to our entire eventing system, with the
logs
action.