Documentation ¶
Index ¶
- Constants
- Variables
- func ErrInValidFieldCnt(msg string) error
- type AdRowParser
- type Config
- type DecodedReq
- type Decoder
- type LogCloser
- type LogEntry
- type M
- type MetricSender
- type PrometheusConfig
- type PrometheusSender
- type ReadCloser
- type ReqHeader
- type RequestRow
- func (a *RequestRow) ApiName() string
- func (a *RequestRow) BatchDelete() map[uint32]int64
- func (a *RequestRow) BillTag() string
- func (a *RequestRow) Bucket() string
- func (a *RequestRow) Code() string
- func (a *RequestRow) LogType() string
- func (a *RequestRow) Method() string
- func (a *RequestRow) Path() string
- func (a *RequestRow) RawQuery() string
- func (a *RequestRow) RemoteAddr() string
- func (a *RequestRow) RemoteIp() string
- func (a *RequestRow) ReqCdn() string
- func (a *RequestRow) ReqFsize() (fsize int64)
- func (a *RequestRow) ReqHost() string
- func (a *RequestRow) ReqLength() (reqLength int64)
- func (a *RequestRow) ReqParams() string
- func (a *RequestRow) ReqSrc() string
- func (a *RequestRow) ReqTime() int64
- func (a *RequestRow) ReqToken() *Token
- func (a *RequestRow) RespLength() (respLength int64)
- func (a *RequestRow) RespSToken() *SToken
- func (a *RequestRow) RespTime() (respTime int64)
- func (a *RequestRow) RespToken() *Token
- func (a *RequestRow) Service() string
- func (a *RequestRow) String() string
- func (a *RequestRow) UA() string
- func (a *RequestRow) Uid() uint32
- func (a *RequestRow) XRespCode() string
- func (a *RequestRow) XWarns() []string
- func (a *RequestRow) XlogSearch(name string) (rets []Xlog)
- func (a *RequestRow) XlogTime(name string) (msSpeed uint64)
- func (a *RequestRow) Xlogs() []string
- func (a *RequestRow) XlogsTime(names []string) (msSpeedTotal uint64)
- type RespHeader
- type RsInfo
- type SToken
- type Token
- type Xlog
Constants ¶
View Source
const ( TAG_SERVICE = 1 TAG_TIME = 2 TAG_METHOD = 3 TAG_PATH = 4 TAG_HEADER = 5 TAG_PARAMS = 6 TAG_CODE = 7 TAG_RESPONSE_HEADER = 8 TAG_RESPONSE = 9 TAG_RESPONSE_SIZE = 10 TAG_RESPONSE_TIME = 11 )
View Source
const ( // upper letter[A-Z] UpperLetter = 0x01 // lower letter[a-z] LowerLetter = 0x02 // digital[0-9] Digital = 0x04 // underline[_] Underline = 0x08 // xdigit[0-9a-fA-F] HexDigital = 0x10 // [\r\n] Newline = 0x20 // [+] AddLetter = 0x40 // [-] SubLetter = 0x80 // [*] Asterisk = 0x100 // [/] SlantLetter = 0x200 // [<] LtLetter = 0x400 // [>] GtLetter = 0x800 // [=] EqLetter = 0x1000 // [\\] RSlantLetter = 0x2000 // [.] DotLetter = 0x4000 // [:], colon ColonLetter = 0x8000 // [%] PercentLetter = 0x10000 // [&] AndLetter = 0x20000 // [|] OrLetter = 0x40000 // [ ] SpaceLetter = 0x80000 // [r] RLetter = 0x100000 // [t] TLetter = 0x200000 // [n] NLetter = 0x400000 // [w] WLetter = 0x800000 // [,] CommaLetter = 0x1000000 // [;] SemiColonLetter = 0x2000000 // [\t] TabLetter = 0x4000000 // ["] QuotLetter = 0x8000000 // [`] BacktickLetter = 0x10000000 // [!] ExclamaLetter = 0x20000000 )
View Source
const (
ALPHA = UpperLetter | LowerLetter
)
View Source
const (
LogTypeAudit = "audit"
)
Variables ¶
View Source
var (
Buckets = []float64{1, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000}
)
View Source
var DefaultRequestHeaderKeys = []string{ "User-Agent", "Range", "Refer", "Referer", "Origin", "Content-Length", "Accept-Encoding", "If-None-Match", "If-Modified-Since", "Cdn", "Cdn-Src-Ip", "Cdn-Scheme", "X-Real-Ip", "X-Forwarded-For", "X-Scheme", "X-Remote-Ip", "X-From-Cdn", "X-Id", "X-From-Proxy-Getter", "X-From-Fsrcproxy", "X-Upload-Encoding", "X-Src", auth.TokenHeaderKey, }
View Source
var MetricLabelNames = []string{hostLabel, "service", "team", "tag", "api", "method", "code", "reqlength", "resplength", "deleteAfterDays", "idc", "xwarn", "country", "region", "isp"}
Functions ¶
func ErrInValidFieldCnt ¶
Types ¶
type AdRowParser ¶
type AdRowParser struct{}
func (*AdRowParser) Parse ¶
func (self *AdRowParser) Parse(line string) (*RequestRow, error)
type Config ¶
type Config struct { // LogDir audit log whether to enable depend on whether config log dir LogDir string `json:"logdir"` // ChunkBits means one audit log file size // eg: chunkbits=20 means one log file will hold 1<<10 size ChunkBits uint `json:"chunkbits"` BodyLimit int `json:"bodylimit"` // rotate new audit log file every start time RotateNew bool `json:"rotate_new"` LogFileSuffix string `json:"log_file_suffix"` // 0 means no backup limit Backup int `json:"backup"` MetricConfig PrometheusConfig `json:"metric_config"` // KeywordsFilter log filter based on uri and request method KeywordsFilter []string `json:"keywords_filter"` }
type DecodedReq ¶
type Decoder ¶
type Decoder interface {
DecodeReq(req *http.Request) *DecodedReq
}
type LogCloser ¶
LogCloser a implemented audit logger should implements ProgressHandler and LogCloser interface to replace qn audit log
type LogEntry ¶
type LogEntry interface { Service() string LogType() string Code() string Method() string Path() string RespTime() int64 // 100ns RespLength() int64 ReqLength() int64 ReqHost() string RemoteAddr() string Xlogs() []string UA() string XRespCode() string // ReqParams returns params of request, including params in raw query and body ReqParams() string Uid() uint32 ApiName() string }
func ParseReqlog ¶
type MetricSender ¶
type PrometheusConfig ¶
type PrometheusConfig struct { Idc string `json:"idc"` Service string `json:"service"` Tag string `json:"tag"` Team string `json:"team"` EnableHttpMethod bool `json:"enable_http_method"` DisableApi bool `json:"disable_api"` EnableReqLengthCnt bool `json:"enable_req_length_cnt"` EnableRespLengthCnt bool `json:"enable_resp_length_cnt"` EnableRespDuration bool `json:"enable_resp_duration"` EnableXWarnCnt bool `json:"enable_xwarn_cnt"` MaxApiLevel int `json:"max_api_level"` XWarns []string `json:"xwarns"` ErrCodes map[string]bool `json:"resp_err_codes"` SizeBuckets []int `json:"size_buckets"` }
type PrometheusSender ¶
type PrometheusSender struct { PrometheusConfig // contains filtered or unexported fields }
func NewPrometheusSender ¶
func NewPrometheusSender(conf PrometheusConfig) (ps *PrometheusSender)
func (*PrometheusSender) Send ¶
func (ps *PrometheusSender) Send(raw []byte) error
Send inherit from Sender
type ReqHeader ¶
type ReqHeader struct { ContentLength string `json:"Content-Length"` BodySize int64 `json:"bs"` // body size RawQuery string `json:"RawQuery"` Host string `json:"Host"` Token *Token `json:"Token"` XRealIp string `json:"X-Real-Ip"` XFromCdn string `json:"X-From-Cdn"` XSrc string `json:"X-Src"` IP string `json:"IP"` UA string `json:"User-Agent"` }
type RequestRow ¶
type RequestRow struct {
// contains filtered or unexported fields
}
func ParseReqlogToAdrow ¶
func ParseReqlogToAdrow(line string) (*RequestRow, error)
func (*RequestRow) ApiName ¶
func (a *RequestRow) ApiName() string
func (*RequestRow) BatchDelete ¶
func (a *RequestRow) BatchDelete() map[uint32]int64
func (*RequestRow) BillTag ¶
func (a *RequestRow) BillTag() string
func (*RequestRow) Bucket ¶
func (a *RequestRow) Bucket() string
func (*RequestRow) Code ¶
func (a *RequestRow) Code() string
func (*RequestRow) LogType ¶
func (a *RequestRow) LogType() string
func (*RequestRow) Method ¶
func (a *RequestRow) Method() string
func (*RequestRow) Path ¶
func (a *RequestRow) Path() string
func (*RequestRow) RawQuery ¶
func (a *RequestRow) RawQuery() string
func (*RequestRow) RemoteAddr ¶
func (a *RequestRow) RemoteAddr() string
func (*RequestRow) RemoteIp ¶
func (a *RequestRow) RemoteIp() string
func (*RequestRow) ReqCdn ¶
func (a *RequestRow) ReqCdn() string
func (*RequestRow) ReqFsize ¶
func (a *RequestRow) ReqFsize() (fsize int64)
func (*RequestRow) ReqHost ¶
func (a *RequestRow) ReqHost() string
func (*RequestRow) ReqLength ¶
func (a *RequestRow) ReqLength() (reqLength int64)
func (*RequestRow) ReqParams ¶
func (a *RequestRow) ReqParams() string
func (*RequestRow) ReqSrc ¶
func (a *RequestRow) ReqSrc() string
func (*RequestRow) ReqToken ¶
func (a *RequestRow) ReqToken() *Token
func (*RequestRow) RespLength ¶
func (a *RequestRow) RespLength() (respLength int64)
func (*RequestRow) RespSToken ¶
func (a *RequestRow) RespSToken() *SToken
func (*RequestRow) RespTime ¶
func (a *RequestRow) RespTime() (respTime int64)
func (*RequestRow) RespToken ¶
func (a *RequestRow) RespToken() *Token
func (*RequestRow) Service ¶
func (a *RequestRow) Service() string
func (*RequestRow) String ¶
func (a *RequestRow) String() string
func (*RequestRow) UA ¶
func (a *RequestRow) UA() string
func (*RequestRow) Uid ¶
func (a *RequestRow) Uid() uint32
func (*RequestRow) XRespCode ¶
func (a *RequestRow) XRespCode() string
func (*RequestRow) XWarns ¶
func (a *RequestRow) XWarns() []string
func (*RequestRow) XlogSearch ¶
func (a *RequestRow) XlogSearch(name string) (rets []Xlog)
func (*RequestRow) XlogTime ¶
func (a *RequestRow) XlogTime(name string) (msSpeed uint64)
func (*RequestRow) Xlogs ¶
func (a *RequestRow) Xlogs() []string
func (*RequestRow) XlogsTime ¶
func (a *RequestRow) XlogsTime(names []string) (msSpeedTotal uint64)
type RespHeader ¶
type RespHeader struct { ContentLength string `json:"Content-Length"` Xlog []string `json:"X-Log"` XWarn []string `json:"X-Warn"` Bucket string `json:"Tbl"` Token *Token `json:"Token"` SToken *SToken `json:"SToken"` FileType int `json:"FileType"` BatchOps map[string]int64 `json:"batchOps"` PreDelSize map[string]int64 `json:"preDelSize"` PreDelArchiveSize map[string]int64 `json:"preDelArchiveSize"` OUid uint32 `json:"ouid"` // owner uid RsInfo *RsInfo `json:"rs-info"` XRespCode string `json:"X-Resp-Code"` // return from dora BillTag string `json:"billtag"` // must be same with definition in billtag.go BatchDeletes map[uint32]int64 `json:"batchDelete"` ApiName string `json:"api"` // api name of this auditlog }
Click to show internal directories.
Click to hide internal directories.