Skip to content

Commit 7413079

Browse files
Merge pull request #223087 from JeffreyWolford/patch-5
Update data-collection-text-log.md
2 parents 19a827e + 4f2a784 commit 7413079

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

articles/azure-monitor/agents/data-collection-text-log.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,50 @@ To complete this procedure, you need:
1717

1818
- Log Analytics workspace where you have at least [contributor rights](../logs/manage-access.md#azure-rbac).
1919
- [Data collection endpoint](../essentials/data-collection-endpoint-overview.md#create-a-data-collection-endpoint).
20-
- [Custom table](../logs/create-custom-table.md) to send your logs to.
2120
- [Permissions to create Data Collection Rule objects](../essentials/data-collection-rule-overview.md#permissions) in the workspace.
2221
- A VM, Virtual Machine Scale Set, or Arc-enabled on-premises server that writes logs to a text file.
2322
- The log file must be stored on the local drive of the machine on which Azure Monitor Agent is running.
2423
- Each entry in the log file must be delineated with an end of line.
2524
- The log file must not allow circular logging, log rotation where the file is overwritten with new entries, or renaming where a file is moved and a new file with the same name is opened.
2625

26+
## Create a custom table
27+
28+
This step will create a new custom table, which is any table name that ends in \_CL. Currently a direct REST call to the table management endpoint is used to create a table. The script at the end of this section is the input to the REST call.
29+
30+
The table created in the script has two columns TimeGenerated: datetime and RawData: string, which is the default schema for a custom text log. If you know your final schema, then you can add columns in the script before creating the table. If you do not, columns can always be added in the log analytics table UI.
31+
32+
The easiest way to make the REST call is from an Azure Cloud PowerShell command line (CLI). To open the shell, go to the Azure Portal, press the Cloud Shell button, and select PowerShell. If this is your first-time using Azure Cloud PowerShell, you will need to walk through the one-time configuration wizard.
33+
34+
35+
Copy and paste the following script in to PowerShell to create the table in your workspace. Make sure to replace the {subscription}, {resource group}, {workspace name}, and {table name} in the script. Make sure that there are no extra blanks at the beginning or end of the parameters
36+
37+
```code
38+
$tableParams = @'
39+
{
40+
"properties": {
41+
"schema": {
42+
"name": "{TableName}_CL",
43+
"columns": [
44+
{
45+
"name": "TimeGenerated",
46+
"type": "DateTime"
47+
},
48+
{
49+
"name": "RawData",
50+
"type": "String"
51+
}
52+
]
53+
}
54+
}
55+
}
56+
'@
57+
58+
Invoke-AzRestMethod -Path "/subscriptions/{subscription}/resourcegroups/{resourcegroup}/providers/microsoft.operationalinsights/workspaces/{WorkspaceName}/tables/{TableName}_CL?api-version=2021-12-01-preview" -Method PUT -payload $tableParams
59+
```
60+
61+
Press return to execute the code. You should see a 200 response, and details about the table you just created will show up. To validate that the table was created go to your workspace and select Tables on the left blade. You should see your table in the list.
62+
63+
2764
## Create data collection rule to collect text logs
2865

2966
The data collection rule defines:

0 commit comments

Comments
 (0)