Monitoring performance

Streaming Data with AWS Kinesis and Lambda

Maksim Pecherskiy

Data Engineer

Last lesson

2020-08-02_11-35.png

Streaming Data with AWS Kinesis and Lambda

Lambda transform

2020-08-02_12-04.png

Streaming Data with AWS Kinesis and Lambda

Lambda transform

def lambda_handler(event, context):

comprehend = boto3.client('comprehend', region_name='us-east-1', aws_access_key_id = AWS_KEY, aws_secret_access_key=AWS_SECRET)
output = []
for record in event['records']: ...
Streaming Data with AWS Kinesis and Lambda

Lambda transform

def lambda_handler(event, context):
    ...
    for record in event['records']:

dict_data = base64.b64decode(record['data']).decode('utf-8').strip() dict_data = json.loads(dict_data)
sentiment_all = comprehend.detect_sentiment( Text=dict_data['text'], LanguageCode=dict_data['lang']) dict_data['sentiment'] = sentiment_all['Sentiment'] ...
Streaming Data with AWS Kinesis and Lambda

Lambda transform

def lambda_handler(event, context):
    ...
    for record in event['records']:
        ...

output_record = { 'recordId': record['recordId'], 'result': 'Ok', 'data': base64.b64encode(json.dumps(dict_data).encode('utf-8')) }
output.append(output_record) return {'records': output}
Streaming Data with AWS Kinesis and Lambda

Wiring it up

2020-08-02_12-19.png

Streaming Data with AWS Kinesis and Lambda

Update firehoseDeliveryRole

2020-08-03_08-05.png

Streaming Data with AWS Kinesis and Lambda

Create delivery stream

2020-08-03_08-10.png

Streaming Data with AWS Kinesis and Lambda

Create delivery stream

2020-08-03_08-13.png

Streaming Data with AWS Kinesis and Lambda

Cloudwatch

The stream should minimize data loss due to downtime.

  • Logs (raw data)
  • Metrics (measures of various activities of the service)
  • Alarms (notifications when a metric is out of a specified range)
  • Dashboards (metrics visualization)
Streaming Data with AWS Kinesis and Lambda

Failure points

2020-08-02_12-39.png

Streaming Data with AWS Kinesis and Lambda

Let's practice!

Streaming Data with AWS Kinesis and Lambda

Preparing Video For Download...