有没有办法从命令行在 Azure Log Analytics 中添加性能计数器

Is there a way to add performance counter in Azure Log Analytics from command line

有没有办法使用 Powershell 或 azure CLI 在 Azure Log Analytics 中添加性能计数器。我看到的唯一选项是查询。

根据我的研究,我们可以使用 PowerShell 命令 new-azoperationalinsightswindowsperformancecounterdatasource 添加 windows 性能计数器。详情请参考document。 例如

Connect-AzAccount
$workspace=Get-AzOperationalInsightsWorkspace -ResourceGroupName jimtest -Name hybridWorkspace32979
New-AzOperationalInsightsWindowsPerformanceCounterDataSource -Workspace $workspace -Name "test" -ObjectName ".NET CLR Loading" -CounterName "Total Appdomains" -InstanceName "*" -IntervalSeconds 10
Get-AzOperationalInsightsDataSource -ResourceGroupName jimtest -WorkspaceName hybridWorkspace32979 -Kind WindowsPerformanceCounter

此外,如果要添加Linux性能计数器,可以使用命令New-AzOperationalInsightsLinuxPerformanceObjectDataSourceEnable-AzOperationalInsightsLinuxPerformanceCollection。详情请参考article