Skip to content

Commit 4edbe3d

Browse files
authored
Add GraphQL example (#20429)
1 parent 32f03b4 commit 4edbe3d

File tree

1 file changed

+44
-1
lines changed
  • src/content/docs/cloudflare-one/insights/analytics

1 file changed

+44
-1
lines changed

src/content/docs/cloudflare-one/insights/analytics/gateway.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,47 @@ To see the top Allowed and Blocked requests across all of your DNS locations, go
1414

1515
## GraphQL queries
1616

17-
You can use the [GraphQL Analytics API](/analytics/graphql-api/) to query your Gateway Analytics data. For more information on the Gateway Analytics dataset, refer to the [available datasets](/analytics/graphql-api/features/data-sets/) table and use the [GraphiQL client](/analytics/graphql-api/getting-started/explore-graphql-schema/) to explore the schema.
17+
You can use the [GraphQL Analytics API](/analytics/graphql-api/) to query your Gateway Analytics data. Available [datasets](/analytics/graphql-api/features/data-sets/) for Gateway include:
18+
19+
| Dataset | Description |
20+
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
21+
| `gatewayL4DownstreamSessionsAdaptiveGroups` | Metrics for Gateway network sessions from user devices to the Cloudflare global network. |
22+
| `gatewayL4UpstreamSessionsAdaptiveGroups` | Metrics for Gateway network sessions from the Cloudflare global network to user devices. |
23+
| `gatewayL4SessionsAdaptiveGroups` | Metrics for Gateway network sessions with adaptive sampling. |
24+
| `gatewayL7RequestsAdaptiveGroups` | Metrics for Gateway HTTP requests with adaptive sampling. |
25+
| `gatewayResolverQueriesAdaptiveGroups` | Metrics for Gateway DNS queries with adaptive sampling. |
26+
| `gatewayResolverByRuleExecutionPerformanceAdaptiveGroups` | Time to execute Gateway DNS policies on the Cloudflare global network. |
27+
| `gatewayResolverByCustomResolverGroups` | Metrics for Gateway DNS queries resolved using custom resolvers. |
28+
| `gatewayResolverByCategoryAdaptiveGroups` | Metrics for Gateway DNS queries sorted by [domain category](/cloudflare-one/policies/gateway/domain-categories/) with adaptive sampling. |
29+
30+
To explore the schema, you can use a GraphQL client such as [GraphiQL](https://github.com/graphql/graphiql/tree/main/packages/graphiql#readme) or [Altair](https://altairgraphql.dev/).
31+
32+
1. [Create an API token](/analytics/graphql-api/getting-started/authentication/api-token-auth/) with the following permissions:
33+
34+
| Type | Item | Permission |
35+
| ------- | ----------------- | ---------- |
36+
| Account | Account Analytics | Read |
37+
38+
2. In your GraphQL client, [add your API token](/analytics/graphql-api/getting-started/authentication/graphql-client-headers/) as an Authorization header.
39+
3. Compose a query to access your Gateway Analytics datasets. For example, you can query the `gatewayResolverQueriesAdaptiveGroups` dataset to return the adaptive groups of DNS queries resolved by Gateway:
40+
41+
```graphql
42+
{
43+
viewer {
44+
accounts(filter: { accountTag: "<ACCOUNT_ID>" }) {
45+
gatewayResolverQueriesAdaptiveGroups(
46+
filter: { datetime_gt: "2025-02-28T00:00:00Z" }
47+
limit: 10
48+
) {
49+
count
50+
dimensions {
51+
queryNameReversed
52+
resolverDecision
53+
}
54+
}
55+
}
56+
}
57+
}
58+
```
59+
60+
For more information, refer to [Compose a query in GraphiQL](/analytics/graphql-api/getting-started/compose-graphql-query/).

0 commit comments

Comments
 (0)