Skip to main content
Glama

get_waf_sampled_requests

Retrieve sampled web requests from AWS WAF Web ACLs to analyze traffic patterns and identify potential security threats for monitoring and troubleshooting purposes.

Instructions

Retrieves sampled requests from a Web ACL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
web_acl_arnYesThe ARN of the Web ACL.
rule_metric_nameYesThe metric name of the rule to sample.
scopeNoThe scope (default: REGIONAL).
time_window_secondsNoTime window in seconds (e.g., 3600 for 1 hour).

Implementation Reference

  • Handler function that executes the AWS WAFv2 GetSampledRequestsCommand to retrieve sampled requests from a specified Web ACL rule.
    if (name === "get_waf_sampled_requests") {
        const aclArn = (args as any)?.web_acl_arn;
        const metricName = (args as any)?.rule_metric_name;
        const scope = (args as any)?.scope || "REGIONAL";
        const timeWindow = (args as any)?.time_window_seconds || 3600;
    
        // WAFv2 Sampled Requests requires a time window
        const endTime = new Date();
        const startTime = new Date(endTime.getTime() - timeWindow * 1000);
    
        const command = new GetSampledRequestsCommand({
            WebAclArn: aclArn,
            RuleMetricName: metricName,
            Scope: scope,
            TimeWindow: { StartTime: startTime, EndTime: endTime },
            MaxItems: 100
        });
        const response = await wafv2Client.send(command);
    
        const requests = response.SampledRequests?.map(r => ({
            ClientIP: r.Request?.ClientIP,
            Country: r.Request?.Country,
            URI: r.Request?.URI,
            Method: r.Request?.Method,
            Headers: r.Request?.Headers,
            Action: r.Action,
            Timestamp: r.Timestamp
        })) || [];
        return { content: [{ type: "text", text: JSON.stringify(requests, null, 2) }] };
    }
  • src/index.ts:621-646 (registration)
    Tool registration in the ListTools response, including name, description, and input schema definition.
        name: "get_waf_sampled_requests",
        description: "Retrieves sampled requests from a Web ACL.",
        inputSchema: {
            type: "object",
            properties: {
                web_acl_arn: {
                    type: "string",
                    description: "The ARN of the Web ACL."
                },
                rule_metric_name: {
                    type: "string",
                    description: "The metric name of the rule to sample."
                },
                scope: {
                    type: "string",
                    enum: ["CLOUDFRONT", "REGIONAL"],
                    description: "The scope (default: REGIONAL)."
                },
                time_window_seconds: {
                    type: "number",
                    description: "Time window in seconds (e.g., 3600 for 1 hour)."
                }
            },
            required: ["web_acl_arn", "rule_metric_name"]
        }
    },
  • Input schema for validating tool arguments: web_acl_arn, rule_metric_name (required), scope, time_window_seconds.
        name: "get_waf_sampled_requests",
        description: "Retrieves sampled requests from a Web ACL.",
        inputSchema: {
            type: "object",
            properties: {
                web_acl_arn: {
                    type: "string",
                    description: "The ARN of the Web ACL."
                },
                rule_metric_name: {
                    type: "string",
                    description: "The metric name of the rule to sample."
                },
                scope: {
                    type: "string",
                    enum: ["CLOUDFRONT", "REGIONAL"],
                    description: "The scope (default: REGIONAL)."
                },
                time_window_seconds: {
                    type: "number",
                    description: "Time window in seconds (e.g., 3600 for 1 hour)."
                }
            },
            required: ["web_acl_arn", "rule_metric_name"]
        }
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bhaveshopss/MCP-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server