Related to #702 Integrate Watchtower for optional logging to AWS CloudWatch Logs. * **Watchtower Integration:** - Import `watchtower` in `swarms/utils/loguru_logger.py`. - Add `initialize_watchtower_logger` function to configure Watchtower logging. - Update `initialize_logger` to optionally use Watchtower logging if configured. * **Agent Logging Updates:** - Import `initialize_watchtower_logger` in `swarms/agents/ape_agent.py`, `swarms/agents/tool_agent.py`, and `swarms/structs/agent.py`. - Update logger initialization in `swarms/agents/ape_agent.py` and `swarms/agents/tool_agent.py` to use `initialize_watchtower_logger`. * **Terraform Configuration:** - Add `terraform/logging.tf` to create log groups and policies for AWS CloudWatch Logs.pull/704/head
parent
4f265f3e35
commit
ce0a5e0099
@ -0,0 +1,53 @@
|
||||
provider "aws" {
|
||||
region = "us-west-2"
|
||||
}
|
||||
|
||||
resource "aws_cloudwatch_log_group" "swarms_log_group" {
|
||||
name = "swarms-log-group"
|
||||
retention_in_days = 14
|
||||
}
|
||||
|
||||
resource "aws_iam_role" "swarms_logging_role" {
|
||||
name = "swarms-logging-role"
|
||||
|
||||
assume_role_policy = jsonencode({
|
||||
Version = "2012-10-17"
|
||||
Statement = [
|
||||
{
|
||||
Action = "sts:AssumeRole"
|
||||
Effect = "Allow"
|
||||
Principal = {
|
||||
Service = "ec2.amazonaws.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
resource "aws_iam_policy" "swarms_logging_policy" {
|
||||
name = "swarms-logging-policy"
|
||||
description = "Policy for allowing swarms to create and manage CloudWatch log groups"
|
||||
policy = jsonencode({
|
||||
Version = "2012-10-17"
|
||||
Statement = [
|
||||
{
|
||||
Action = [
|
||||
"logs:CreateLogGroup",
|
||||
"logs:CreateLogStream",
|
||||
"logs:PutLogEvents",
|
||||
"logs:DescribeLogGroups",
|
||||
"logs:DescribeLogStreams",
|
||||
"logs:PutRetentionPolicy",
|
||||
"logs:TagLogGroup"
|
||||
]
|
||||
Effect = "Allow"
|
||||
Resource = "*"
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "swarms_logging_role_attachment" {
|
||||
role = aws_iam_role.swarms_logging_role.name
|
||||
policy_arn = aws_iam_policy.swarms_logging_policy.arn
|
||||
}
|
Loading…
Reference in new issue