Set-AzDiagnosticSetting
Sets the logs and metrics settings for the resource.
语法
OldSetDiagnosticSetting (默认值)
Set-AzDiagnosticSetting
-ResourceId <String>
[-Name <String>]
[-StorageAccountId <String>]
[-ServiceBusRuleId <String>]
[-EventHubName <String>]
[-EventHubAuthorizationRuleId <String>]
[-Enabled <Boolean>]
[-Category <System.Collections.Generic.List`1[System.String]>]
[-MetricCategory <System.Collections.Generic.List`1[System.String]>]
[-Timegrain <System.Collections.Generic.List`1[System.String]>]
[-RetentionEnabled <Boolean>]
[-WorkspaceId <String>]
[-ExportToResourceSpecific]
[-RetentionInDays <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
NewSetDiagnosticSetting
Set-AzDiagnosticSetting
-InputObject <PSServiceDiagnosticSettings>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
The Set-AzDiagnosticSetting cmdlet enables or disables each time grain and log category for the particular resource.
The logs and metrics are stored in the specified storage account.
This cmdlet implements the ShouldProcess pattern, i.e. it might request confirmation from the user before actually creating, modifying, or removing the resource.
示例
Example 1: Enable all metrics and logs for a resource
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True
This command enables all available metrics and logs for Resource01.
Example 2: Disable all metrics and logs
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $False
This command disables all available metrics and logs for the resource Resource01.
Example 3: Enable/disable multiple metrics categories
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $False -MetricCategory MetricCategory1,MetricCategory2
StorageAccountId : <storageAccountId>
StorageAccountName : <storageAccountName>
Metrics
Enabled : False
Category : MetricCategory1
Timegrain : PT1M
Enabled : False
Category : MetricCategory2
Timegrain : PT1H
Enabled : True
Category : MetricCategory3
Timegrain : PT1H
Logs
Enabled : True
Category : Category1
Enabled : True
Category : Category2
Enabled : True
Category : Category3
Enabled : False
Category : Category4
This command disables the metrics categories called Category1 and Category2.
All the other categories remain the same.
Example 4: Enable/disable multiple log categories
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Category Category1,Category2
StorageAccountId : <storageAccountId>
StorageAccountName : <storageAccountName>
Metrics
Enabled : False
Category : MetricCategory1
Timegrain : PT1M
Enabled : False
Category : MetricCategory2
Timegrain : PT1H
Enabled : True
Category : MetricCategory3
Timegrain : PT1H
Logs
Enabled : True
Category : Category1
Enabled : True
Category : Category2
Enabled : True
Category : Category3
Enabled : False
Category : Category4
This command enables Category1 and Category2.
All the other metrics and logs categories remain the same.
Example 4: Enable a time grain and multiple categories
PS C:\>Set-AzDiagnosticSetting -ResourceId "Resource01" -Enabled $True -Category Category1,Category2 -Timegrain PT1M
This command enables only Category1, Category2, and time grain PT1M.
All other time grains and categories are unchanged.
Example 5: Using pipeline
PS C:\>Get-AzDiagnosticSetting -ResourceId "Resource01" | Set-AzDiagnosticSetting -Enabled $True -Category Category1,Category2
This command uses the PowerShell pipeline to set (no change made) a diagnostic setting.
参数
-Category
Specifies the list of log categories to enable or disable, according to the value of Enabled .
If no category is specified, this command operates on all supported categories.
参数属性
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-Confirm
Prompts you for confirmation before running the cmdlet.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-Enabled
Indicates whether to enable diagnostics.
Specify $True to enable diagnostics, or $False to disable diagnostics.
参数属性
类型: Boolean
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-EventHubAuthorizationRuleId
The event hub authorization rule id
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-EventHubName
The event hub name
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-ExportToResourceSpecific
Flag indicating that the export to LA must be done to a resource specific table, a.k.a. dedicated or fixed schema table, as opposed to the default dynamic schema table called AzureDiagnostics .
This argument is effective only when the argument -workspaceId is also given.
参数属性
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
The input object (possible from the pipeline.) The name and resourceId will be extracted from this object.
NewSetDiagnosticSetting
Position: Named
必需: True
来自管道的值: True
来自管道的值(按属性名称): False
来自剩余参数的值: False
-MetricCategory
The list of metric categories.
If no category is specified, this command operates on all supported categories.
参数属性
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-Name
The name of the diagnostic setting. The default value is service .
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-ResourceId
Specifies the ID of the resource.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: True
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-RetentionEnabled
Indicates whether retention of diagnostic information is enabled.
参数属性
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-RetentionInDays
Specifies the retention policy, in days.
参数属性
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-ServiceBusRuleId
The Service Bus Rule id.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-StorageAccountId
Specifies the ID of the Storage account in which to save the data.
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-Timegrain
Specifies the time grains to enable or disable for metrics, according to the value of Enabled .
If you do not specify a time grain, this command operates on all available time grains.
参数属性
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
参数属性
参数集
(All)
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): False
来自剩余参数的值: False
-WorkspaceId
The resource Id of the Log Analytics workspace to send logs/metrics to
参数属性
类型: String
默认值: None
支持通配符: False
不显示: False
参数集
OldSetDiagnosticSetting
Position: Named
必需: False
来自管道的值: False
来自管道的值(按属性名称): True
来自剩余参数的值: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
输出