@@ -39,6 +39,12 @@ func (at *OracleTopSQLTaskV2) Params(instanceId ...string) params.Params {
3939 Type : params .ParamTypeInt ,
4040 I18nDesc : locale .Bundle .LocalizeAll (locale .ParamCollectIntervalMinuteOracle ),
4141 },
42+ {
43+ Key : "top_n" ,
44+ Value : "10" ,
45+ Type : params .ParamTypeInt ,
46+ I18nDesc : locale .Bundle .LocalizeAll (locale .ParamTopN ),
47+ },
4248 }
4349}
4450
@@ -125,7 +131,7 @@ func (at *OracleTopSQLTaskV2) ExtractSQL(logger *logrus.Entry, ap *AuditPlan, pe
125131 notInUser = append (notInUser , blacklist .FilterContent )
126132 }
127133 // filter db user by
128- sqls , err := db .QueryTopSQLs (ctx , ap .Params .GetParam ("collect_interval_minute" ).String (), ap .Params .GetParam ("top_n" ).Int (), notInUser , ap .Params .GetParam ("order_by_column" ).String ())
134+ sqls , err := db .QueryTopSQLs (ctx , ap .Params .GetParam (paramKeyCollectIntervalMinute ).String (), ap .Params .GetParam ("top_n" ).Int (), notInUser , ap .Params .GetParam ("order_by_column" ).String ())
129135 if err != nil {
130136 return nil , fmt .Errorf ("query top sql fail, error: %v" , err )
131137 }
@@ -230,6 +236,38 @@ func (at *OracleTopSQLTaskV2) Head(ap *AuditPlan) []Head {
230236 }
231237}
232238
239+ func (at * OracleTopSQLTaskV2 ) Filters (ctx context.Context , logger * logrus.Entry , ap * AuditPlan , persist * model.Storage ) []FilterMeta {
240+ return []FilterMeta {
241+ {
242+ Name : "sql" ,
243+ Desc : locale .ApSQLStatement ,
244+ FilterInputType : FilterInputTypeString ,
245+ FilterOpType : FilterOpTypeEqual ,
246+ },
247+ {
248+ Name : "rule_name" ,
249+ Desc : locale .ApRuleName ,
250+ FilterInputType : FilterInputTypeString ,
251+ FilterOpType : FilterOpTypeEqual ,
252+ FilterTips : GetSqlManagerRuleTips (ctx , logger , ap .ID , persist ),
253+ },
254+ {
255+ Name : "priority" ,
256+ Desc : locale .ApPriority ,
257+ FilterInputType : FilterInputTypeString ,
258+ FilterOpType : FilterOpTypeEqual ,
259+ FilterTips : GetSqlManagerPriorityTips (ctx , logger ),
260+ },
261+ {
262+ Name : MetricNameDBUser ,
263+ Desc : locale .ApMetricNameDBUser ,
264+ FilterInputType : FilterInputTypeString ,
265+ FilterOpType : FilterOpTypeEqual ,
266+ FilterTips : GetSqlManagerMetricTips (logger , ap .ID , persist , MetricNameDBUser ),
267+ },
268+ }
269+ }
270+
233271func (at * OracleTopSQLTaskV2 ) GetSQLData (ctx context.Context , ap * AuditPlan , persist * model.Storage , filters []Filter , orderBy string , isAsc bool , limit , offset int ) ([]map [string ] /* head name */ string , uint64 , error ) {
234272 auditPlanSQLs , count , err := persist .GetInstanceAuditPlanSQLsByReqV2 (ap .ID , ap .Type , limit , offset , checkAndGetOrderByName (at .Head (ap ), orderBy ), isAsc , genArgsByFilters (filters ))
235273 if err != nil {
0 commit comments