Prometheus
GraphQL Mesh v0 documentation (superseded by v1): Learn how to track and analyze GraphQL execution metrics using @graphql-mesh/plugin-prometheus. Expose and collect data to optimize your gateway.
Prometheus is a platform for scraping metrics from services and utilities. You can use
@graphql-mesh/plugin-prometheus plugin to expose and collect metrics from all phases of your
GraphQL execution including internal query planning and outgoing HTTP requests.
This plugin tracks the complete gateway execution flow and exposes the following metrics:
- Successful requests (
requestCount) - Request summary (
requestSummary) - errors (categorized by
phase) - resolvers tracing and runtime
- deprecated fields usage
- count of graphql operations
parseexecution timevalidateexecution timecontextBuildingexecution timeexecuteexecution time- Latency of outgoing HTTP request
- Latency of the delegation to the individual sources
Getting Started
Example Configuration
Note: Tracing resolvers using
resolvers: truemight have a performance impact on your GraphQL runtime. Please consider to test it locally first and then decide if it’s needed.
Custom Registry
You can customize the client’s registry by passing a custom registry to the registry option.
Caveats
Due to Prometheus client API limitations, if this plugin is initialized multiple times, only the metrics configuration of the first initialization will be applied.
If necessary, use a different registry instance for each plugin instance, or clear the registry before plugin initialization.
Keep in mind that this implies potential data loss in pull mode if some data is produced between last pull and the re-initialization of the plugin.
Config API Reference
requestCount- One of:BooleanString
requestTotalDuration- One of:BooleanString
requestSummary- One of:BooleanString
parse- One of:BooleanString
validate- One of:BooleanString
contextBuilding- One of:BooleanString
execute- One of:BooleanString
errors- One of:BooleanString
deprecatedFields- One of:BooleanString
skipIntrospection(type:Boolean)registry(type:String)delegation- One of:BooleanString
delegationArgs(type:Boolean)delegationKey(type:Boolean)subgraphExecute- One of:BooleanString
fetchMetrics- One of:BooleanString
fetchRequestHeaders(type:Boolean)fetchResponseHeaders(type:Boolean)http- One of:BooleanString
httpRequestHeaders(type:Boolean)httpResponseHeaders(type:Boolean)endpoint- - The path to the metrics endpoint default:/metricsOne of:BooleanString