Appendix E: Create views for custom events - Digital User Engagement Events Database

Appendix E: Create views for custom events

Customers can use the Amazon Pinpoint Events API to report custom events. These events are emitted by the Amazon Pinpoint project into Amazon Kinesis Data Firehose and will be available in the events database for analysis. To create views for these custom events, complete the following steps.

  1. Navigate to the Amazon Athena console.

  2. Under the Database dropdown, select the database name you provided earlier in Step 1.

  3. Modify the example query below. Replace the italicized items to match the custom event.

    CREATE OR REPLACE VIEW custom_view_name AS SELECT from_unixtime((event_timestamp / 1000)) event_timestamp , from_unixtime((arrival_timestamp / 1000)) arrival_timestamp , application.app_id application_id , client.client_id endpoint_id , awsaccountid aws_account_id , attributes['MyCustomEventAttribute1'] as custom_attr_1 , attributes['MyCustomEventAttribute2'] as custom_attr_2 … continue as necessary …
 , ingest_timestamp FROM all_events WHERE (event_type = 'custom_event_name')

    The views take advantage of the Athena table partition field ingest_timestamp. This field maps directly to Amazon S3 file paths and helps the query engine determine which files must be scanned for results. This best practice increases performance and decreases Athena query costs. Create your views with this field from the all_events table. For more details, see Amazon Athena Partitioning Data in the Amazon Athena User Guide.

  4. Paste the modified query into one of the query tabs and select Run query.