Documentation
¶
Overview ¶
Package reqlog records every API call and data-plane request as a structured entry (FR-CORE-061) and keeps the most recent ones in memory for the admin API (FR-CORE-045).
Index ¶
Constants ¶
const MaxBody = 16 << 10
MaxBody is how much of a body an entry keeps.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bodies ¶ added in v0.6.0
type Bodies struct {
Request *Body `json:"requestBody,omitempty"`
Response *Body `json:"responseBody,omitempty"`
}
Bodies are the bodies of one API call.
type Body ¶ added in v0.6.0
type Body struct {
ContentType string `json:"contentType,omitempty"`
// Size is the body's length in bytes: what the handler read of a
// request, or wrote of a response.
Size int64 `json:"size"`
// Text is the first MaxBody bytes; empty when Binary.
Text string `json:"text,omitempty"`
Truncated bool `json:"truncated,omitempty"`
// Binary is set when the kept bytes are not UTF-8 text.
Binary bool `json:"binary,omitempty"`
}
Body is the start of a request or response body.
type Capture ¶ added in v0.6.0
type Capture struct {
// contains filtered or unexported fields
}
Capture collects the first MaxBody bytes written to it and counts the rest.
type Entry ¶
type Entry struct {
// ID numbers the entries of one process from 1, in the order added.
ID int64 `json:"id"`
Time time.Time `json:"time"`
Service string `json:"service"`
Protocol string `json:"protocol"` // http, grpc, dns, postgres, tcp, udp
Method string `json:"method"`
// Resource is the resource acted on: the one whose permission an API
// call checked first, the answering DNS zone, the Cloud SQL instance or
// the Cloud NAT gateway.
Resource string `json:"resource,omitempty"`
Principal string `json:"principal,omitempty"`
// Status is protocol-specific: the HTTP status, gRPC code or DNS
// rcode; for connections (postgres, NAT) 0 when admitted and 1 when
// refused, with the reason in Code.
Status int `json:"status"`
Code string `json:"code,omitempty"`
LatencyMS float64 `json:"latencyMs"`
// Delegated is the link over which the API gateway forwarded the
// request, for a Project delegated to a Linked Instance (ADR 0027).
Delegated string `json:"delegated,omitempty"`
// LB is the load balancer's trace of a data-plane request.
LB *LBTrace `json:"lb,omitempty"`
// NAT is the NAT egress proxy's trace of an internet egress attempt.
NAT *NATTrace `json:"nat,omitempty"`
// Bodies are the API call's request and response bodies. They are left
// out of Entries and of the event stream, and read with Get.
Bodies *Bodies `json:"-"`
}
Entry is one logged request.
type LBTrace ¶ added in v0.6.0
type LBTrace struct {
Host string `json:"host"`
// Path is the path and query as the client sent them.
Path string `json:"path"`
TargetProxy string `json:"targetProxy,omitempty"`
URLMap string `json:"urlMap,omitempty"`
// Match is the URL map rule that matched: "routeRule", "pathRule",
// "pathMatcherDefault" or "urlMapDefault"; empty when the URL map is
// missing or invalid.
Match string `json:"match,omitempty"`
PathMatcher string `json:"pathMatcher,omitempty"`
// Priority is the matched route rule's; Paths the matched path rule's.
Priority *int64 `json:"priority,omitempty"`
Paths []string `json:"paths,omitempty"`
// Redirect is the Location of a redirect the load balancer answered.
Redirect string `json:"redirect,omitempty"`
// Backend is the backend service or bucket path, Endpoint the
// endpoint (ip:port, or the bucket) that answered.
Backend string `json:"backend,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
// CacheStatus is Cloud CDN's {cdn_cache_status}: hit, miss,
// revalidated, uncacheable, or disabled when the backend has no CDN.
CacheStatus string `json:"cacheStatus,omitempty"`
StatusDetails string `json:"statusDetails,omitempty"`
BackendLatencyMS float64 `json:"backendLatencyMs,omitempty"`
}
LBTrace is how a load balancer served one request: the forwarding rule is the Entry's Resource.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is a bounded ring buffer of entries that also writes to a logger.
func (*Log) Clear ¶
func (l *Log) Clear()
Clear drops all entries. IDs keep counting, so an ID never names two entries.
func (*Log) Entries ¶
Entries returns the retained entries, oldest first, optionally filtered by service.
type NATTrace ¶ added in v0.6.0
type NATTrace struct {
Network string `json:"network"`
Subnetwork string `json:"subnetwork,omitempty"`
// VM is the workload holding the source address, e.g. a GKE node.
VM string `json:"vm,omitempty"`
SrcIP string `json:"srcIp"`
SrcPort int `json:"srcPort"`
DestIP string `json:"destIp"`
DestPort int `json:"destPort"`
// NatIP and NatPort are the translated source, when one was allocated.
NatIP string `json:"natIp,omitempty"`
NatPort int `json:"natPort,omitempty"`
// Request is the first line the offline sink received.
Request string `json:"request,omitempty"`
}
NATTrace is one connection the NAT egress proxy saw leave a VPC network: translated, dropped or answered by the offline sink (the Entry's Code). The Cloud NAT gateway, or the network when no NAT covers the source, is the Entry's Resource. Fields follow Cloud NAT's log (FR-NAT-004).