|
| 1 | +--- |
| 2 | +title: Forward syslog data to Microsoft Sentinel and Azure Monitor by using the Azure Monitor agent |
| 3 | +description: Monitor linux-based devices by forwarding syslog data to a Log Analytics workspace. |
| 4 | +author: cwatson-cat |
| 5 | +ms.author: cwatson |
| 6 | +ms.service: microsoft-sentinel |
| 7 | +ms.topic: tutorial |
| 8 | +ms.date: 08/18/2022 |
| 9 | +ms.custom: template-tutorial |
| 10 | +#Customer intent: As a security-engineer, I want to get syslog data into Microsoft Sentinel so that I can use the data with other data to do attack detection, threat visibility, proactive hunting, and threat response. As an IT administrator, I want to get syslog data into my Log Analytics workspace to monitor my linux-based devices. |
| 11 | +--- |
| 12 | + |
| 13 | +# Tutorial: Forward syslog data to a Log Analytics workspace by using the Azure Monitor agent |
| 14 | + |
| 15 | +In this tutorial, you'll configure a Linux virtual machine (VM) to forward syslog data to your workspace by using the Azure Monitor agent. These steps allow you to collect and monitor data from Linux-based devices where you can't install an agent like a firewall network device. |
| 16 | + |
| 17 | +Configure your linux-based device to send data to a Linux VM. The Azure Monitor agent on the VM forwards the syslog data to the Log Analytics workspace. Then use Microsoft Sentinel or Azure Monitor to monitor the device from the data stored in the Log Analytics workspace. |
| 18 | + |
| 19 | +In this tutorial, you learn how to: |
| 20 | + |
| 21 | +> [!div class="checklist"] |
| 22 | +> * Create a data collection rule |
| 23 | +> * Verify the Azure Monitor agent is running |
| 24 | +> * Enable log reception on port 514 |
| 25 | +> * Verify syslog data is forwarded to your Log Analytics workspace |
| 26 | +
|
| 27 | +## Prerequisites |
| 28 | + |
| 29 | +To complete the steps in this tutorial, you must have the following resources and roles. |
| 30 | + |
| 31 | +- Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 32 | +- Azure account with the following roles to deploy the agent and create the data collection rules: |
| 33 | + |
| 34 | + |Built-in Role |Scope |Reason | |
| 35 | + |---------|---------|---------| |
| 36 | + |- [Virtual Machine Contributor](/azure/role-based-access-control/built-in-roles)</br>- [Azure Connected Machine Resource Administrator](/azure/role-based-access-control/built-in-roles) | - Virtual machines</br>- Scale sets</br>- Arc-enabled servers | To deploy the agent | |
| 37 | + |Any role that includes the action Microsoft.Resources/deployments/* | - Subscription and/or</br>- Resource group and/or</br>- An existing data collection rule | To deploy ARM templates | |
| 38 | + |[Monitoring Contributor ](/azure/role-based-access-control/built-in-roles) |- Subscription and/or </br>- Resource group and/or</br>- An existing data collection rule | To create or edit data collection rules | |
| 39 | +- Log Analytics workspace. |
| 40 | +- Linux server that's running an operating system that supports Azure Monitor agent. |
| 41 | + |
| 42 | + - [Supported Linux operating systems for Azure Monitor agent](/azure/azure-monitor/agents/agents-overview#linux) |
| 43 | + - [Create a Linux virtual machine in the Azure portal](/azure/virtual-machines/linux/quick-create-portal) or |
| 44 | + - Onboard an on-premises Linux server to Azure Arc. See [Quickstart: Connect hybrid machines with Azure Arc-enabled servers](/azure/azure-arc/servers/learn/quick-enable-hybrid-vm) |
| 45 | + |
| 46 | +- Linux-based device that generates event log data like a firewall network device. |
| 47 | + |
| 48 | +## Create a data collection rule |
| 49 | + |
| 50 | +Create a *data collection rule* in the same region as your Microsoft Sentinel workspace. |
| 51 | +A data collection rule is an Azure resource that allows you to define the way data should be handled as it's ingested into Microsoft Sentinel. |
| 52 | + |
| 53 | +1. Sign in to the [Azure portal](https://portal.azure.com). |
| 54 | +1. Search for and open **Monitor**. |
| 55 | +1. Under **Settings**, select **Data Collection Rules**. |
| 56 | +1. Select **Create**. |
| 57 | + |
| 58 | + :::image type="content" source="media/forward-syslog-monitor-agent/create-data-collection-rule.png" alt-text="Screenshot of the data collections rules pane with the create option selected."::: |
| 59 | + |
| 60 | +### Enter basic information |
| 61 | + |
| 62 | +1. On the **Basics** pane, enter the following information: |
| 63 | + |
| 64 | + |Field |Value | |
| 65 | + |---------|---------| |
| 66 | + |Rule Name | Enter a name like dcr-syslog | |
| 67 | + |Subscription | Select the appropriate subscription | |
| 68 | + |Resource group | Select the appropriate resource group | |
| 69 | + |Region | Select the same region that your Microsoft Sentinel workspace is located | |
| 70 | + |Platform Type | Linux | |
| 71 | +1. Select **Next: Resources**. |
| 72 | + |
| 73 | +### Add resources |
| 74 | +1. Select **Add resources**. |
| 75 | +1. Use the filters to find the virtual machine that you'll use to collect logs. |
| 76 | + :::image type="content" source="media/forward-syslog-monitor-agent/create-rule-scope.png" alt-text="Screenshot of the page to select the scope for the data collection rule. "::: |
| 77 | +1. Select the virtual machine. |
| 78 | +1. Select **Apply**. |
| 79 | +1. Select **Next: Collect and deliver**. |
| 80 | + |
| 81 | +### Add data source |
| 82 | + |
| 83 | +1. Select **Add data source**. |
| 84 | +1. For **Data source type**, select **Linux syslog**. |
| 85 | + :::image type="content" source="media/forward-syslog-monitor-agent/create-rule-data-source.png" alt-text="Screenshot of page to select data source type and minimum log level"::: |
| 86 | +1. For **Minimum log level**, leave the default values **LOG_DEBUG**. |
| 87 | +1. Select **Next: Destination**. |
| 88 | + |
| 89 | +### Add destination |
| 90 | + |
| 91 | +1. Select **Add destination**. |
| 92 | + |
| 93 | + :::image type="content" source="media/forward-syslog-monitor-agent/create-rule-add-destination.png" alt-text="Screenshot of the destination tab with the add destination option selected."::: |
| 94 | +1. Enter the following values: |
| 95 | + |
| 96 | + |Field |Value | |
| 97 | + |---------|---------| |
| 98 | + |Destination type | Azure Monitor Logs | |
| 99 | + |Subscription | Select the appropriate subscription | |
| 100 | + |Account or namespace |Select the appropriate Log Analytics workspace| |
| 101 | + |
| 102 | +1. Select **Add data source**. |
| 103 | +1. Select **Next: Review + create**. |
| 104 | + |
| 105 | +### Create rule |
| 106 | + |
| 107 | +1. Select **Create**. |
| 108 | +1. Wait 20 minutes before moving on to the next section. |
| 109 | + |
| 110 | +If your VM doesn't have the Azure Monitor agent installed, the data collection rule deployment triggers the installation of the agent on the VM. |
| 111 | + |
| 112 | +## Verify the Azure Monitor agent is running |
| 113 | + |
| 114 | +In Microsoft Sentinel or Azure Monitor, verify that the Azure Monitor agent is running on your VM. |
| 115 | + |
| 116 | +1. In the Azure portal, search for and open **Microsoft Sentinel** or **Monitor**. |
| 117 | +1. If you're using Microsoft Sentinel, select the appropriate workspace. |
| 118 | +1. Under **General**, select **Logs**. |
| 119 | +1. Close the **Queries** page so that the **New Query** tab is displayed. |
| 120 | +1. Run the following query where you replace the computer value with the name of your Linux virtual machine. |
| 121 | + |
| 122 | + ```kusto |
| 123 | + Heartbeat |
| 124 | + | where Computer == "vm-ubuntu" |
| 125 | + | take 10 |
| 126 | + ``` |
| 127 | + |
| 128 | +## Enable log reception on port 514 |
| 129 | + |
| 130 | +Verify that the VM that's collecting the log data allows reception on port 514 TCP or UDP depending on the syslog source. Then configure the built-in Linux syslog daemon on the VM to listen for syslog messages from your devices. After you complete those steps, configure your linux-based device to send logs to your VM. |
| 131 | + |
| 132 | +The following two sections cover how to add an inbound port rule for an Azure VM and configure the built-in Linux syslog daemon. |
| 133 | + |
| 134 | +### Allow inbound syslog traffic on the VM |
| 135 | + |
| 136 | +If you're forwarding syslogs to an Azure VM, use the following steps to allow reception on port 514. |
| 137 | + |
| 138 | +1. In the Azure portal, search for and select **Virtual Machines**. |
| 139 | +1. Select the VM. |
| 140 | +1. Under **Settings**, select **Networking**. |
| 141 | +1. Select **Add inbound port rule**. |
| 142 | +1. Enter the following values. |
| 143 | + |
| 144 | + |Field |Value | |
| 145 | + |---------|---------| |
| 146 | + |Destination port ranges | 514 | |
| 147 | + |Protocol | TCP or UDP depending on syslog source | |
| 148 | + |Action | Allow | |
| 149 | + |Name | AllowSyslogInbound | |
| 150 | + |
| 151 | + Use the default values for the rest of the fields. |
| 152 | + |
| 153 | +1. Select **Add**. |
| 154 | + |
| 155 | +### Configure Linux syslog daemon |
| 156 | + |
| 157 | +Connect to your Linux VM and run the following command to configure the Linux syslog daemon: |
| 158 | + |
| 159 | +```bash |
| 160 | +sudo wget -O Forwarder_AMA_installer.py https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/DataConnectors/Syslog/Forwarder_AMA_installer.py&&sudo python3 Forwarder_AMA_installer.py |
| 161 | +``` |
| 162 | + |
| 163 | +This script can make changes for both rsyslog.d and syslog-ng. |
| 164 | + |
| 165 | +## Verify syslog data is forwarded to your Log Analytics workspace |
| 166 | + |
| 167 | +After you configured your linux-based device to send logs to your VM, verify that the Azure Monitor agent is forwarding syslog data to your workspace. |
| 168 | + |
| 169 | +1. In the Azure portal, search for and open **Microsoft Sentinel** or **Azure Monitor**. |
| 170 | +1. If you're using Microsoft Sentinel, select the appropriate workspace. |
| 171 | +1. Under **General**, select **Logs**. |
| 172 | +1. Close the **Queries** page so that the **New Query** tab is displayed. |
| 173 | +1. Run the following query where you replace the computer value with the name of your Linux virtual machine. |
| 174 | + |
| 175 | + ```kusto |
| 176 | + Syslog |
| 177 | + | where Computer == "vm-ubuntu" |
| 178 | + | summarize by HostName |
| 179 | + ``` |
| 180 | + |
| 181 | +## Clean up resources |
| 182 | + |
| 183 | +Evaluate whether you still need the resources you created like the virtual machine. Resources you leave running can cost you money. Delete the resources you don't need individually. Or delete the resource group to delete all the resources you've created. |
| 184 | + |
| 185 | +## Next steps |
| 186 | + |
| 187 | +> [!div class="nextstepaction"] |
| 188 | +> [Data collection rules in Azure Monitor](/azure/azure-monitor/essentials/data-collection-rule-overview) |
0 commit comments