GetSampledRequests - AWS WAFV2

GetSampledRequests

Note

This is the latest version of AWS WAF, named AWS WAFV2, released in November, 2019. For information, including how to migrate your AWS WAF resources from the prior release, see the AWS WAF Developer Guide.

Gets detailed information about a specified number of requests--a sample--that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received during a time range that you choose. You can specify a sample size of up to 500 requests, and you can specify any time range in the previous three hours.

GetSampledRequests returns a time range, which is usually the time range that you specified. However, if your resource (such as a CloudFront distribution) received 5,000 requests before the specified time range elapsed, GetSampledRequests returns an updated time range. This new time range indicates the actual period during which AWS WAF selected the requests in the sample.

Request Syntax

{ "MaxItems": number, "RuleMetricName": "string", "Scope": "string", "TimeWindow": { "EndTime": number, "StartTime": number }, "WebAclArn": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

MaxItems

The number of requests that you want AWS WAF to return from among the first 5,000 requests that your AWS resource received during the time range. If your resource received fewer requests than the value of MaxItems, GetSampledRequests returns information about all of them.

Type: Long

Valid Range: Minimum value of 1. Maximum value of 500.

Required: Yes

RuleMetricName

The metric name assigned to the Rule or RuleGroup for which you want a sample of requests.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 255.

Pattern: ^[\w#:\.\-/]+$

Required: Yes

Scope

Specifies whether this is for an AWS CloudFront distribution or for a regional application. A regional application can be an Application Load Balancer (ALB) or an API Gateway stage.

To work with CloudFront, you must also specify the Region US East (N. Virginia) as follows:

  • CLI - Specify the Region when you use the CloudFront scope: --scope=CLOUDFRONT --region=us-east-1.

  • API and SDKs - For all calls, use the Region endpoint us-east-1.

Type: String

Valid Values: CLOUDFRONT | REGIONAL

Required: Yes

TimeWindow

The start date and time and the end date and time of the range for which you want GetSampledRequests to return a sample of requests. You must specify the times in Coordinated Universal Time (UTC) format. UTC format includes the special designator, Z. For example, "2016-09-27T14:50Z". You can specify any time range in the previous three hours.

Type: TimeWindow object

Required: Yes

WebAclArn

The Amazon resource name (ARN) of the WebACL for which you want a sample of requests.

Type: String

Length Constraints: Minimum length of 20. Maximum length of 2048.

Pattern: .*\S.*

Required: Yes

Response Syntax

{ "PopulationSize": number, "SampledRequests": [ { "Action": "string", "Request": { "ClientIP": "string", "Country": "string", "Headers": [ { "Name": "string", "Value": "string" } ], "HTTPVersion": "string", "Method": "string", "URI": "string" }, "RuleNameWithinRuleGroup": "string", "Timestamp": number, "Weight": number } ], "TimeWindow": { "EndTime": number, "StartTime": number } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

PopulationSize

The total number of requests from which GetSampledRequests got a sample of MaxItems requests. If PopulationSize is less than MaxItems, the sample includes every request that your AWS resource received during the specified time range.

Type: Long

SampledRequests

A complex type that contains detailed information about each of the requests in the sample.

Type: Array of SampledHTTPRequest objects

TimeWindow

Usually, TimeWindow is the time range that you specified in the GetSampledRequests request. However, if your AWS resource received more than 5,000 requests during the time range that you specified in the request, GetSampledRequests returns the time range for the first 5,000 requests. Times are in Coordinated Universal Time (UTC) format.

Type: TimeWindow object

Errors

For information about the errors that are common to all actions, see Common Errors.

WAFInternalErrorException

Your request is valid, but AWS WAF couldn’t perform the operation because of a system problem. Retry your request.

HTTP Status Code: 500

WAFInvalidParameterException

The operation failed because AWS WAF didn't recognize a parameter in the request. For example:

  • You specified an invalid parameter name or value.

  • Your nested statement isn't valid. You might have tried to nest a statement that can’t be nested.

  • You tried to update a WebACL with a DefaultAction that isn't among the types available at DefaultAction.

  • Your request references an ARN that is malformed, or corresponds to a resource with which a Web ACL cannot be associated.

HTTP Status Code: 400

WAFNonexistentItemException

AWS WAF couldn’t perform the operation because your resource doesn’t exist.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: