Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
Merge pull request #96 from dynatrace-oss/PCLOUDS-3370-lambda-integra…
Browse files Browse the repository at this point in the history
…tion-add-a-link-to-generic-lambda-in-log-forwarder-logs

Pclouds 3370 lambda integration add a link to generic lambda in log forwarder logs
  • Loading branch information
dt-be authored Jan 15, 2024
2 parents b1bd605 + db9c5e7 commit a0bacdd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/config/lambda.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
"key": "aws.arn",
"pattern": "format_arn('arn:{}:lambda:{}:{}:function:{}', [partition, region, account_id, function_name])"
},
{
"key": "faas.id",
"pattern": "format_arn('arn:{}:lambda:{}:{}:function:{}', [partition, region, account_id, function_name])"
},
{
"key": "severity",
"pattern": "if( starts_with(log_content, '[ERROR]'), &'ERROR', &'INFO', @)"
},
{
"key": "dt.source_entity",
"key": "dt.entity.aws_lambda_function",
"pattern": "dt_meid_lambda_function(function_name, region, account_id)"
}
]
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/logs/metadata_engine/entity_id/test_me_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,39 @@ def test_meid_in_credentials_v2_core_services__murmurhash_awsseed():
meid = jmes_custom_functions._func_dt_meid_rds_v2(dbInstanceArn)
assert meid == real_meid_from_dt_cluster, "From jmesPath customFunctions - seed should be -512093083:"
assert id == real_long_id_from_dt_cluster


def test_meid_credentials_v1_v2_builtin_service_lambda_md5():
# arn: "arn:aws:lambda:us-east-1:444652832050:function:metricstreamprocessorinte-CloudWatchStreamFunction-bpIv5lY7e0k8"
id_calc_input = "metricstreamprocessorinte-CloudWatchStreamFunction-bpIv5lY7e0k8" + \
"us-east-1" + \
"_" + \
"444652832050"

id = me_id._legacy_entity_id_md5(id_calc_input)
meid = me_id.meid_md5("AWS_LAMBDA_FUNCTION", id_calc_input)
meid_from_format = me_id.meid_md5("AWS_LAMBDA_FUNCTION", format_required("{}{}_{}", [
"metricstreamprocessorinte-CloudWatchStreamFunction-bpIv5lY7e0k8", #awsArnParts[6] - name
"us-east-1", # awsArnParts[3] - region
"444652832050" # awsArnParts[4] - account
]))

assert id == -6510566195266530280
assert meid == "AWS_LAMBDA_FUNCTION-A5A5D28A3478D418"
assert meid == meid_from_format


def test_meid_credentials_v2_supporting_service_lambda__murmurhash():
id_calc_input = "lambdaarn:aws:lambda:us-east-1:444652832050:function:metricstreamprocessorinte-CloudWatchStreamFunction-bpIv5lY7e0k8"

id = me_id._murmurhash2_64A(id_calc_input)
meid = me_id.meid_murmurhash("CUSTOM_DEVICE", id_calc_input)
meid_from_list = me_id.meid_murmurhash("CUSTOM_DEVICE", format_required("{}{}", [
"lambda", ##supporting service id/shortname
"arn:aws:lambda:us-east-1:444652832050:function:metricstreamprocessorinte-CloudWatchStreamFunction-bpIv5lY7e0k8" #arn
]))

assert id == -2879273126824973378
assert meid == "CUSTOM_DEVICE-D80AC458A044EBBE"
assert meid == meid_from_list

4 changes: 2 additions & 2 deletions tests/unit/logs/test_transformation_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"aws.service": "lambda",
"aws.resource.id": "dynatrace-aws-logs-Lambda-1K7HG2Q2LIQKU",
"aws.arn": "arn:aws:lambda:us-east-1:444000444:function:dynatrace-aws-logs-Lambda-1K7HG2Q2LIQKU",
"dt.source_entity": "AWS_LAMBDA_FUNCTION-F141CAEAE2BED565",
"dt.entity.aws_lambda_function": "AWS_LAMBDA_FUNCTION-F141CAEAE2BED565",
'content': "LOG MESSAGE",
'cloud.provider': 'aws',
'cloud.account.id': "444000444",
Expand Down Expand Up @@ -145,7 +145,7 @@
"aws.service": "lambda",
"aws.resource.id": "dynatrace-aws-logs-Lambda-1K7HG2Q2LIQKU",
"aws.arn": "arn:aws:lambda:us-east-1:444000444:function:dynatrace-aws-logs-Lambda-1K7HG2Q2LIQKU",
"dt.source_entity": "AWS_LAMBDA_FUNCTION-F141CAEAE2BED565",
"dt.entity.aws_lambda_function": "AWS_LAMBDA_FUNCTION-F141CAEAE2BED565",
'content': "[ERROR] UnboundLocalError: local variable 'single_log_entry' referenced before assignment\n"
+ "Traceback (most recent call last):\n"
+ " File \"/var/task/lambda_function.py\", line 101, in lambda_handler\n"
Expand Down

0 comments on commit a0bacdd

Please sign in to comment.