Skip to content

Commit aa48abc

Browse files
Merge pull request #270267 from quillanogle/docs-editor/data-retention-archive-1711478862
Update data-retention-archive.md
2 parents 8b97cf1 + 88183d2 commit aa48abc

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

articles/azure-monitor/logs/data-retention-archive.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ If you change the archive settings on a table with existing data, the relevant d
5353

5454
You can set a Log Analytics workspace's default retention in the Azure portal to 30, 31, 60, 90, 120, 180, 270, 365, 550, and 730 days. You can apply a different setting to specific tables by [configuring retention and archive at the table level](#configure-retention-and-archive-at-the-table-level). If you're on the *free* tier, you need to upgrade to the paid tier to change the data retention period.
5555

56+
# [Portal](#tab/portal-3)
57+
5658
To set the default workspace retention:
5759

5860
1. From the **Log Analytics workspaces** menu in the Azure portal, select your workspace.
@@ -63,6 +65,73 @@ To set the default workspace retention:
6365

6466
1. Move the slider to increase or decrease the number of days, and then select **OK**.
6567

68+
# [API](#tab/api-3)
69+
70+
To set the retention and archive duration for a table, call the [Workspaces - Update API](/rest/api/azureml/workspaces/update):
71+
72+
```http
73+
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}?api-version=2023-09-01
74+
```
75+
76+
**Request body**
77+
78+
The request body includes the values in the following table.
79+
80+
|Name | Type | Description |
81+
| --- | --- | --- |
82+
|properties.retentionInDays | integer | The workspace data retention in days. Allowed values are per pricing plan. See pricing tiers documentation for details. |
83+
84+
**Example**
85+
86+
This example sets the workspace's retention to the workspace default of 30 days.
87+
88+
**Request**
89+
90+
```http
91+
PATCH https://management.azure.com/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/oiautorest6685/providers/Microsoft.OperationalInsights/workspaces/oiautorest6685?api-version=2023-09-01
92+
93+
{
94+
"properties": {
95+
"retentionInDays": 30,
96+
}
97+
}
98+
```
99+
100+
**Response**
101+
102+
Status code: 200
103+
104+
```http
105+
{
106+
"properties": {
107+
"retentionInDays": 30,
108+
},
109+
"location": "australiasoutheast",
110+
"tags": {
111+
"tag1": "val1"
112+
}
113+
}
114+
```
115+
116+
# [CLI](#tab/cli-3)
117+
118+
To set the retention and archive duration for a table, run the [az monitor log-analytics workspace update](/cli/azure/monitor/log-analytics/workspace/#az-monitor-log-analytics-workspace-update) command and pass the `--retention-time` parameter.
119+
120+
This example sets the table's interactive retention to 30 days, and the total retention to two years, which means that the archive duration is 23 months:
121+
122+
```azurecli
123+
az monitor log-analytics workspace update --resource-group myresourcegroup --retention-time 30 --workspace-name myworkspace
124+
```
125+
126+
# [PowerShell](#tab/PowerShell-3)
127+
128+
Use the [Set-AzOperationalInsightsWorkspace](/powershell/module/az.operationalinsights/Set-AzOperationalInsightsWorkspace) cmdlet to set the retention for a workspace. This example sets the workspace's retention to 30 days:
129+
130+
```powershell
131+
Set-AzOperationalInsightsWorkspace -ResourceGroupName "myResourceGroup" -Name "MyWorkspace" -RetentionInDays 30
132+
```
133+
---
134+
66135
## Configure retention and archive at the table level
67136

68137
By default, all tables in your workspace inherit the workspace's interactive retention setting and have no archive. You can modify the retention and archive settings of individual tables, except for workspaces in the legacy Free Trial pricing tier.
@@ -90,7 +159,7 @@ To set the retention and archive duration for a table in the Azure portal:
90159

91160
# [API](#tab/api-1)
92161

93-
To set the retention and archive duration for a table, call the **Tables - Update** API:
162+
To set the retention and archive duration for a table, call the [Tables - Update API](/rest/api/loganalytics/tables/update):
94163

95164
```http
96165
PATCH https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{tableName}?api-version=2022-10-01

0 commit comments

Comments
 (0)