Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"invoked_function_arn": "arn:aws:lambda:us-east-1:0:function:test"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>",
"ddsource": "cloudwatch",
"service": "cloudwatch",
"host": "testLogGroup"
Expand All @@ -38,7 +38,7 @@
"invoked_function_arn": "arn:aws:lambda:us-east-1:0:function:test"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>",
"ddsource": "cloudwatch",
"service": "cloudwatch",
"host": "testLogGroup"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
Expand All @@ -44,7 +44,7 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
Expand All @@ -66,7 +66,7 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"invoked_function_arn": "arn:aws:lambda:us-east-1:0:function:test"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,custom_tag1:value1,custom_tag2:value2",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,custom_tag1:value1,custom_tag2:value2",
"ddsource": "cloudwatch",
"service": "cloudwatch",
"host": "testLogGroup"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
Expand All @@ -44,7 +44,7 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
Expand All @@ -66,7 +66,7 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
Expand All @@ -88,12 +88,35 @@
"arn": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
},
"ddsourcecategory": "aws",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:x.x.x,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,env:none,account_id:0,aws_account:0,functionname:storms-cloudwatch-event,region:us-east-1,service:storms-cloudwatch-event",
"ddsource": "lambda",
"service": "storms-cloudwatch-event",
"host": "arn:aws:lambda:us-east-1:0:function:storms-cloudwatch-event"
}
]
},
{
"path": "/api/v1/distribution_points?api_key=abcdefghijklmnopqrstuvwxyz012345",
"verb": "POST",
"content-type": "application/json",
"data": {
"series": [
{
"metric": "aws.lambda.enhanced.timeouts",
"points": "<redacted from snapshot>",
"type": "distribution",
"host": null,
"device": null,
"tags": [
"region:us-east-1",
"account_id:0",
"aws_account:0",
"functionname:storms-cloudwatch-event"
],
"interval": 10
}
]
}
}
]
}
3 changes: 0 additions & 3 deletions aws/logs_monitoring/tools/Dockerfile_integration
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ ARG forwarder

# Add the code into /var/task (will unzip files)
ADD $forwarder /var/task/

ENV DD_API_KEY "fake-api-key"
ENV DD_SITE "datadog.com"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these to docker-compose to be with the other env vars

3 changes: 2 additions & 1 deletion aws/logs_monitoring/tools/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ version: "3.7"
services:
forwarder:
image: datadog-log-forwarder:${PYTHON_RUNTIME:-python3.7}
command: lambda_function.datadog_forwarder
command: lambda_function.lambda_handler
environment:
AWS_ACCOUNT_ID: 0000000000
DOCKER_LAMBDA_STAY_OPEN: 1
DD_LOG_LEVEL: info
DD_API_KEY: abcdefghijklmnopqrstuvwxyz012345 # Must be 32 characters exactly
DD_URL: forwarder-recorder # Used for logs intake
DD_PORT: 8080 # API port to use
DD_SITE: datadog.com
DD_API_URL: http://forwarder-recorder:8080
DD_LOGS_INTAKE_URL: forwarder-recorder:8080
DD_TRACE_INTAKE_URL: http://forwarder-recorder:8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class RecorderHandler(BaseHTTPRequestHandler):
def __init__(self, request, client_address, server):
super().__init__(request, client_address, server)()
super().__init__(request, client_address, server)
Copy link
Contributor Author

@nhinsch nhinsch Aug 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was raising exceptions in the integration tests, so I cleaned it up


def handle_request(self):
global events
Expand Down Expand Up @@ -52,7 +52,6 @@ def handle_request(self):
self.wfile.write(response.encode("utf-8"))
return

# Handler for the GET requests
def do_GET(self):
self.handle_request()

Expand Down
25 changes: 19 additions & 6 deletions aws/logs_monitoring/tools/test_harness/tests/test_snapshots.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import unittest
import base64
import os
import urllib.request, json
import urllib.request
import json
import re
import gzip
from time import sleep

recorder_url = os.environ.get("RECORDER_URL", default="")
forwarder_url = os.environ.get("FORWARDER_URL", default="")
Expand All @@ -20,7 +22,7 @@ class TestForwarderSnapshots(unittest.TestCase):

def get_recording(self):
with urllib.request.urlopen(recorder_url) as url:
message = self.filter_message(url.read().decode())
message = self.filter_snapshot(url.read().decode())
data = json.loads(message)
return data

Expand All @@ -35,11 +37,22 @@ def send_log_event(self, event):
request = urllib.request.Request(forwarder_url, data=event.encode("utf-8"))
urllib.request.urlopen(request)

def filter_message(self, message):
# Remove forwarder_version from output
return re.sub(
r"forwarder_version:\d+\.\d+\.\d+", "forwarder_version:x.x.x", message
def filter_snapshot(self, snapshot):
# Remove things that can vary during each test run
# forwarder_version
snapshot = re.sub(
r"forwarder_version:\d+\.\d+\.\d+",
"forwarder_version:<redacted from snapshot>",
snapshot,
)
# Metric points
snapshot = re.sub(
r"\"points\":.*?,(?=\s*\")",
'"points": "<redacted from snapshot>",',
snapshot,
flags=re.MULTILINE,
)
return snapshot

def compare_snapshot(self, input_filename, snapshot_filename):
with open(input_filename, "r") as input_file:
Expand Down