Access Live Amazon Athena Data in Tableau with CData API Server



With CData API Server, easily create OData endpoints for live Amazon Athena data and connect directly in Tableau for real-time dashboards, reporting, and analytics without manual data movement.

Tableau is one of the leading BI platforms for connecting, visualizing, and sharing data insights.

With the CData API Server and the Amazon Athena Connector (or any of the 270+ available), you can quickly create APIs that expose live data from multiple sources, using industry standards like OData and Swagger for seamless integration with Tableau.

In this article, we'll create a simple Tableau dashboard with live data from Amazon Athena, without moving or replicating data.

Let's get started!

Prerequisites

  1. CData API Server: Download a free trial here.
  2. Tableau: Sign in, sign up, or download from here.
  3. An active Amazon Athena account with access to your data.

Overview

Here's a quick overview of the steps we'll follow:

  1. Install the CData API Server, configure a connection to Amazon Athena, and use the OData endpoints.
  2. Connect to these endpoints in Tableau to build live dashboards and reports.

About Amazon Athena Data Integration

CData provides the easiest way to access and integrate live data from Amazon Athena. Customers use CData connectivity to:

  • Authenticate securely using a variety of methods, including IAM credentials, access keys, and Instance Profiles, catering to diverse security needs and simplifying the authentication process.
  • Streamline their setup and quickly resolve issue with detailed error messaging.
  • Enhance performance and minimize strain on client resources with server-side query execution.

Users frequently integrate Athena with analytics tools like Tableau, Power BI, and Excel for in-depth analytics from their preferred tools.

To learn more about unique Amazon Athena use cases with CData, check out our blog post: https://www.cdata.com/blog/amazon-athena-use-cases.


Getting Started


Step 1: Install the API Server and Add a Connection to Amazon Athena

1.1 Install the API Server

If you haven't already, download an installer for your machine from the CData API Server page. Follow the installation instruction to complete the setup.

Once installed, you can start the server in the following ways:

  • Windows: CData API Server runs as a service by default. Make sure the service is running, then open the http://hostname:port (e.g., http://localhost:8080/) in your browser to access the API Server admin console.
  • Linux/Mac: You can run the server manually or as a service. To start it manually, navigate to the installation directory and run java -jar apiserver.jar.
  • Alternatively, run service.sh with root privileges to set up API Server as a Linux system service.

1.2 Enable CORS

When Tableau and the CData API Server are hosted on different domains, CORS (Cross-Origin Resource Sharing) must be enabled to allow Tableau to access the data endpoints. To enable CORS in the API Server:

  1. Go to Settings and click the icon to edit CORS settings.
  2. Enable Cross-Origin Resource Sharing (CORS).
  3. Enable Allow all domains without '*' to accept any origin.
  4. In Access-Control-Allow-Origin, enter your Tableau origin domain, or use * to allow all domains (suitable for public APIs).
  5. Enable Access-Control-Allow-Credentials to allow cookies and auth headers.
  6. In Access-Control-Allow-Methods, enter GET, PUT, POST, OPTIONS.
  7. In Access-Control-Allow-Headers, enter Authorization, Content-Type.
  8. Set Access-Control-Max-Age (default: 3600 seconds) to cache preflight requests.
  9. Click Save.

1.3 Add a Amazon Athena Connection in the API Server

  1. Go to Settings and click Add Connection in the top-right.
  2. Select Amazon Athena. If it's not visible, toggle off Only Installed to view all connectors.
  3. Click Install Connector to auto-install. For a manual setup, choose Manual Install and upload the downloaded ZIP file.
  4. Once installed, click Amazon Athena again to open its connection settings and configure using the details below.
  5. Authenticating to Amazon Athena

    To authorize Amazon Athena requests, provide the credentials for an administrator account or for an IAM user with custom permissions: Set AccessKey to the access key Id. Set SecretKey to the secret access key.

    Note: Though you can connect as the AWS account administrator, it is recommended to use IAM user credentials to access AWS services.

    Obtaining the Access Key

    To obtain the credentials for an IAM user, follow the steps below:

    1. Sign into the IAM console.
    2. In the navigation pane, select Users.
    3. To create or manage the access keys for a user, select the user and then select the Security Credentials tab.

    To obtain the credentials for your AWS root account, follow the steps below:

    1. Sign into the AWS Management console with the credentials for your root account.
    2. Select your account name or number and select My Security Credentials in the menu that is displayed.
    3. Click Continue to Security Credentials and expand the Access Keys section to manage or create root account access keys.

    Authenticating from an EC2 Instance

    If you are using the CData Data Provider for Amazon Athena 2018 from an EC2 Instance and have an IAM Role assigned to the instance, you can use the IAM Role to authenticate. To do so, set UseEC2Roles to true and leave AccessKey and SecretKey empty. The CData Data Provider for Amazon Athena 2018 will automatically obtain your IAM Role credentials and authenticate with them.

    Authenticating as an AWS Role

    In many situations it may be preferable to use an IAM role for authentication instead of the direct security credentials of an AWS root user. An AWS role may be used instead by specifying the RoleARN. This will cause the CData Data Provider for Amazon Athena 2018 to attempt to retrieve credentials for the specified role. If you are connecting to AWS (instead of already being connected such as on an EC2 instance), you must additionally specify the AccessKey and SecretKey of an IAM user to assume the role for. Roles may not be used when specifying the AccessKey and SecretKey of an AWS root user.

    Authenticating with MFA

    For users and roles that require Multi-factor Authentication, specify the MFASerialNumber and MFAToken connection properties. This will cause the CData Data Provider for Amazon Athena 2018 to submit the MFA credentials in a request to retrieve temporary authentication credentials. Note that the duration of the temporary credentials may be controlled via the TemporaryTokenDuration (default 3600 seconds).

    Connecting to Amazon Athena

    In addition to the AccessKey and SecretKey properties, specify Database, S3StagingDirectory and Region. Set Region to the region where your Amazon Athena data is hosted. Set S3StagingDirectory to a folder in S3 where you would like to store the results of queries.

    If Database is not set in the connection, the data provider connects to the default database set in Amazon Athena.

  6. Click Save & Test to validate and complete the connection setup.

1.4 Add and Configure Users

To allow secure access to the created OData endpoints, create and configure Users in the CData API Server. Each user has authentication credentials and role-based access control, ensuring that only authorized users with appropriate roles can query the connected data.

  1. Go to Users from the navigation pane, then click Add User in the top-right corner.
  2. Enter a Username and set a secure Password for the user.
  3. Select a Role:
    • Admin: Full access to all features, including settings and connections.
    • Query: Limited to data access via API endpoints (suitable for Tableau use).
  4. (Optional) Configure rate limits:
    • Requests Per Hour: Number of allowed API calls per hour (default: 1000).
    • Max Concurrent Requests: Number of parallel API requests allowed (default: 10).
  5. Define Privileges for the user:
    • GET: Allows data retrieval.
    • POST: Allows creation of new records.
    • PUT, MERGE, PATCH: Allows updates to existing records.
    • DELETE: Allows deletion of records.
  6. Click Add User to save and activate the user account.

Once a user is added, an Authtoken is automatically generated. This token can be used in API requests as a secure authentication method instead of a password.

You can also refresh the Authtoken, disable it, or set expiration rules (e.g., number of days until expiry) by enabling the Token Expiration option in the user settings.


1.5 Add Tables for the Endpoint

To make data from Amazon Athena available in Tableau via OData, you need to expose your desired tables through the API Server. Here's how:

  1. In the CData API Server, go to API from the left navigation, then click Add Table at the top-right.
  2. Select the Amazon Athena connection you configured earlier, then click Next.
  3. Browse available entities and schema by expanding the Tables section. Select individual tables, or click the TABLE NAME checkbox at the top to select all. Then click Confirm.

1.6 Access the Endpoints in Tableau

Now that your API is configured, you can connect Tableau directly to the OData endpoints to visualize live data. Below are the URL formats for the OData endpoints:

Endpoint   URL
Entity List http://address:port/api.rsc/
Table Metadata (e.g., albums) http://address:port/api.rsc/albums/$metadata?@json
Table Data (e.g., albums) http://address:port/api.rsc/albums

These OData endpoints can now be connected to Tableau to create live dashboards, charts, and reports.

The CData API Server supports full OData filtering capabilities (OData ABNF). For refined queries, you can append standard OData query parameters like $select, $filter, $orderby, $top, and $skip to the requests.


Step 2: Create a Simple Dashboard in Tableau

With your CData API Server exposing OData endpoints for Amazon Athena data, you can now connect Tableau to the API and build a real-time dashboard. Here's how to do it.

For this article, we'll use Tableau Desktop on Windows, but the steps should work with all Tableau versions.

2.1. Connect to the OData Endpoint

  1. Get the CData API Endpoint URL by logging into your CData API Server. Go to API from the left navigation, then click View Endpoints at the top-right.
  2. Copy the URL (e.g., http://localhost:8080/api.rsc).
  3. Launch Tableau and log in to your account.
  4. On the left under To a Server, click More, then search for OData and select it.
  1. Add the following details:
    • Server: Your CData API Server Endpoint URL (e.g., http://localhost:8080/api.rsc)
    • Authentication: Select Username and Password.
    • Username: Enter your CData Server API Username.
    • Password: Enter your CData API Server Password.

2.2. Create a Dashboard

  1. On the left under Tables, drag your desired table to the canvas, then click on Sheet 1 at the bottom left.
  1. In Sheet 1, on the left under Tables, double-click your desired columns from the selected table to add them to the view.
  1. Drag and drop columns into the Columns and Rows sections at the top to create a visualization. In this example, we have created a simple forecasting bar chart.

2.3. Refine Your Dashboard

Continue refining your dashboard by adding filters, formatting, and combining multiple sheets. You can create more complex visualizations and interactive dashboards based on your live API data.


Try CData API Server Free for 30 Days

Build OData REST APIs with a low-code/no-code platform and unlock seamless integration with your live data. Try CData API Server free for 30 days and experience how easily you can connect live Amazon Athena data (or any of the 270+ available connectors) directly into Tableau for real-time dashboards and analytics.

Start your free trial here.

Ready to get started?

Learn more or sign up for a free trial:

CData API Server