Skip to content

Commit 37f7698

Browse files
Merge pull request #233050 from bwren/custom-fields
Migrate from custom fields in Azure Monitor
2 parents 061aaff + 2f337d0 commit 37f7698

File tree

8 files changed

+114
-11
lines changed

8 files changed

+114
-11
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Migration of custom fields to KQL-based transformations in Azure Monitor
3+
description: Learn how to migrate custom fields in a Log Analytics workspace in Azure Monitor with KQL-based custom columns using transformations.
4+
ms.service: azure-monitor
5+
ms.topic: tutorial
6+
ms.date: 03/31/2023
7+
---
8+
9+
10+
# Tutorial: Replace custom fields in Log Analytics workspace with KQL-based custom columns
11+
12+
Custom fields is a feature of Azure Monitor that allows you to extract into a separate column data from a different text column of the same table. Creation of new custom fields will be disabled starting March 31st, 2023. Custom fields functionality will be deprecated and existing custom fields will stop functioning on March 31st, 2026.
13+
14+
There are several advantages to using DCR-based [ingestion-time transformations](../essentials/data-collection-transformations.md) to accomplish the same result:
15+
16+
- You can apply full set of [string functions](/azure/data-explorer/kusto/query/scalarfunctions#string-functions) to shape your custom columns.
17+
- You can apply multiple operations to the same data. For example, extract a portion of a value to a separate column and remove the original column.
18+
- You can use ingestion-time transformations in your ARM templates to deploy custom columns at scale.
19+
20+
With the introduction of [data collection rules (DCR)](../essentials/data-collection-rule-overview.md), KQL-based transformations are the standard method of table customization, replacing legacy custom fields.
21+
22+
In this tutorial, you learn how to:
23+
24+
> [!div class="checklist"]
25+
> * Locate custom fields that require replacement
26+
> * Understand the content of the custom fields
27+
> * Setup ingestion-time transformation to replace custom fields within the table
28+
29+
30+
## Prerequisites
31+
32+
- Log Analytics workspace with a table containing custom fields
33+
- Sufficient account privilege to create and modify data collection rules (DCR)
34+
35+
36+
37+
## Locate custom fields for replacement
38+
Start by locating custom fields to replace. If you already know the custom fields you plan to replace, proceed to the next step.
39+
40+
1. Navigate to the Log Analytics workspace where the table with custom fields is located.
41+
2. In the side menu, select **Tables**. Select **Manage table** from the context menu for the table.
42+
43+
:::image type="content" source="media/custom-fields-migrate/manage-table.png" alt-text="Screenshot showing the manage table option for a table in a Log Analytics workspace" lightbox="media/custom-fields-migrate/manage-table.png":::
44+
45+
1. Note if any data collection rules (DCRs) are associated with given table.
46+
47+
- If any DCRs are present in corresponding section, it means that any pre-existing custom fields were either already implemented within these DCRs, or abandoned upon DCR creation. You're going to examine the content of custom fields on the next step of this tutorial and determine whether more updates to DCRs needed.
48+
- If there are no data collection rules associated with the table, then all columns in given table with names ending with "_CF" will be custom fields subject to replacement.
49+
50+
:::image type="content" source="media/custom-fields-migrate/manage-table-details.png" alt-text="Screenshot showing the properties of a table including data collection rules associated with the table" lightbox="media/custom-fields-migrate/manage-table-details.png":::
51+
52+
2. Close the table properties dialog and select **Edit schema** from the table context menu. Scroll to the bottom of page where custom columns are listed. These columns end with *_CF*.
53+
54+
:::image type="content" source="media/custom-fields-migrate/custom-columns.png" alt-text="Screenshot showing the column listing for a table including any custom columns" lightbox="media/custom-fields-migrate/custom-columns.png":::
55+
56+
1. Note the names of these columns since you'll determine their content in the next step.
57+
58+
## Understand custom field content
59+
Since there is no way to examine the custom field definition directly, you need to query the table to determine the custom field formula.
60+
61+
1. Select **Logs** in the side menu and run a query to get a sample of data from the table.
62+
63+
:::image type="content" source="media/custom-fields-migrate/log-analytics-sample-data.png" alt-text="Screenshot of Log Analytics with query returning sample data" lightbox="media/custom-fields-migrate/log-analytics-sample-data.png":::
64+
65+
1. Locate the columns noted in the previous step and examine their content.
66+
- If the column *is not empty* and *there are DCRs* associated with the table, then custom field logic has been already implemented with transformation. No action is required
67+
- If the column *is empty* (or not present in query results) and *there are DCRs* associated with the table, the custom field logic was not implemented with the DCR. Add a transformation to the dataflow in the existing DCR.
68+
- If the column *is not empty* and *there are no DCRs* associated with the table, the custom field logic needs to implemented as a transformation in the [workspace DCR](../essentials/data-collection-transformations.md#workspace-transformation-dcr).
69+
70+
1. Examine the content of the custom field and determine the logic how it's being calculated. Custom fields usually calculate substrings of other columns in the same table. Determine which column the data comes from and the portion of the string it extracts.
71+
72+
## Create transformation
73+
You're now ready to create the required KQL snippet and add it to a DCR. This logic is applied to each record as it's ingested into the workspace.
74+
75+
1. Modify the query for the table using KQL to replicate the custom field logic. If you have multiple custom fields to replace, you may combine their calculation logic into a single statement.
76+
77+
- Use [parse](/azure/data-explorer/kusto/query/parseoperator) operator for pattern-based search of a substring within a string.
78+
- Use [extract()](/azure/data-explorer/kusto/query/extractfunction) function for regex-based substring search.
79+
- String functions as [split()](/azure/data-explorer/kusto/query/splitfunction), [substring()](/azure/data-explorer/kusto/query/substringfunction) and [many others](/azure/data-explorer/kusto/query/scalarfunctions#string-functions) may also be useful.
80+
81+
:::image type="content" source="media/custom-fields-migrate/log-analytics-transformation-query.png" alt-text="Screenshot of Log Analytics with query returning data using transformation query" lightbox="media/custom-fields-migrate/log-analytics-transformation-query.png":::
82+
83+
2. Determine where your new KQL definition of the custom column needs to be placed.
84+
85+
- For logs collected using [Azure Monitor Agent (AMA)](../agents/agents-overview.md), [edit the DCR](../essentials/data-collection-rule-edit.md) collecting data for the table, adding a transformation. For an example, see [Samples](../essentials/data-collection-transformations.md#samples). The transformation query is defined in the `transformKql` element.
86+
- For resource logs collected with [diagnostic settings](../essentials/diagnostic-settings.md), add the transformation to the [workspace default DCR](../essentials/data-collection-transformations.md#workspace-transformation-dcr). The table must [support transformations](../logs/tables-feature-support.md).
87+
88+
89+
90+
## Frequently Asked Questions
91+
92+
### How do I migrate custom fields for a text log collected with legacy Log Analytics agent (MMA)?
93+
94+
Consider migrating to Azure Monitor Agent (AMA). Log Analytics agent is approaching its end of support, and you should migrate to Azure Monitor Agent (AMA). [Text logs collected with AMA](../agents/data-collection-text-log.md) use log parsing logic defined in form of KQL transformations from the start. Custom fields are not required and not supported in text logs collected by Azure Monitor Agent.
95+
96+
### Is migration of custom fields to KQL mandatory?
97+
98+
No. You need to migrate your custom fields only if you still want your custom columns populated. If you don't migrate your custom fields, corresponding columns will stop being populated when support of custom fields is ended. Data that has been already processed and stored in the table will not be affected and will remain usable.
99+
100+
### Will I lose my existing data in corresponding columns if I don't migrate my custom fields in time?
101+
102+
No. Custom fields are calculated at the time of data ingestion. Deleting the field definition or not migrating them in time will not affect any data previously ingested.
103+
104+
## Next steps
105+
106+
- [Read more about transformations in Azure Monitor.](../essentials/data-collection-transformations.md)
107+

articles/azure-monitor/logs/custom-fields.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
---
2-
title: Custom fields in Azure Monitor (Preview) | Microsoft Docs
2+
title: Custom fields in Azure Monitor (Preview)
33
description: The Custom Fields feature of Azure Monitor allows you to create your own searchable fields from records in a Log Analytics workspace that add to the properties of a collected record. This article describes the process to create a custom field and provides a detailed walkthrough with a sample event.
44
ms.topic: conceptual
55
author: guywild
66
ms.author: guywild
77
ms.reviewer: roygal
8-
ms.date: 10/20/2021
8+
ms.date: 03/31/2023
99

1010
---
1111

1212
# Create custom fields in a Log Analytics workspace in Azure Monitor (Preview)
1313

14-
> [!NOTE]
15-
> This article describes how to parse text data in a Log Analytics workspace as it's collected. We recommend parsing text data in a query filter after it's collected following the guidance described in [Parse text data in Azure Monitor](./parse-text.md). It provides several advantages over using custom fields.
16-
1714
> [!IMPORTANT]
18-
> Custom fields increases the amount of data collected in the Log Analytics workspace which can increase your cost. See [Azure Monitor Logs pricing details](cost-logs.md) for details.
15+
> Creation of new custom fields will be disabled starting March 31, 2023. Custom fields functionality will be deprecated, and existing custom fields will stop functioning by March 31, 2026. You should [migrate to ingestion-time transformations](custom-fields-migrate.md) to keep parsing your log records.
16+
>
17+
> Currently, when you add a new custom field, it may take up to 7 days before data starts appearing.
1918
2019
The **Custom Fields** feature of Azure Monitor allows you to extend existing records in your Log Analytics workspace by adding your own searchable fields. Custom fields are automatically populated from data extracted from other properties in the same record.
2120

@@ -64,11 +63,6 @@ Once you have performed the initial extract, Log Analytics will display its resu
6463
6. Wait for new records matching the specified criteria to be collected and then run the log search again. New records should have the custom field.
6564
7. Use the custom field like any other record property. You can use it to aggregate and group data and even use it to produce new insights.
6665

67-
## Viewing custom fields
68-
You can view a list of all custom fields in your management group from the **Advanced Settings** menu of your Log Analytics workspace in the Azure portal. Select **Data** and then **Custom fields** for a list of all custom fields in your workspace.
69-
70-
![Custom fields](media/custom-fields/list.png)
71-
7266
## Removing a custom field
7367
There are two ways to remove a custom field. The first is the **Remove** option for each field when viewing the complete list as described above. The other method is to retrieve a record and click the button to the left of the field. The menu will have an option to remove the custom field.
7468

368 KB
Loading
165 KB
Loading
175 KB
Loading
204 KB
Loading
215 KB
Loading

articles/azure-monitor/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ items:
278278
href: agents/data-sources-custom-logs.md
279279
- name: Custom fields
280280
href: logs/custom-fields.md
281+
- name: Migrate from custom fields
282+
href: logs/custom-fields-migrate.md
281283
- name: Azure Diagnostics extension
282284
items:
283285
- name: Overview

0 commit comments

Comments
 (0)