Skip to content

Commit

Permalink
fix: fix logs formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
EreminAnton committed Nov 11, 2024
1 parent 0ffdfcc commit c15ff4f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def should_message_be_processed(

def push_total_access_denied_events_cloudwatch_metric() -> None:
"""Pushes CloudWatch metrics for all AccessDenied events."""
logger.info({"Pushing TotalAccessDeniedEvents CloudWatch metric"})
logger.info({"Info":"Pushing TotalAccessDeniedEvents CloudWatch metric"})
metrics = [
{
"MetricName": "TotalAccessDeniedEvents",
Expand All @@ -186,14 +186,14 @@ def push_total_access_denied_events_cloudwatch_metric() -> None:
]
try:
cloudwatch_client.put_metric_data(Namespace="CloudTrailToSlack/AccessDeniedEvents", MetricData=metrics)
logger.info({"Pushed TotalAccessDeniedEvents CloudWatch metric"})
logger.info({"Info":"Pushed TotalAccessDeniedEvents CloudWatch metric"})
except Exception as e:
logger.exception({"Failed to push CloudWatch metrics": {"error": e}})


def push_total_ignored_access_denied_events_cloudwatch_metric() -> None:
"""Pushes CloudWatch metrics for ignored AccessDenied events only."""
logger.info({"Pushing TotalIgnoredAccessDeniedEvents CloudWatch metric"})
logger.info({"Info":"Pushing TotalIgnoredAccessDeniedEvents CloudWatch metric"})
metrics = [
{
"MetricName": "TotalIgnoredAccessDeniedEvents",
Expand All @@ -204,7 +204,7 @@ def push_total_ignored_access_denied_events_cloudwatch_metric() -> None:
]
try:
cloudwatch_client.put_metric_data(Namespace="CloudTrailToSlack/AccessDeniedEvents", MetricData=metrics)
logger.info({"Pushed TotalIgnoredAccessDeniedEvents CloudWatch metric"})
logger.info({"Info": "Pushed TotalIgnoredAccessDeniedEvents CloudWatch metric"})
except Exception as e:
logger.exception({"Failed to push CloudWatch metrics": {"error": e}})

Expand Down Expand Up @@ -234,9 +234,9 @@ def handle_event(
logger.debug({"Processing result": {"result":result}})

if flatten_json(event).get("errorCode", "").startswith(("AccessDenied")):
logger.info({"Event is AccessDenied"})
logger.info({"Info": "Event is AccessDenied"})
if cfg.push_access_denied_cloudwatch_metrics is True:
logger.info({"Pushing AccessDenied CloudWatch metrics"})
logger.info({"Info":"Pushing AccessDenied CloudWatch metrics"})
push_total_access_denied_events_cloudwatch_metric()
if result.is_ignored:
push_total_ignored_access_denied_events_cloudwatch_metric()
Expand Down

0 comments on commit c15ff4f

Please sign in to comment.