[aws-data-model-acceleration] definition = summariesonly=f [aws-accountid-to-name] definition = lookup account_name LinkedAccountId OUTPUT LinkedAccountName | eval LinkedAccountName = if(match(LinkedAccountName, ".*?"), " (".LinkedAccountName.")","") | eval Account=LinkedAccountId.LinkedAccountName [aws-billing-details(1)] args = accountId definition = `aws-billing-sourcetype` eventtype=aws_billing_detail_report $accountId$ [aws-billing-datamodel-tags] definition = datamodel Detailed_Billing | spath output=fieldName path=objects{}.calculations{}.outputFields{}.fieldName | spath output=displayName path=objects{}.calculations{}.outputFields{}.displayName | table fieldName displayName | eval names=mvzip(fieldName,displayName) | mvexpand names| eval names=split(names,",") | eval fieldName=mvindex(names,0) | eval displayName=mvindex(names,1) | rename displayName as title, fieldName as key | table key, title | search key!="LinkedAccountId" [aws-billing-index] definition = (index="main") [aws-billing-sourcetype] definition = `aws-billing-index` sourcetype="aws:billing" [aws-billing-monthly-accounts] definition = `aws-billing-sourcetype` eventtype=aws_billing_monthly_report (RecordType=AccountTotal OR RecordType=StatementTotal) | eval LinkedAccountId=if(isnull(LinkedAccountId),PayerAccountId,LinkedAccountId) | stats count by LinkedAccountId CurrencyCode [aws-billing-monthly-total(3)] args = accountId, currency, monthSpl definition = `aws-billing-sourcetype` $monthSpl$ eventtype=aws_billing_monthly_report CurrencyCode=$currency$ (RecordType=AccountTotal OR RecordType=StatementTotal) | eval LinkedAccountId=if(isnull(LinkedAccountId),PayerAccountId,LinkedAccountId) | search $accountId$ | billingtype [aws-billing-monthly-item(3)] args = accountId, currency, monthSpl definition = `aws-billing-sourcetype` $monthSpl$ eventtype=aws_billing_monthly_report CurrencyCode=$currency$ InvoiceID!="Estimated" (RecordType=PayerLineItem OR RecordType=LinkedLineItem) | eval LinkedAccountId=if(isnull(LinkedAccountId),PayerAccountId,LinkedAccountId) | search $accountId$ [aws-account-summary] definition = search `cp-aws-dashboards-summary-index` sourcetype="aws:addon:account" | dedup host, account_id, name [aws-cloudwatch-billing(2)] args = accountId, currency definition = `aws-cloudwatch-sourcetype` source="*:AWS/Billing" metric_dimensions="*Currency=[$currency$]*" metric_dimensions="*],*" \ | dedup _time metric_dimensions aws_account_id | `aws-cloudwatch-dimension-rex("LinkedAccount", "LinkedAccountId")` \ | search $accountId$ \ | eval zone=strftime(time(),"%z") | eval rel_time=replace(zone, "^([-+]?)0?((?<=0)\d|\d\d)0?((?<=0)\d|\d\d).*$", "\1\2h\1\3m") \ | eval utctime= _time + 86400 - relative_time(86400, rel_time) | eval currentmonth = strftime(_time,"%m") \ | eval utcmonth = strftime(utctime,"%m") | where utcmonth=currentmonth [aws-sourcetype-index-summary] definition = search `cp-aws-dashboards-summary-index` sourcetype="aws:addon:input" earliest=-1d | dedup input_sourcetype, input_index | table input_sourcetype, input_index [aws-cloudwatch-dimension-rex(2)] args = dimension, key definition = rex field=metric_dimensions "([ ,]|^)$dimension$=\[(?<$key$>.*?)\]" [aws-cloudwatch-sourcetype] definition = `aws-cloudwatch-index` sourcetype="aws:cloudwatch" [aws-cloudwatch-index] definition = (index="main") [aws-metadata-index] definition = (index="main") [aws-metadata-sourcetype] definition = `aws-metadata-index` sourcetype="aws:metadata" [aws-metadata-field-extraction] definition = eval AccountId=if(isnum(AccountId),AccountId, user_id) , aws_account_id = AccountId, account_id = AccountId [aws-metadata(4)] args = accountId, region, resource, dedupfield definition = `aws-metadata-sourcetype` source="*:$resource$" | `aws-metadata-field-extraction` | search $accountId$ $region$ | eventstats latest(_time) as latest_time | eval latest_time=relative_time(latest_time,"-55m") | where _time > latest_time | dedup $dedupfield$ sortby -_time [aws-metadata-resource(3)] args = accountId, region, resource definition = `aws-metadata-sourcetype` source="*:$resource$" | `aws-metadata-field-extraction` | search $accountId$ $region$ | eventstats latest(_time) as latest_time | eval latest_time=relative_time(latest_time,"-55m") | where _time > latest_time | dedup id sortby -start_time [aws-unused-eip(2)] args = accountId, region definition = `aws-metadata(($accountId$), ($region$), "ec2_addresses", "PublicIp")` | rename InstanceId as instance_id ,NetworkInterfaceId as network_interface_id, PublicIp as public_ip,AccountId as account_id | eval instance_id = if(isnull(instance_id),"null",instance_id)| eval network_interface_id = if(isnull(network_interface_id),"null",network_interface_id)| join type=left instance_id [search earliest=-1d `aws-metadata(($accountId$), ($region$), "ec2_instances", "InstanceId")` | spath output=tagsname path=Tags{} | rex field=tagsname "\"Key\": \"Name\", \"Value\": \"(?.+)\"" | rename InstanceId as instance_id, tagname as name ,State.Name as state | fields instance_id name state] | eval insight = case(instance_id=="null" AND network_interface_id=="null","No attached instance", state!="running", "Inactive attached instance") [aws-unused-elb(2)] args = accountId, region definition = `aws-metadata-recommend-elb(($accountId$), ($region$))` | where total_instance_count >= 0 AND healthy_instance_count = 0 | eval insight="No healthy instance" [aws-not-autoscaling-elb(2)] args = accountId, region definition = `aws-metadata-recommend-elb(($accountId$), ($region$))` | where healthy_instance_count = 1 | mvexpand instances | rex field=instances "(?[^,]+),(?[^,]+)" | search (instance_elb_state="InService" OR instance_elb_state="healthy") | join type=left instance_id [search earliest=-1d `aws-metadata-recommend-autoscaling-instance(($accountId$), ($region$))`] | where isnull(autoscaling_group) | eval insight="One healthy instance without autoscaling" [aws-not-enough-request-elb(2)] args = accountId, region definition = `aws-metadata-recommend-elb(($accountId$), ($region$))` | join type=left account_id, region, name [search earliest=-7d `aws-cloudwatch-recommend-elb(($accountId$), ($region$))`] | where isnotnull(request_count) AND request_count<200 | eval insight="Not enough requests" [aws-insecure-listener-elb(2)] args = accountId, region definition = `aws-metadata-elb(($accountId$), ($region$))` | eval listener_protocols=if(isnotnull('ListenerDescriptions{}.Listener.Protocol'), mvjoin('ListenerDescriptions{}.Listener.Protocol',","), mvjoin('Listeners{}.Protocol', ",")), contain_secure_protocol=if(like(listener_protocols, "%HTTPS%") OR like(listener_protocols, "%SSL%"), 1, 0), insight="Insecure listener protocol" | where contain_secure_protocol = 0 | eval availability_zones=if(isnotnull('AvailabilityZones{}'), mvjoin('AvailabilityZones{}', ","), mvjoin('AvailabilityZones{}.ZoneName', ",")) | fields account_id, region, name, insight, availability_zones, Type [aws-not-cross-zone-elb(2)] args = accountId, region definition = `aws-metadata-recommend-elb(($accountId$), ($region$))` | where healthy_instance_count>=1 | mvexpand instances | rex field=instances "(?[^,]+),(?[^,]+)" | search (instance_elb_state="InService" OR instance_elb_state="healthy") | join type=left instance_id [search earliest=-1d `aws-metadata-recommend-instance(($accountId$),($region$))`] | stats count(placement) as healthy_AZ_count, values(Type) as Type, values(placement) as placement by account_id, region, name, availability_zones | search healthy_AZ_count = 1 | eval insight="Healthy instances are not cross-zone" [aws-metadata-recommend-elb(2)] args = accountId, region definition =`aws-metadata-elb(($accountId$), ($region$))` | eval availability_zones=if(isnotnull('AvailabilityZones{}'), mvjoin('AvailabilityZones{}', ","), mvjoin('AvailabilityZones{}.ZoneName', ",")), instances=if(isnotnull('instances{}.State'), mvzip('instances{}.InstanceId', 'instances{}.State'), mvzip('TargetGroups{}.TargetHealthDescriptions{}.Target.Id','TargetGroups{}.TargetHealthDescriptions{}.TargetHealth.State')), healthy_instance_state = mvfilter(match(instances,"\w+,InService$") OR match(instances, "\w+,healthy$")) , healthy_instance_count=if(isnull(healthy_instance_state),0, mvcount(healthy_instance_state)), total_instance_count=if(isnull(instances), 0, mvcount(instances) ) | fields account_id, region, name, instances, availability_zones, healthy_instance_count, total_instance_count, Type [aws-metadata-recommend-autoscaling-instance(2)] args = accountId, region definition = `aws-metadata(($accountId$), ($region$),"ec2_instances", "InstanceId")` | spath output=tagsname path=Tags{} | rex field=tagsname "\"Key\": \"aws:autoscaling:groupName\", \"Value\": \"(?.+)\"" | rename autoscale as autoscaling_group, InstanceId as instance_id,State.Name as state,Placement.AvailabilityZone as placement | where isnotnull(autoscaling_group) | fields instance_id, state, placement, autoscaling_group [aws-cloudwatch-recommend-elb(2)] args = accountId, region definition = `aws-cloudwatch-elb(($accountId$), ($region$))` metric_name="RequestCount" \ | `aws-cloudwatch-dimension-rex("LoadBalancerName", "name")` \ | rex field=metric_dimensions "([ ,]|^)LoadBalancer=\[\w*/(?.*?)/" \ | bucket _time span=1d | stats sum(Sum) as request_count by _time, account_id, region, name \ | stats max(request_count) as request_count by account_id, region, name [aws-metadata-elb(2)] args = accountId, region definition = `aws-metadata-sourcetype` source="*_load_balancers" | `aws-metadata-field-extraction` | search $accountId$ $region$ \ | eventstats latest(_time) as latest_time | eval latest_time=relative_time(latest_time,"-55m") \ | where _time > latest_time \ | eval name=if(isnull(name), LoadBalancerName, name), vpc_id=if(isnull(VpcId), VPCId, VpcId), dns_name=if(isnull(dns_name), DNSName, dns_name) \ | `aws-resource-uniqId` | dedup uniq_id sortby -_time [aws-metadata-lambda(2)] args = accountId, region definition = `aws-metadata-sourcetype` source="*:lambda_functions" | `aws-metadata-field-extraction`\ | search $accountId$ $region$ \ | eventstats latest(_time) as latest_time \ | eval latest_time=relative_time(latest_time,"-55m") | where _time > latest_time \ | rename FunctionName AS name\ | `aws-resource-uniqId` \ | dedup uniq_id sortby -_time [aws-resource-uniqId] definition = eval uniq_id = name."#".aws_account_id."#".region [aws-sqs-sourcetype] definition = `aws-sqs-index` sourcetype="aws:sqs" [aws-sqs-index] definition = (index="main") [aws-config-rule(3)] args = accountId, region, source definition = `aws-config-rule-sourcetype` source="*configRule$source$" $accountId$ $region$ [aws-config-rule-sourcetype] definition = `aws-config-rule-index` sourcetype="aws:config:rule" [aws-config-rule-index] definition = (index="main") [aws-cloudwatch-ec2(2)] args = accountId, region definition = `aws-cloudwatch-sourcetype` $accountId$ $region$ eventtype="aws_cloudwatch_ec2_events" metric_dimensions!="*],*" metric_dimensions="InstanceId=*" [volume_size(1)] args = field definition = eval $field$=case($field$>1024, tostring(round($field$/1024, 1))+" TB", true(), tostring(round($field$, 0))+" GB") [aws-metadata-clb(2)] args = accountId, region definition = `aws-metadata-elb(($accountId$), ($region$))` | search (source="*:classic_load_balancers" OR source="*:elastic_load_balancers") [aws-metadata-alb(2)] args = accountId, region definition = `aws-metadata-elb(($accountId$), ($region$))` | search source="*:application_load_balancers" [aws-config-rules-insights(2)] args = accountId, region definition = `aws-config-rule(($accountId$) ,($region$) , ":complianceDetail")` EvaluationResultIdentifier.EvaluationResultQualifier.ConfigRuleName=* ComplianceType="NON_COMPLIANT" | bucket _time span=1d | stats distinct_count(EvaluationResultIdentifier.EvaluationResultQualifier.ResourceId) as count by account_id, region, _time [aws-inspector-insights(2)] args = accountId, region definition = `aws-inspector-findings` `aws-inspector-rex-arn` | search $accountId$ $region$ | bucket _time span=1d | stats distinct_count(arn) as count by account_id, region, _time [aws-personal-health-insights(2)] args = accountId, region definition = `aws-sqs-sourcetype` AND BodyJson.source="aws.health" AND BodyJson.detail.eventTypeCategory="issue" | rename BodyJson.time as time, BodyJson.account as account_id, BodyJson.region as region | search $accountId$ $region$ | eval _time = strptime(time, "%Y-%m-%dT%H:%M:%S")| bucket _time span=1d | stats count by account_id, region, _time [aws-insights-combination(3)] args = accountId, region, earliest definition = `cp-aws-dashboards-summary-index` insights=* $accountId$ | eval region=if(insights="iam", "Global", region), insights=case(insights="iam", "IAM", insights="eip", "Elastic IP", insights="sg", "Security Group", insights="elb", "ELB", insights="ec2", "EC2", insights="ebs", "EBS")\ | search $region$ | bucket _time span=1d | stats sum(count) as count by account_id, region, insights, _time \ | append [search earliest=$earliest$ `aws-config-rules-insights(($accountId$) ,($region$))` | eval insights="Config Rules" ] \ | append [search earliest=$earliest$ `aws-inspector-insights(($accountId$) ,($region$))` | eval insights="Amazon Inspector" ] \ | append [search earliest=$earliest$ `aws-personal-health-insights(($accountId$) ,($region$))` | eval insights="AWS Personal Health"] [aws-inspector-findings] definition = `aws-inspector-sourcetype` source="*:inspector:finding" [aws-inspector-rex-arn] definition = | rex field=arn "^arn:.+?:inspector:(?[^:]+):(?[^:]+):target/(?[^/]+)/template/(?