使用特权终结点 (PEP) 将 Azure Stack Hub 诊断日志发送到 AzureSend Azure Stack Hub diagnostic logs to Azure using the privileged endpoint (PEP)

使用此方法时,无需提供任何目标存储位置。You do not have to provide any target storage location when using this method. 如果未提供 fromDate 和 toDate 参数,则默认为从执行时间开始持续 4 个小时 。If fromDate and toDate parameters are not provided, then it defaults to last 4 hours from the time of execution.

你可以选择指定 FilterByRole 或 FilterByResourceProvider 参数,以仅包括特定的角色或增值 RP 日志 。You can optionally specify FilterByRole or FilterByResourceProvider parameter to include only specific role or value-add RP logs.

下面是一个可以通过 PEP 来运行的示例脚本,用于在集成系统上收集日志。Here's an example script you can run using the PEP to collect logs on an integrated system.

$ipAddress = "<IP ADDRESS OF THE PEP VM>" # You can also use the machine name instead of IP address. 
 
$password = ConvertTo-SecureString "<CLOUD ADMIN PASSWORD>" -AsPlainText -Force 
$cred = New-Object -TypeName System.Management.Automation.PSCredential ("<DOMAIN NAME>\CloudAdmin", $password) 
 
$session = New-PSSession -ComputerName $ipAddress -ConfigurationName PrivilegedEndpoint -Credential $cred 
 
$fromDate = (Get-Date).AddHours(-8) # Optional. 
$toDate = (Get-Date).AddHours(-2) # Optional. Provide the time that includes the period for your issue 
 
Invoke-Command -Session $session {Send-AzureStackDiagnosticLog -FromDate $using:fromDate -ToDate $using:toDate} 
 
if ($session) { 
    Remove-PSSession -Session $session 
} 

参数注意事项Parameter considerations

  • 可以使用 FromDateToDate 参数来收集特定时间段的日志。The FromDate and ToDate parameters can be used to collect logs for a particular time period. 如果未指定这些参数,则默认收集过去四小时的日志。If these parameters aren't specified, logs are collected for the past four hours by default.

  • 使用 FilterByNode 参数按计算机名筛选日志。Use the FilterByNode parameter to filter logs by computer name. 例如:For example:

    Send-AzureStackDiagnosticLog -FilterByNode azs-xrp01
    
  • 使用 FilterByLogType 参数按类型筛选日志。Use the FilterByLogType parameter to filter logs by type. 可以选择按文件、共享或 WindowsEvent 进行筛选。You can choose to filter by File, Share, or WindowsEvent. 例如:For example:

    Send-AzureStackDiagnosticLog -FilterByLogType File
    
  • 使用 FilterByResourceProvider 参数为增值资源提供程序 (RP) 发送诊断日志。Use the FilterByResourceProvider parameter to send diagnostic logs for value-add Resource Providers (RPs). 常规语法为:The general syntax is:

    Send-AzureStackDiagnosticLog -FilterByResourceProvider <<value-add RP name>>
    

    为 IoT 中心发送诊断日志:To send diagnostic logs for IoT Hub:

    Send-AzureStackDiagnosticLog -FilterByResourceProvider IotHub
    

    为事件中心发送诊断日志:To send diagnostic logs for Event Hubs:

    Send-AzureStackDiagnosticLog -FilterByResourceProvider eventhub
    

    为 Azure Stack Edge 发送诊断日志:To send diagnostic logs for Azure Stack Edge:

    Send-AzureStackDiagnosticLog -FilterByResourceProvide databoxedge
    
  • 使用 FilterByRole 参数从 VirtualMachines 和 BareMetal 角色发送诊断日志:Use the FilterByRole parameter to send diagnostic logs from VirtualMachines and BareMetal roles:

    Send-AzureStackDiagnosticLog -FilterByRole VirtualMachines,BareMetal
    
  • 从 VirtualMachines 和 BareMetal 角色发送诊断日志,通过日期筛选功能筛选出过去 8 小时的日志文件:To send diagnostic logs from VirtualMachines and BareMetal roles, with date filtering for log files for the past 8 hours:

    Send-AzureStackDiagnosticLog -FilterByRole VirtualMachines,BareMetal -FromDate (Get-Date).AddHours(-8)
    
  • 从 VirtualMachines 和 BareMetal 角色发送诊断日志,通过日期筛选功能筛选出 8 小时前到 2 小时前这个时间段的日志文件:To send diagnostic logs from VirtualMachines and BareMetal roles, with date filtering for log files for the time period between 8 hours ago and 2 hours ago:

    Send-AzureStackDiagnosticLog -FilterByRole VirtualMachines,BareMetal -FromDate (Get-Date).AddHours(-8) -ToDate (Get-Date).AddHours(-2)
    

后续步骤Next steps

使用特权终结点 (PEP) 发送 Azure Stack Hub 诊断日志Use the privileged endpoint (PEP) to send Azure Stack Hub diagnostic logs