Collect Metrics for AWS API Gateway
- Sumo Logic supports collecting metrics using two source types
Metadata: Add an account field to the source and assign it a value that is a friendly name/alias to your AWS account from which you are collecting metrics. This name will appear in the Sumo Logic Explorer View. Metrics can be queried via the “account field”.
Collect AWS API Gateway CloudTrail Logs
- To your Hosted Collector, add an AWS CloudTrail Source.
- Name. Enter a name to display the new Source.
- Description. Enter an optional description.
- S3 Region. Select the Amazon Region for your API Gateway S3 bucket.
- Bucket Name. Enter the exact name of your API Gateway S3 bucket.
- Path Expression. Enter the string that matches the S3 objects you'd like to collect. You can use a wildcard (*) in this string. (DO NOT use a leading forward slash. See Amazon Path Expressions.)
- Source Category. Enter aws/observability/cloud trail/logs
- Fields. Add an account field and assign it a value that is a friendly name/alias to your AWS account from which you are collecting logs. This name will appear in the Sumo Logic Explorer View. Logs can be queried via the “account field”.
- Access Key ID and Secret Access Key. Enter your Amazon Access Key ID and Secret Access Key. Learn how to use Role-based access to AWS here
- Log File Discovery -> Scan Interval. Use the default of 5 minutes. Alternately, enter the frequency. Sumo Logic will scan your S3 bucket for new data. Learn how to configure Log File Discovery here.
- Enable Timestamp Parsing. Select the check box.
- Time Zone. Select Ignore time zone from the log file and instead use, and select UTC.
- Timestamp Format. Select Automatically detect the format.
- Enable Multiline Processing. Select the check box, and select Infer Boundaries.
- Click Save.
Field in Field Schema
Login to Sumo Logic, go to Manage Data > Logs > Fields. Search for the “apiname” field. If not present, create it. Learn how to create and manage fields here.
Field Extraction Rule(s)
Create Field Extraction Rule for CloudTrail Logs. Learn how to create Field Extraction Rule here.
Rule Name: AwsObservabilityApiGatewayCloudTrailLogsFER Applied at: Ingest Time Scope (Specific Data): account=* eventname eventsource "apigateway.amazonaws.com" Parse Expression: | json "eventSource", "awsRegion", "responseElements", "recipientAccountId" as eventSource, region, responseElements, accountid nodrop | where eventSource = "apigateway.amazonaws.com" | "aws/apigateway" as namespace | json field=responseElements "name" as ApiName nodrop | tolowercase(ApiName) as apiname | fields region, namespace, apiname, accountid
Centralized AWS CloudTrail Log Collection
In case you have a centralized collection of cloudtrail logs and are ingesting them from all accounts into a single Sumo Logic cloudtrail log source, create following Field Extraction Rule to map proper AWS account(s) friendly name/alias. Create it if not already present / update it as required.
Rule Name: AWS Accounts Applied at: Ingest Time Scope (Specific Data): _sourceCategory=aws/observability/cloudtrail/logs
Enter a parse expression to create an “account” field that maps to the alias you set for each sub account. For example, if you used the “dev” alias for an AWS account with ID "528560886094" and the “prod” alias for an AWS account with ID "567680881046", your parse expression would look like this:
| json "recipientAccountId" // Manually map your aws account id with the AWS account alias you setup earlier for individual child account | "" as account | if (recipientAccountId = "528560886094", "dev", account) as account | if (recipientAccountId = "567680881046", "prod", account) as account | fields account