Configure QLI for Version 1.4.0 or Newer

Alation Cloud Service Applies to Alation Cloud Service instances of Alation

Customer Managed Applies to customer-managed instances of Alation

Important

This section is applicable for Alation version 2024.1 or higher and Azure SQL DB OCF connector version 1.4.0 or higher.

Query log ingestion (QLI) extracts and ingests the query history of a database and powers the lineage, popularity, top user, and join and filter information in the catalog. Explore examples of ingested queries on schema and table catalog pages.

The steps involved in configuring and running QLI are:

Select a QLI Method

For Azure SQL DB data sources added using the Azure SQL DB OCF connector, Alation supports the following QLI methods:

  • View or Table-Based

  • Custom Query-Based

Configure View or Table-Based QLI

To configure a view-based or table-based QLI, perform these steps:

  • Create a view or table

  • Provide the QLI view or table name in Alation

Create a View or Table

For information on creating a view or table for Azure SQL DB Audit, see Enable Auditing in Azure in Configure Query Log Ingestion.

Provide the QLI View Name

Important

The Alation user interface displays standard configuration settings for credentials and connection information stored in the Alation database. If your organization has configured Azure KeyVault or AWS Secrets Manager to hold such information, the user interface will change to include the following buttons adjacent to the respective fields:

By default, you see the user interface for Standard. In the case of Vault, instead of the actual credential information, you must select the source and provide the corresponding key. For details, see Configure Secrets for OCF Connector Settings.

  1. On the Settings page of your Azure SQL DB data source, go to the Query Log Ingestion.

  2. In the QLI Configuration tab, provide the view or table name in the View Name field.

    Important

    • Ensure that the service account has the permissions to access the view or table.

    • Use the format database_name.schema_name.view_name.

  1. Click Save.

Configure Custom Query-Based QLI

If you cannot create a view or table for QLI, for example, due to access restrictions, you can use a custom QLI query to extract query history into Alation.

To configure custom query-based QLI, you must:

  • Use the QLI query template to create a query structure

  • Provide the custom query in Alation

QLI Query Template

Use any of the following query structures:

Custom Query Structure 1:

SELECT
  <userNameColumn> AS userName,
  <textColumn> as queryString,
  <defaultDatabases> AS defaultDatabases,
  <sessionIdColumn> AS sessionId,
  <sessionStartTimeColumn> AS sessionStartTime,
  <StartTimeColumn> AS startTime,
  <QueryCancelledColumn> AS cancelled,
  <milliSecondsColumn> AS seconds
FROM <object_name>
    WHERE startTime BETWEEN 'STARTTIME' and 'ENDTIME'
    ORDER BY sessionId, startTime;

Note

  • object_name can be a view or table .

  • Do not substitute the STARTTIME and ENDTIME parameters in the WHERE filter. These parameters are not actual column names and should stay as is. They are expected by the connector and will be substituted with the start and end date of the QLI range selected in the user interface when QLI is run manually or on schedule.

Custom Query Structure 2:

SELECT
      server_principal_name as userName,
      event_time as startTime,
      [statement] as queryString,
      session_id as sessionId,
      event_time as sessionStartTime,
      duration_milliseconds as milliSeconds,
      'N' as cancelled,
      database_name as defaultDatabases
FROM sys.fn_get_audit_file('<container_URI>', default, default)
WHERE event_time BETWEEN (STARTTIME) AND (ENDTIME);

Note

  • When you use the above query template, substitute the placeholder <container_URI> with the container URI you find in your container properties, for example: https://testaccountvipra.blob.core.windows.net/sqldbauditlogs/my_database/.

  • Do not substitute the STARTTIME and ENDTIME parameters in the WHERE filter. These parameters are not actual column names and should stay as is. They are expected by the connector and will be substituted with the start and end date of the QLI range selected in the user interface when QLI is run manually or on schedule.

Provide the Custom Query

To provide the custom query in Alation, perform these steps:

  1. Go to the Query Log Ingestion tab of the Settings page.

  2. In the QLI Configuration tab, under the Step 1: Provide the QLI view name step, go to Alternatively, use a custom SQL query.

  3. In the Custom QLI Query field, provide a custom query to retrieve the query history.

  4. Click Save.

Test the Access

Before you perform the QLI, you must validate that the service account has access to the QLI view.

To test the access and find out the approximate size of the query history metadata, perform these steps:

  1. On the Settings page of your Azure SQL DB data source, go to the Query Log Ingestion tab.

  2. Under the Test access section, click Test.

    A dialog box appears displaying the access validation result.

Preview Results

Before performing the QLI, perform these steps to preview the queries:

  1. On the Settings page of your Azure SQL DB data source, go to the Query Log Ingestion tab.

  2. Under the Preview Results section, enter the date range for which you want to generate the preview of the query history.

  3. Click Preview.

  4. Click View Results to view the generated preview.

    The Preview dialog appears displaying the total number of query statements per user under the User Queries tab and a detailed query statement under the Statements tab. Click Download to download the detailed query statement as a JSON file.

Note

You can use this option to run default QLI using just the date range.

Run QLI

You can either run QLI manually on demand or configure it to run automatically on a schedule.

Run QLI Manually

To perform QLI manually on demand:

  1. On the Settings page of your Azure SQL DB data source, go to the Query Log Ingestion tab.

  2. Under the Run QLI section, turn off the Enable QLI Schedule toggle.

  3. Specify the desired date range using the Date Range calendar widgets. You will need to specify the start date and the end date separately.

  4. Click Import.

    A query log ingestion job is initiated.

Schedule QLI

  1. On the Settings page of your Azure SQL DB data source, go to the Query Log Ingestion tab.

  2. Under the Run QLI section, turn on the Enable QLI Schedule toggle.

  3. Specify values for the job recurrence and time. The values are set in your local time.

Note

Here are some of the recommended schedules for better performance:

  • Schedule QLI to run for every 12 hours at the 30th minute of the hour

  • Schedule QLI to run for every 2 days at 11:30 PM

  • Schedule QLI to run every week on Sunday and Wednesday

  • Schedule QLI to run for every 3 months on the 15th day of the month

  1. Click Import.

The next QLI runs on the set schedule.

View the Job Status

To view the QLI job status after you run the QLI manually or after Alation triggers the QLI as per the schedule, go to Query Log Ingestion > QLI Job Status.

The Query log ingestion job status table logs the following status:

  • Succeeded - Indicates that the query ingestion was successful.

  • Partial Success - Indicates that the query ingestion was successful with warnings. If Alation fails to ingest some of the objects during the QLI, it skips them and proceeds with the query ingestion, resulting in partial success. Similarly, if all the queries are ingested by a single user, QLI results in a partial success.

  • Failed - Indicates that the query ingestion failed with errors.

Click the View Details link to view a detailed report of query ingestion. If there are errors, the Job errors table displays the error category, error message, and a hint (ways to resolve the issue). Follow the instructions under the Hints column to resolve the error.