Azure Synapse Serverless SQL - Get SQL requests through REST API or Sys Views

Dashora, Tushar 1 Reputation point
2022-08-18T13:59:16+00:00

Hello Everyone,

We are using Azure Synapse and Serverless SQL to query data from Azure Data Lake gen 2 storage. I want to get the information of SQL requests made by pipelines. I can see those in Synapse Studio under Monitor > Activities > SQL requests.

232466-synapse.png

I want to get this data pragmatically so we can calculate the total processed data and costs related to it. I am comfortable with using REST API or any System view to get this data. Searched a lot but couldn't find the exact API or table to get this data.

The closest I got was by running this query SELECT * FROM sys.dm_external_data_processed
But it doesn't give the amount of data processed by each pipeline run.

232492-synapsequery.png

Thanks in advance!

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
{count} votes

1 answer

Sort by: Most helpful
  1. Dashora, Tushar 1 Reputation point
    2022-09-07T03:36:31.47+00:00

    I connected with Microsoft support team and got a query working. This can be used to get the required data:
    SELECT [Status], Transaction_id as [Request ID], 'SQL On-demand' as [SQL Resource], login_name as [Submitter], 'N/A' as [Session ID], start_time as [Submit time], start_time as [Start time], end_time as [End time], command as [Request Type], query_text as [Query Text], total_elapsed_time_ms as [Duration], 'N/A' as [Queued Duration], data_processed_mb as [Data processed in MB], 'N/A' as [Workload group], 'N/A' as [Source], 'N/A' as [Pipeline], 'N/A' as [Importance], 'N/A' as [Classifier], [Error] FROM sys.dm_exec_requests_history;


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.