@@ -945,7 +945,7 @@ def extract_params(self, event):
945945
946946
947947class SumoLogicFieldExtractionRule (SumoResource ):
948- def get_fer_by_name (self , fer_name ):
948+ def _get_fer_by_name (self , fer_name ):
949949 token = ""
950950 page_limit = 100
951951 response = self .sumologic_cli .get_all_field_extraction_rules (limit = page_limit , token = token )
@@ -1348,52 +1348,55 @@ def extract_params(self, event):
13481348
13491349if __name__ == '__main__' :
13501350 props = {
1351- "SumoAccessID" : "suU2PzuEzdacyE " ,
1352- "SumoAccessKey" : "dZks62YfZ8n3pPXzLFpNrJOMlxyJ5soUEHcKL7nOCOFJCGmefwreHaP6UUC7IAIp " ,
1351+ "SumoAccessID" : "" ,
1352+ "SumoAccessKey" : "" ,
13531353 "SumoDeployment" : "us1" ,
13541354 }
1355-
1356- # Delete the FER
1357- fer_names = ["AwsObservabilityAlbAccessLogsFER" , "AwsObservabilityApiGatewayCloudTrailLogsFER" ,
1358- "AwsObservabilityDynamoDBCloudTrailLogsFER" , "AwsObservabilityECSCloudTrailLogsFER" ,
1359- "AwsObservabilityElastiCacheCloudTrailLogsFER" , "AwsObservabilityFieldExtractionRule" ,
1360- "AwsObservabilityLambdaCloudWatchLogsFER" , "AwsObservabilityNlbAccessLogsFER" ,
1361- "AwsObservabilityRdsCloudTrailLogsFER" ]
1362- fer_resource = SumoLogicFieldExtractionRule (props )
1363- for fer_name in fer_names :
1364- try :
1365- fer_details = fer_resource .get_fer_by_name (fer_name )
1366- fer_resource .delete (fer_details ["id" ], True )
1367- except Exception as e :
1368- print ("FER Not Found" )
1369-
1370- # Delete the Metric Rules
1371- metric_rule_names = ["AwsObservabilityALBMetricsEntityRule" , "AwsObservabilityApiGatewayMetricsEntityRule" ,
1372- "AwsObservabilityDynamoDBMetricsEntityRule" , "AwsObservabilityEC2MetricsEntityRule" ,
1373- "AwsObservabilityECSMetricsEntityRule" , "AwsObservabilityElastiCacheMetricsEntityRule" ,
1374- "AwsObservabilityLambdaMetricsEntityRule" , "AwsObservabilityNLBMetricsEntityRule" ,
1375- "AwsObservabilityRDSClusterMetricsEntityRule" , "AwsObservabilityRDSInstanceMetricsEntityRule" ]
1376- metric_resource = SumoLogicMetricRules (props )
1377- for metric_rule_name in metric_rule_names :
1378- metric_resource .delete (metric_rule_name , metric_rule_name , True )
1379-
1380- # Delete the Hierarchy
1381- explorer_resource = SumoLogicAWSExplorer (props )
1382- try :
1383- id = explorer_resource .get_explorer_id ("AWS Observability" )
1384- explorer_resource .delete (id , "AWS Observability" , True )
1385- except Exception as e :
1386- print ("Explorer Not Found" )
1387-
1388- # Delete the Fields
1389- fields = ["loadbalancer" , "apiname" , "account" , "region" , "namespace" , "tablename" , "instanceid" , "clustername" ,
1390- "cacheclusterid" , "functionname" , "networkloadbalancer" , "dbidentifier" , "dbinstanceidentifier" ,
1391- "dbclusteridentifier" ]
1392- field_resource = SumoLogicFieldsSchema (props )
1393- for field in fields :
1394- try :
1395- id = field_resource .get_field_id (field )
1396- field_resource .delete (id , field , True )
1397- except Exception as e :
1398- print ("Field Not Found" )
1355+ app_prefix = "CloudTrail"
1356+ # app_prefix = "GuardDuty"
1357+ collector_id = None
1358+ collector_type = "Hosted"
1359+ collector_name = "%sCollector" % app_prefix
1360+ source_name = "%sEvents" % app_prefix
1361+ source_category = "Labs/AWS/%s" % app_prefix
1362+ # appname = "Global Intelligence for Amazon GuardDuty"
1363+ appname = "Global Intelligence for AWS CloudTrail"
1364+ appid = "570bdc0d-f824-4fcb-96b2-3230d4497180"
1365+ # appid = "ceb7fac5-1137-4a04-a5b8-2e49190be3d4"
1366+ # appid = None
1367+ # source_params = {
1368+ # "logsrc": "_sourceCategory=%s" % source_category
1369+ # }
1370+ source_params = {
1371+ "cloudtraillogsource" : "_sourceCategory=%s" % source_category ,
1372+ "indexname" : '%rnd%' ,
1373+ "incrementalindex" : "%rnd%"
1374+ }
1375+ # col = Collector(**params)
1376+ # src = HTTPSource(**params)
1377+ app = App (props )
1378+
1379+ # create
1380+ # _, collector_id = col.create(collector_type, collector_name, source_category)
1381+ # _, source_id = src.create(collector_id, source_name, source_category)
1382+
1383+ _ , app_folder_id = app .create (appname , source_params , appid )
1384+ app .delete (app_folder_id , True )
1385+
1386+ # update
1387+ # _, new_collector_id = col.update(collector_id, collector_type, "%sCollectorNew" % app_prefix, "Labs/AWS/%sNew" % app_prefix, description="%s Collector" % app_prefix)
1388+ # assert(collector_id == new_collector_id)
1389+ # _, new_source_id = src.update(collector_id, source_id, "%sEventsNew" % app_prefix, "Labs/AWS/%sNew" % app_prefix, date_format="yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", date_locator='\"createTime\":(.*),')
1390+ # assert(source_id == new_source_id)
1391+ # new_source_params = {
1392+ # "logsrc": "_sourceCategory=%s" % ("Labs/AWS/%sNew" % app_prefix)
1393+ # }
1394+
1395+ # _, new_app_folder_id = app.update(app_folder_id, appname, new_source_params, appid)
1396+ # assert(app_folder_id != new_app_folder_id)
1397+
1398+ # delete
1399+ # src.delete(collector_id, source_id, True)
1400+ # col.delete(collector_id, True)
1401+ # app.delete(new_app_folder_id, True)
13991402
0 commit comments