Business Productivity

Server-Side Logging and Monitoring of Amazon Chime SDK Events

When you start running Amazon Chime SDK implemented service in production, you want to make sure you are logging and monitoring usage of Chime SDK. This might be finding the duration of the meetings, or tracking attendee’s meeting activity, or simply checking the number of meetings being held to identify any abnormality.

There are different important areas to monitor depending on your business. If you are interested in client side events like the root cause of failure of joining a meeting or capturing audio/video quality issues due to network bandwidth, please refer to the blog ‘Monitoring and troubleshooting with Amazon Chime SDK meeting events’. In this blog post, we will share examples of how you can use Amazon EventBridge which integrates directly with Chime SDK to monitor and respond to back-end service meeting events and resource changes in near real time. You can also write simple rules to filter any meeting session events that are interest to you and automate any action that matches the rule.

Amazon Chime SDK has limit quotas like other AWS services that you need to keep in mind when using in production. When your service adoption starts to increase, you will want to make sure there is enough capacity to your assigned quotas. We will be sharing procedures to get you started on the setup and share some example metrics and alarms to monitor that could be useful for your operation.

In this post, you will learn how to:

  • Setup Amazon EventBridge to produce Chime SDK events to Amazon CloudWatch logs
  • Create metric filters to see metrics of your interest and set an alarm
  • Create log insights to monitor data of your interest
  • Combine widgets to create useful CloudWatch dashboard

Prerequisites:

  • Basic understanding of Amazon Chime SDK
  • Running Amazon Chime SDK environment that you can test this on

Step 1. Setup Amazon EventBridge to produce Chime SDK events to CloudWatch log output

  1. Sign in to the AWS Management Console and switch to a region that API endpoint is supported.
    This step shows how to set EventBridge to store Chime SDK API events to Amazon CloudWatch logs. For details, see here.
  2. Go to Amazon EventBridge and click on create rule.
  3. Enter name as chime-sdk-rule
  4. In Define pattern, select Event pattern and Pre-defined pattern
  5. Select Service provider as AWS, Service name as Chime, and Event type as All Events
    • Note: You can restrict number of events produced to CloudWatch by selecting ‘AWS API Call via CloudTrail’ if you only prefer API calls or ‘Chime Meeting State Change’ for only in-meeting state change events. You can also apply custom pattern by putting specific event pattern that you want to capture.
  6. Keep AWS default event bus selected for Select event bus
  7. At Select targets, choose CloudWatch log group and enter /aws/events/chime-sdk-event-logs
  8. Click create

     

  9. Go to CloudWatch and open Log groups and select /aws/events/chime-sdk-event-logs
  10. Once there are activities through Chime SDK, you should be able to see a list of log streams
    • Note: Types of Chime SDK events that can be received through EventBridge can be found here.

Step 2. Create metric filters to see metrics of your interest and set alarm

Now that you have Amazon ChimeSDK meeting events into CloudWatch logs, you can use metric filters to capture for specific events from the logs and display the data as a graph. Once you have a graph, you can create an alarm that will notify you if the threshold exceeds.

  1. Go to Metrics filter tab on the Log group of your choice and click on create metrics filter
  2. Enter filter pattern of your choice. Below are a few samples you can try.

This is a filter pattern to capture only ‘CreateMeeting’ API requests.
* To simulate CreateMeeting events using AWS CLI, you can use aws chime create-meeting command to create one

Filter pattern
{ $.detail.eventType = "AwsApiCall" && $.detail.eventName = "CreateMeeting" }

You can change the filter pattern like below to only capture ‘AttendeeJoined’ events which gets triggered whenever an attendee joins into a meeting session.

Filter pattern
{ $.detail.eventType = "chime:AttendeeJoined" }

  1. Once you have a metrics graph of your choice, you can create alarm to notify when the value reaches the threshold you set. To get started, select Create alarm from Actions on the Graphed metrics tab. For details on how to set Amazon CloudWatch alarms, see here. The illustration below demonstrates an alarm set to trigger with 50 or more CreateMeeting API requests within 10 seconds.

 

You can assign Amazon CloudWatch to use Amazon SNS to send an email when alarm is triggered, or other options include to use incident creation with Incident Manager. Below example demonstrates creating SNS topic and registering email address to receive the notification. Once you create SNS topic, email confirmation is sent to the email address to confirm. The email receiver will need to click on ‘Confirm subscription’ to receive notifications.

 
When the alarm triggers, Amazon SNS will send an email notification like sample below. The email contains which threshold was bleached (note below sample has threshold set to 10 instead of 50) with timestamp and link to the CloudWatch metrics on AWS Management Console to be able to investigate further.

Step 3. Create log insights to monitor data of your interest

CloudWatch Logs Insights enables you to search and analyze log data in Amazon CloudWatch Logs using queries. This allows you to efficiently retrieve the data you want to monitor by saving and adding them to the dashboard for easy accessibility. I will share a few sample queries that might be useful to monitor. To learn about the query syntax, visit this page.

    1. Go to Logs Insights and select /aws/events/chime-sdk-event-logs as log group
    2. Here are some examples you can try and modify to fit your requirements
    1. “List of Chime API calls made in chronological descending order”

This can be a good one to monitor general patterns of API calls made from your service.

query:

display detail.eventName, detail.eventTime
| sort detail.eventTime desc 
| filter detail.eventType LIKE /AwsApiCall/





    1. “Number of Chime API requests made in 1 second period”

This can be used to monitor how close your API requests are to the API rate threshold.

query:

stats count(detail.eventTime) as api_request_count by bin(1s) as timestamp
| filter @message like /AwsApiCall/ 
| sort timestamp desc



    1. “Number of CreateMeeting/DeleteMeeting API requests per hour”

This will allow you to monitor specific API calls (CreateMeeting or DeleteMeeting) with a specific purpose. For example, you can get the sum of CreateMeeting API calls per day to find out how many meetings are being held each day.

query:

stats count(detail.eventTime) as request_count by bin(1h) as hour, detail.eventName as api_type
| sort detail.eventTime desc 
| filter detail.eventName IN ["CreateMeeting","DeleteMeeting"]

    1. “Track duration of the meeting”

You can track the duration of a meeting by getting timestamps of MeetingStarted and MeetingEnded event call.

query:

fields @message
| display detail.eventType, detail.meetingId, time
| filter detail.eventType in ['chime:MeetingStarted', 'chime:MeetingEnded']
| sort detail.meetingId, time desc


    1. “Track attendee activity in the meeting”

You can filter to specific attendee to track attendee related activities

query:

fields detail.externalUserId, detail.externalMeetingId, time, detail.eventType, detail.meetingId
| filter detail.attendeeId = ''



Step 4. Combine widgets to create useful dashboard

Once you have a list of Logs Insights metrics that interests you from Step 3, you can put these metrics as widgets on Amazon CloudWatch’s Dashboard for easy access. Dashboards allow you to put each defined metrics as a widget and has UI flexibility so you can design the dashboard to your preference.

Conclusion

This post walked you through the process of setting up Amazon EventBridge and Amazon CloudWatch to capture events triggered from Amazon Chime SDK API requests. It also taught you how to use query and filter log data to display only the data you care about as widgets on a dashboard.

For the next step, we suggest you try selecting meeting events data that are important to you in your operation and then applying those data to your customized Amazon CloudWatch dashboard. You can also refer this LTI-ready virtual classroom demo app that uses information from Amazon EventBridge to present meaningful insight into meeting activities.