# Azure

## Installation

In-order to send the logs from Azure we need to use Azure EventHub. Please get the `YOUR_PAI_IID` and `YOUR_PAI_TOKEN` [from ](https://logpatterns.packetai.co/deploy/agent)<https://logpatterns.packetai.co/deploy/agent>

* Installing using Azure Cloud Shell
  \*

  ```
  <figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FGT0ajTSpFpC6P34ICQyR%2FScreenshot%202022-09-26%20at%2009.43.40.png?alt=media&#x26;token=95c6a5fb-e020-499c-b0d7-93002eaa80a2" alt=""><figcaption></figcaption></figure>
  ```
* Run the below command to download `logs-forwarder.ps1` in the Azure cloud Shell (select Powershell)
  * `(New-Object System.Net.WebClient).DownloadFile("https://raw.githubusercontent.com/PacketAI/azure-logs-forwarder/main/logs-forwarder.ps1", "logs-forwarder.ps1")`
* `./logs-forwarder.ps1 -SubscriptionId YOUR_SID -PAI_IID YOUR_PAI_IID -PAI_TOKEN YOUR_PAI_TOKEN -PacketAISite vector-ingester-logpatterns.packetai.co -ResourceGroupLocation westeurope`
  * ResourceLocation(region) should be where your application logs are located on Azure
  * `SubscriptionId` enter the subscription id which will be used to deploy azure functions forward the data PacketAI.
  * `YOUR_PAI_IID` and `YOUR_PAI_TOKEN` needs to get them from `https://logpatterns.packetai.co/deploy/agent`

## Forward logs from App insights

### App Insights

Goto App Insights page on Azure portal.

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FTifB3YmmwvRQQshnQOQ0%2FScreenshot%202022-09-26%20at%2011.46.55.png?alt=media&#x26;token=8c74ec8b-83bf-4714-9fb4-68bb0c1a638f" alt=""><figcaption></figcaption></figure>

Click on one of the application and click on Diagnose settings and Click on Add diagnosis settings.&#x20;

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FYahNkZsEouc9jBvYlRuC%2FScreenshot%202022-09-26%20at%2011.49.53.png?alt=media&#x26;token=9a6d4a9e-77ad-4dd8-97c6-6cb29afb5663" alt=""><figcaption></figcaption></figure>

Enter diagnosis setting name, and select the categories and click on the checkboxes. you can exclude the metrics. Afterwards select the Stream to an event hub, Select the subscription (the same as the one we used when installing packetai log forwarder), Select the hub namespace (should starts with packetai-ns-uid), and event hub name (packetai-eventhub). Afterwards, you can click on save button on top left.&#x20;

**PS: The event hub namespace and you application should be in the same region, otherwise event hub won't be visible**

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FILp2JLHtPgbPSesN5aSn%2FScreenshot%202022-09-26%20at%2011.50.42.png?alt=media&#x26;token=9bd1225d-4b96-4f15-a03a-3fa915a6a029" alt=""><figcaption></figcaption></figure>

### Azure Log Analytics

To forward logs from Azure Log Analytics, go to Log analytics page in Azure portal.

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FCKgPhSmKsE6CTVJtM395%2FScreenshot%202022-09-26%20at%2013.09.46.png?alt=media&#x26;token=73506b61-7667-42d4-a28b-2ba94b6a6f57" alt=""><figcaption></figcaption></figure>

Click on New export rule, to select the logs to forward to event hub.&#x20;

Enter the Rule name (packetai-eventhub)

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2F7A6B5C6KuheQjc71Bjpu%2FScreenshot%202022-09-26%20at%2013.13.47.png?alt=media&#x26;token=a5888a57-c668-42eb-8aae-d14ea7268f6c" alt=""><figcaption></figcaption></figure>

Select the list of log sources to export

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FHzyCZBb1IxEyGVZyYD9U%2FScreenshot%202022-09-26%20at%2013.14.06.png?alt=media&#x26;token=aaf7e70b-78e9-4ddd-9050-9567770ffd85" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FPh14aRbnAfhE0UW6RoJL%2FScreenshot%202022-09-26%20at%2013.15.09.png?alt=media&#x26;token=71778dc9-e21d-40b1-b0d0-c299dea13098" alt=""><figcaption></figcaption></figure>

Select the destination: select the event hub namespace previously created and the even hub name as packetai-eventhub

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FiyCorgwGN0rGQwx1vrH2%2FScreenshot%202022-09-26%20at%2013.58.24.png?alt=media&#x26;token=0cb39c1b-0370-4f30-ba78-56f8e2e1fe98" alt=""><figcaption></figcaption></figure>

Review and click on Create

<figure><img src="https://1004160589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MUh1bMx9Zb5YpSL8Jqw%2Fuploads%2FY6D9utNKq1SXLeDLtPO5%2FScreenshot%202022-09-26%20at%2013.58.41.png?alt=media&#x26;token=f9f80a48-532a-4b4b-b02e-6687e06b98f4" alt=""><figcaption></figcaption></figure>

### Other Azure services

It's possible to forward the logs from other services of Azure, As long as the resource has a **`Diagnostic settings`**  available it's possible to forward the logs to Event hub, and then sent to PacketAI backend server. The process is same as [App Insights](#app-insights)

### Logs

Once setup is complete, you should see your first logs on[ ](https://logpatterns.packetai.co/deploy/agent)<https://logpatterns.packetai.co/logs> !
