トップ回答者
イベントビューアーフィルタについて

質問
-
イベントビューアーのフィルタ機能を使って特定のイベントIDを除外して表示させたいのですが、除外設定すると「指定されたクエリは無効です」となります。
原因が分からず、困っております。
詳細
OS:Windows server 2012、2012 R2 の2OS
イベントビューアーフィルタ設定にて
・ログの日付:過去12時間
・イベントレベル:重大、警告、エラー
・イベントログ:システム
・イベントID除外:30個
・他設定:デフォルト
除外するイベントIDを10個ほどにするとエラーなくログが見れるのですが30個ほど設定すると上記の「クエリが無効」となりログが見れません。
また、上記の解決が難しい場合、コマンドの「wevtutil」で指定するイベントIDの除外方法をご教示頂きたく、よろしくお願いいたします。
回答
-
Consuming Events (Windows Event Log) - Win32 apps | Microsoft Docs
には、
If the XPath expression is a compound expression that contains more than 20 expressions or you are querying for events from multiple sources, then you must use a structured XML query.と書かれていますので、XPathのフィルタ式には20以上の式を含むことはできないようです。
以下のようなXMLファイルによる構造化クエリを利用してみて下さい。このようにSuppress要素に除外したいイベントIDを指定したフィルタ式を、一つずつ記述するやり方でいけそうです。
<QueryList> <Query Id="0" Path="System"> <Select Path="System">*[System[(Level=1 or Level=2 or Level=3) and TimeCreated[timediff(@SystemTime) <= 43200000]]]</Select> <Suppress Path="System">*[System[(EventID=1)]]</Suppress> <Suppress Path="System">*[System[(EventID=2)]]</Suppress> <Suppress Path="System">*[System[(EventID=3)]]</Suppress> <Suppress Path="System">*[System[(EventID=4)]]</Suppress> </Query> </QueryList>
上記XMLをquery.xmlとして保存し、wevtutilを以下のように実行します。
wevtutil export-log query.xml output.evtx /sq:true
- 編集済み 牟田口大介Moderator 2021年2月26日 0:02
- 回答としてマーク shin99 2021年2月26日 0:42
すべての返信
-
Consuming Events (Windows Event Log) - Win32 apps | Microsoft Docs
には、
If the XPath expression is a compound expression that contains more than 20 expressions or you are querying for events from multiple sources, then you must use a structured XML query.と書かれていますので、XPathのフィルタ式には20以上の式を含むことはできないようです。
以下のようなXMLファイルによる構造化クエリを利用してみて下さい。このようにSuppress要素に除外したいイベントIDを指定したフィルタ式を、一つずつ記述するやり方でいけそうです。
<QueryList> <Query Id="0" Path="System"> <Select Path="System">*[System[(Level=1 or Level=2 or Level=3) and TimeCreated[timediff(@SystemTime) <= 43200000]]]</Select> <Suppress Path="System">*[System[(EventID=1)]]</Suppress> <Suppress Path="System">*[System[(EventID=2)]]</Suppress> <Suppress Path="System">*[System[(EventID=3)]]</Suppress> <Suppress Path="System">*[System[(EventID=4)]]</Suppress> </Query> </QueryList>
上記XMLをquery.xmlとして保存し、wevtutilを以下のように実行します。
wevtutil export-log query.xml output.evtx /sq:true
- 編集済み 牟田口大介Moderator 2021年2月26日 0:02
- 回答としてマーク shin99 2021年2月26日 0:42