@@ -89,7 +89,7 @@ def get_datadog_metrics(start_ts, end_ts):
8989 return data
9090
9191
92- def get_aws_waf_stats (start_iso , end_iso ):
92+ def get_aws_waf_stats (start_dt , end_dt ):
9393 client = boto3 .client ('cloudwatch' , region_name = AWS_REGION )
9494
9595 def get_metric (metric_name ):
@@ -101,13 +101,14 @@ def get_metric(metric_name):
101101 {'Name' : 'WebACL' , 'Value' : WAF_WEB_ACL_NAME },
102102 {'Name' : 'Region' , 'Value' : AWS_REGION },
103103 ],
104- StartTime = start_iso ,
105- EndTime = end_iso ,
106- Period = 2592000 ,
104+ StartTime = start_dt ,
105+ EndTime = end_dt ,
106+ Period = 86400 ,
107107 Statistics = ['Sum' ]
108108 )
109109 if response ['Datapoints' ]:
110- return int (response ['Datapoints' ][0 ]['Sum' ])
110+ return int (sum ([dp ['Sum' ] for dp in response ['Datapoints' ]]))
111+
111112 print (f"⚠️ No datapoints for WAF metric: { metric_name } " )
112113 return 0
113114 except Exception as e :
@@ -141,7 +142,8 @@ def send_discord_report():
141142 current_period , prev_period = get_date_ranges ()
142143
143144 dd_data = get_datadog_metrics (current_period ['start_ts' ], current_period ['end_ts' ])
144- waf_data = get_aws_waf_stats (current_period ['start_iso' ], current_period ['end_iso' ])
145+
146+ waf_data = get_aws_waf_stats (current_period ['start_dt' ], current_period ['end_dt' ])
145147
146148 curr_cost = get_total_cost (current_period ['start_iso' ], current_period ['end_iso' ])
147149 prev_cost = get_total_cost (prev_period ['start_iso' ], prev_period ['end_iso' ])
0 commit comments