Repository navigation
Graphwake CI agent v0.3.0
Usage Discovery. The agent has a second command, graphwake usage: it reads a gateway log or trace export and sends Graphwake a summary of which caller used which endpoint, how many times and on which day last. It reads one file or standard input, runs wherever you run it (a scheduled CI job or any scheduler) and connects to nothing but Graphwake (it never follows a redirect). The summary holds the caller name, the endpoint as a path template, the call count and the last-seen day. Other than the one value you choose as the caller name, nothing from a request is sent: no body, header, query string or IP address.
Optional. Without it, Graphwake still needs only your spec.
upload is unchanged in this release. The top-level help (graphwake -h) now also lists the usage commands.
Highlights
graphwake usage --source <preset>reads--input <file>or standard input (in CI always pass--input: piped input is read until the pipe is closed), fetches the endpoint list of the usage key's usage source from Graphwake, matches every request to an endpoint template on this machine and sends the summary. The key is read fromGRAPHWAKE_USAGE_KEY(--keyis accepted);GRAPHWAKE_KEY, the spec upload's key, is a different key. The other variables:GRAPHWAKE_USAGE_SOURCE,GRAPHWAKE_USAGE_INPUT,GRAPHWAKE_USAGE_SERVICE,GRAPHWAKE_USAGE_CALLER_FIELD,GRAPHWAKE_USAGE_NO_COUNTS,GRAPHWAKE_USAGE_DRY_RUN, andGRAPHWAKE_URLfor the API URL (--url).- Seven sources:
apim(Azure API Management),appinsights(Azure Application Insights, workspace-based, throughaz monitor log-analytics query),datadog(Datadog APM, the spans aggregate API),kong(Kong file-log or http-log),nginx(NGINX, a JSON log format),otel(OpenTelemetry Collector file exporter; the printed configuration needs the Collector's contrib distribution, 0.146.0 or later) andgeneric(CSV or JSON from any other tool).graphwake usage query --source <preset>prints the query or configuration that produces the input, without a key or a network call. --dry-runfetches the endpoint list, builds the summary and prints the exact body that would be sent, then what is not sent: the unmatched requests by host and path prefix (printed to the job log, so masked: a path segment with a digit,@or%, or longer than 24 characters, shows as*, and at most 20 rows are listed) and the withheld and anonymous request counts, then, when the preset skipped lines or elements, how many (2 lines could not be read.). When the summary has no rows, it ends withNote: this summary has no rows, so it would not be sent., because the real run sends nothing then. It sends no summary; it only fetches the endpoint list with the usage key.--caller-fieldnames the field that identifies the caller when the preset's default does not;--servicenames the Graphwake service for requests that no mapping, server URL host orservicecolumn assigns;--no-countssends the summary without per-row counts (the three totalsunmatchedRequests,withheldRequestsandanonymousRequestsare still sent).
Privacy, as the code does it
- A closed field list. The summary has the fields
preset,agentVersion,windowStart,windowEnd,countsIncluded,unmatchedRequests,withheldRequests,anonymousRequestsandrows; each row hascaller,callerKind,endpointId,service,method,path,countandlastSeen. A test fails if a field is added. The row's endpoint, service, method and path template come from the endpoint list Graphwake sent, never from the raw request. - From the input, only the caller field is sent as free text. The value of the field you choose as the caller (the preset's default or
--caller-field) is sent as the caller name unless it is withheld: without white space at its ends and cut to its first 200 characters (the rules are checked before and after the cut). A certificate subject the agent can read (mutual TLS, NGINX's$ssl_client_s_dn; the README's step 2 under What the usage step sends says which) is reduced to its common name; only the common name is sent, soCN=checkout,OU=Payments,O=Acmegives the caller namecheckout. A subject with aUID,DC,emailAddressorEpart may be a person's, so it is not reduced: it is withheld whole. Besides the request counts, the days and, in thegenericpreset, theclientorservicekind from thecallerKindcolumn, nothing is sent from any field other than the chosen caller field: not a request's path or query string, host, API name, body, status code or client IP address. No header value is sent except the one you choose as the caller name (NGINX's suggested format fillscallerfrom$http_x_client_id; Kong's--caller-fieldcan name a header). The caller name is whatever that field holds: a value that no rule below withholds, such as a host name or a status code, is sent if the caller field names one, so point it at a field that names the application. - Withheld caller names, a safety net. A caller name that matches one of the withholding rules is not sent, and its requests are counted in
withheldRequests. The exact rules, with examples of what each one catches and does not catch, are in the README under What the usage step sends. As a summary only, the shapes they look for: an e-mail address; an IPv4 or IPv6 address; 32 or more hexadecimal characters in a row; a run of 32 or more letters, digits and+/_=-with upper case, lower case and a digit; a control character; the sequence##; a path or a URL; and any of the characters{,},",<,>or=. These rules catch common shapes of personal or secret values; they are a safety net, not a guarantee, so choose a caller field that holds a client or application name. - A caller limit: with more distinct callers (caller name and kind pairs) than the limit (2,000 unless Graphwake's endpoint list sets another), nothing is sent and the warning says to choose another
--caller-field. When the summary fits but the usage source already holds too many callers (claimed and ignored ones count), Graphwake refuses it and the agent warns:usage not sent: this source already holds too many callers (claimed and ignored callers count). Unclaim or stop ignoring callers you no longer need in Graphwake, or add a new usage source.The agent stops keeping callers and rows once a limit is passed, so their number cannot exhaust memory; in an input read line by line, a line longer than 16 MB is skipped and counted as unreadable. - Counts saturate at the largest 64-bit integer;
--no-countsleaves the per-row counts out. - The usage key is never printed. A dry run only fetches the endpoint list and never sends a summary.
- Incomplete exports are reported: a Datadog answer with a status other than
done, a warning or cut short, or an Application Insights API answer (thetablesform) with anerrormember that is not null, adds "The export was incomplete (the tool reported a timeout or a warning)." to the result line. Datadog answers carry no dates, so their requests get the day the step runs.
graphwake usage exits 0 for every error it handles (bad input, network, key, plan, limits, an internal error) and prints one result line (--dry-run and usage query print several). It cannot exit 0 when the process is stopped before it finishes: when it runs out of memory (for example on one JSON value of several gigabytes, which is read whole; only input read line by line has the 16 MB cap) or when the runner kills it because standard input is a pipe that is never closed. That is why CI should pass --input.
Install
The GitHub Action, the GitLab template and the Azure DevOps task run upload only and now download agent 0.3.0 by default. Run graphwake usage with the Docker image or the binary.
Docker
docker run --rm -e GRAPHWAKE_USAGE_KEY -v "$PWD:/w" -w /w ghcr.io/graphwake/agent:0.3.0 usage --source generic --input usage.csv --dry-runBinary
VERSION=0.3.0
BASE=https://github.com/graphwake/agent/releases/download/v$VERSION
ARCHIVE=graphwake_${VERSION}_linux_amd64.tar.gz
curl -fsSLO "$BASE/$ARCHIVE" && curl -fsSLO "$BASE/checksums.txt" &&
sha256sum --check --ignore-missing checksums.txt &&
tar -xzf "$ARCHIVE" graphwake &&
./graphwake usage --source generic --input usage.csv --dry-runSpec upload (unchanged)
- uses: graphwake/agent/github-action@v0.3.0
with:
spec: openapi.json
key: ${{ secrets.GRAPHWAKE_KEY }}See the README for every source, flag, output line and a daily GitHub Actions and Azure Pipelines example. Setup for each tool: https://graphwake.com/guides/find-api-consumers-from-gateway-logs. What the step sends: https://graphwake.com/security/usage-data.
Assets
| Platform | amd64 | arm64 |
|---|---|---|
| Linux | graphwake_0.3.0_linux_amd64.tar.gz |
graphwake_0.3.0_linux_arm64.tar.gz |
| macOS | graphwake_0.3.0_darwin_amd64.tar.gz |
graphwake_0.3.0_darwin_arm64.tar.gz |
| Windows | graphwake_0.3.0_windows_amd64.zip |
graphwake_0.3.0_windows_arm64.zip |
SHA-256 checksums are in checksums.txt. The multi-arch Docker image ghcr.io/graphwake/agent:0.3.0 (also :latest) is published for linux/amd64 and linux/arm64.
Upgrade notes
- None required.
uploadis unchanged; pipelines that pin 0.2.0 keep working. - The GitHub Action (
versioninput), the GitLab template (image tag) and the Azure DevOps task (agentVersioninput, task version 0.3.0, extension version 0.3.0) now default to agent 0.3.0. graphwake usageneeds a usage key from Graphwake. Whatever the server answers, the command exits 0.