0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure VM診断設定でカスタムイベントログを追加する

Posted at

Azure VM(Windows Server)でWindowsイベントログを収集する方法として診断設定があります。
診断設定を利用することでWindowsイベントログをストレージアカウント(Azure Table Storage)に収集することができますが、デフォルトだとアプリケーション、セキュリティ、システムの3種類が対象となります。

上記3種類以外、具体的にはSetupイベントログを収集できないか試したので手順を残します。

診断設定を有効化する

  • 対象の仮想マシンを選択し、左メニューより[監視]→[診断設定]の順に選択します
    image.png

  • 収集するストレージアカウントを選択し[ゲストレベルの監視を有効にする]をクリックします
    image.png

  • しばらくすると仮想マシンにDiagnostics拡張機能がインストールされ、イベントログやパフォーマンスカウンターの収集が始まります(仮想マシンは起動状態である必要があります)

カスタムログを追加する

  • 診断設定画面より[ログ]を選択します
    image.png

  • デフォルトだと以下の状態になっており、アプリケーション、セキュリティ、システムが収集される設定となっています
    image.png

  • カスタムログ欄にSetup!*と入力し[追加]を選択します
    image.png

  • これでSetupの全てのレベルのログが収集されるようになりました

テスト

  • 最後にイベントログの書き込みを行い、収集されるかテストします
  • Windows ServerでPowerShellを管理者権限で開きます
  • 以下コマンドを実行しSetupイベントログにテストログを書き込みます
$EventSource = "TestSource"
$EventLog = "Setup"

# イベントソースが存在しない場合は作成
if (-not [System.Diagnostics.EventLog]::SourceExists($EventSource)) {
    New-EventLog -LogName $EventLog -Source $EventSource
}

# イベントを書き込む
Write-EventLog -LogName $EventLog -Source $EventSource -EntryType Information -EventId 1000 -Message "This is a test event for Setup log."
  • Storage Explorer等でTable Storageにアクセスし、テストログが収集されていることを確認します
  • 以下はAzure CLIでの確認例
az storage entity query --table-name WADWindowsEventLogsTable --account-name [Storage Account Name]

以上です

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?