> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/a/azure-log-analytics.md).

# Azure Log Analytics

Azure Log Analytics stores logs and monitoring data. OctoXLabs runs a KQL query against one or more workspaces and adds each returned computer as a device. The default query reads the Heartbeat table.

## Use cases

* Find devices that Azure Log Analytics reports but your EDR does not cover.

```
Adapters = azure-log-analytics AND NOT Adapters = falcon-crowdstrike
```

* Review devices that Azure Log Analytics has not seen recently.

```
Adapters = azure-log-analytics AND NOT LastSeen last now-30d/d
```

* Check what one Azure Log Analytics connection collected.

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination                                        | Port | Protocol |
| ------------------- | -------------------------------------------------- | ---- | -------- |
| OctoXLabs connector | login.microsoftonline.com                          | 443  | HTTPS    |
| OctoXLabs connector | api.loganalytics.io (default, configurable Domain) | 443  | HTTPS    |

### Required permissions

The app registration needs permission to run queries on the workspaces (read access to Log Analytics data). The exact role name is not documented in the source. Not verified.

## Create credentials in Azure Log Analytics

{% stepper %}
{% step %}

### Get the Tenant ID

In the Azure portal, switch to the right tenant. Under Azure services select **Azure Active Directory** and copy the **Tenant ID** from the **Basic information** section of the Overview.
{% endstep %}

{% step %}

### Get the Client ID

In Azure Active Directory choose **Enterprise applications** > **All applications**, select your application, open **Properties** and copy the **Application ID**.
{% endstep %}

{% step %}

### Create a client secret

In your app registration open **Certificates & secrets**. Under **Client secrets** click **New client secret**, add a description and an expiration, then copy the value. It is shown only once.
{% endstep %}

{% step %}

### Find the workspace IDs

Copy the unique ID of each Log Analytics workspace from the Azure portal. No assets are fetched without valid workspace IDs.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter     | Required | Type            | Default                                                                                      | Description                                                                              |
| ------------- | -------- | --------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| Domain        | No       | String          | api.loganalytics.io                                                                          | Domain of the Log Analytics API.                                                         |
| Tenant ID     | Yes      | String          | None                                                                                         | Azure tenant ID.                                                                         |
| Workspace IDs | Yes      | List of strings | None                                                                                         | IDs of the workspaces to query.                                                          |
| Client ID     | Yes      | String          | None                                                                                         | Application (client) ID.                                                                 |
| Client Secret | Yes      | String          | None                                                                                         | Client secret value.                                                                     |
| Query         | No       | String          | Heartbeat\|where TimeGenerated > ago(1h)\| summarize arg\_max(TimeGenerated, \*) by Computer | KQL query to run. The result must contain a `Computer` column, which is the primary key. |
| Timeout       | No       | Integer         | 30                                                                                           | Time in seconds to wait for API responses.                                               |

## Troubleshooting

| Error message                                                          | Cause                                                                  | Fix                                                                                                                                           |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Status Code: `, followed by the URL, the method and the response body` | The API answered with a status other than the one the adapter expects. | Read the code and body. 401 or 403 usually points to wrong credentials or missing permissions. Check the address, port and Is Secure setting. |

## Change history
