1package log
2
3// AccessLogField is used to select which fields are recorded in the access log. See WithoutFields.
4type AccessLogField uint16
5
6const (
7	// CorrelationID field will record the Correlation-ID in the access log.
8	CorrelationID AccessLogField = 1 << iota
9
10	// HTTPHost field will record the Host Header in the access log.
11	HTTPHost
12
13	// HTTPRemoteIP field will record the remote caller in the access log, taking Real-IP and X-Forwarded-For headers into account.
14	HTTPRemoteIP
15
16	// HTTPRemoteAddr field will record the remote socket endpoint in the access log.
17	HTTPRemoteAddr
18
19	// HTTPRequestMethod field will record the HTTP method in the access log.
20	HTTPRequestMethod
21
22	// HTTPURI field will record the URI, including parameters.
23	HTTPURI
24
25	// HTTPProto field will record the protocol used to make the request in the access log.
26	HTTPProto
27
28	// HTTPResponseStatusCode field will record the response HTTP status code in the access log.
29	HTTPResponseStatusCode
30
31	// HTTPResponseSize field will record the response size, in bytes, in the access log.
32	HTTPResponseSize
33
34	// HTTPRequestReferrer field will record the referer header in the access log.
35	HTTPRequestReferrer
36
37	// HTTPUserAgent field will record the useragent header in the access log.
38	HTTPUserAgent
39
40	// RequestDuration field will record the request duration in the access log.
41	RequestDuration
42
43	// System field will record the system for the log entry.
44	System
45
46	// HTTPResponseContentType field will record the response content-type in the access log.
47	HTTPResponseContentType
48
49	// RequestTTFB field will record the time to the first byte being written (HTTP Header effectively)
50	// in the access log. Time is recorded before an actual Write happens to ensure that this metric
51	// is not affected by a slow client receiving data.
52	RequestTTFB
53)
54
55const defaultEnabledFields = ^AccessLogField(0) // By default, all fields are enabled
56
57// For field definitions, consult the Elastic Common Schema field reference
58// https://www.elastic.co/guide/en/ecs/current/ecs-field-reference.html.
59const (
60	httpHostField                = "host"          // ESC: url.domain
61	httpRemoteIPField            = "remote_ip"     // ESC: client.ip
62	httpRemoteAddrField          = "remote_addr"   // ESC: client.address
63	httpRequestMethodField       = "method"        // ESC: http.request.method
64	httpURIField                 = "uri"           // ESC url.path + `?` + url.query
65	httpProtoField               = "proto"         // ESC: url.scheme
66	httpResponseStatusCodeField  = "status"        // ESC: http.response.status_code
67	httpResponseSizeField        = "written_bytes" // ESC: http.response.body.bytes
68	httpRequestReferrerField     = "referrer"      // ESC: http.request.referrer
69	httpUserAgentField           = "user_agent"    // ESC: user_agent.original
70	requestDurationField         = "duration_ms"   // ESC: no mapping
71	requestTTFBField             = "ttfb_ms"       // ESC: no mapping
72	systemField                  = "system"        // ESC: no mapping
73	httpResponseContentTypeField = "content_type"  // ESC: no mapping
74)
75