Logging request info with Apollo Router #1961
Replies: 13 comments 26 replies
|
I'm wondering if providing something like |
|
This discussion might be related to #1840 we will add more configuration options for logging in the future. Feel free to give ideas or feedback about what you liked in the gateway and also what you would like to have. But we definitely want to improve the logging experience |
|
At this time there is no way to control the logging of Apollo Router at a finer granularity than what is provided out of the box. One could build a custom Apollo Router and modify the code base but this is challenging for small teams and those who don't have in-house Rust development skills. The best thing one can do is track issues like #1840 and/or labels like component/logging . |
|
One common usecase for more thorough logging is logging subgraph error responses. Currently, its very "hard/weird" to achieve that, as I propose something along these lines: when_error:
body: true
... |
|
One addition that would be nice is the ability to not only set the value of the logged information, but the loglevel as well- for example, if the header of |
|
We have enabled Apollo Router logging with the following configuration: This pretty much logs everything. But one problem we have is that it is logging our auth headers as well. I'd prefer to not log that single header and also not log |
|
What about filtering out introspection queries (or filtering in/out by operation name)? This type of logging is most useful during development and troubleshooting, and that often means the sandbox, which can be chatty. |
|
When logging from a rust plugin, is it possible to not have the log output include so much extra data? For example the full query body that gets added in the field “graphql.document”. Good to have the option to keep log lines really tight. tracing::info!("hello");{
"timestamp": "2023-05-04T09:07:04.549535Z",
"level": "INFO",
"message": "hello",
"span": {
"apollo_private.field_level_instrumentation_ratio": 0.01,
"apollo_private.graphql.variables": "...",
"graphql.document": "...",
"graphql.operation.name": "...",
"otel.kind": "INTERNAL",
"name": "supergraph"
},
"spans": [
{
"http.flavor": "HTTP/1.1",
"http.method": "POST",
"http.route": "/",
"otel.kind": "SERVER",
"name": "request"
},
{
"apollo_private.http.request_headers": "{}",
"client.name": "jonas",
"client.version": "",
"http.flavor": "HTTP/1.1",
"http.method": "POST",
"http.route": "/",
"otel.kind": "INTERNAL",
"trace_id": "0ae619c191850a762fadf23da2c28abb",
"name": "router"
},
{
"apollo_private.field_level_instrumentation_ratio": 0.01,
"apollo_private.graphql.variables": "...",
"graphql.document": "...",
"graphql.operation.name": "...",
"otel.kind": "INTERNAL",
"name": "supergraph"
}
]
} |
|
A simple way to enable JSON-formatted logs for now is to make stdout not be a tty by running |
|
hey! In our production environment, we have Envoy configuring the My use case would be that I'd like to make Apollo Router to log, in a JSON structured format, a field with At the moment, I've tried to:
Which does not really work for our use case, I'd expect to see:
We haven't really got yet into tracing, so nowadays we're just trying to aggregate all logs related to a single user request in production :/ @marc-barry do you think this makes sense? |
|
Looks like |
|
Love this feature. Would be nice if we had a little more granularity to be able to exclude certain headers from getting logged. For example, our JWT tokens are really large so it would be nice to log them once for the supergraph headers but then exclude them from subgraph header logging. |
|
Bringing this to top-level. I'd love to be able to pass a list of headers to redact. |
Uh oh!
There was an error while loading. Please reload this page.
We are migrating from Apollo Server to Apollo Router. With Server we have pretty exhaustive logging about subgraph requests and other details. But switching to Apollo Router it appears we don't even get request logs. The documentation for logging isn't super intuitive as it seems to lead one to believe that log output can be customized. Even when navigating to and reading https://www.apollographql.com/docs/router/configuration/logging/#json-formatted-logging I cannot figure out how to enable
jsonformatted logs.In any regard, it would be super helpful for us to get some parity for logging which is closer to what we have today. Something like logging
operation_name,subgraphandstatuswould be a start. That is what it outputs for Prometheus metrics. Does anyone know if there is any way to get request logs out of Router?All reactions