Debugging Client Requests to GraphOS Router
Options for analyzing and debugging incoming requests
By default, the GraphOS Router operates without generating HTTP request logs or exporting telemetry metrics beyond what it sends to GraphOS. This default minimizes potentially high observability costs that can result from high request volumes. If you need more data than the default GraphOS Insights, you can configure your router to collect and export additional telemetry.
Using GraphOS Insights
GraphOS Studio lets you analyze data from failed requests, such as GraphQL error messages (if enabled) and the ID of the client making the request. You can also segment your insights data based on the client ID.
Enabling additional telemetry
You can instrument router telemetry if you need information outside of what's presented in GraphOS Studio to debug client requests.
Logging requests
You can conditionally include request bodies, including GraphQL operations, in your telemetry based on specific conditions. Apply these conditions on a router request event like so:
1telemetry:
2 instrumentation:
3 events:
4 router:
5 request:
6 level: info
7 condition: # Only log the router request if you sent `x-log-request` with the value `enabled`
8 eq:
9 - request_header: x-log-request
10 - "enabled"
Debugging router logs
By default, the router uses the info
level for its logging. Enabling other logging levels can help debug specific scenarios. Using non-info
level configurations is only recommended for local or non-production environments.
Rhai scripts and coprocessors
Hooking into the router service layer with either Rhai scripts or coprocessors gives you access to the full HTTP request before processing occurs. You can use either Rhai scripts or coprocessors to add custom logic for what to log and when.
See the Apollo Solutions "Hello World" coprocessor for an example of a coprocessor that simply logs the router's payload.
Alternative cloud services
If you are deploying the router to a cloud service, you likely already have access to the raw HTTP logs through other services like load balancers. You should be able to find specific client request logs for a particular operation using the operation hash or trace ID. Refer to the docs for your cloud providers for more information. Popular cloud provider links are provided below.