Skip to content

Commit

Permalink
[AWSMC-588] Support Bedrock log source (#708)
Browse files Browse the repository at this point in the history
* [AWSMC-588] Support Bedrock log source

* Remove amazon_ prefix

* Properly set source and service for cw logs

* Lint

* Remove duplicate logStream check
  • Loading branch information
ktmq authored Nov 16, 2023
1 parent c8af523 commit c372bd3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aws/logs_monitoring/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def find_cloudwatch_source(log_group):
"elasticsearch",
"transitgateway",
"verified-access",
"bedrock",
]:
if source in log_group:
return source
Expand Down Expand Up @@ -381,6 +382,7 @@ def find_s3_source(key):
"network-firewall",
"cloudfront",
"verified-access",
"bedrock",
]:
if source in key:
return source.replace("amazon_", "")
Expand Down Expand Up @@ -487,12 +489,14 @@ def awslogs_handler(event, context, metadata):
# Set the source on the logs
source = logs.get("logGroup", "cloudwatch")

# Use the logStream to identify if this is a CloudTrail event
# Use the logStream to identify if this is a CloudTrail, TransitGateway, or Bedrock event
# i.e. 123456779121_CloudTrail_us-east-1
if "_CloudTrail_" in logs["logStream"]:
source = "cloudtrail"
if "tgw-attach" in logs["logStream"]:
source = "transitgateway"
if logs["logStream"] == "aws/bedrock/modelinvocations":
source = "bedrock"
metadata[DD_SOURCE] = parse_event_source(event, source)

# Build aws attributes
Expand All @@ -515,6 +519,7 @@ def awslogs_handler(event, context, metadata):
)

# Set service from custom tags, which may include the tags set on the log group
# Returns DD_SOURCE by default
metadata[DD_SERVICE] = get_service_from_tags(metadata)

# Set host as log group where cloudwatch is source
Expand Down

0 comments on commit c372bd3

Please sign in to comment.