Schedule an appointment

Unlocking Amazon Connect Insights using CloudWatch Log Insights

Leverage AWS CloudWatch Insights to gain real-time troubleshooting, pattern identification, and valuable insights into contact flows through log data analysis.

Amazon Connect is a cloud-based contact center solution that provides businesses with a simple and scalable way to manage customer interactions. With Amazon Connect, companies can set up a customizable contact center that integrates with their existing systems and processes, allowing them to provide high-quality customer service.

Amazon Connect generates data Contact Flow logs stored in Amazon Connect log groups. The log streams provide detailed information about the call journey. However, it becomes challenging for contact centers with large call volumes to navigate and analyze standard log data in Amazon CloudWatch log streams.

AWS CloudWatch Insights is a fully managed service that allows you to search and analyze log data using a query language. You can use CloudWatch Insights to troubleshoot issues, identify patterns, and find solutions to problems in near real time. CloudWatch Insights uses a simple yet powerful query language that allows you to filter, aggregate, and group log data to gain insights into your contact flows.

To use CloudWatch Insights to analyze contact flow logs, you must first enable logging for your Amazon Connect instance and add Set logging behavior to the contact flows. Once logging is enabled, CloudWatch Insights will automatically start receiving and storing contact flow logs.

You can use CloudWatch Insights to answer questions like:

  • Detailed information about individual calls, including start and end times, caller and agent IDs, and call status.
  • How many contacts were handled by my Amazon Connect instance during a period, and identify the peak calls?
  • Find abandoned calls before the calls reach an agent.

Quick Look at AWS CloudWatch Insights

Go to the CloudWatch Console home page, and click on the Logs Insights menu under Logs.

From the CloudWatch Insights page, select the log group(s) you want to run queries against.

For Amazon Connect, you can query Amazon Connect Instance logs or streaming data (Kinesis Stream) from Connect. This article will show sample queries against instance logs and streaming logs.

For Contact Flow Logs, you’ll choose your Connect Instance.

Select the data and specify the date range you want to run the query.

Basic Log Queries

Default Query

This query is the default, which appears when you first load the page. It shows the logs in descending order and is limited to the last 20 log messages. The syntax commands start with the “|” (pipe character) at the beginning of the line. You may comment using “#” at the front of the line, which your query will ignore.


fields @timestamp, @message
| sort @timestamp desc
| limit 20 

Result

Contact Flow Logs for specific Contact Id

This query will return all Contact Flow Logs for the specified Contact Id displayed in order by timestamp


fields @timestamp, @message
| sort @timestamp desc
| filter ContactId = "{contactid}"
| display Results, ContactId, @timestamp, ContactFlowModuleType 

Result

Count Unique Calls

The query will return the number of calls that generated some logging. This query will not necessarily return the number of calls to your Connect Instance, only those where logging is enabled.


fields @timestamp, @message
| sort @timestamp
| stats count_distinct(ContactId) 

Result

Find all Specific Lambda Invocations

This query will return all logs for a specific Lambda Function. You can see the Parameters sent to the Lambda Function, and the return results for each invocation logged.


fields @timestamp, @message
| sort @timestamp
| filter ContactFlowModuleType = "InvokeExternalResource"
| filter Parameters.FunctionArn = "{lambda-arn}" 

Distinct Call Count with time series visualization

The query will return the results showing a number of log events in the log group that CloudWatch Logs received every 30 seconds.


fields @timestamp, @message
| sort @timestamp
| stats count_distinct(ContactId) by bin(15m) 

Choose the Visualization tab. The results are shown as a graph. To switch to a bar chart, pie chart, or stacked area chart, choose the arrow next to the Pie at the upper left of the graph.

Query on Stream Data Log

You can enable Data Streaming which generates Contact Trace Records (CTRs) and Agent Events to perform real-time analysis on contacts. Data Streaming sends data to Amazon Kinesis. You can create Lambda functions that read data from the Kinesis stream and analyze the logs from the Lambda function.

From the dropdown, choose your lambda function, which triggers kinesis stream data.

Find the call disconnected by the customer.

This query will return distinct calls disconnected by the customer within the selected duration.


fields @timestamp, @message
| stats latest(@timestamp) as @latestTimestamp by @message
| filter DisconnectReason = "CUSTOMER_DISCONNECT"
| sort @timestamp 

Find specific fields

This query shows to select specific fields instead of fetching all fields.


fields @timestamp, @message
| filter DisconnectReason = "CUSTOMER_DISCONNECT"
| sort @timestamp
| stats count_distinct (ContactId) by bin(60m), ContactId, Queue.Duration, CustomerEndpoint.Address, InitiationMethod, Queue.Name 

Find Abandoned calls

This query will return Abandoned calls within the selected duration.


fields @timestamp, @message
| filter Agent = "None"
| filter DisconnectReason = "CUSTOMER_DISCONNECT"
| filter ispresent (Queue.Name) and Queue.Name != "None"
| filter InitiationMethod = "INBOUND"
| filter Queue.Duration > 0
| sort @timestamp
| stats count_distinct (ContactId) by bin(60m), Queue.Duration, ContactId, CustomerEndpoint.Address, InitiationMethod, Queue.Name,Queue.EnqueueTimestamp 

Save Queries

After you create a query, you can save it and rerun it later. You can organize the queries in folders by category or service.

To save a query :

  1. In the query editor, create a query.
  2. Choose Save.
  3. Enter a name for the query.
  4. Choose a folder where you want to save the query. Then, select Create new to create a folder. If you create a new folder, you can use slash (/) characters in the folder name to define a folder structure.
  5. Change the query’s log groups or query text.
  6. Choose Save.

To run a saved query :

  1. On the right, choose Queries.
  2. Select your query from the Saved queries list. It appears in the query editor.
  3. Choose Run.

Conclusion:

CloudWatch Insights is a powerful tool that provides businesses with detailed insights into their contact center operations, allowing them to monitor and optimize their operations in real time and make informed decisions.

Tags

Arystech Logo

We Love to Talk Tech

Whether you need advice or are ready to get started, we're here to help. We go the extra mile to empower your digital transformation.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

accreditations

AWS - Lambda Delivery PartnerAWS - Well-Architected PartnerMicrosoft Partner