How to read data from Azure Log Analitycs ?

William_Scardua
Valued Contributor

Hi guys,

I need to read data from Azure Log Analitycs Workspace directaly, have any idea ?

thank you

Ajay-Pandey
Databricks MVP

Hi @William Scardua​ 

You can use Log Analytics REST API to extract the data from databricks.

Please refer below link for more information-

Log Analytics REST API | Microsoft Learn

Ajay Kumar Pandey

Priyag1
Honored Contributor II

Thank you for sharing best answers here

alexott
Databricks Employee
Databricks Employee

You can use Kusto Spark connector for that: https://github.com/Azure/azure-kusto-spark/blob/master/docs/KustoSource.md#source-read-command

It heavily depends on how you access data, there could be a need for using ADX cluster for it: https://learn.microsoft.com/en-us/azure/data-explorer/query-monitor-data

pregress
New Contributor II

Here is a sample on how to do it using azure-kusto-spark connector with managed identity.

 

df = spark.read.format("com.microsoft.kusto.spark.datasource") \
    .option("kustoCluster", "https://ade.loganalytics.io/subscriptions/{subscriptionid}/resourceGroups/{rg-name}/providers/microsoft.operationalinsights/workspaces/{log-analytics-name}") \
    .option("kustoDatabase", "{log-analytics-name}") \
    .option("kustoQuery", "Table| take 10") \
    .option("managedIdentityAuth", "true") \
    .option("managedIdentityClientId", "00000000-0000-0000-0000-000000000000") \
    .load()