Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(enrichment): search for service as key, not as value in extracted ddtags #876

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws/logs_monitoring/steps/enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def extract_ddtags_from_message(event):
return

# Extract service tag from message.ddtags if exists
if "service" in extracted_ddtags:
if "service:" in extracted_ddtags:
event[DD_SERVICE] = next(
tag[8:]
for tag in extracted_ddtags.split(",")
Expand Down
15 changes: 15 additions & 0 deletions aws/logs_monitoring/tests/test_enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ def test_extract_ddtags_from_message_multiple_values_tag(self):
"my_application_service",
)

def test_extract_ddtags_from_message_service_only_in_extracted_ddtags_values(self):
loaded_message_tags = {"ddtags": "key:my-service-repo"}
event = {"message": loaded_message_tags, "ddtags": self.custom_tags}

extract_ddtags_from_message(event)

self.assertEqual(
event["ddtags"],
"custom_tag_2:value2,service:my_custom_service,key:my-service-repo",
)
self.assertNotIn(
"service",
event,
)


class TestExtractHostFromLogEvents(unittest.TestCase):
def test_parse_source_cloudtrail(self):
Expand Down