> For the complete documentation index, see [llms.txt](https://docs.betterbugs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.betterbugs.io/product-features/integrations/cloudwatch.md). Agents can also search and read this documentation through its [MCP server](https://docs.betterbugs.io/~gitbook/mcp).

# CloudWatch

Pull your backend logs from Amazon CloudWatch Logs straight into BetterBugs bug reports, so developers see what the server was doing at the moment a bug happened.

<table><thead><tr><th width="117.111083984375">ACCESS</th><th width="190.111083984375">SETUP WITH</th><th width="195.888916015625">WHO CAN CONNECT</th><th>WHERE LOGS APPEAR</th></tr></thead><tbody><tr><td>Read-only</td><td>AWS CloudFormation</td><td>Workspace or project admins</td><td>Bug report › Backend tab</td></tr></tbody></table>

### BetterBugs integration with AWS CloudWatch

The CloudWatch integration links an AWS account to your BetterBugs workspace or project. Once you connect, anyone on the project can open a bug report and see the CloudWatch log events from the same time window, without signing in to the AWS console.

{% hint style="info" %}
IMPORTANT NOTE: BetterBugs never asks for AWS access keys. You create a small IAM role in your account with a one-click CloudFormation stack. That role can only list log groups and read log events. You can remove it at any time by deleting the stack.
{% endhint %}

### How it works

<div data-with-frame="true"><figure><img src="https://3235868439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBzBhuIUDDav7ztnadaoO%2Fuploads%2FOAziSXZTlwIhK0ceo1Vw%2Fimage.png?alt=media&amp;token=775c6659-3621-4a10-bc8b-6284b6055c79" alt=""><figcaption></figcaption></figure></div>

* **Logs matched to the bug**: BetterBugs fetches log events from just before to just after the moment the bug was captured. You choose a window of **`±1`**, **`±5`** or **`±15`** minutes. The default is **`±5`** minutes.
* **Up to 5 log groups at once**: Pick the log groups for your API, workers or Lambda functions. Events from all of them are merged into one timeline, sorted by time.
* **Filter and search**: Show all events, only errors, or only warnings, and search the log text. Search is caseinsensitive.
* **Settings saved per project**: The region, log groups and time window you choose are saved for the project, so every teammate sees the same logs.
* **Secure, read-only access**: BetterBugs signs in to your account through an IAM role that trusts only BetterBugs and only with your connection's unique external ID.

{% hint style="warning" icon="lightbulb" %}
**PREREQUISITES**

1. Your **12-digit AWS account ID**. It is shown in the top-right menu of the AWS console.
2. Permission in AWS to **create a CloudFormation stack and an IAM role** in that account.
3. The right role in BetterBugs:
   * To connect for the **whole workspace**, you must be a workspace admin.
   * To connect for a **single project**, you must be a workspace admin or an admin of that project.
     {% endhint %}

### How to Integrate BetterBugs Project with AWS CloudWatch

{% hint style="info" %}
Here, we've covered the steps to integrate a single BetterBugs project (within your BetterBugs Workspace) with AWS CloudWatch. You can also integrate the complete BetterBugs Workspace in one go (that includes all the projects within your Workspace) to AWS CloudWatch or any other project tool. [**Check out the steps for Workspace Integration**](https://docs.betterbugs.io/dashboard/workspace-settings/integrations/workspace-integration.md)**.**
{% endhint %}

{% stepper %}
{% step %}

#### Open Workspace Settings > Integrations

In your BetterBugs Workspace, click **⚙️ Settings** (at the bottom of left pane) > **Integrations** (under Integrations tab).
{% endstep %}

{% step %}

#### Search AWS CloudWatch

Search for AWS CloudWatch and and click to open the card.
{% endstep %}

{% step %}

#### Turn off workspace-wide integration

Toggle off the "**All Projects**" option and hit "**Continue**". You should see the "**Manage per project**" option now.

{% hint style="info" %}
By default, its turned on for workspace level integration. For project-wise integration, you need to disable "**All Projects**".
{% endhint %}
{% endstep %}

{% step %}

#### Select a BetterBugs project to integrate and hit "Connect"

Select a project from the projects name list (that's within your Workspace). From the "**Actions**" column, hit "**Connect**" for that project.
{% endstep %}

{% step %}

#### &#x20;Enter your AWS account ID in the AWS CloudWatch dialog box

**Enter the 12-digit account ID** (for example **`123456789012`**) and continue. BetterBugs creates a unique external ID for your connection. It looks like **`bb-0123456789abcdef0123456789abcdef`**
{% endstep %}

{% step %}

#### Launch the CloudFormation stack

BetterBugs opens the AWS CloudFormation Quick create stack page with the BetterBugs template and your external ID already filled in. The stack is named **`BetterBugsCloudWatch`**.
{% endstep %}

{% step %}

#### Create the stack in AWS&#xD;

Check the box "**I acknowledge that AWS CloudFormation might create IAM resources with custom names**", then click **Create stack**. Wait until the status shows **`CREATE_COMPLETE`**. This usually takes less than a minute.
{% endstep %}

{% step %}

#### Return to BetterBugs

Go back to the BetterBugs tab. BetterBugs checks that it can reach your account. When the check succeeds, the integration shows as Connected with the name **`AWS Account`** **`123456789012`**.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**NOTE**: If the external ID field on the AWS page is empty, copy it from the Connect AWS CloudWatch dialog in BetterBugs and paste it in. The template only accepts IDs that start with **`bb-`** .
{% endhint %}

{% hint style="warning" %}
**CONNECTION STAYS PENDING?**

BetterBugs marks the connection as pending until it can sign in to your account. If the stack is still being created, or was created with a different external ID, you will see a message asking you to create the stack and try again.
{% endhint %}

### How to Create a Bug Report with CloudWatch Logs

{% stepper %}
{% step %}

#### Capture the bug

Take a [screenshot](https://docs.betterbugs.io/product-features/screen-capturing.md), [record a video](https://docs.betterbugs.io/product-features/screen-recording.md), or hit [Rewind](https://docs.betterbugs.io/product-features/rewind.md) (if it's already enabled for the website).
{% endstep %}

{% step %}

#### Open the Backend tab

In the bug report, open the Backend tab and choose AWS CloudWatch.
{% endstep %}

{% step %}

#### Pick a region

**Select the AWS region** where your logs live

For example **`us-east-1`** or **`ap-south-1`** . You can search the list.
{% endstep %}

{% step %}

#### Pick your log groups

Select **a log group.** For example **`/aws/lambda/checkout`** or **`/ecs/api-production`**. Type to search. The search matches any part of the name.
{% endstep %}

{% step %}

#### Choose the time window

Pick **`±1`**, **`±5`** or **`±15`** minutes around the moment the bug was captured
{% endstep %}

{% step %}

#### Read the logs

Events from all selected log groups appear in one list, oldest first. Each event shows its time, log group, log stream, and level.
{% endstep %}
{% endstepper %}

{% hint style="success" icon="party-horn" %}
**SAVED FOR YOUR TEAM**

Your region, log groups and time window are saved for the project. The next bug report in this project opens with the same selection. Guests can read the logs but cannot change these settings.
{% endhint %}

### Filtering and Searching Logs&#xD;

<table><thead><tr><th width="159">CONTROL</th><th>WHAT IT DOES</th></tr></thead><tbody><tr><td><strong>Level: All</strong></td><td>Shows every event in the time window.</td></tr><tr><td><strong>Level: Error</strong></td><td>Shows events marked as error, fatal, critical, exception or panic.</td></tr><tr><td><strong>Level: Warn</strong></td><td>Shows events marked as warn or warning</td></tr><tr><td><strong>Search</strong></td><td>Matches text anywhere in the log message, ignoring case. Up to 100 characters. You can combine search with a level filter.</td></tr><tr><td><strong>Load more</strong></td><td>Each page loads up to 500 events per log group. Click <strong>Load more</strong> to fetch the next page from the groups that have more.</td></tr></tbody></table>

### How BetterBugs Detects the Log Level

CloudWatch stores plain log lines, so BetterBugs reads the level from the line itself:

* **JSON logs** (pino, winston, bunyan, Python logging, ECS): the **`level`** , **`severity`**, **`levelname`** or  \
  **`log.level`** field. Numeric pino levels work too: *50 and above is an error*, *40 is a warning*.
* **Text logs**: a level word near the start of the line, such as **`ERROR [OrdersService] …`** or **`WARN …`** .

Lines with no clear level show only under **All**.

```javascript
// Detected as an error
{"level":"error","msg":"Payment failed","orderId":"ord_8231"}
{"level":50,"msg":"Timeout calling inventory service"}
[Nest] 4120 - 11/13/2026, 10:42:07 AM ERROR [CheckoutController] Card declined
```

### What BetterBugs Can Access&#xD;

The CloudFormation stack creates one IAM role named **`BetterBugsCloudWatchLogsAccess`**. You can read the full template before you create the stack.

<table><thead><tr><th width="244.5555419921875">PERMISSION</th><th>WHY BETTERBUGS NEEDS IT</th></tr></thead><tbody><tr><td><strong><code>logs:DescribeLogGroups</code></strong></td><td>List log groups so you can pick them in the Backend tab.</td></tr><tr><td><strong><code>logs:FilterLogEvents</code></strong></td><td>Read log events from the selected groups within the bug's time window.</td></tr><tr><td><strong><code>account:ListRegions</code></strong></td><td>List the regions enabled in your account for the region picker.</td></tr></tbody></table>

* The role is **read-only**. BetterBugs cannot change, delete or write logs, and cannot touch any other AWS service.
* The role trusts only the BetterBugs AWS account, and only when the request carries your connection's external ID. Knowing your AWS account ID is not enough to read your logs.
* BetterBugs uses short-lived credentials (one hour at most) and never stores AWS keys.

### Reconnecting and Disconnecting

| Reconnect or change account                                                                                                                                             | Disconnect                                  |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| Connect again with the same or a different AWS&#xD; account ID. BetterBugs keeps your external ID and&#xD; saved log settings, so an existing stack keeps&#xD; working. | <p>Click Disconnect under AWS CloudWatch in |
| <br>Integrations. To remove BetterBugs' access in AWS                                                                                                                   |                                             |
| too, delete the <strong><code>BetterBugsCloudWatch</code></strong> stack in                                                                                             |                                             |
| CloudFormation.</p>                                                                                                                                                     |                                             |

### Troubleshooting

<table><thead><tr><th width="257.888916015625">MESSAGE</th><th>WHAT TO DO</th></tr></thead><tbody><tr><td><strong>BetterBugs can't access AWS account … yet. Create the stack with external ID …</strong></td><td>The stack is missing, still being created, or uses a different<br>external ID. Create or update the stack with the external ID<br>shown, then try again.</td></tr><tr><td><strong>AWS account … isn't a valid AWS account ID</strong></td><td>Disconnect and connect again with the 12-digit account ID.</td></tr><tr><td><strong>This CloudWatch connection is out of date</strong></td><td>The connection was made before external IDs were added.<br>Disconnect and connect again.</td></tr><tr><td><strong>Log group … doesn't exist in <code>&#x3C;region></code></strong></td><td>The log group was deleted or is in another region. Pick a different region or log group. Other selected groups still load.</td></tr><tr><td><strong>CloudWatch couldn't use that search</strong></td><td>Try simpler search text, such as a single word or an ID.</td></tr><tr><td><strong>No events found</strong></td><td>Widen the time window to <strong><code>±15</code></strong> minutes, set the level to All, or<br>check that your app writes logs to the selected groups.</td></tr></tbody></table>

{% hint style="info" %}
**IMPORTANT**: Teammates on the project see the same CloudWatch logs in every bug report, and they don't need their own AWS access.
{% endhint %}
