diff --git a/packages/web/docs/src/pages/docs/gateway/monitoring-tracing.mdx b/packages/web/docs/src/pages/docs/gateway/monitoring-tracing.mdx index c546510b4..aeff2f1f8 100644 --- a/packages/web/docs/src/pages/docs/gateway/monitoring-tracing.mdx +++ b/packages/web/docs/src/pages/docs/gateway/monitoring-tracing.mdx @@ -1173,7 +1173,7 @@ curl -v http://localhost:4000/metrics ### Customizations - + @@ -1183,6 +1183,23 @@ ignore introspection queries for all metrics prefixed by `graphql_envelop_` by s + +By default, all labels are enabled, but each one can be disabled to reduce cardinality: + +```ts filename="gateway.confing.ts" +import { defineConfig } from '@graphql-hive/gateway' + +export const gatewayConfig = defineConfig({ + prometheus: { + labels: { + url: false // remove `url` labels from all relevant metrics + } + } +}) +``` + + + By providing a string, you can change the name of the metric. For example, to change the name of the @@ -1193,7 +1210,9 @@ import { defineConfig } from '@graphql-hive/gateway' export const gatewayConfig = defineConfig({ prometheus: { - graphql_yoga_http_duration: 'http_request_duration' + metrics: { + graphql_yoga_http_duration: 'http_request_duration' + } } }) ``` @@ -1226,23 +1245,25 @@ import { register as registry } from 'prom-client' export const gatewayConfig = defineConfig({ prometheus: { - graphql_yoga_http_duration: createHistogram({ - registry, - histogram: { - name: 'graphql_yoga_http_duration', - help: 'Time spent on HTTP connection', - labels: ['method', 'statusCode', 'operationName', 'operationType'], - buckets: [0.1, 5, 15, 50, 100, 500], - } - fillLabelsFn(params, { request, response }) { - return { - method: request.method, - statusCode: response.status, - operationType: params.operationType, - operationName: params.operationName || 'Anonymous', - }; - } - }) + metrics: { + graphql_yoga_http_duration: createHistogram({ + registry, + histogram: { + name: 'graphql_yoga_http_duration', + help: 'Time spent on HTTP connection', + labels: ['method', 'statusCode', 'operationName', 'operationType'], + buckets: [0.1, 5, 15, 50, 100, 500], + } + fillLabelsFn(params, { request, response }) { + return { + method: request.method, + statusCode: response.status, + operationType: params.operationType, + operationName: params.operationName || 'Anonymous', + }; + } + }) + } } }) ```