Reading GraphQL logs
We use Kibana to filter GraphQL query logs. Sign in to Kibana
with a @gitlab.com
email address.
In Kibana we can inspect two kinds of GraphQL logs:
- Logs of each GraphQL query executed within the request.
- Logs of the full request, which due to query multiplexing may have executed multiple queries.
Logs of each GraphQL query
In a multiplex query, each individual query is logged separately. We can use subcomponent filtering to inspect these logs. Visit Kibana with this filter enabled or set up the subcomponent filter using these steps:
- Add a filter:
- Filter:
json.subcomponent
- Operator:
is
- Value:
graphql_json
- Filter:
- Select Refresh.
You can select Kibana fields from the Available fields section of the sidebar to add columns to the log table, or visit this view, which already has a set of Kibana fields selected. Some relevant Kibana fields include:
Kibana field | Description |
---|---|
json.operation_name |
The operation name used by the client. |
json.operation_fingerprint |
The fingerprint of the query, used to recognize repeated queries over time. |
json.meta.caller_id |
Appears as graphql:<operation_name> for queries that came from the GitLab frontend, otherwise as graphql:unknown . Can be used to identify internal versus external queries. |
json.query_string |
The query string itself. |
json.is_mutation |
true when a mutation, false when not. |
json.query_analysis.used_fields |
List of GraphQL fields selected by the query. |
json.query_analysis.used_deprecated_fields |
List of deprecated GraphQL fields selected by the query. |
json.query_analysis.duration_s |
Duration of query execution in seconds. |
json.query_analysis.complexity |
The complexity score of the query. |
Useful filters
Combine the subcomponent filter with the following Kibana filters to further interrogate the query logs.
Queries that used a particular field
Filter logs by queries that used a particular field:
- Add a filter:
- Filter:
json.query_analysis.used_fields
- Operator:
is
- Value:
Type.myField
, whereType.myField
is the type name and field name as it appears in our GraphQL API resources documentation.
- Filter:
- Select Refresh.
Queries that used a deprecated field
Filter logs of queries that used a particular deprecated field by following the
steps above but use the json.graphql.used_deprecated_fields
filter instead.
Logs of the full request
The full request logs encompass log data for all multiplexed queries
in the request, as well as data from time spent outside of GraphQLController#execute
.
To see the full request logs, do not apply the json.subcomponent
filter, and instead:
- Add a filter:
- Filter:
json.meta.caller_id
- Operator:
is
- Value:
GraphqlController#execute
- Filter:
- Select Refresh.
Some differences from the query logs described above:
- Some of the Kibana fields mentioned above are not available to the full request logs.
- The names of filters differ. For example, instead of
json.query_analysis.used_fields
you selectjson.graphql.used_fields
.