Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CMSMonitProducer string
CMSMonitProducer controls CMS Monit producer name
var CMSMonitType string
CMSMonitType controls CMS Monit log record type
var CollectorLogin string
CollectorLogin
var CollectorPassword string
CollectorPassword
var CollectorSize int
CollectorSize
var CollectorURL string
CollectorURL
var CollectorVerbose int
CollectorVerbose
var UTC bool
UTC flag represents UTC time zone for log messages
var ZapLogger string
ZapLogger defines zap logger structure
Functions ¶
func LogRequest ¶
func LogRequest(w http.ResponseWriter, r *http.Request, start time.Time, cauth string, status *int, tstamp int64, bytesOut int64)
helper function to log every single user request, here we pass pointer to status code as it may change through the handler while we use defer logRequest
func LoggingMiddleware ¶
LoggingMiddleware provides logging middleware for HTTP requests https://arunvelsriram.dev/simple-golang-http-logging-middleware
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector holds a fixed-size list of records
var LogCollector *Collector
LogCollector pointer
func NewCollector ¶
func NewCollector(maxSize int, endpoint, login, password string, httpClient *http.Client) *Collector
NewCollector initializes and returns a new Collector
func (*Collector) CollectAndSend ¶
func (c *Collector) CollectAndSend(record HTTPRecord) error
CollectAndSend collects a new record. If the list reaches the maxSize, it sends the records to the configured endpoint and resets the list.
type CustomResponseWriter ¶
type CustomResponseWriter struct { http.ResponseWriter BytesWritten int }
CustomResponseWriter wraps http.ResponseWriter to capture the number of bytes written
type HTTPRecord ¶
type HTTPRecord struct { Producer string `json:"producer"` // name of the producer Type string `json:"type"` // type of metric Timestamp int64 `json:"timestamp"` // UTC milliseconds Host string `json:"host"` // used to add extra information about the node submitting your data Data LogRecord `json:"data"` // log record data }
HTTPRecord provides http record we send to logs endpoint
type LogRecord ¶
type LogRecord struct { Method string `json:"method"` // http.Request HTTP method URI string `json:"uri"` // http.RequestURI API string `json:"api"` // http service API being used System string `json:"system"` // cmsweb service name ClientIP string `json:"clientip"` // client IP address BytesSend int64 `json:"bytes_send"` // number of bytes send with HTTP request BytesReceived int64 `json:"bytes_received"` // number of bytes received with HTTP request Proto string `json:"proto"` // http.Request protocol Status int64 `json:"status"` // http.Request status code ContentLength int64 `json:"content_length"` // http.Request content-length AuthProto string `json:"auth_proto"` // authentication protocol AuthCert string `json:"auth_cert"` // auth certificate, user DN LoginName string `json:"login_name"` // login name, user DN Auth string `json:"auth"` // auth method Cipher string `json:"cipher"` // TLS cipher name Referer string `json:"referer"` // http referer UserAgent string `json:"user_agent"` // http user-agent field UserAgentName string `json:"user_agent_name"` // http user-agent name w/o version XForwardedHost string `json:"x_forwarded_host"` // http.Request X-Forwarded-Host XForwardedFor string `json:"x_forwarded_for"` // http.Request X-Forwarded-For RemoteAddr string `json:"remote_addr"` // http.Request remote address ResponseStatus string `json:"response_status"` // http.Response status ResponseTime float64 `json:"response_time"` // http response time RequestTime float64 `json:"request_time"` // http request time Timestamp int64 `json:"timestamp"` // record timestamp RecTimestamp int64 `json:"rec_timestamp"` // timestamp for backward compatibility with apache RecDate string `json:"rec_date"` // timestamp for backward compatibility with apache // additional fields required by monitoring CmswebEnv string `json:"cmsweb_env"` // cmsweb environment CmswebCluster string `json:"cmsweb_cluster"` // cmsweb cluster ClientVersion string `json:"client_version"` // client version ProxyServer string `json:"proxy_server"` // proxy server }
LogRecord represents HTTP log record
type RotateLogWriter ¶
type RotateLogWriter struct {
RotateLogs *rotatelogs.RotateLogs
}
custom rotate logger