Documentation
¶
Index ¶
- Constants
- Variables
- func AddAccessLogHook(hook *AccessLogHook)
- func AllStorageFormats() []maps.Map
- func AllStorages() []maps.Map
- func CallAccessLogHooks(accessLog *accesslogs.AccessLog)
- func FindPolicy(policyId string) *teaconfigs.AccessLogStoragePolicy
- func FindPolicyName(policyId string) string
- func FindStorageFormatName(code string) string
- func FindStorageTypeName(storageType string) string
- func ResetAllPolicies()
- func ResetPolicyStorage(policyId string)
- type AccessLogHook
- type AccessLogQueue
- type AccessLogger
- type CommandStorage
- type ESStorage
- type FileStorage
- type MySQLStorage
- type Storage
- type StorageFormat
- type StorageInterface
- type StorageType
- type SyslogStorage
- type SyslogStoragePriority
- type SyslogStorageProtocol
- type TCPStorage
Constants ¶
View Source
const (
DBBatchLogSize = 256
)
导入数据库的访问日志的步长
Variables ¶
View Source
var SyslogStoragePriorities = []maps.Map{ { "name": "[无]", "value": -1, }, { "name": "EMERG", "value": SyslogStoragePriorityEmerg, }, { "name": "ALERT", "value": SyslogStoragePriorityAlert, }, { "name": "CRIT", "value": SyslogStoragePriorityCrit, }, { "name": "ERR", "value": SyslogStoragePriorityErr, }, { "name": "WARNING", "value": SyslogStoragePriorityWarning, }, { "name": "NOTICE", "value": SyslogStoragePriorityNotice, }, { "name": "INFO", "value": SyslogStoragePriorityInfo, }, { "name": "DEBUG", "value": SyslogStoragePriorityDebug, }, }
Functions ¶
func FindPolicy ¶ added in v0.1.8
func FindPolicy(policyId string) *teaconfigs.AccessLogStoragePolicy
通过策略ID查找策略
func FindStorageFormatName ¶ added in v0.1.6
根据代号查找名称
func FindStorageTypeName ¶ added in v0.1.6
根据类型查找名称
Types ¶
type AccessLogHook ¶
type AccessLogHook struct {
Process func(accessLog *accesslogs.AccessLog) (goNext bool)
}
请求Hook定义
type AccessLogQueue ¶ added in v0.1.6
type AccessLogQueue struct {
// contains filtered or unexported fields
}
访问日志队列
func NewAccessLogQueue ¶ added in v0.1.6
func NewAccessLogQueue(buffer *logbuffer.Buffer, index int) *AccessLogQueue
创建队列对象
func (*AccessLogQueue) Receive ¶ added in v0.1.6
func (this *AccessLogQueue) Receive(ch chan *accesslogs.AccessLog)
从队列中接收日志
type CommandStorage ¶ added in v0.1.6
type CommandStorage struct {
Storage `yaml:", inline"`
Command string `yaml:"command" json:"command"`
Args []string `yaml:"args" json:"args"`
Dir string `yaml:"dir" json:"dir"`
// contains filtered or unexported fields
}
通过命令行存储
func (*CommandStorage) Write ¶ added in v0.1.6
func (this *CommandStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type ESStorage ¶ added in v0.1.6
type ESStorage struct {
Storage `yaml:", inline"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
Index string `yaml:"index" json:"index"`
MappingType string `yaml:"mappingType" json:"mappingType"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
}
ElasticSearch存储策略
type FileStorage ¶ added in v0.1.6
type FileStorage struct {
Storage `yaml:", inline"`
Path string `yaml:"path" json:"path"` // 文件路径,支持变量:${year|month|week|day|hour|minute|second}
AutoCreate bool `yaml:"autoCreate" json:"autoCreate"` // 是否自动创建目录
// contains filtered or unexported fields
}
文件存储策略
func (*FileStorage) Write ¶ added in v0.1.6
func (this *FileStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type MySQLStorage ¶ added in v0.1.6
type MySQLStorage struct {
Storage `yaml:", inline"`
Host string `yaml:"host" json:"host"`
Port int `yaml:"port" json:"port"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
Database string `yaml:"database" json:"database"`
Table string `yaml:"table" json:"table"` // can use variables, such as ${year}
LogField string `yaml:"logField" json:"logField"`
AutoCreateTable bool `yaml:"autoCreateTable" json:"autoCreateTable"`
}
MySQL存储
func (*MySQLStorage) Write ¶ added in v0.1.6
func (this *MySQLStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type Storage ¶ added in v0.1.6
type Storage struct {
Format StorageFormat `yaml:"format" json:"format"` // 日志格式
Template string `yaml:"template" json:"template"` // 只有在Format为template时有效
}
基础的Storage
func (*Storage) FormatAccessLogBytes ¶ added in v0.1.6
func (this *Storage) FormatAccessLogBytes(accessLog *accesslogs.AccessLog) ([]byte, error)
格式化访问日志成字节
func (*Storage) FormatAccessLogString ¶ added in v0.1.6
func (this *Storage) FormatAccessLogString(accessLog *accesslogs.AccessLog) (string, error)
格式化访问日志成字符串
func (*Storage) FormatVariables ¶ added in v0.1.6
格式化字符串中的变量
type StorageFormat ¶ added in v0.1.6
type StorageFormat = string
存储日志的格式
const ( StorageFormatJSON StorageFormat = "json" StorageFormatTemplate StorageFormat = "template" )
type StorageInterface ¶ added in v0.1.6
type StorageInterface interface {
// 开启
Start() error
// 写入日志
Write(accessLogs []*accesslogs.AccessLog) error
// 关闭
Close() error
}
日志存储接口
func DecodePolicyStorage ¶ added in v0.1.6
func DecodePolicyStorage(policy *teaconfigs.AccessLogStoragePolicy) StorageInterface
解析策略中的存储对象
func FindPolicyStorage ¶ added in v0.1.6
func FindPolicyStorage(policyId string) StorageInterface
通过策略ID查找存储
type StorageType ¶ added in v0.1.6
type StorageType = string
存储引擎类型
const ( StorageTypeFile StorageType = "file" StorageTypeES StorageType = "es" StorageTypeMySQL StorageType = "mysql" StorageTypeTCP StorageType = "tcp" StorageTypeSyslog StorageType = "syslog" StorageTypeCommand StorageType = "command" )
type SyslogStorage ¶ added in v0.1.9
type SyslogStorage struct {
Storage `yaml:", inline"`
Protocol string `yaml:"protocol" json:"protocol"` // SysLogStorageProtocol*
ServerAddr string `yaml:"serverAddr" json:"serverAddr"`
ServerPort int `yaml:"serverPort" json:"serverPort"`
Socket string `yaml:"socket" json:"socket"` // sock file
Tag string `yaml:"tag" json:"tag"`
Priority SyslogStoragePriority `yaml:"priority" json:"priority"`
// contains filtered or unexported fields
}
syslog存储策略
func (*SyslogStorage) Write ¶ added in v0.1.9
func (this *SyslogStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
type SyslogStoragePriority ¶ added in v0.1.9
type SyslogStoragePriority = int
const ( SyslogStoragePriorityEmerg SyslogStoragePriority = iota SyslogStoragePriorityAlert SyslogStoragePriorityCrit SyslogStoragePriorityErr SyslogStoragePriorityWarning SyslogStoragePriorityNotice SyslogStoragePriorityInfo SyslogStoragePriorityDebug )
type SyslogStorageProtocol ¶ added in v0.1.9
type SyslogStorageProtocol = string
const ( SyslogStorageProtocolTCP SyslogStorageProtocol = "tcp" SyslogStorageProtocolUDP SyslogStorageProtocol = "udp" SyslogStorageProtocolNone SyslogStorageProtocol = "none" SyslogStorageProtocolSocket SyslogStorageProtocol = "socket" )
type TCPStorage ¶ added in v0.1.6
type TCPStorage struct {
Storage `yaml:", inline"`
Network string `yaml:"network" json:"network"` // tcp, unix
Addr string `yaml:"addr" json:"addr"`
// contains filtered or unexported fields
}
TCP存储策略
func (*TCPStorage) Write ¶ added in v0.1.6
func (this *TCPStorage) Write(accessLogs []*accesslogs.AccessLog) error
写入日志
Source Files
¶
Click to show internal directories.
Click to hide internal directories.