Created
August 23, 2023 11:16
-
-
Save peterjgrainger/d7487b7481b1d9e60f9fe4fb2101ac19 to your computer and use it in GitHub Desktop.
Requests per minute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use cloudwatch API with Boto3 to get the highest requests per second over a given month for wafv2 | |
import boto3 | |
from datetime import datetime, timedelta | |
client = boto3.client("cloudwatch") | |
response = client.get_metric_statistics( | |
Namespace="AWS/WAFV2", | |
MetricName="AllowedRequests", | |
Dimensions=[ | |
{"Name": "WebACL", "Value": "test"}, | |
{"Name": "Region", "Value": "us-east-1"}, | |
{"Name": "Rule", "Value": "ALL"} | |
], | |
StartTime="2023-08-22T09:00:00Z", | |
EndTime="2023-08-23T09:00:00Z", | |
Period=60, | |
Statistics=["Sum"] | |
) | |
# get the maximum value of requests per second | |
print(max(response['Datapoints'], key=lambda x: x['Sum'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment