Skip to content

Commit 33a5b01

Browse files
committed
Add aws_account tag to logs and enhanced metrics
1 parent 635c61a commit 33a5b01

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

aws/logs_monitoring/enhanced_lambda_metrics.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def generate_enhanced_lambda_metrics(log, tags_cache):
341341
return parsed_metrics
342342

343343

344-
def parse_lambda_tags_from_arn(arn):
344+
def parse_lambda_tags_from_arn(arn, aws_account_tag=False):
345345
"""Generate the list of lambda tags based on the data in the arn
346346
347347
Args:
@@ -360,6 +360,8 @@ def parse_lambda_tags_from_arn(arn):
360360
return [
361361
"region:{}".format(region),
362362
"account_id:{}".format(account_id),
363+
# Include the aws_account tag to match the aws.lambda CloudWatch metrics
364+
"aws_account:{}".format(account_id),
363365
"functionname:{}".format(function_name),
364366
]
365367

@@ -435,5 +437,4 @@ def get_enriched_lambda_log_tags(log):
435437
lambda_custom_tags = account_lambda_tags_cache.get(log_function_arn)
436438
# Combine and dedup tags
437439
tags = list(set(tags_from_arn + lambda_custom_tags))
438-
tags.sort()
439440
return tags

aws/logs_monitoring/lambda_function.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,11 @@ def enrich(events):
645645

646646

647647
def add_metadata_to_lambda_log(event):
648-
"""Mutate log dict to add functionname tag, host, and service from the existing Lambda attribute
648+
"""Mutate log dict to add tags, host, and service metadata
649+
650+
* tags for functionname, aws_account, region
651+
* host from the Lambda ARN
652+
* service from the Lambda name
649653
650654
If the event arg is not a Lambda log then this returns without doing anything
651655

0 commit comments

Comments
 (0)