Add or delete tables and columns in Azure Monitor Logs
Data collection rules let you filter and transform log data before sending the data to an Azure table or a custom table. This article explains how to create custom tables and add custom columns to tables in your Log Analytics workspace.
Important
Whenever you update a table schema, be sure to update any data collection rules that send data to the table. The table schema you define in your data collection rule determines how Azure Monitor streams data to the destination table. Azure Monitor does not update data collection rules automatically when you make table schema changes.
Prerequisites
To create a custom table, you need:
A Log Analytics workspace where you have at least contributor rights.
A JSON file with at least one record of sample for your custom table. This will look similar to the following:
[ { "TimeGenerated": "supported_datetime_format", "<column_name_1>": "<column_name_1_value>", "<column_name_2>": "<column_name_2_value>" }, { "TimeGenerated": "supported_datetime_format", "<column_name_1>": "<column_name_1_value>", "<column_name_2>": "<column_name_2_value>" }, { "TimeGenerated": "supported_datetime_format", "<column_name_1>": "<column_name_1_value>", "<column_name_2>": "<column_name_2_value>" } ]
All tables in a Log Analytics workspace must have a column named
TimeGenerated
. If your sample data has a column namedTimeGenerated
, then this value will be used to identify the ingestion time of the record. If not, aTimeGenerated
column will be added to the transformation in your DCR for the table. For information about theTimeGenerated
format, see supported datetime formats.
Create a custom table
Azure tables have predefined schemas. To store log data in a different schema, use data collection rules to define how to collect, transform, and send the data to a custom table in your Log Analytics workspace.
Important
Custom tables have a suffix of _CL; for example, tablename_CL. The Azure portal adds the _CL suffix to the table name automatically. When you create a custom table using a different method, you need to add the _CL suffix yourself. The tablename_CL in the DataFlows Streams properties in your data collection rules must match the tablename_CL name in the Log Analytics workspace.
Note
For information about creating a custom table for logs you ingest with the deprecated Log Analytics agent, also known as MMA or OMS, see Collect text logs with the Log Analytics agent.
To create a custom table in the Azure portal:
From the Log Analytics workspaces menu, select Tables.
Select Create and then New custom log (DCR-based).
Specify a name and, optionally, a description for the table. You don't need to add the _CL suffix to the custom table's name - this is added automatically to the name you specify in the portal.
Select an existing data collection rule from the Data collection rule dropdown, or select Create a new data collection rule and specify the Subscription, Resource group, and Name for the new data collection rule.
Select a data collection endpoint and select Next.
Select Browse for files and locate the JSON file with the sample data for your new table.
If your sample data doesn't include a
TimeGenerated
column, then you will receive a message that a transformation is being created with this column.If you want to transform log data before ingestion into your table:
Select Apply to save the transformation and view the schema of the table that's about to be created. Select Next to proceed.
Verify the final details and select Create to save the custom log.
Delete a table
There are several types of tables in Log Analytics and the delete experience is different for each:
- Azure table -- Can't be deleted. Tables that are part of a solution are removed from workspace when deleting the solution, but data remains in workspace for the duration of the retention policy defined for the tables, or if not exist, for the duration of the retention policy defined in workspace. If the solution is re-created in the workspace, these tables and previously ingested data become visible again. To avoid charges, define retention policy for tables in solutions to minimum (4-days) before deleting the solution.
- Restored table (table_RST) -- Deletes the hot cache provisioned for the restore, but source table data isn't deleted.
- Search results table (table_SRCH) -- Deletes the table and data immediately and permanently.
- Custom log table (table_CL) -- Deletes the table definition immediately, but data remains in workspace for the duration of the retention policy defined for the table, or workspace. The retention policy for table is removed in 14-days and workspace retention governs. If custom log table is created with the same name and schema, the table and previously ingested data become visible again. To avoid charges and remove data from table, define retention policy for table to minimum (4-days) before deleting the table.
To delete a table from the Azure portal:
From the Log Analytics workspace menu, select Tables.
Search for the tables you want to delete by name, or by selecting Search results in the Type field.
Select the table you want to delete, select the ellipsis ( ... ) to the right of the table, select Delete, and confirm the deletion by typing yes.
Add or delete a custom column
You can modify the schema of custom tables and add custom columns to, or delete columns from, a standard table.
Note
Column names must start with a letter and can consist of up to 45 alphanumeric characters and underscores (_
). _ResourceId
, id
, _ResourceId
, _SubscriptionId
, TenantId
, Type
, UniqueId
, and Title
are reserved column names.
To add a custom column to a table in your Log Analytics workspace, or delete a column:
From the Log Analytics workspaces menu, select Tables.
Select the ellipsis ( ... ) to the right of the table you want to edit and select Edit schema. This opens the Schema Editor screen.
Scroll down to the Custom Columns section of the Schema Editor screen.
To add a new column:
- Select Add a column.
- Set the column name and description (optional), and select the expected value type from the Type dropdown.
- Select Save to save the new column.
To delete a column, select the Delete icon to the left of the column you want to delete.
Next steps
Learn more about: