Skip to content

Commit fba96c6

Browse files
authored
Merge pull request #190720 from guywi-ms/guywi-ms-add-cli-commands
Update basic-logs-configure.md
2 parents 80ca6c4 + fb8bea9 commit fba96c6

File tree

4 files changed

+207
-45
lines changed

4 files changed

+207
-45
lines changed

articles/azure-monitor/logs/basic-logs-configure.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ You can currently configure the following tables for Basic Logs:
2525
> [!NOTE]
2626
> Tables created with the [Data Collector API](data-collector-api.md) do not support Basic Logs.
2727
28+
2829
## Set table configuration
30+
# [API](#tab/api-1)
31+
2932
To configure a table for Basic Logs or Analytics Logs, call the **Tables - Update** API:
3033

3134
```http
@@ -34,14 +37,17 @@ PATCH https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups
3437
> [!IMPORTANT]
3538
> Use the Bearer token for authentication. Read more about [using Bearer tokens](https://social.technet.microsoft.com/wiki/contents/articles/51140.azure-rest-management-api-the-quickest-way-to-get-your-bearer-token.aspx).
3639
37-
### Request body
40+
**Request body**
41+
3842
|Name | Type | Description |
3943
| --- | --- | --- |
4044
|properties.plan | string | The table plan. Possible values are *Analytics* and *Basic*.|
4145

42-
### Example
46+
**Example**
47+
4348
This example configures the `ContainerLog` table for Basic Logs.
44-
#### Sample request
49+
50+
**Sample request**
4551

4652
```http
4753
PATCH https://management.azure.com/subscriptions/ContosoSID/resourcegroups/ContosoRG/providers/Microsoft.OperationalInsights/workspaces/ContosoWorkspace/tables/ContainerLog?api-version=2021-12-01-preview
@@ -67,7 +73,8 @@ Use this request body to change to Analytics Logs:
6773
}
6874
```
6975

70-
#### Sample response
76+
**Sample response**
77+
7178
This is the response for a table changed to Basic Logs.
7279

7380
Status code: 200
@@ -87,6 +94,27 @@ Status code: 200
8794
}
8895
```
8996

97+
# [CLI](#tab/cli-1)
98+
99+
To configure a table for Basic Logs or Analytics Logs, run the [az monitor log-analytics workspace table update](/cli/azure/monitor/log-analytics/workspace/table#az-monitor-log-analytics-workspace-table-update) command and set the `--plan` parameter to `Basic` or `Analytics`.
100+
101+
For example:
102+
103+
- To set Basic Logs:
104+
105+
```azurecli
106+
az monitor log-analytics workspace table update --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
107+
--name ContainerLog --plan Basic
108+
```
109+
110+
- To set Analytics Logs:
111+
112+
```azurecli
113+
az monitor log-analytics workspace table update --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
114+
--name ContainerLog --plan Analytics
115+
```
116+
117+
---
90118
91119
## Check table configuration
92120
# [Portal](#tab/portal-1)
@@ -148,6 +176,17 @@ Status code: 200
148176
}
149177
```
150178

179+
# [CLI](#tab/cli-2)
180+
181+
To check the configuration of a table, run the [az monitor log-analytics workspace table show](/cli/azure/monitor/log-analytics/workspace/table#az-monitor-log-analytics-workspace-table-show) command.
182+
183+
For example:
184+
185+
```azurecli
186+
az monitor log-analytics workspace table show --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
187+
--name Syslog --output table \
188+
```
189+
151190
---
152191

153192
## Retention and archiving of Basic Logs

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

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,19 @@ To set the default workspace retention policy:
3737

3838
## Set retention and archive policy by table
3939

40-
You can set retention policies for individual tables, except for workspaces in the legacy Free Trial pricing tier, using Azure Resource Manager APIs. You cannot currently configure data retention for individual tables in the Azure portal.
40+
You can set retention policies for individual tables, except for workspaces in the legacy Free Trial pricing tier, using Azure Resource Manager APIs. You can’t currently configure data retention for individual tables in the Azure portal.
4141

4242
You can keep data in interactive retention between 4 and 730 days. You can set the archive period for a total retention time of up to 2,555 days (seven years).
4343

44-
Each table is a sub-resource of the workspace it's in. For example, you can address the `SecurityEvent` table in [Azure Resource Manager](../../azure-resource-manager/management/overview.md) as:
44+
Each table is a subresource of the workspace it's in. For example, you can address the `SecurityEvent` table in [Azure Resource Manager](../../azure-resource-manager/management/overview.md) as:
4545

4646
```
4747
/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/MyResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/MyWorkspaceName/Tables/SecurityEvent
4848
```
4949

50-
Note that the table name is case-sensitive.
50+
The table name is case-sensitive.
5151

52-
### Get retention and archive policy by table
53-
54-
To get the retention policy of a particular table (in this example, `SecurityEvent`), Call the **Tables - Get** API:
55-
56-
```JSON
57-
GET /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/MyResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/MyWorkspaceName/Tables/SecurityEvent?api-version=2021-12-01-preview
58-
```
59-
60-
To get all table-level retention policies in your workspace, don't set a table name; for example:
61-
62-
```JSON
63-
GET /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/MyResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/MyWorkspaceName/Tables?api-version=2021-12-01-preview
64-
```
65-
### Set the retention and archive policy for a table
52+
# [API](#tab/api-1)
6653

6754
To set the retention and archive duration for a table, call the **Tables - Update** API:
6855

@@ -79,24 +66,26 @@ You can use either PUT or PATCH, with the following difference:
7966
- The **PUT** API sets *retentionInDays* and *totalRetentionInDays* to the default value if you don't set non-null values.
8067
- The **PATCH** API doesn't change the *retentionInDays* or *totalRetentionInDays* values if you don't specify values.
8168

69+
**Request body**
8270

83-
#### Request body
8471
The request body includes the values in the following table.
8572

8673
|Name | Type | Description |
8774
| --- | --- | --- |
8875
|properties.retentionInDays | integer | The table's data retention in days. This value can be between 4 and 730; or 1095, 1460, 1826, 2191, or 2556. <br/>Setting this property to null will default to the workspace retention. For a Basic Logs table, the value is always 8. |
8976
|properties.totalRetentionInDays | integer | The table's total data retention including archive period. Set this property to null if you don't want to archive data. |
9077

91-
#### Example
92-
The following table sets table retention to workspace default of 30 days, and total of 2 years. This means that the archive duration would be 23 months.
93-
###### Request
78+
**Example**
79+
80+
This example sets the table's interactive retention to the workspace default of 30 days, and the total retention to two years. This means the archive duration is 23 months.
81+
82+
**Request**
9483

9584
```http
9685
PATCH https://management.azure.com/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/testRG/providers/Microsoft.OperationalInsights/workspaces/testWS/tables/CustomLog_CL?api-version=2021-12-01-preview
9786
```
9887

99-
#### Request body
88+
**Request body**
10089
```http
10190
{
10291
"properties": {
@@ -106,7 +95,7 @@ PATCH https://management.azure.com/subscriptions/00000000-0000-0000-0000-0000000
10695
}
10796
```
10897

109-
###### Response
98+
**Response**
11099

111100
Status code: 200
112101

@@ -121,15 +110,66 @@ Status code: 200
121110
...
122111
}
123112
```
113+
114+
# [CLI](#tab/cli-1)
115+
116+
To set the retention and archive duration for a table, run the [az monitor log-analytics workspace table update](/cli/azure/monitor/log-analytics/workspace/table#az-monitor-log-analytics-workspace-table-update) command and pass the `--retention-time` and `--total-retention-time` parameters.
117+
118+
This example sets table's interactive retention to 30 days, and the total retention to two years. This means the archive duration is 23 months:
119+
120+
```azurecli
121+
az monitor log-analytics workspace table update --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
122+
--name AzureMetrics --retention-time 30 --total-retention-time 730
123+
```
124+
125+
To reapply the workspace's default interactive retention value to the table and reset its total retention to 0, run the [az monitor log-analytics workspace table update](/cli/azure/monitor/log-analytics/workspace/table#az-monitor-log-analytics-workspace-table-update) command with the `--retention-time` and `--total-retention-time` parameters set to `-1`.
126+
127+
For example:
128+
129+
```azurecli
130+
az monitor log-analytics workspace table update --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
131+
--name Syslog --retention-time -1 --total-retention-time -1
132+
```
133+
134+
---
124135

136+
## Get retention and archive policy by table
137+
138+
# [API](#tab/api-2)
139+
140+
To get the retention policy of a particular table (in this example, `SecurityEvent`), call the **Tables - Get** API:
141+
142+
```JSON
143+
GET /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/MyResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/MyWorkspaceName/Tables/SecurityEvent?api-version=2021-12-01-preview
144+
```
145+
146+
To get all table-level retention policies in your workspace, don't set a table name; for example:
147+
148+
```JSON
149+
GET /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/MyResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/MyWorkspaceName/Tables?api-version=2021-12-01-preview
150+
```
151+
152+
# [CLI](#tab/cli-2)
153+
154+
To get the retention policy of a particular table, run the [az monitor log-analytics workspace table show](/cli/azure/monitor/log-analytics/workspace/table#az-monitor-log-analytics-workspace-table-show) command.
155+
156+
For example:
157+
158+
```azurecli
159+
az monitor log-analytics workspace table show --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
160+
--name SecurityEvent
161+
```
162+
163+
---
164+
125165
## Purge retained data
126166
When you shorten an existing retention policy, it takes several days for Azure Monitor to remove data that you no longer want to keep.
127167

128-
If you set the data retention policy to 30 days, you can purge older data immediately using the `immediatePurgeDataOn30Days` parameter in Azure Resource Manager. This can be useful when you need to remove personal data immediately. The immediate purge functionality is not available through the Azure portal.
168+
If you set the data retention policy to 30 days, you can purge older data immediately using the `immediatePurgeDataOn30Days` parameter in Azure Resource Manager. The purge functionality is useful when you need to remove personal data immediately. The immediate purge functionality isn't available through the Azure portal.
129169

130170
Note that workspaces with a 30-day retention policy might actually keep data for 31 days if you don't set the `immediatePurgeDataOn30Days` parameter.
131171

132-
You can also purge data from a workspace using the [purge feature](personal-data-mgmt.md#how-to-export-and-delete-private-data), which removes personal data. You cannot purge data from archived logs.
172+
You can also purge data from a workspace using the [purge feature](personal-data-mgmt.md#how-to-export-and-delete-private-data), which removes personal data. You can’t purge data from archived logs.
133173

134174
The Log Analytics [Purge API](/rest/api/loganalytics/workspacepurge/purge) doesn't affect retention billing. **To lower retention costs, decrease the retention period for the workspace or for specific tables.**
135175

articles/azure-monitor/logs/restore.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ The restore operation creates the restore table and allocates additional compute
2222

2323
The destination table provides a view of the underlying source data, but does not affect it in any way. The table has no retention setting, and you must explicitly [dismiss the restored data](#dismiss-restored-data) when you no longer need it.
2424

25-
## Restore data using API
25+
## Restore data
26+
27+
# [API](#tab/api-1)
2628
To restore data from a table, call the **Tables - Create or Update** API. The name of the destination table must end with *_RST*.
2729

2830
```http
2931
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{user defined name}_RST?api-version=2021-12-01-preview
3032
```
31-
### Request body
33+
34+
**Request body**
35+
3236
The body of the request must include the following values:
3337

3438
|Name | Type | Description |
@@ -37,7 +41,8 @@ The body of the request must include the following values:
3741
|properties.restoredLogs.startRestoreTime | string | Start of the time range to restore. |
3842
|properties.restoredLogs.endRestoreTime | string | End of the time range to restore. |
3943

40-
### Restore table status
44+
**Restore table status**
45+
4146
The **provisioningState** property indicates the current state of the restore table operation. The API returns this property when you start the restore, and you can retrieve this property later using a GET operation on the table. The **provisioningState** property has one of the following values:
4247

4348
| Value | Description
@@ -46,7 +51,8 @@ The **provisioningState** property indicates the current state of the restore ta
4651
| Succeeded | Restore operation completed. |
4752
| Deleting | Deleting the restored table. |
4853

49-
#### Sample request
54+
**Sample request**
55+
5056
This sample restores data from the month of January 2020 from the *Usage* table to a table called *Usage_RST*.
5157

5258
**Request**
@@ -67,21 +73,45 @@ PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000
6773
}
6874
}
6975
```
76+
# [CLI](#tab/cli-1)
7077

78+
To restore data from a table, run the [az monitor log-analytics workspace table restore create](/cli/azure/monitor/log-analytics/workspace/table/restore#az-monitor-log-analytics-workspace-table-restore-create) command.
79+
80+
For example:
81+
82+
```azurecli
83+
az monitor log-analytics workspace table restore create --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
84+
--name Heartbeat_RST --restore-source-table Heartbeat --start-restore-time "2022-01-01T00:00:00.000Z" --end-restore-time "2022-01-08T00:00:00.000Z" --no-wait
85+
```
86+
87+
---
7188
## Dismiss restored data
7289

7390
To save costs, dismiss restored data when you no longer need it by deleting the restored table.
7491

92+
Deleting the restored table does not delete the data in the source table.
93+
94+
> [!NOTE]
95+
> Restored data is available as long as the underlying source data is available. When you delete the source table from the workspace or when the source table's retention period ends, the data is dismissed from the restored table. However, the empty table will remain if you do not delete it explicitly.
96+
97+
# [API](#tab/api-2)
7598
To delete a restore table, call the **Tables - Delete** API:
7699

77100
```http
78101
DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/tables/{user defined name}_RST?api-version=2021-12-01-preview
79102
```
80-
Deleting the restored table does not delete the data in the source table.
103+
# [CLI](#tab/cli-2)
81104

82-
> [!NOTE]
83-
> Restored data is available as long as the underlying source data is available. When you delete the source table from the workspace or when the source table's retention period ends, the data is dismissed from the restored table. However, the empty table will remain if you do not delete it explicitly.
105+
To delete a restore table, run the [az monitor log-analytics workspace table delete](/cli/azure/monitor/log-analytics/workspace/table#az-monitor-log-analytics-workspace-table-delete) command.
106+
107+
For example:
84108

109+
```azurecli
110+
az monitor log-analytics workspace table delete --subscription ContosoSID --resource-group ContosoRG --workspace-name ContosoWorkspace \
111+
--name Heartbeat_RST
112+
```
113+
114+
---
85115
## Limitations
86116
Restore is subject to the following limitations.
87117

0 commit comments

Comments
 (0)