On this page
What you get
Graphwake learns which callers use which of your endpoints behind Amazon API Gateway, and how often. When a team confirms a caller, every endpoint that caller uses becomes a subscription of that team.
Optional. Without it, Graphwake still needs only your spec.
Before you start
- Access logging to CloudWatch Logs turned on for the stage, in the format
graphwake usage query --source apigatewayprints for your API type, REST API or HTTP API. - A Graphwake workspace on Pro or Enterprise, and an Admin to add the usage source.
- The Graphwake agent, which is open source: a binary from its releases on the machine where you try the steps below, or Docker to run its image
ghcr.io/graphwake/agent:0.5.0. - A place to run a daily job with Docker and the AWS CLI, such as GitHub Actions or Azure Pipelines, with permission to read the log group (
logs:FilterLogEvents).
Step 1: add a usage source
- In Graphwake, open Settings → Integrations → Usage sources and choose Add a source.
- Copy the usage key. It is shown once. Store it as a secret named
GRAPHWAKE_USAGE_KEYin the pipeline that will run the step.
Step 2: export the calls
graphwake usage query --source apigateway prints a one-line access log format for each API type, which logs the route template, the caller and the ids a caller map can name, and the command that exports the log:
# Amazon API Gateway: turn on access logging to CloudWatch Logs for the stage, with the
# format of your API type (one line), then export the log and send the file.
# REST API:
{"time":"$context.requestTime","method":"$context.httpMethod","host":"$context.domainName","route":"$context.resourcePath","caller":"$context.authorizer.principalId","apiKeyId":"$context.identity.apiKeyId","clientId":"$context.authorizer.claims.client_id"}
# HTTP API:
{"time":"$context.requestTime","method":"$context.httpMethod","host":"$context.domainName","route":"$context.routeKey","caller":"$context.authorizer.clientName","clientId":"$context.authorizer.claims.client_id"}
# "route" is the route template, such as /orders/{id}; the request path is not logged.
# A $default route or a {proxy+} route has no template and counts as matching no endpoint.
# The caller comes from what your API uses:
# - Lambda authorizer: "caller". REST API: the principalId it returns. HTTP API: a key of
# the context map it returns; replace clientName with your key.
# - API key (REST API only): "apiKeyId" is a random-looking id. Name it with --caller-map
# (a row "<key id>,<client name>"); without a row it names no caller and is never sent.
# - Cognito or JWT authorizer: "clientId" (the client_id claim); name it with --caller-map
# in the same way. The client_id claim is in access tokens; an ID token carries the client
# id in its "aud" claim instead.
# A key id or client id the map holds wins over "caller". Leave out what your API does not use.
# Export the last 7 days, one log line per line:
# aws logs filter-log-events --log-group-name <log group> \
# --start-time $(( ($(date +%s) - 7*86400) * 1000 )) \
# --output text --query 'events[].[message]' > apigateway-usage.jsonl
# The answer of --output json --query 'events[].message' (a JSON array of lines) is read too.graphwake usage query --source apigateway prints.In the stage's logging settings, turn on access logging to a CloudWatch Logs log group and use the line for your API type, REST API or HTTP API, as the log format. Leave out the members your API does not use. The logged route is the template, such as /orders/{id}; the request path is not logged.
The caller comes from what your API uses. With a Lambda authorizer, caller is the principalId it returns (REST API) or a key of the context map it returns (HTTP API: replace clientName with your key). Use principalId as the caller only when the authorizer returns the client application; when it is an end user's id (a Cognito sub, for example), leave caller out of the format and name the API key id or client id in a caller map instead. With API keys, a REST API feature, apiKeyId is a random-looking id. With a Cognito or JWT authorizer, clientId is the client_id claim of an access token; an ID token carries the client id in its aud claim instead. Name those ids in a caller map (step 3): without a row they name no caller and are never sent.
Then export the last 7 days of the log, one log line per line:
aws logs filter-log-events --log-group-name <log group> \
--start-time $(( ($(date +%s) - 7*86400) * 1000 )) \
--output text --query 'events[].[message]' > apigateway-usage.jsonlThe JSON array that --output json --query 'events[].message' writes is read too.
Step 3: read what would be sent
Run the step with --dry-run. It uses the usage key to ask Graphwake for your endpoint list, prints the summary it would send and what is not sent, and sends no summary. In CI its output is the job log.
export GRAPHWAKE_USAGE_KEY=<your usage key>
graphwake usage --source apigateway --input apigateway-usage.jsonl --dry-runWith the Docker image instead, give it the file on standard input: docker run --rm -i -e GRAPHWAKE_USAGE_KEY ghcr.io/graphwake/agent:0.5.0 usage --source apigateway --dry-run < apigateway-usage.jsonl.
--- would send ---
{"preset":"apim","agentVersion":"0.5.0","windowStart":"2026-11-12","windowEnd":"2026-11-18",
"countsIncluded":true,"unmatchedRequests":412,"withheldRequests":3,"anonymousRequests":7,
"rows":[{"caller":"checkout-web","callerKind":"client","endpointId":"9d2c...",
"service":"orders-api","method":"GET","path":"/orders/{}","count":14200,"lastSeen":"2026-11-18"}]}
--- end ---
Not sent to Graphwake:
Requests that matched no endpoint, by host and path prefix:
- gateway.internal /internal/health 412
Requests withheld because the caller name looked personal: 3
Requests without a caller name: 7Requests that matched none of your endpoints are listed by host and path prefix, at most 20 rows: the prefix is the first two segments of the path, and a segment that contains a digit, @ or %, or is longer than 24 characters, is printed as *. In a real run only their number is sent. If they are calls to your services through a gateway, add a mapping rule on the usage source and run the dry run again.
API key ids and client ids are not names, so the step only looks them up in a caller map: a CSV file you keep next to the pipeline that names them. A key id or client id the map holds wins over caller. Each row is match,name: match is an exact value, compared letter case included, or an address range such as 10.2.0.0/16, and name is the caller name sent instead. A mapped name still goes through the withholding rules. The caller map file, and the raw values it maps, are never sent.
match,name
<api key id>,partner-sync
<app client id>,checkout-webcallers.csv: an example caller map. The header line is optional.graphwake usage --source apigateway --input apigateway-usage.jsonl --caller-map callers.csv --dry-runWith a caller map the dry run also prints how many requests the map named and how many were left unnamed. A row that cannot be used, such as an invalid range, an empty name or a match an earlier row has, stops the run before the input is read: nothing is sent, and the warning names the row number only.
Step 4: send it on a schedule
The job can run on a hosted runner; the export reads the log group with AWS credentials. GitHub Actions takes them from an IAM role through OpenID Connect (role-to-assume, with id-token: write); Azure Pipelines from the secret variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. The credentials need logs:FilterLogEvents on the log group. Replace <region> and <log group> with your own.
name: Graphwake usage
on:
schedule:
- cron: "0 5 * * *"
permissions:
id-token: write
contents: read
jobs:
usage:
runs-on: ubuntu-latest
steps:
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: <region>
- name: Export the access log
run: |
aws logs filter-log-events --log-group-name <log group> \
--start-time $(( ($(date +%s) - 7*86400) * 1000 )) \
--output text --query 'events[].[message]' > apigateway-usage.jsonl
- name: Send the usage summary
env:
GRAPHWAKE_USAGE_KEY: ${{ secrets.GRAPHWAKE_USAGE_KEY }}
run: docker run --rm -i -e GRAPHWAKE_USAGE_KEY ghcr.io/graphwake/agent:0.5.0 usage --source apigateway < apigateway-usage.jsonl.github/workflows/graphwake-usage.yml.schedules:
- cron: '0 5 * * *'
displayName: Daily usage summary
branches:
include: [main]
always: true
trigger: none
pr: none
pool:
vmImage: ubuntu-latest
steps:
- checkout: none
- bash: |
aws logs filter-log-events --log-group-name <log group> \
--start-time $(( ($(date +%s) - 7*86400) * 1000 )) \
--output text --query 'events[].[message]' > apigateway-usage.jsonl
displayName: Export the access log
env:
AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
AWS_DEFAULT_REGION: <region>
- bash: docker run --rm -i -e GRAPHWAKE_USAGE_KEY ghcr.io/graphwake/agent:0.5.0 usage --source apigateway < apigateway-usage.jsonl
displayName: Send the usage summary
env:
GRAPHWAKE_USAGE_KEY: $(GRAPHWAKE_USAGE_KEY)GRAPHWAKE_USAGE_KEY as a secret variable.Both examples run the agent's Docker image ghcr.io/graphwake/agent:0.5.0 once a day at 05:00 UTC, with the usage key from a secret. The export goes into the container on standard input, which is why docker run has -i.
Each run exports the last 7 days. Each summary's counts replace the previous one's for the same caller and endpoint, so the days two runs share are not added up.
To use the caller map in the schedule, keep callers.csv in the repository that holds the pipeline, check the repository out in the job (in GitHub Actions add the actions/checkout step first; in Azure Pipelines replace checkout: none with checkout: self), and give the file to the container: docker run --rm -i -e GRAPHWAKE_USAGE_KEY -v "$PWD/callers.csv:/callers.csv:ro" ghcr.io/graphwake/agent:0.5.0 usage --source apigateway --caller-map /callers.csv < apigateway-usage.jsonl.
The agent does not fail the pipeline: it prints one result line, so a summary that was not sent shows as a warning in the job log, not as a red job (a missing file or image still fails the step, and so does the runner stopping the agent before it finishes, for example when it runs out of memory).
Step 5: claim your callers
After the first summary arrives, open Discovery → Callers in Graphwake.
- When Graphwake can suggest a team for a caller, for example because the names match, Confirm adds the caller to that team and Not us dismisses the suggestion.
- Any caller can be claimed with Claim for my team: a team member claims it for their own team, an Admin for any team.
- Every endpoint a claimed caller uses becomes a subscription of that team, and new endpoints follow with later summaries. The next breaking change on them reaches the team in its own channel.
- A subscription the team removes is not added back, and a caller that stops calling keeps its subscriptions. An Admin can ignore a caller that is not a client, such as a health check.
What is sent
- The caller's name. The
callermember of the log line: the principal or context key your Lambda authorizer returns. When your caller map has a row for the request's API key id or client id, that row's name is sent instead; the id itself never is. To read another member of the log line, other thanapiKeyIdandclientId, name it with--caller-field. Point it at a field that names the client and nothing else: whatever it holds is what is sent as the caller name, unless it is withheld. - The endpoint, as a path template such as
/orders/{}, never the concrete path. - How many calls, and the last day the caller was seen.
Other than the one value you choose as the caller name, nothing from a request leaves your network: no body, header, query string or IP address. What the usage step sends lists every field.
Good to know
- A
$defaultroute or a{proxy+}route has no route template, so its calls count as matching no endpoint. - The stage is not in the logged route. When your spec's server URL carries the stage, add a mapping on the usage source for the host.
- An API key id or a client id is only looked up in your caller map, and is never sent.
- API keys are a REST API feature. An HTTP API names its callers through a Lambda authorizer or a JWT authorizer.
- Export the log with
aws logs filter-log-eventsas in step 2. A log group exported to S3 is in another format, which the step does not read.
Questions
Does Graphwake need access to our AWS account?
No. The export runs in your pipeline with your own AWS credentials. Graphwake holds no credential for your gateway or your cloud; it receives only the summary.
Are API key ids or client ids sent?
No. The step only looks them up in your caller map and sends the name the map gives. The caller map file, and the raw values it maps, are never sent.
Is Usage Discovery required?
No. It is optional, on Pro and Enterprise. Without it, Graphwake still needs only your spec, and teams subscribe to the endpoints they call.
Pick an endpoint. See who it reaches. 14-day free trial, then a free plan. No credit card needed.
Start free trialSources and last verified
Sources checked on 2026-12-01.