Version 1.3.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 2023.3.2.1 or newer and Teradata OCF connector Version 1.3.0 or newer.
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:
You can configure query log ingestion on the Query Log Ingestion tab of the Settings page. You can choose to configure QLI in one of the following ways:
View-Based
Custom Query-Based
Configure View-Based QLI¶
Prerequisite¶
Use the query format to create a new view and flush the query history from the data source. You can create the view in a schema of your choice. In the query below, substitute the placeholder value <schema_name.view_name>
with an actual value.
CREATE VIEW <schema_name.view_name> AS
SELECT
s.ProcID,
s.CollectTimeStamp,
s.QueryID,
UserID,
AcctString,
ExpandAcctString,
SessionID,
LogicalHostID,
RequestNum,
InternalRequestNum,
LogonDateTime,
AcctStringTime,
AcctStringHour,
AcctStringDate,
LogonSource,
AppID,
ClientID,
ClientAddr,
QueryBand,
ProfileID,
StartTime,
FirstStepTime,
FirstRespTime,
LastStateChange,
NumSteps,
NumStepswPar,
MaxStepsInPar,
NumResultRows,
TotalIOCount,
AMPCPUTime,
ParserCPUTime,
UtilityByteCount,
UtilityRowCount,
ErrorCode,
ErrorText,
WarningOnly,
((firstresptime - starttime) hour(4) to second) (Named ElapsedTime),
DelayTime,
AbortFlag,
CacheFlag,
StatementType,
StatementGroup,
sqltextinfo AS QueryText,
NumOfActiveAMPs,
MaxAMPCPUTime,
MaxCPUAmpNumber,
MinAmpCPUTime,
MaxAmpIO,
MaxIOAmpNumber,
MinAmpIO,
SpoolUsage,
WDID,
OpEnvID,
SysConID,
LSN,
NoClassification,
WDOverride,
ResponseTimeMet,
ExceptionValue,
FinalWDID,
TDWMEstMaxRows,
TDWMEstLastRows,
TDWMEstTotalTime,
TDWMAllAmpFlag,
TDWMConfLevelUsed,
TDWMRuleID,
UserName,
DefaultDatabase,
AMPCPUTimeNorm,
ParserCPUTimeNorm,
MaxAMPCPUTimeNorm,
MaxCPUAmpNumberNorm,
MinAmpCPUTimeNorm,
EstResultRows,
EstProcTime,
EstMaxRowCount,
ProxyUser,
ProxyRole,
SessionTemporalQualifier,
CalendarName,
SessionWDID,
DataCollectAlg,
ParserExpReq,
CallNestingLevel,
NumRequestCtx,
KeepFlag,
QueryRedriven,
ReDriveKind,
CPUDecayLevel,
IODecayLevel,
TacticalCPUException,
TacticalIOException,
SeqRespTime,
ReqIOKB,
ReqPhysIO,
ReqPhysIOKB,
r.sqlrowno
FROM dbc.dbqlsqltbl r,
dbc.dbqlogtbl s
WHERE r.queryid = s.queryid;
Grant the service account permissions to access this view. For details, see Prerequisites.
Provide the QLI View Name¶
On the Teradata connector page, go to the Query Log Ingestion tab of the Settings page.
Under the Provide the QLI view name section, enter the QLI view name in the View name field.
Use the format
schema.tablename or schema.viewname
.Click Save.
Configure Custom Query-Based QLI¶
The custom query takes the precedence over QLI view name.
If you cannot create the view for QLI, for example, due to access restrictions, you can use a custom QLI query to extract query history into Alation. If you opt for custom query-based QLI, Alation will directly query the system view that stores the query history every time you manually run QLI or when the QLI job runs on schedule.
For custom query-based QLI to succeed, ensure that the service account has enough permissions to select from the system view. For details, see Grant Permissions for Query Log Ingestion section in Prerequisites.
The following is an example of a custom query for QLI.
SELECT
SessionID AS "sessionId",
UserName AS "userName",
StartTime AS "startTime",
sqltextinfo AS "queryString",
((firstresptime - starttime) hour(4) to second) AS "milliSeconds",
DefaultDatabase AS "defaultDatabases",
AbortFlag AS "cancelled",
LogonDateTime AS "sessionStartTime"
FROM dbc.dbqlsqltbl r,
dbc.dbqlogtbl s
WHERE r.queryid = s.queryid
AND r.procid = s.procid
AND sqltextinfo IS NOT null
AND StartTime >= STARTTIME
AND StartTime < ENDTIME
Provide the Custom Query¶
On the Teradata data source, go to the Query Log Ingestion tab of the Settings page.
Under the Provide the QLI view name section, go to Alternatively, use a custom SQL query.
In the Custom QLI Query field, provide a custom query to retrieve the query history.
Click Save.
Test the Access and Find the Query History Size¶
Before you perform the QLI, you must validate that the service account has access to the QLI view and gauge the approximate size of the query history metadata. The size is estimated based on the average query volume of the last 7 days.
To test the access and find out the approximate size of the query history metadata, perform these steps:
On the Settings page of your Teradata data source, go to the Query Log Ingestion tab.
Under the Test access and query history size section, click Test.
A dialog box appears displaying the access validation result and upon successful validation, the size of the query history is displayed. The size is estimated based on the query volume of the last 7 days.
Note
If the average query size for the last seven days exceeds 500k, a warning message indicates the same.
Preview Results¶
Before performing the QLI, you can preview the queries that are ingested.
On the Settings page of your Teradata data source, click go to the Query Log Ingestion tab.
Under the Preview Results section, enter the date range for which you want to generate the preview of the query history.
Click Preview.
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 without using a view-based or custom query-based QLI.
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:
On the Settings page of your Teradata data source, go to the Query Log Ingestion tab.
Under the Run QLI section, disable the Enable QLI Schedule toggle.
Specify the desired date range using the Date Range calendar widgets. You will need to specify the start date and the end date separately.
Click Import.
A query log ingestion job is initiated.
Schedule QLI¶
On the Settings page of your Teradata data source, go to the Query Log Ingestion tab.
Under the Run QLI section, enable the Enable QLI Schedule toggle.
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 the Sunday and Wednesday of the week
Schedule QLI to run for every 3 months on the 15th day of the month
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.
Failed - Indicates that the query ingestion failed with errors.
Click the View Details link to view a detailed report of query ingestion. Click the View Details link to view a detailed report of metadata extraction. 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.