

# Amazon Quick Sight events integration
<a name="events-integration"></a>

With Amazon EventBridge, you can respond automatically to events in Amazon Quick Sight such as new dashboard creation or updates. These events are delivered to EventBridge in near real time. As a developer, you can write simple rules to indicate which events are of interest, and what actions to take when an event matches a rule. By using events, you can complete use cases such as continuous backup and deployment.

**Topics**
+ [Supported events](#events-supported)
+ [Example event payload](#sample-events-payload)
+ [Creating rules to send Amazon Quick Sight events to Amazon CloudWatch](events-send-cloudwatch.md)
+ [Creating rules to send Amazon Quick Sight events to Amazon Lambda](events-send-lambda.md)

## Supported events
<a name="events-supported"></a>

Amazon Quick Sight currently supports the following events.


| Asset type | Action | Event detail type | Event detail | 
| --- | --- | --- | --- | 
| Dashboard | Create | Amazon Quick Sight Dashboard Creation Successful | <pre>{<br />    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83",<br />    "versionNumber": 1<br />}</pre> | 
| Dashboard | Create | Amazon Quick Sight Dashboard Creation Failed | <pre>{<br />    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83",<br />    "versionNumber": 1,<br />    "errors": [<br />      {<br />        "Type": "PARAMETER_NOT_FOUND",<br />        "Message": "Missing property abc"<br />      },<br />      {<br />        "Type": "DATA_SET_NOT_FOUND",<br />        "Message": "Cannot find dataset with id abc"<br />      }<br />    ]<br />}</pre> | 
| Dashboard | Create | Amazon Quick Sight Dashboard Permissons Updated | <pre>{"dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83" }</pre> | 
| Dashboard | Update | Amazon Quick Sight Dashboard Update Successful | <pre>{<br />    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83",<br />    "versionNumber": 1<br />}</pre> | 
| Dashboard | Update | Amazon Quick Sight Dashboard Update Failed | <pre>{<br />    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83",<br />    "versionNumber": 1,<br />    "errors": [<br />      {<br />        "Type": "PARAMETER_NOT_FOUND",<br />        "Message": "Missing property abc"<br />      },<br />      {<br />        "Type": "DATA_SET_NOT_FOUND",<br />        "Message": "Cannot find dataset with id abc"<br />      }<br />    ]<br />}</pre> | 
| Dashboard | Update | Amazon Quick Sight Dashboard Permissons Updated | <pre>{"dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83"}</pre> | 
| Dashboard | Publish | Amazon Quick Sight Dashboard Published Version Updated | <pre>{<br />    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83",<br />    "versionNumber": 2<br />}</pre> | 
| Dashboard | Delete | Amazon Quick Sight Dashboard Deleted | <pre>{<br />    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83"<br />}</pre> | 
| Analysis | Create | Amazon Quick Sight Analysis Creation Successful | <pre>{<br />    "analysisId": "e5f37119-e24c-4874-901a-af9032b729b5"<br />}</pre> | 
| Analysis | Create | Amazon Quick Sight Analysis Creation Failed | <pre>{<br />    "analysisId": "e5f37119-e24c-4874-901a-af9032b729b5",<br />    "errors": [<br />      {<br />        "Type": "PARAMETER_NOT_FOUND",<br />        "Message": "Missing property abc"<br />      },<br />      {<br />        "Type": "DATA_SET_NOT_FOUND",<br />        "Message": "Cannot find dataset with id abc"<br />      }<br />    ]<br />}</pre> | 
| Analysis | Create | Amazon Quick Sight Analysis Permissons Updated | <pre>{"analysisId": "e5f37119-e24c-4874-901a-af9032b729b5" }</pre> | 
| Analysis | Delete | Amazon Quick Sight Analysis Deleted | <pre>{<br />    "analysisId": "e5f37119-e24c-4874-901a-af9032b729b5"<br />}</pre> | 
| Analysis | Update | Amazon Quick Sight Analysis update successful | <pre>{<br />    "analysisId": "e5f37119-e24c-4874-901a-af9032b729b5"<br />}</pre> | 
| Analysis | Update | Amazon Quick Sight Analysis update failed | <pre>{<br />    "analysisId": "e5f37119-e24c-4874-901a-af9032b729b5",    <br />    "errors": [        <br />        {            <br />            "Type": "PARAMETER_NOT_FOUND",            <br />            "Message": "Missing property abc"        <br />        },        <br />        {             <br />            "Type": "DATA_SET_NOT_FOUND",            <br />            "Message": "Cannot find dataset with id abc"        <br />        }    <br />    ]<br />}</pre> | 
| Analysis | Update | Amazon Quick Sight Analysis Permissons Updated | <pre>{"analysisId": "e5f37119-e24c-4874-901a-af9032b729b5" }</pre> | 
| VPC connection | Create | Amazon Quick Sight VPC Connection Creation Successful | <pre>{<br />    "vpcConnectionId": "53d34238-57e7-488d-b99a-a0037d275a4e",<br />    "availabilityStatus": "CREATION_SUCCESSFUL"<br />}</pre> | 
| VPC connection | Create | Amazon Quick Sight VPC Connection Creation Failed | <pre>{<br />    "vpcConnectionId": "53d34238-57e7-488d-b99a-a0037d275a4e",<br />    "availabilityStatus": "CREATION_FAILED"<br />}</pre> | 
| VPC connection | Update | Amazon Quick Sight VPC Connection Update Successful | <pre>{<br />    "vpcConnectionId": "53d34238-57e7-488d-b99a-a0037d275a4e",<br />    "availabilityStatus": "UPDATE_SUCCESSFUL"<br />}</pre> | 
| VPC connection | Update | Amazon Quick Sight VPC Connection Update Failed | <pre>{<br />    "vpcConnectionId": "53d34238-57e7-488d-b99a-a0037d275a4e",<br />    "availabilityStatus": "UPDATE_FAILED"<br />}</pre> | 
| VPC connection | Delete | Amazon Quick Sight VPC Connection Deletion Successful | <pre>{<br />    "vpcConnectionId": "53d34238-57e7-488d-b99a-a0037d275a4e",<br />    "availabilityStatus": "DELETED"<br />}</pre> | 
| VPC connection | Delete | Amazon Quick Sight VPC Connection Deletion Failed | <pre>{<br />    "vpcConnectionId": "53d34238-57e7-488d-b99a-a0037d275a4e",<br />    "availabilityStatus": "DELETION_FAILED"<br />}</pre> | 
| Folder | Create | Amazon Quick Sight Folder Created | <pre>{<br />    "folderId": "77e307e8-b41b-472a-90e8-fe3f471537be",<br />    "parentFolderArn": "arn:aws-cn:quicksight:us-east-1:123456789012:folder/098765432134"<br />}</pre> | 
| Folder | Create | Amazon Quick Sight Folder Permissions Updated | <pre>{"folderId": "77e307e8-b41b-472a-90e8-fe3f471537be" }</pre> | 
| Folder | Update | Amazon Quick Sight Folder Updated | <pre>{<br />    "folderId": "77e307e8-b41b-472a-90e8-fe3f471537be"<br />}</pre> | 
| Folder | Update | Amazon Quick Sight Folder Permissions Updated | <pre>{"folderId": "77e307e8-b41b-472a-90e8-fe3f471537be" }</pre> | 
| Folder | Delete | Amazon Quick Sight Folder Deleted | <pre>{<br />    "folderId": "77e307e8-b41b-472a-90e8-fe3f471537be"<br />}</pre> | 
| Folder | Membership update | Amazon Quick Sight Folder Membership Updated | <pre>{<br />    "folderId": "77e307e8-b41b-472a-90e8-fe3f471537be",<br />    "membersAdded": ["arn:aws-cn:quicksight:us-east-1:123456789012:analysis/e5f37119-e24c-4874-901a-af9032b729b5"],<br />    "membersRemoved": []<br />}</pre> | 
| Dataset | Create | Amazon Quick Sight Dataset Created | <pre>{<br />    "datasetId": "a6553a81-f97e-4ffa-a860-baea63196efa"<br />}</pre> | 
| Dataset | Create | Amazon Quick Sight Dataset Permissions Updated | <pre>{"datasetId": "a6553a81-f97e-4ffa-a860-baea63196efa" }</pre> | 
| Dataset | Update | Amazon Quick Sight Dataset Updated | <pre>{<br />    "datasetId": "a6553a81-f97e-4ffa-a860-baea63196efa"<br />}</pre> | 
| Dataset | Update | Amazon Quick Sight Dataset Permissions Updated | <pre>{"datasetId": "a6553a81-f97e-4ffa-a860-baea63196efa" }</pre> | 
| Dataset | Delete | Amazon Quick Sight Dataset Deleted | <pre>{<br />    "datasetId": "a6553a81-f97e-4ffa-a860-baea63196efa"<br />}</pre> | 
| DataSource | Create | Amazon Quick Sight DataSource Creation Successful | <pre>{<br />    "datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824"<br />}</pre> | 
| DataSource | Create | Amazon Quick Sight DataSource Creation Failed | <pre>{<br />    "datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824",<br />    "error": {<br />        "message": "AMAZON_ELASTICSEARCH engine version 7.4 is lower than minimum supported version 7.7",<br />        "type": "ENGINE_VERSION_NOT_SUPPORTED"<br />    }<br />}</pre> | 
| DataSource | Create | Amazon Quick Sight DataSource Permissions Updated | <pre>{"datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824" }</pre> | 
| DataSource | Update | Amazon Quick Sight DataSource Update Successful | <pre>{<br />    "datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824"<br />}</pre> | 
| DataSource | Update | Amazon Quick Sight DataSource Update Failed | <pre>{<br />    "datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824",<br />    "error": {<br />        "message": "AMAZON_ELASTICSEARCH engine version 7.4 is lower than minimum supported version 7.7",<br />        "type": "ENGINE_VERSION_NOT_SUPPORTED"<br />    }<br />}</pre> | 
| DataSource | Update | Amazon Quick Sight DataSource Permissions Updated | <pre>{"datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824" }</pre> | 
| DataSource | Delete | Amazon Quick Sight DataSource Deleted | <pre>{<br />    "datasourceId": "230caa6e-dc87-406b-91fb-037f29c32824"<br />}</pre> | 
| Theme | Create | Amazon Quick Sight Theme Creation Successful | <pre>{<br />    ""themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83", <br />    "versionNumber": 1"<br />}</pre> | 
| Theme | Create | Amazon Quick Sight Theme Creation Failed | <pre>{ <br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83", <br />    "versionNumber": 1<br />}</pre> | 
| Theme | Create | Amazon Quick Sight Theme Permissions Updated | <pre>{"themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83" }</pre> | 
| Theme | Update | Amazon Quick Sight Theme Update Successful | <pre>{<br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83",    <br />    "versionNumber": 2<br />}</pre> | 
| Theme | Update | Amazon Quick Sight Theme Update Failed | <pre>{<br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83",    <br />    "versionNumber": 2<br />}</pre> | 
| Theme | Update | Amazon Quick Sight Theme Permissions Updated | <pre>{"themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83" }</pre> | 
| Theme | Delete | Amazon Quick Sight Theme deleted | <pre>{<br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83"<br />}</pre> | 
| Theme | Alias Create | Amazon Quick Sight Theme Alias Created | <pre>{<br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83",    <br />    "aliasName": "MyThemeAlias"    <br />    "versionNumber": 2<br />}</pre> | 
| Theme | Alias Update | Amazon Quick Sight Alias Updated | <pre>{<br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83",    <br />    "aliasName": "MyThemeAlias"    <br />    "versionNumber": 4<br />}</pre> | 
| Theme | Alias Delete | Amazon Quick Sight Theme Alias Deleted | <pre>{<br />    "themeId": "6fdbc328-ebbd-457f-aa02-9780173afc83",    <br />    "aliasName": "MyThemeAlias"    <br />    "versionNumber": 2<br />}</pre> | 

## Example event payload
<a name="sample-events-payload"></a>

All events follow the standard EventBridge [object structure](https://docs.amazonaws.cn/eventbridge/latest/userguide/eb-events-structure.html). The detail field is a JSON object that contains more information about the event.

```
{
  "version": "0",
  "id": "3acb26c8-397c-4c89-a80a-ce672a864c55",
  "detail-type": "QuickSight Dashboard Creation Successful",
  "source": "aws.quicksight",
  "account": "123456789012",
  "time": "2023-10-30T22:06:31Z",
  "region": "us-east-1",
  "resources": ["arn:aws-cn:quicksight:us-east-1:123456789012:dashboard/6fdbc328-ebbd-457f-aa02-9780173afc83"],
  "detail": {
    "dashboardId": "6fdbc328-ebbd-457f-aa02-9780173afc83",
    "versionNumber": 1
  }
}
```

# Creating rules to send Amazon Quick Sight events to Amazon CloudWatch
<a name="events-send-cloudwatch"></a>

You can write simple rules to indicate which Amazon Quick Sight events interest you and which automated actions to take when an event matches a rule. For example, you can configure Amazon Quick Sight to send events to Amazon CloudWatch whenever a Amazon Quick Sight asset is placed in a folder. For more information, see the [Amazon EventBridge user guide](https://docs.amazonaws.cn/eventbridge/latest/userguide/eb-what-is.html).

1. Sign in to the Amazon Web Services Management Console and open the CloudWatch console at [https://console.amazonaws.cn/cloudwatch/](https://console.amazonaws.cn/cloudwatch/).

1. Under **Events** in the navigation pane, choose **Rules**.

1. Choose **Create rule**.

1. Enter a name and description for the rule. The rule name must be unique within this Region. For example, enter `QuickSightAssetChangeRuleCloudWatch`.

1. Choose **default** Event bus.

1. Choose **Rule with an event pattern**, and then choose **Next**.

1. For **Event source**, choose **Amazon events or EventBridge partner events**.

1. In the **Creation method** section, choose **Custom pattern (JSON editor)**.

1. In the **Event pattern** text box, enter the following snippet and choose **Next**.

   ```
   {
     "source": ["aws.quicksight"]
   }
   ```

   Alternatively, you can create the rule that only subscribes to a subset of event types in Amazon Quick Sight. For example, the following rule will only triggered when an asset is added to or removed from a folder with id `77e307e8-b41b-472a-90e8-fe3f471537be`.

   ```
   {
     "source": ["aws.quicksight"],
     "detail-type": ["QuickSight Folder Membership Updated"],
     "detail": {
       "folderId": "77e307e8-b41b-472a-90e8-fe3f471537be"
     }
   }
   ```

1. For **Targets**, choose **Amazon service** > **CloudWatch log group.**

1. Choose from an existing log group or create a new one by entering a new log group name.

1. Optionally, you can add another target for this rule.

1. In **Configure tags**, choose **Next**.

1. Choose **Create rule**.

For more information, see [Creating Amazon EventBridge rule that reacts To events](https://docs.amazonaws.cn/eventbridge/latest/userguide/eb-create-rule.html) in the Amazon EventBridge user guide.

# Creating rules to send Amazon Quick Sight events to Amazon Lambda
<a name="events-send-lambda"></a>

In this tutorial, you create an Amazon Lambda function that logs the asset events in the Amazon Quick Sight account. You then create a rule that runs the function whenever there is an asset change. This tutorial assumes that you already signed up for Amazon Quick Sight.

**Step 1: Create a Lambda function**

Create a Lambda function to log the state change events. You specify this function when you create your rule.

1. Sign in to the Amazon Web Services Management Console and open the Amazon Lambda console at [https://console.amazonaws.cn/lambda/](https://console.amazonaws.cn/lambda/).

1. If you're new to Lambda, you see a welcome page. Choose **Get Started Now**. Otherwise, choose **Create function**.

1. Choose **Author from scratch**.

1. On the Create function page, enter a name and description for the Lambda function. For example, name the function `QuickSightAssetChangeFn`.

1. In **Runtime**, select **Node.js 18.x**.

1. For **Architecture**, choose **x86\$164**.

1. For **Execution role**, choose either **Create a new role with basic Lambda permissions** or **Use an existing role** and choose the role you want.

1. Choose **Create function**.

1. On the **QuickSightAssetChange** page, choose **index.js**.

1. In the **index.js** pane, delete the existing code.

1. Enter the following code snippet.

   ```
   console.log('Loading function');
   exports.handler = async (event, context) => {
     console.log('Received QuickSight event:', JSON.stringify(event));
   };
   ```

1. Choose **Deploy**.

**Step 2: Create a rule**

Create a rule to run your Lambda function whenever you create/update/delete a Amazon Quick Sight asset.

1. Sign in to the Amazon Web Services Management Console and open the Amazon EventBridge console at [https://console.amazonaws.cn/events/](https://console.amazonaws.cn/events/).

1. In the navigation pane, choose **Rules**.

1. Choose **Create rule**.

1. Enter a name and description for the rule. For example, enter `QuickSightAssetChangeRule`.

1. Select **default** Event bus.

1. Choose **Rule with an event pattern**, and then choose **Next**.

1. For **Event source**, choose **Amazon events or EventBridge partner events**.

1. In the **Creation method** section, choose **Custom pattern (JSON editor)**.

1. In the **Event pattern** text box, enter the following snippet and choose **Next**.

   ```
   {
     "source": ["aws.quicksight"]
   }
   ```

   Alternatively, you can create the rule that only subscribes to a subset of event types in Amazon Quick Sight. For example, the following rule will only triggered when an asset is added to or removed from a folder with id `77e307e8-b41b-472a-90e8-fe3f471537be`.

   ```
   {
     "source": ["aws.quicksight"],
     "detail-type": ["QuickSight Folder Membership Updated"],
     "detail": {
       "folderId": "77e307e8-b41b-472a-90e8-fe3f471537be"
     }
   }
   ```

1. For **Target types**, choose **Amazon service** and **Lambda function**.

1. For **Function**, choose the Lambda function that you created. Then choose **Next**.

1. In **Configure tags**, choose **Next**.

1. Review the steps in your rule. Then choose **Create rule**.

**Step 3: Test the rule**

To test your rule, create an analysis. After waiting a minute, verify that your Lambda function was invoked.

1. Open the Amazon Quick Sight console at [https://quicksight.aws.amazon.com/](https://quicksight.aws.amazon.com/).

1. Create a new analysis.

1. In the navigation pane, choose **Rules**, choose the name of the rule that you created.

1. In **Rule details**, choose **Monitoring**.

1. You will be redirected to the Amazon CloudWatch console. If you are not redirected, choose **View the metrics in CloudWatch**.

1. In **All metrics**, choose the name of the rule that you created. The graph indicates that the rule was invokved.

1. In the navigation pane, choose **Log groups**.

1. Choose the name of the log group for your Lambda function. For example, `/aws/lambda/function-name`.

1. Choose the name of the log stream to view the data provided by the function for the instance that you launched. You should see a received event similar to the following:

   ```
   {
     "version": "0",
     "id": "3acb26c8-397c-4c89-a80a-ce672a864c55",
     "detail-type": "QuickSight Analysis Creation Successful",
     "source": "aws.quicksight",
     "account": "123456789012",
     "time": "2023-10-30T22:06:31Z",
     "region": "us-east-1",
     "resources": ["arn:aws-cn:quicksight:us-east-1:123456789012:analysis/e5f37119-e24c-4874-901a-af9032b729b5"],
     "detail": {
       "analysisId": "e5f37119-e24c-4874-901a-af9032b729b5"
     }
   }
   ```

For an example of Amazon Quick Sight event in JSON format, see [Overview of events for Amazon Quick Sight](https://docs.amazonaws.cn/quicksight/latest/developerguide/events.html).