Skip to content

Commit

Permalink
Add AWS region support to CloudWatch integration and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mfittko committed Sep 12, 2024
1 parent d07f6f6 commit 2e7c41c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion litellm/integrations/cloud_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
self,
log_group_name=None,
log_stream_name=None,
aws_region=None,
):
try:
verbose_logger.debug(
Expand All @@ -30,18 +31,21 @@ def __init__(
# now set cloudwatch params from litellm.cloudwatch_callback_params
log_group_name = litellm.cloudwatch_callback_params.get("log_group_name", log_group_name)
log_stream_name = litellm.cloudwatch_callback_params.get("log_stream_name", log_stream_name)
aws_region = litellm.cloudwatch_callback_params.get("aws_region", aws_region)

self.log_group_name = log_group_name or os.getenv("CLOUDWATCH_LOG_GROUP_NAME")
self.log_stream_name = log_stream_name or os.getenv("CLOUDWATCH_LOG_STREAM_NAME")
self.aws_region = aws_region or os.getenv("AWS_REGION")

if self.log_group_name is None:
raise ValueError("log_group_name must be provided either through parameters, cloudwatch_callback_params, or environment variables.")

# Initialize CloudWatch Logs client
self.logs_client = boto3.client("logs")
self.logs_client = boto3.client("logs", region_name=self.aws_region)

# Ensure the log group exists
self._ensure_log_group()
self._ensure_log_stream()
self.sequence_token = None

except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions sofatutor_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ litellm_settings:
success_callback: ["cloudwatch"]
cloudwatch_callback_params:
log_group_name: /litellm/sandbox
aws_region: eu-central-1

general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
Expand Down

0 comments on commit 2e7c41c

Please sign in to comment.