mirror of
https://github.com/graphql-hive/console
synced 2026-05-24 01:28:32 +00:00
docs: fix prometheus documentation (#5645)
This commit is contained in:
parent
e52caa90e7
commit
3d5829b753
1 changed files with 40 additions and 19 deletions
|
|
@ -1173,7 +1173,7 @@ curl -v http://localhost:4000/metrics
|
|||
|
||||
### Customizations
|
||||
|
||||
<Tabs items={["Introspection Queries", "Metric Name", "Metric Config", "Registry"]}>
|
||||
<Tabs items={["Introspection Queries", "Labels", "Metric Name", "Metric Config", "Registry"]}>
|
||||
|
||||
<Tabs.Tab>
|
||||
|
||||
|
|
@ -1183,6 +1183,23 @@ ignore introspection queries for all metrics prefixed by `graphql_envelop_` by s
|
|||
|
||||
</Tabs.Tab>
|
||||
|
||||
<Tabs.Tab>
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</Tabs.Tab>
|
||||
|
||||
<Tabs.Tab>
|
||||
|
||||
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',
|
||||
};
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue