Skip to content

Commit 9959e56

Browse files
authored
feat(aws): AWSX-1987 Migrate remaining soure identification to logs-backend (#998)
Signed-off-by: Vincent Boutour <vincent.boutour@datadoghq.com>
1 parent aa6fbb8 commit 9959e56

File tree

4 files changed

+0
-62
lines changed

4 files changed

+0
-62
lines changed

aws/logs_monitoring/steps/enrichment.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def enrich(events, cache_layer):
2525
add_metadata_to_lambda_log(event, cache_layer)
2626
extract_ddtags_from_message(event)
2727
extract_host_from_cloudtrails(event)
28-
extract_host_from_guardduty(event)
2928

3029
return events
3130

@@ -206,12 +205,3 @@ def extract_host_from_cloudtrails(event):
206205
match = HOST_IDENTITY_REGEXP.match(arn)
207206
if match is not None:
208207
event[DD_HOST] = match.group("host")
209-
210-
211-
def extract_host_from_guardduty(event):
212-
if event is not None and event.get(DD_SOURCE) == str(AwsEventSource.GUARDDUTY):
213-
host = event.get("detail", {}).get("resource")
214-
if isinstance(host, dict):
215-
host = host.get("instanceDetails", {}).get("instanceId")
216-
if host is not None:
217-
event[DD_HOST] = host

aws/logs_monitoring/steps/enums.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@ class AwsEventSource(Enum):
55
AWS = "aws"
66
CLOUDTRAIL = "cloudtrail"
77
CLOUDWATCH = "cloudwatch"
8-
ELASTICSEARCH = "elasticsearch"
9-
FARGATE = "fargate"
10-
GUARDDUTY = "guardduty"
118
KINESIS = "kinesis"
129
LAMBDA = "lambda"
13-
MARIADB = "mariadb"
14-
MSK = "msk"
15-
MYSQL = "mysql"
16-
POSTGRESQL = "postgresql"
1710
S3 = "s3"
1811
SNS = "sns"
1912
STEPFUNCTION = "stepfunction"
@@ -26,9 +19,6 @@ def __str__(self):
2619
def cloudwatch_sources():
2720
return [
2821
AwsEventSource.CLOUDTRAIL,
29-
AwsEventSource.ELASTICSEARCH,
30-
AwsEventSource.FARGATE,
31-
AwsEventSource.MSK,
3222
]
3323

3424

@@ -41,9 +31,7 @@ def __init__(self, string, event_source):
4131
WAF_0 = ("aws-waf-logs", AwsEventSource.WAF)
4232
WAF_1 = ("waflogs", AwsEventSource.WAF)
4333

44-
GUARDDUTY = ("guardduty", AwsEventSource.GUARDDUTY)
4534
KINESIS = ("amazon_kinesis", AwsEventSource.KINESIS)
46-
MSK = ("amazon_msk", AwsEventSource.MSK)
4735

4836
def __str__(self):
4937
return f"{self.string}"

aws/logs_monitoring/tests/test_enrichment.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
add_metadata_to_lambda_log,
1010
extract_ddtags_from_message,
1111
extract_host_from_cloudtrails,
12-
extract_host_from_guardduty,
1312
)
1413

1514

@@ -160,14 +159,6 @@ def test_parse_source_cloudtrail(self):
160159
extract_host_from_cloudtrails(event)
161160
self.assertEqual(event["host"], "i-99999999")
162161

163-
def test_parse_source_guardduty(self):
164-
event = {
165-
"ddsource": "guardduty",
166-
"detail": {"resource": {"instanceDetails": {"instanceId": "i-99999999"}}},
167-
}
168-
extract_host_from_guardduty(event)
169-
self.assertEqual(event["host"], "i-99999999")
170-
171162

172163
class TestLambdaMetadataEnrichment(unittest.TestCase):
173164
def test_empty_event(self):

aws/logs_monitoring/tests/test_parsing.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,6 @@ def test_redshift_gov_event(self):
134134
str(AwsEventSource.S3),
135135
)
136136

137-
def test_fargate_event(self):
138-
self.assertEqual(
139-
parse_event_source(
140-
{"awslogs": "logs"},
141-
"/ecs/fargate-logs",
142-
),
143-
str(AwsEventSource.FARGATE),
144-
)
145-
146137
def test_cloudfront_event(self):
147138
self.assertEqual(
148139
parse_event_source(
@@ -152,28 +143,6 @@ def test_cloudfront_event(self):
152143
str(AwsEventSource.S3),
153144
)
154145

155-
def test_elasticsearch_event(self):
156-
self.assertEqual(
157-
parse_event_source({"awslogs": "logs"}, "/elasticsearch/domain"),
158-
str(AwsEventSource.ELASTICSEARCH),
159-
)
160-
161-
def test_msk_event(self):
162-
self.assertEqual(
163-
parse_event_source(
164-
{"awslogs": "logs"},
165-
"/myMSKLogGroup",
166-
),
167-
str(AwsEventSource.MSK),
168-
)
169-
self.assertEqual(
170-
parse_event_source(
171-
{"Records": ["logs-from-s3"]},
172-
"AWSLogs/amazon_msk/us-east-1/xxxxx.log.gz",
173-
),
174-
str(AwsEventSource.MSK),
175-
)
176-
177146
def test_cloudwatch_source_if_none_found(self):
178147
self.assertEqual(
179148
parse_event_source({"awslogs": "logs"}, ""), str(AwsEventSource.CLOUDWATCH)

0 commit comments

Comments
 (0)