Documentation ¶
Index ¶
- Constants
- Variables
- func InitManager(s *model.Storage) chan struct{}
- type AliRdsMySQLAuditLogTask
- func (at AliRdsMySQLAuditLogTask) Audit() (*model.AuditPlanReportV2, error)
- func (at AliRdsMySQLAuditLogTask) CreateClient(rdsPath string, accessKeyId *string, accessKeySecret *string) (_result *rds20140815.Client, _err error)
- func (at AliRdsMySQLAuditLogTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- type AliRdsMySQLSlowLogTask
- func (at AliRdsMySQLSlowLogTask) Audit() (*model.AuditPlanReportV2, error)
- func (at AliRdsMySQLSlowLogTask) CreateClient(rdsPath string, accessKeyId *string, accessKeySecret *string) (_result *rds20140815.Client, _err error)
- func (at AliRdsMySQLSlowLogTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- type DefaultTask
- func (at *DefaultTask) Audit() (*model.AuditPlanReportV2, error)
- func (at DefaultTask) FullSyncSQLs(sqls []*SQL) error
- func (at DefaultTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- func (at DefaultTask) PartialSyncSQLs(sqls []*SQL) error
- func (at DefaultTask) Start() error
- func (at DefaultTask) Stop() error
- type Head
- type Manager
- func (mgr *Manager) Audit(apName string) (*model.AuditPlanReportV2, error)
- func (mgr *Manager) GetSQLs(apName string, args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- func (mgr *Manager) SyncTask(apName string) error
- func (mgr *Manager) UploadSQLs(apName string, sqls []*SQL, isPartialSync bool) error
- type Meta
- type OracleTopSQLTask
- func (at *OracleTopSQLTask) Audit() (*model.AuditPlanReportV2, error)
- func (at OracleTopSQLTask) FullSyncSQLs(sqls []*SQL) error
- func (at *OracleTopSQLTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- func (at OracleTopSQLTask) PartialSyncSQLs(sqls []*SQL) error
- func (at OracleTopSQLTask) Start() error
- func (at OracleTopSQLTask) Stop() error
- type SQL
- type SchemaMetaTask
- func (at *SchemaMetaTask) Audit() (*model.AuditPlanReportV2, error)
- func (at SchemaMetaTask) FullSyncSQLs(sqls []*SQL) error
- func (at *SchemaMetaTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- func (at SchemaMetaTask) PartialSyncSQLs(sqls []*SQL) error
- func (at SchemaMetaTask) Start() error
- func (at SchemaMetaTask) Stop() error
- type SqlFromAliCloud
- type Task
- func NewAliRdsMySQLAuditLogTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- func NewAliRdsMySQLSlowLogTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- func NewDefaultTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- func NewOracleTopSQLTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- func NewSchemaMetaTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- func NewTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- func NewTiDBAuditLogTask(entry *logrus.Entry, ap *model.AuditPlan) Task
- type TiDBAuditHook
- type TiDBAuditLogTask
- func (at *TiDBAuditLogTask) Audit() (*model.AuditPlanReportV2, error)
- func (at TiDBAuditLogTask) FullSyncSQLs(sqls []*SQL) error
- func (at TiDBAuditLogTask) GetSQLs(args map[string]interface{}) ([]Head, []map[string]string, uint64, error)
- func (at TiDBAuditLogTask) PartialSyncSQLs(sqls []*SQL) error
- func (at TiDBAuditLogTask) Start() error
- func (at TiDBAuditLogTask) Stop() error
Constants ¶
View Source
const ( TypeDefault = "default" TypeMySQLSlowLog = "mysql_slow_log" TypeMySQLMybatis = "mysql_mybatis" TypeMySQLSchemaMeta = "mysql_schema_meta" TypeAliRdsMySQLSlowLog = "ali_rds_mysql_slow_log" TypeAliRdsMySQLAuditLog = "ali_rds_mysql_audit_log" TypeOracleTopSQL = "oracle_top_sql" TypeTiDBAuditLog = "tidb_audit_log" TypeAllAppExtract = "all_app_extract" )
View Source
const ( InstanceTypeAll = "" InstanceTypeMySQL = "MySQL" InstanceTypeOracle = "Oracle" InstanceTypeTiDB = "TiDB" )
Variables ¶
View Source
var ErrAuditPlanExisted = errors.New(errors.DataExist, fmt.Errorf("audit plan existed"))
View Source
var ErrAuditPlanNotExist = errors.New(errors.DataNotExist, fmt.Errorf("audit plan not exist"))
View Source
var MetaMap = map[string]Meta{}
View Source
var Metas = []Meta{ { Type: TypeDefault, Desc: "自定义", InstanceType: InstanceTypeAll, CreateTask: NewDefaultTask, }, { Type: TypeMySQLSlowLog, Desc: "慢日志", InstanceType: InstanceTypeMySQL, Params: []*params.Param{ { Key: paramKeyAuditSQLsScrappedInLastPeriodMinute, Desc: "审核过去时间段内抓取的SQL(分钟)", Value: "0", Type: params.ParamTypeInt, }, }, CreateTask: NewDefaultTask, }, { Type: TypeMySQLMybatis, Desc: "Mybatis 扫描", InstanceType: InstanceTypeMySQL, CreateTask: NewDefaultTask, }, { Type: TypeMySQLSchemaMeta, Desc: "库表元数据", InstanceType: InstanceTypeMySQL, CreateTask: NewSchemaMetaTask, Params: []*params.Param{ ¶ms.Param{ Key: paramKeyCollectIntervalMinute, Desc: "采集周期(分钟)", Value: "60", Type: params.ParamTypeInt, }, ¶ms.Param{ Key: "collect_view", Desc: "是否采集视图信息", Value: "0", Type: params.ParamTypeBool, }, }, }, { Type: TypeAliRdsMySQLSlowLog, Desc: "阿里RDS MySQL慢日志", InstanceType: InstanceTypeMySQL, CreateTask: NewAliRdsMySQLSlowLogTask, Params: []*params.Param{ { Key: paramKeyDBInstanceId, Desc: "实例ID", Value: "", Type: params.ParamTypeString, }, { Key: paramKeyAccessKeyId, Desc: "Access Key ID", Value: "", Type: params.ParamTypeString, }, { Key: paramKeyAccessKeySecret, Desc: "Access Key Secret", Value: "", Type: params.ParamTypeString, }, { Key: paramKeyFirstSqlsScrappedInLastPeriodHours, Desc: "启动任务时拉取慢日志时间范围(单位:小时,最大31天)", Value: "", Type: params.ParamTypeInt, }, { Key: paramKeyAuditSQLsScrappedInLastPeriodMinute, Desc: "审核过去时间段内抓取的SQL(分钟)", Value: "0", Type: params.ParamTypeInt, }, { Key: paramKeyRdsPath, Desc: "RDS Open API地址", Value: "rds.aliyuncs.com", Type: params.ParamTypeString, }, }, }, { Type: TypeAliRdsMySQLAuditLog, Desc: "阿里RDS MySQL审计日志", InstanceType: InstanceTypeMySQL, CreateTask: NewAliRdsMySQLAuditLogTask, Params: []*params.Param{ { Key: paramKeyDBInstanceId, Desc: "实例ID", Value: "", Type: params.ParamTypeString, }, { Key: paramKeyAccessKeyId, Desc: "Access Key ID", Value: "", Type: params.ParamTypeString, }, { Key: paramKeyAccessKeySecret, Desc: "Access Key Secret", Value: "", Type: params.ParamTypeString, }, { Key: paramKeyFirstSqlsScrappedInLastPeriodHours, Desc: "启动任务时拉取日志时间范围(单位:小时,最大31天)", Value: "", Type: params.ParamTypeInt, }, { Key: paramKeyAuditSQLsScrappedInLastPeriodMinute, Desc: "审核过去时间段内抓取的SQL(分钟)", Value: "0", Type: params.ParamTypeInt, }, { Key: paramKeyRdsPath, Desc: "RDS Open API地址", Value: "rds.aliyuncs.com", Type: params.ParamTypeString, }, }, }, { Type: TypeOracleTopSQL, Desc: "Oracle TOP SQL", InstanceType: InstanceTypeOracle, CreateTask: NewOracleTopSQLTask, Params: []*params.Param{ { Key: paramKeyCollectIntervalMinute, Desc: "采集周期(分钟)", Value: "60", Type: params.ParamTypeInt, }, { Key: "top_n", Desc: "Top N", Value: "3", Type: params.ParamTypeInt, }, { Key: "order_by_column", Desc: "V$SQLAREA中的排序字段", Value: oracle.DynPerformanceViewSQLAreaColumnElapsedTime, Type: params.ParamTypeString, }, }, }, { Type: TypeAllAppExtract, Desc: "应用程序SQL抓取", InstanceType: InstanceTypeAll, CreateTask: NewDefaultTask, }, { Type: TypeTiDBAuditLog, Desc: "TiDB审计日志", InstanceType: InstanceTypeTiDB, CreateTask: NewTiDBAuditLogTask, Params: []*params.Param{ { Key: paramKeyAuditSQLsScrappedInLastPeriodMinute, Desc: "审核过去时间段内抓取的SQL(分钟)", Value: "0", Type: params.ParamTypeInt, }, }, }, }
Functions ¶
func InitManager ¶
Types ¶
type AliRdsMySQLAuditLogTask ¶ added in v1.2209.0
type AliRdsMySQLAuditLogTask struct {
// contains filtered or unexported fields
}
func (AliRdsMySQLAuditLogTask) Audit ¶ added in v1.2209.0
func (at AliRdsMySQLAuditLogTask) Audit() (*model.AuditPlanReportV2, error)
func (AliRdsMySQLAuditLogTask) CreateClient ¶ added in v1.2209.0
type AliRdsMySQLSlowLogTask ¶ added in v1.2208.0
type AliRdsMySQLSlowLogTask struct {
// contains filtered or unexported fields
}
func (AliRdsMySQLSlowLogTask) Audit ¶ added in v1.2208.0
func (at AliRdsMySQLSlowLogTask) Audit() (*model.AuditPlanReportV2, error)
func (AliRdsMySQLSlowLogTask) CreateClient ¶ added in v1.2208.0
type DefaultTask ¶ added in v1.2202.0
type DefaultTask struct {
// contains filtered or unexported fields
}
func (*DefaultTask) Audit ¶ added in v1.2202.0
func (at *DefaultTask) Audit() (*model.AuditPlanReportV2, error)
func (DefaultTask) FullSyncSQLs ¶ added in v1.2202.0
func (DefaultTask) PartialSyncSQLs ¶ added in v1.2202.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the struct managing the persistent AuditPlans. It is *goroutine-safe*, since all exported methods are protected by a lock.
All audit plan operations except select should go through Manager.
func GetManager ¶
func GetManager() *Manager
func (*Manager) Audit ¶ added in v1.2202.0
func (mgr *Manager) Audit(apName string) (*model.AuditPlanReportV2, error)
type Meta ¶ added in v1.2201.0
type OracleTopSQLTask ¶ added in v1.2202.0
type OracleTopSQLTask struct {
// contains filtered or unexported fields
}
OracleTopSQLTask implement the Task interface.
OracleTopSQLTask is a loop task which collect Top SQL from oracle instance.
func (*OracleTopSQLTask) Audit ¶ added in v1.2202.0
func (at *OracleTopSQLTask) Audit() (*model.AuditPlanReportV2, error)
func (OracleTopSQLTask) FullSyncSQLs ¶ added in v1.2202.0
func (OracleTopSQLTask) PartialSyncSQLs ¶ added in v1.2202.0
type SchemaMetaTask ¶ added in v1.2202.0
type SchemaMetaTask struct {
// contains filtered or unexported fields
}
func (*SchemaMetaTask) Audit ¶ added in v1.2202.0
func (at *SchemaMetaTask) Audit() (*model.AuditPlanReportV2, error)
func (SchemaMetaTask) FullSyncSQLs ¶ added in v1.2202.0
func (SchemaMetaTask) PartialSyncSQLs ¶ added in v1.2202.0
type SqlFromAliCloud ¶ added in v1.2209.0
type SqlFromAliCloud struct {
// contains filtered or unexported fields
}
type Task ¶ added in v1.2202.0
type Task interface { Start() error Stop() error Audit() (*model.AuditPlanReportV2, error) FullSyncSQLs([]*SQL) error PartialSyncSQLs([]*SQL) error GetSQLs(map[string]interface{}) ([]Head, []map[string]string, uint64, error) }
func NewAliRdsMySQLAuditLogTask ¶ added in v1.2209.0
func NewAliRdsMySQLSlowLogTask ¶ added in v1.2208.0
func NewDefaultTask ¶ added in v1.2202.0
func NewOracleTopSQLTask ¶ added in v1.2202.0
func NewSchemaMetaTask ¶ added in v1.2202.0
type TiDBAuditHook ¶ added in v1.2207.0
type TiDBAuditHook struct {
// contains filtered or unexported fields
}
审核前填充上缺失的schema, 审核后还原被审核SQL, 并添加注释说明sql在哪个库执行的
func (*TiDBAuditHook) AfterAudit ¶ added in v1.2207.0
func (t *TiDBAuditHook) AfterAudit(sql *model.ExecuteSQL)
func (*TiDBAuditHook) BeforeAudit ¶ added in v1.2207.0
func (t *TiDBAuditHook) BeforeAudit(sql *model.ExecuteSQL)
type TiDBAuditLogTask ¶ added in v1.2207.0
type TiDBAuditLogTask struct {
*DefaultTask
}
func (*TiDBAuditLogTask) Audit ¶ added in v1.2207.0
func (at *TiDBAuditLogTask) Audit() (*model.AuditPlanReportV2, error)
func (TiDBAuditLogTask) FullSyncSQLs ¶ added in v1.2207.0
func (TiDBAuditLogTask) PartialSyncSQLs ¶ added in v1.2207.0
Click to show internal directories.
Click to hide internal directories.