Expand description
The google-cloud-logging node — ships access-log entries to
Google Cloud Logging in batches.
Ported from APISIX’s google-cloud-logging.lua. On the request path the
node builds a log entry (via the shared
build_entry) and hands it
to a BatchSink. A background task wraps the buffered entries into the
Cloud Logging entries:write payload and POSTs them to
https://logging.googleapis.com/v2/entries:write with an OAuth2 bearer
token. The node passes the context through unchanged.
§Authentication (service-account JWT → OAuth2 access token)
Cloud Logging is called with a short-lived OAuth2 access token obtained via the service-account JWT-bearer grant:
- A JWT is assembled and RS256-signed with the service account’s
private_key— claimsiss=client_email,scope= space-joined scopes,aud=token_uri,iat/exp(1h lifetime). - The JWT is POSTed to
token_uriasgrant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=<jwt>. - The returned
access_tokenis cached ([tokio::sync::Mutex]) and reused until ~60s before itsexpires_in, then refreshed.
§Deviations from APISIX
- APISIX derives per-entry
httpRequest/insertIdfields and mergeslog_format_extra. featherbit uses the shared log entry as thejsonPayloadand omitshttpRequest/insertId; uselog_formatto shape the payload. log_iddefaults tofeatherbit%2Flogs(APISIX:apisix.apache.org%2Flogs).resourcedefaults to{"type":"global"}.
Structs§
- Auth
Config 🔒 - Service-account credentials resolved from
auth_configorauth_file. - Cached
Token 🔒 - Google
Cloud 🔒Flusher - Delivers batched log entries to the Cloud Logging
entries:writeendpoint. - Google
Cloud Logging Plugin - Ships log entries to Google Cloud Logging in batches.
- Token
Manager 🔒 - Caches the OAuth2 access token and refreshes it near expiry.
- Token
Response 🔒
Constants§
Functions§
- build_
jwt 🔒 - Assembles and RS256-signs the service-account JWT assertion.
- build_
log_ 🔒entry - Wraps one log entry into a Cloud Logging
LogEntry. - build_
write_ 🔒payload - Builds the full
entries:writerequest payload. - civil_
from_ 🔒days - Howard Hinnant’s civil-from-days: days since the unix epoch → (year, month, day).
- now_
secs 🔒 - resolve_
auth 🔒 - Resolves the service-account credentials from
auth_config(inline) orauth_file(path to a JSON file).client_email,private_key, andproject_idare required. - rfc3339_
zulu 🔒 - RFC3339 UTC timestamp (
YYYY-MM-DDTHH:MM:SSZ) from a unix second count.