|
| 1 | +--- |
| 2 | +title: Microsoft Sentinel API request examples for creating Data Collection Rules (DCRs) |
| 3 | +description: See samples of API requests for creating Data Collection Rules and their associations, for use with the Azure Monitor Agent. |
| 4 | +author: yelevin |
| 5 | +ms.author: yelevin |
| 6 | +ms.topic: reference |
| 7 | +ms.date: 03/01/2024 |
| 8 | +ms.service: microsoft-sentinel |
| 9 | +--- |
| 10 | +# API request examples for creating Data Collection Rules (DCRs) |
| 11 | + |
| 12 | +This article presents some examples of API requests and responses for creating Data Collection Rules (DCRs) and DCR Associations (DCRAs) for use with the Azure Monitor Agent (AMA). |
| 13 | + |
| 14 | +## Syslog/CEF |
| 15 | + |
| 16 | +The following examples are for DCRs using the AMA to collect Syslog and CEF messages. |
| 17 | + |
| 18 | +### Syslog/CEF DCR |
| 19 | + |
| 20 | +These examples are of the API request and response for creating a DCR. |
| 21 | + |
| 22 | +#### Syslog/CEF DCR creation request URL and header |
| 23 | + |
| 24 | +Example: |
| 25 | + |
| 26 | +```http |
| 27 | +PUT https://management.azure.com/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.Insights/dataCollectionRules/Contoso-DCR-01?api-version=2022-06-01 |
| 28 | +``` |
| 29 | + |
| 30 | +#### Syslog/CEF DCR creation request body |
| 31 | + |
| 32 | +The following is an example of a DCR creation request. For each stream—you can have several in one DCR—change the value of the `"Streams"` field according to the source of the messages you want to ingest: |
| 33 | + |
| 34 | +| Log source | `"Streams"` field value | |
| 35 | +| --- | --- | |
| 36 | +| **Syslog** | `"Microsoft-Syslog"` | |
| 37 | +| **CEF** | `"Microsoft-CommonSecurityLog"` | |
| 38 | +| **Cisco ASA** | `"Microsoft-CiscoAsa"` | |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "location": "centralus", |
| 43 | + "kind": "Linux", |
| 44 | + "properties": { |
| 45 | + "dataSources": { |
| 46 | + "syslog": [ |
| 47 | + { |
| 48 | + "name": "localsSyslog", |
| 49 | + "streams": [ |
| 50 | + "Microsoft-Syslog" |
| 51 | + ], |
| 52 | + "facilityNames": [ |
| 53 | + "auth", |
| 54 | + "local0", |
| 55 | + "local1", |
| 56 | + "local2", |
| 57 | + "local3", |
| 58 | + "syslog" |
| 59 | + ], |
| 60 | + "logLevels": [ |
| 61 | + "Critical", |
| 62 | + "Alert", |
| 63 | + "Emergency" |
| 64 | + ] |
| 65 | + }, |
| 66 | + { |
| 67 | + "name": "authprivSyslog", |
| 68 | + "streams": [ |
| 69 | + "Microsoft-Syslog" |
| 70 | + ], |
| 71 | + "facilityNames": [ |
| 72 | + "authpriv" |
| 73 | + ], |
| 74 | + "logLevels": [ |
| 75 | + "Error", |
| 76 | + "Alert", |
| 77 | + "Critical", |
| 78 | + "Emergency" |
| 79 | + ] |
| 80 | + } |
| 81 | + ] |
| 82 | + }, |
| 83 | + "destinations": { |
| 84 | + "logAnalytics": [ |
| 85 | + { |
| 86 | + "workspaceResourceId": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.OperationalInsights/workspaces/Contoso", |
| 87 | + "workspaceId": "11111111-2222-3333-4444-555555555555", |
| 88 | + "name": "DataCollectionEvent" |
| 89 | + } |
| 90 | + ] |
| 91 | + }, |
| 92 | + "dataFlows": [ |
| 93 | + { |
| 94 | + "streams": [ |
| 95 | + "Microsoft-Syslog" |
| 96 | + ], |
| 97 | + "destinations": [ |
| 98 | + "DataCollectionEvent" |
| 99 | + ] |
| 100 | + } |
| 101 | + ] |
| 102 | + } |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +#### Syslog/CEF DCR creation response |
| 107 | + |
| 108 | +Here's the response you should receive according to the sample request above: |
| 109 | + |
| 110 | +```json |
| 111 | + { |
| 112 | + "properties": { |
| 113 | + "immutableId": "dcr-0123456789abcdef0123456789abcdef", |
| 114 | + "dataSources": { |
| 115 | + "syslog": [ |
| 116 | + { |
| 117 | + "streams": [ |
| 118 | + "Microsoft-Syslog" |
| 119 | + ], |
| 120 | + "facilityNames": [ |
| 121 | + "auth", |
| 122 | + "local0", |
| 123 | + "local1", |
| 124 | + "local2", |
| 125 | + "local3", |
| 126 | + "syslog" |
| 127 | + ], |
| 128 | + "logLevels": [ |
| 129 | + "Critical", |
| 130 | + "Alert", |
| 131 | + "Emergency" |
| 132 | + ], |
| 133 | + "name": "localsSyslog" |
| 134 | + }, |
| 135 | + { |
| 136 | + "streams": [ |
| 137 | + "Microsoft-Syslog" |
| 138 | + ], |
| 139 | + "facilityNames": [ |
| 140 | + "authpriv" |
| 141 | + ], |
| 142 | + "logLevels": [ |
| 143 | + "Error", |
| 144 | + "Alert", |
| 145 | + "Critical", |
| 146 | + "Emergency" |
| 147 | + ], |
| 148 | + "name": "authprivSyslog" |
| 149 | + } |
| 150 | + ] |
| 151 | + }, |
| 152 | + "destinations": { |
| 153 | + "logAnalytics": [ |
| 154 | + { |
| 155 | + "workspaceResourceId": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.OperationalInsights/workspaces/Contoso", |
| 156 | + "workspaceId": "11111111-2222-3333-4444-555555555555", |
| 157 | + "name": "DataCollectionEvent" |
| 158 | + } |
| 159 | + ] |
| 160 | + }, |
| 161 | + "dataFlows": [ |
| 162 | + { |
| 163 | + "streams": [ |
| 164 | + "Microsoft-Syslog" |
| 165 | + ], |
| 166 | + "destinations": [ |
| 167 | + "DataCollectionEvent" |
| 168 | + ] |
| 169 | + } |
| 170 | + ], |
| 171 | + "provisioningState": "Succeeded" |
| 172 | + }, |
| 173 | + "location": "centralus", |
| 174 | + "kind": "Linux", |
| 175 | + "id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.Insights/dataCollectionRules/Contoso-DCR-01", |
| 176 | + "name": "Contoso-DCR-01", |
| 177 | + "type": "Microsoft.Insights/dataCollectionRules", |
| 178 | + "etag": "\"00000000-0000-0000-0000-000000000000\"", |
| 179 | + "systemData": { |
| 180 | + } |
| 181 | + } |
| 182 | +``` |
| 183 | + |
| 184 | +### Syslog/CEF DCRA |
| 185 | + |
| 186 | +#### Syslog/CEF DCRA creation request URL and header |
| 187 | + |
| 188 | +```http |
| 189 | +PUT |
| 190 | +https://management.azure.com/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.Compute/virtualMachines/LogForwarder-VM-1/providers/Microsoft.Insights/dataCollectionRuleAssociations/contoso-dcr-assoc?api-version=2022-06-01 |
| 191 | +``` |
| 192 | + |
| 193 | +#### Syslog/CEF DCRA creation request body |
| 194 | + |
| 195 | +```json |
| 196 | +{ |
| 197 | + "properties": { |
| 198 | + "dataCollectionRuleId": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.Insights/dataCollectionRules/Contoso-DCR-01" |
| 199 | + } |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +#### Syslog/CEF DCRA creation response |
| 204 | + |
| 205 | +```json |
| 206 | +{ |
| 207 | + "properties": { |
| 208 | + "dataCollectionRuleId": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.Insights/dataCollectionRules/Contoso-DCR-01" |
| 209 | + }, |
| 210 | + "id": "/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/ContosoRG/providers/Microsoft.Compute/virtualMachines/LogForwarder-VM-1/providers/Microsoft.Insights/dataCollectionRuleAssociations/contoso-dcr-assoc", |
| 211 | + "name": "contoso-dcr-assoc", |
| 212 | + "type": "Microsoft.Insights/dataCollectionRuleAssociations", |
| 213 | + "etag": "\"00000000-0000-0000-0000-000000000000\"", |
| 214 | + "systemData": { |
| 215 | + } |
| 216 | + } |
| 217 | +``` |
| 218 | + |
0 commit comments