Amazon Connect troubleshooting data lives in several CloudWatch log groups: flow logs, AWS Lambda logs and Amazon Lex conversation logs. This page is a copy-paste library of CloudWatch Logs Insights query examples for Amazon Connect, grouped by log source, plus the cost and limit facts AWS documents. Every fact comes from AWS documentation, listed at the end.
Note: test each query on a short time range in your own account first. Field names in your own Lambda logs depend on your code.
Which Log Group to Query
| Log source | Log group | How it is created |
|---|---|---|
| Amazon Connect flow logs | /aws/connect/your-instance-alias |
Turn on flow logs for the instance and add a Set logging behavior block. See Debug Amazon Connect Contact Flows. |
| AWS Lambda logs | /aws/lambda/your-function-name |
Lambda creates it automatically when the function is first invoked |
| Amazon Lex V2 text conversation logs | The log group you set on the bot alias | Turn on text logs for the bot alias |
Logs Insights automatically discovers fields in Lambda logs and in logs written as JSON. Use dot notation for nested JSON fields, for example Parameters.FunctionArn. Logs Insights extracts up to 200 fields from a JSON log event. Use parse for anything beyond that.
CloudWatch Logs Insights Queries for Amazon Connect Contact Flow Logs
Run these on /aws/connect/your-instance-alias. Flow log entries include ContactId, ContactFlowId, ContactFlowName, ContactFlowModuleType (the block type), Timestamp, Parameters and, on blocks that report one, Results. AWS notes that not every block reports a Results value.
1. Error count by flow and block type
filter Results like /(?i)error|fail|timeout|exception|invalid|not found/
| stats count(*) as errors by ContactFlowName, ContactFlowModuleType
| sort errors desc
2. Contacts per flow per hour
filter ispresent(ContactFlowName)
| stats count_distinct(ContactId) as contacts by ContactFlowName, bin(1h)
3. Last block reached per contact
stats latest(ContactFlowName) as lastFlow, latest(ContactFlowModuleType) as lastBlock by ContactId
| stats count(*) as contacts by lastFlow, lastBlock
| sort contacts desc
4. Lambda blocks: results by function
The Invoke AWS Lambda function block appears in flow logs as InvokeExternalResource, with the function ARN in Parameters.FunctionArn.
filter ContactFlowModuleType = "InvokeExternalResource"
| stats count(*) as calls by Parameters.FunctionArn, Results
| sort calls desc
5. Full path of one contact
fields @timestamp, ContactFlowName, ContactFlowModuleType, Results
| filter ContactId = "PASTE-CONTACT-ID"
| sort @timestamp asc
AWS delivers flow logs at least once, so the same entry can appear more than once. That’s why query 2 counts distinct contact IDs.
Logs Insights Queries for Lambda Functions Called by Amazon Connect
Run these on /aws/lambda/your-function-name. AWS says Lambda logs always include @timestamp, @logStream, @message, @requestId, @duration, @billedDuration, @type, @maxMemoryUsed and @memorySize. @duration is in milliseconds.
6. Latency report every 5 minutes
filter @type = "REPORT"
| stats avg(@duration), max(@duration), min(@duration) by bin(5m)
7. Slow invocations
The Invoke AWS Lambda function block allows a timeout of up to 8 seconds. Set the number below to the timeout configured on your block, in milliseconds.
filter @type = "REPORT" and @duration > 3000
| fields @timestamp, @requestId, @duration
| sort @duration desc
| limit 50
8. Cold starts (Init Duration)
AWS says the REPORT line includes Init Duration for the first request served by a new execution environment. This query extracts it with parse.
filter @type = "REPORT"
| parse @message /Init Duration: (?<initMs>[0-9.]+) ms/
| filter ispresent(initMs)
| stats count(*) as coldStarts, avg(initMs) as avgInitMs, max(initMs) as maxInitMs by bin(1h)
9. Errors and timeouts
filter @message like /(?i)error|exception|Task timed out/
| fields @timestamp, @requestId, @message
| sort @timestamp desc
| limit 100
10. Over-provisioned memory (AWS sample query)
filter @type = "REPORT"
| stats max(@memorySize / 1000 / 1000) as provisionedMB,
avg(@maxMemoryUsed / 1000 / 1000) as avgUsedMB,
max(@maxMemoryUsed / 1000 / 1000) as maxUsedMB
To match a Lambda error to a call, AWS suggests correlating timestamps or the contact ID between the flow logs and the Lambda logs.
Amazon Lex V2 Conversation Log Queries
Run these on the log group set on your bot alias. Lex V2 text logs include fields such as sessionId, inputTranscript, inputMode, missedUtterance, bot.name, bot.localeId and sessionState.
11. Missed utterances
filter @message like /"missedUtterance":\s*true/
| fields @timestamp, bot.name, bot.localeId, inputTranscript
| sort @timestamp desc
| limit 200
12. Most common intents
filter ispresent(sessionState.intent.name)
| stats count(*) as turns by bot.name, sessionState.intent.name
| sort turns desc
13. Input mode mix
stats count(*) as turns by bot.name, inputMode
AWS says the intent, slots and slotToElicit fields don’t appear in an entry when missedUtterance is true. AWS also notes the format may change without a change in the message version, so your code should not fail when new fields appear.
CloudWatch Logs Insights Cost and Limits
| Fact | What AWS says |
|---|---|
| Pricing | Charged per query, based on the amount of log data scanned |
| Free tier | 5 GB of logs data per month, covering ingestion, archive storage and data scanned by Logs Insights |
| Cancelled queries | Charged for the data scanned up to the point you cancel |
| Failed queries | Not charged |
| Estimate first | Since September 2026, Logs Insights can estimate the bytes a query would scan. Estimates incur no query charges. |
| Query timeout | 60 minutes |
| Result retention | Query results are available for 7 days |
| Result size | Up to 100,000 results with Logs Insights QL (since May 2026) |
| Concurrency | 100 concurrent Logs Insights QL queries per account, including queries on dashboards |
| Saved queries | Up to 1,000 per Region per account, saved per Region (not per user) |
Keep costs low: AWS recommends selecting only the log groups you need and using the narrowest possible time range. Field indexes can also reduce the data scanned.
Save Your Queries
You can save queries in Logs Insights in a folder structure, for example Connect/Flows, Connect/Lambda and Connect/Lex. Saving needs the logs:PutQueryDefinition permission.
Prefer not to write queries? Paste or upload your logs into our free CloudWatch Log Analyzer for Amazon Connect.
FAQ
Where are Amazon Connect flow logs in CloudWatch?
In the log group /aws/connect/your-instance-alias, in the same Region as your instance, once flow logging is turned on.
How much does CloudWatch Logs Insights cost?
You pay per query, based on the data scanned. The CloudWatch free tier includes 5 GB of logs data per month. Use the scan estimate and short time ranges to control cost.
Why does my Lambda block query return nothing?
Field names are case-sensitive. The flow log field is Parameters.FunctionArn.
Can I query several log groups together?
Yes. You can select more than one log group in a single Logs Insights query.
Related Guides
- Debug Amazon Connect Contact Flows: Logs, Block Errors and Fixes
- Fix AWS Lambda Timeout Errors Triggered by Amazon Connect
Sources (AWS documentation)
- Search Amazon Connect flow logs
- Enable Amazon Connect flow logs
- Isolate routing problems using CTRs and flow logs
- AWS re:Post – Troubleshoot contact flow errors
- AWS Lambda – Parsing logs and structured logging
- AWS Lambda – REPORT line fields
- CloudWatch Logs Insights sample queries
- Supported logs and discovered fields
- Analyzing log data with CloudWatch Logs Insights
- Logs Insights query syntax and cost best practices
- Save and re-run Logs Insights queries
- Amazon Lex V2 – Text logs in CloudWatch Logs
- Amazon CloudWatch FAQs (Logs Insights pricing)
- Amazon CloudWatch pricing (free tier)
- AWS What’s New – Estimate bytes scanned (Sep 2026)
- AWS What’s New – 100,000 query results (May 2026)
- AWS What’s New – 100 concurrent queries (Mar 2026)