Skip to content

aws.waf.get_sampled_requests

Example SQL Queries

SELECT * FROM
aws.waf.get_sampled_requests
WHERE
"web_acl_id" = 'VALUE'
AND "rule_id" = 'VALUE'
AND "time_window" = 'VALUE'
AND "max_items" = 'VALUE';

Description

This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.

For the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the latest version, AWS WAF has a single set of endpoints for regional and global use.

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.

Table Definition

Column NameColumn Data Type
max_items Required Input Column

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.

BIGINT
rule_id Required Input Column

RuleId is one of three values:

  • The RuleId of the Rule or the RuleGroupId of the RuleGroup for which you want GetSampledRequests to return a sample of requests.

  • Default_Action, which causes GetSampledRequests to return a sample of the requests that didn't match any of the rules in the specified WebACL.

VARCHAR
time_window Required Input Column

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.

STRUCT(
"start_time" TIMESTAMP_S,
"end_time" TIMESTAMP_S
)
Show child fields
time_window.end_time

The end of the time range from which you want GetSampledRequests to return a sample of the requests that your AWS resource received. You must specify the date and time 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.

time_window.start_time

The beginning of the time range from which you want GetSampledRequests to return a sample of the requests that your AWS resource received. You must specify the date and time 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.

web_acl_id Required Input Column

The WebACLId of the WebACL for which you want GetSampledRequests to return a sample of requests.

VARCHAR
_aws_profile Input Column

The AWS profile defines the AWS identity used. It can be defined via credentials or by assuming a IAM role.

STRUCT(
"type" VARCHAR,
"name" VARCHAR,
"account_id" VARCHAR,
"via_profile_name" VARCHAR,
"assumed_role_arn" VARCHAR,
"organization" STRUCT(
"account_name" VARCHAR,
"id" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[],
"master_account" STRUCT(
"id" VARCHAR,
"email" VARCHAR
),
"parents" STRUCT(
"type" VARCHAR,
"id" VARCHAR,
"name" VARCHAR,
"tags" STRUCT(
"key" VARCHAR,
"value" VARCHAR
)[]
)[]
)
)
Show child fields
_aws_profile.account_id

The AWS account id

_aws_profile.assumed_role_arn

The ARN of the assumed role

_aws_profile.name

The unique name of the profile.

_aws_profile.organization

Information about this profile's membership in the AWS organization.

Show child fields
_aws_profile.organization.account_name

The name of account speciifed by the organization

_aws_profile.organization.id

The organization id

_aws_profile.organization.master_account
Show child fields
_aws_profile.organization.master_account.email

The organization master account email address

_aws_profile.organization.master_account.id

The organization master account id

_aws_profile.organization.parents[]
Show child fields
_aws_profile.organization.parents[].id

The id of the parent

_aws_profile.organization.parents[].name

The name of the parent

_aws_profile.organization.parents[].tags[]
Show child fields
_aws_profile.organization.parents[].tags[].key
_aws_profile.organization.parents[].tags[].value
_aws_profile.organization.parents[].type

The type of parent can be an organization unit or a root

_aws_profile.organization.tags[]
Show child fields
_aws_profile.organization.tags[].key
_aws_profile.organization.tags[].value
_aws_profile.type

The type of profile, either 'credentials' or 'assumed_role'

_aws_profile.via_profile_name

This IAM role for this profile is assumed by first utilizing another profile with this name to obtain credentials.

population_size

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.

BIGINT
sampled_requests

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

STRUCT(
"request" STRUCT(
"client_ip" VARCHAR,
"country" VARCHAR,
"uri" VARCHAR,
"method" VARCHAR,
"http_version" VARCHAR,
"headers" STRUCT(
"name" VARCHAR,
"value" VARCHAR
)[]
),
"weight" BIGINT,
"timestamp" TIMESTAMP_S,
"action" VARCHAR,
"rule_within_rule_group" VARCHAR
)[]
Show child fields
sampled_requests[]
Show child fields
sampled_requests[].action

The action for the Rule that the request matched: ALLOW, BLOCK, or COUNT.

sampled_requests[].request

A complex type that contains detailed information about the request.

Show child fields
sampled_requests[].request.client_ip

The IP address that the request originated from. If the WebACL is associated with a CloudFront distribution, this is the value of one of the following fields in CloudFront access logs:

  • c-ip, if the viewer did not use an HTTP proxy or a load balancer to send the request

  • x-forwarded-for, if the viewer did use an HTTP proxy or a load balancer to send the request

sampled_requests[].request.country

The two-letter country code for the country that the request originated from. For a current list of country codes, see the Wikipedia entry ISO 3166-1 alpha-2.

sampled_requests[].request.headers[]
Show child fields
sampled_requests[].request.headers[].name

The name of one of the headers in the sampled web request.

sampled_requests[].request.headers[].value

The value of one of the headers in the sampled web request.

sampled_requests[].request.http_version

The HTTP version specified in the sampled web request, for example, HTTP/1.1.

sampled_requests[].request.method

The HTTP method specified in the sampled web request. CloudFront supports the following methods: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.

sampled_requests[].request.uri

The part of a web request that identifies the resource, for example, /images/daily-ad.jpg.

sampled_requests[].rule_within_rule_group

This value is returned if the GetSampledRequests request specifies the ID of a RuleGroup rather than the ID of an individual rule. RuleWithinRuleGroup is the rule within the specified RuleGroup that matched the request listed in the response.

sampled_requests[].timestamp

The time at which AWS WAF received the request from your AWS resource, in Unix time format (in seconds).

sampled_requests[].weight

A value that indicates how one result in the response relates proportionally to other results in the response. A result that has a weight of 2 represents roughly twice as many CloudFront web requests as a result that has a weight of 1.