다음을 통해 공유


VHD 디스크 압축 사용량 및 성능 이해

Windows 이벤트 로그를 사용하여 VHD 디스크 압축이 사용되는 빈도, 저장된 공간 및 실행 시간을 이해할 수 있습니다. 다음은 이벤트를 해석하는 데 사용할 수 있는 몇 가지 샘플 PowerShell 스크립트 및 Azure Log Analytics 쿼리입니다.

PowerShell

VHD 디스크 압축 메트릭 스크립트

이 예제에서는 PowerShell을 사용하여 이전 30일 간의 VHD 디스크 압축 이벤트를 그리드 형식으로 가져옵니다. 관리자 권한 PowerShell 프롬프트에서 다음 코드 블록을 실행합니다.

# Set startTime to number of days to search the event logs
$startTime = (Get-Date).AddDays(-30)

# Query Event Log using Get-WinEvent filtered to the VHD Disk Compaction metric events
$diskCompactionEvents = Get-WinEvent -FilterHashtable @{
    StartTime       = $startTime
    ProviderName    = 'Microsoft-FSLogix-Apps'
    ID         = 57
}

# Format event properties
$compactionMetrics = $diskCompactionEvents | Select-Object `
    @{l="Timestamp";e={$_.TimeCreated}},`
    @{l="ComputerName";e={$_.MachineName}},`
    @{l="Path";e={$_.Properties[0].Value}},`
    @{l="WasCompacted";e={$_.Properties[1].Value}},`
    @{l="TimeSpent(sec)";e={[math]::round($_.Properties[7].Value / 1000,2)}},`
    @{l="MaxSize(GB)";e={[math]::round($_.Properties[2].Value / 1024,2)}},`
    @{l="MinSize(GB)";e={[math]::round($_.Properties[3].Value / 1024,2)}},`
    @{l="InitialSize(GB)";e={[math]::round($_.Properties[4].Value / 1024,2)}},`
    @{l="FinalSize(GB)";e={[math]::round($_.Properties[5].Value / 1024,2)}},`
    @{l="SavedSpace(GB)";e={[math]::round($_.Properties[6].Value / 1024,2)}}

# Display metrics in Out-GridView
$compactionMetrics | Out-GridView

Azure Log Analytics 쿼리

Important

아래 쿼리를 사용하려면 먼저 이벤트 로그를 Log Analytics 작업 영역으로 보내도록 가상 머신을 구성해야 합니다. 자세한 내용은 Log Analytics 에이전트를 사용하여 Windows 이벤트 로그 데이터 원본 수집을 참조하세요. VHD 디스크 압축에 사용되는 로그는 다음과 같습니다.

  • Microsoft-FSLogix-Apps/Operational
  • Microsoft-FSLogix-Apps/관리

VHD 디스크 압축 메트릭 쿼리

VHD 디스크 압축 작업 중 소요된 시간

압축 작업 중에 소요된 평균, 최소 및 최대 시간을 표시합니다. 데이터는 디스크를 압축할 수 있었는지에 따라 요약됩니다.

Event
| where EventLog == 'Microsoft-FSLogix-Apps/Operational' and EventID == 57
| parse kind=relaxed EventData with *
    "<Data Name=\"Path\">" Path
    "</Data><Data Name=\"WasCompacted\">" DiskCompaction
    "</Data><Data Name=\"MaxSupportedSizeMB\">" MaxSupportedSizeMB
    "</Data><Data Name=\"MinSupportedSizeMB\">" MinSupportedSizeMB
    "</Data><Data Name=\"SizeBeforeMB\">" SizeBeforeMB
    "</Data><Data Name=\"SizeAfterMB\">" SizeAfterMB
    "</Data><Data Name=\"SavedSpaceMB\">" SavedSpaceMB
    "</Data><Data Name=\"TimeSpentMillis\">" TimeSpentMillis "</Data>" *
| extend TimeSpent = todecimal(TimeSpentMillis) / 1024
| where DiskCompaction <> ""
| summarize Average=round(avg(TimeSpent),2), Max=round(max(TimeSpent),2), Min=round(min(TimeSpent),2) by DiskCompaction

출력 예는 다음과 같습니다.

A bar chart showing the result of running the Time Spent query

압축된 컨테이너 VHD(x) 파일 수

임계값에 따라 압축을 위해 선택한 컨테이너 VHD(x) 파일 수를 표시합니다.

Event
| where EventLog == 'Microsoft-FSLogix-Apps/Operational' and EventID == 57
| parse kind=relaxed EventData with *
    "<Data Name=\"Path\">" Path
    "</Data><Data Name=\"WasCompacted\">" DiskCompaction
    "</Data><Data Name=\"MaxSupportedSizeMB\">" MaxSupportedSizeMB
    "</Data><Data Name=\"MinSupportedSizeMB\">" MinSupportedSizeMB
    "</Data><Data Name=\"SizeBeforeMB\">" SizeBeforeMB
    "</Data><Data Name=\"SizeAfterMB\">" SizeAfterMB
    "</Data><Data Name=\"SavedSpaceMB\">" SavedSpaceMB
    "</Data><Data Name=\"TimeSpentMillis\">" TimeSpentMillis "</Data>" *
| where DiskCompaction <> ""
| summarize NumberOfVhdContainers=count() by DiskCompaction

출력 예는 다음과 같습니다.

A pie chart showing the number of V H D files (containers) compacted

저장된 총 스토리지 공간

VHD 디스크 압축 작업 중에 회수된 스토리지 크기(GB)를 표시합니다.

Event
| where EventLog == 'Microsoft-FSLogix-Apps/Operational' and EventID == 57
| parse kind=relaxed EventData with *
    "<Data Name=\"Path\">" Path
    "</Data><Data Name=\"WasCompacted\">" DiskCompaction
    "</Data><Data Name=\"MaxSupportedSizeMB\">" MaxSupportedSizeMB
    "</Data><Data Name=\"MinSupportedSizeMB\">" MinSupportedSizeMB
    "</Data><Data Name=\"SizeBeforeMB\">" SizeBeforeMB
    "</Data><Data Name=\"SizeAfterMB\">" SizeAfterMB
    "</Data><Data Name=\"SavedSpaceMB\">" SavedSpaceMB
    "</Data><Data Name=\"TimeSpentMillis\">" TimeSpentMillis "</Data>" *
| extend Storage = todecimal(SavedSpaceMB)
| summarize StorageSavings = (format_bytes(sum(Storage * 1024 * 1024),2,"GB"))

Winlogon(로그아웃) 지연 경고

60초 임계값을 초과하는 모든 서비스를 Winlogon 표시합니다. 평균 및 최대 소요 시간과 함께 발생 횟수를 표시합니다.

Event
| where Source == 'Microsoft-Windows-Winlogon' and EventID == 6006
| parse kind=relaxed ParameterXml with "<Param>" ServiceName "</Param><Param>" Duration "</Param><Param>" EventType "</Param><Param>-</Param>"
| extend TimeInSeconds = todecimal(Duration)
| where EventType == "Logoff"
| summarize Occurrences=count(),Average=round(avg(TimeInSeconds),2), Minimum=round(min(TimeInSeconds),2), Maximum=round(max(TimeInSeconds),2) by ServiceName

출력 예는 다음과 같습니다.

A table showing the services which exceeded the Winlogon threshold