|
| 1 | +import { Callout, Cards, Tabs } from '@theguild/components' |
| 2 | + |
| 3 | +# Usage Reporting |
| 4 | + |
| 5 | +Hive Router can send usage reports to Hive Console to provide insights into the operations being |
| 6 | +executed against your GraphQL API. This includes details such as operation names, client |
| 7 | +information, and field-level usage statistics. |
| 8 | + |
| 9 | +The Hive Router can report usage metrics to the Hive schema registry, giving you |
| 10 | +[insights for executed GraphQL operations](/docs/dashboard/insights), and |
| 11 | +[field level usage information](/docs/dashboard/explorer), but also enabling |
| 12 | +[conditional breaking changes](/docs/management/targets#conditional-breaking-changes). |
| 13 | + |
| 14 | +Before proceeding, make sure you have |
| 15 | +[created a registry token with write permissions on the Hive dashboard](/docs/management/targets#registry-access-tokens). |
| 16 | + |
| 17 | +You can either provide the usage reporting configuration via environment variables or the |
| 18 | +`router.config.yaml` file. |
| 19 | + |
| 20 | +<Tabs items={["Environment Variables", "Configuration File"]}> |
| 21 | + |
| 22 | +{/* Environment Variables */} |
| 23 | + |
| 24 | +<Tabs.Tab> |
| 25 | + |
| 26 | +- `HIVE__USAGE_REPORTING__TARGET_ID`: The target ID, this can either be a slug following the format |
| 27 | + `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) or an UUID |
| 28 | + (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`). To be used when the token is configured with an |
| 29 | + organization access token. |
| 30 | + |
| 31 | +- `HIVE__USAGE_REPORTING__TOKEN`: Your |
| 32 | + [Registry Access Token](https://the-guild.dev/graphql/hive/docs/management/targets#registry-access-tokens) |
| 33 | + with write permission. |
| 34 | + |
| 35 | +```sh filename="Run Hive Router with Usage Reporting enabled." |
| 36 | +HIVE__USAGE_REPORTING__TOKEN="<hive_usage_access_token>" \ |
| 37 | + HIVE__USAGE_REPORTING__TARGET_ID="<hive_usage_target>" \ |
| 38 | + hive-router |
| 39 | +``` |
| 40 | + |
| 41 | +</Tabs.Tab> |
| 42 | + |
| 43 | +{/* Configuration File */} |
| 44 | + |
| 45 | +<Tabs.Tab> |
| 46 | + |
| 47 | +Alternatively, you can provide the usage reporting configuration via the `router.config.yaml` file. |
| 48 | + |
| 49 | +```yaml filename="router.config.yaml" |
| 50 | +usage_reporting: |
| 51 | + # The registry token provided by Hive Registry |
| 52 | + token: '<hive_usage_access_token>' |
| 53 | + # The registry target which the usage data should be reported to defaulting to process.env.HIVE_USAGE_TARGET |
| 54 | + # This can either be a slug following the format `$organizationSlug/$projectSlug/$targetSlug` (e.g `the-guild/graphql-hive/staging`) |
| 55 | + # or an UUID (e.g. `a0f4c605-6541-4350-8cfe-b31f21a4bf80`). |
| 56 | + target_id: '<hive_usage_target>' |
| 57 | + |
| 58 | + # Endpoint override for self-hosting |
| 59 | + # endpoint: 'https://my-hive-instance.com/usage' |
| 60 | +``` |
| 61 | + |
| 62 | +</Tabs.Tab> |
| 63 | + |
| 64 | +</Tabs> |
| 65 | + |
| 66 | +If you want to control the usage reporting to the Hive Console like `client_name_header`, |
| 67 | +`client_version_header` or `sample_rate` etc, please look at the Hive Client documentation to learn |
| 68 | +more about other options. |
| 69 | +[See more in Hive Client reference](/docs/router/configuration/usage_reporting). |
0 commit comments