{"id":309,"date":"2017-10-17T11:03:56","date_gmt":"2017-10-17T11:03:56","guid":{"rendered":"http:\/\/eventlogxp.com\/blog\/?p=309"},"modified":"2017-10-17T11:06:21","modified_gmt":"2017-10-17T11:06:21","slug":"the-fastest-way-to-filter-events-by-description","status":"publish","type":"post","link":"https:\/\/eventlogxp.com\/blog\/the-fastest-way-to-filter-events-by-description\/","title":{"rendered":"The fastest way to filter events by description"},"content":{"rendered":"<p>Filtering events by description is one of the most asked questions to us. Some time ago I wrote an <a href=\"http:\/\/eventlogxp.com\/blog\/advanced-filtering-how-to-filter-events-by-event-descriptions\/\">article<\/a> devoted to this problem.<\/p>\n<p>Recently we had to check all events in the security log linked with a certain file (let&#8217;s say, it&#8217;s winword.exe, C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE). The easiest solution was to use Filter command and type file name in the &#8220;Text in description&#8221; line.<\/p>\n<p><a href=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/SimpleFilter.png\" data-rel=\"lightbox-gallery-ysqvx6Aa\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-310\" src=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/SimpleFilter-300x65.png\" alt=\"Filter by description\" width=\"300\" height=\"65\" srcset=\"https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/SimpleFilter-300x65.png 300w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/SimpleFilter-768x166.png 768w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/SimpleFilter-660x143.png 660w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/SimpleFilter.png 875w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Commonly this works fine, but it scans all records in the log, forms event description for each event and looks for this phrase in the description. Forming event descriptions may require loading extra modules from the target computer (or a computer you designated as a description server) to load the description template. And although Event Log Explorer caches and reuses description templates, such filtering may take long time on large logs.<\/p>\n<p>As a rule, security log stores file names, process names and other details in separate XML elements under \u00a0EventData and all these elements are named &#8220;Data&#8221;.<\/p>\n<p><a href=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLRecord.png\" data-rel=\"lightbox-gallery-ysqvx6Aa\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-311\" src=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLRecord-300x262.png\" alt=\"XML Record\" width=\"300\" height=\"262\" srcset=\"https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLRecord-300x262.png 300w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLRecord-660x576.png 660w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLRecord.png 695w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>So, we can make an XPath query to a log which compares each Data element with our search string. This query will look like:<\/p>\n<pre>*[EventData[Data=\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]]<\/pre>\n<p>To apply this filter, open Security event log, select View-&gt;XML Query, type your XPath expression and click OK.<\/p>\n<p><a href=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XPathQueryDataFilter.png\" data-rel=\"lightbox-gallery-ysqvx6Aa\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-312\" src=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XPathQueryDataFilter-300x238.png\" alt=\"XPath Query Data Filter\" width=\"300\" height=\"238\" srcset=\"https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XPathQueryDataFilter-300x238.png 300w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XPathQueryDataFilter-660x524.png 660w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XPathQueryDataFilter.png 664w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>It executes swiftly and doesn&#8217;t load network when connecting a remote computer.<\/p>\n<p>But what about the other logs? Many Windows events doesn&#8217;t have EventData element, but have UserData (some events have DebugData, BinaryEventData, or ProcessingErrorData instead). UserData commonly has an extra level of XML elements, so to query event by UserData, we should use the following XPath request:<\/p>\n<pre>*[UserData[*[*=\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]]]<\/pre>\n<p>And what if you want to check for the same file name in several logs, e.g. in Security, System and Application logs? It can be also done with one XML query:<\/p>\n<pre>&lt;QueryList&gt;\r\n  &lt;Query Id=\"0\"&gt;\r\n    &lt;Select Path=\"Security\"&gt;*[EventData[Data=\r\n\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]] or \r\n    *[UserData[*[*=\r\n\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]]]\r\n    &lt;\/Select&gt;\r\n\r\n    &lt;Select Path=\"System\"&gt;*[EventData[Data=\r\n\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]] or \r\n    *[UserData[*[*=\r\n\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]]]\r\n    &lt;\/Select&gt;\r\n\r\n    &lt;Select Path=\"Application\"&gt;*[EventData[Data=\r\n\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]] or \r\n    *[UserData[*[*=\r\n\"C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE\"]]]\r\n    &lt;\/Select&gt;\r\n  &lt;\/Query&gt;\r\n&lt;\/QueryList&gt;<\/pre>\n<p>Here is the result of this query on my machine:<\/p>\n<p><a href=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLEventQueryWinwordResult.png\" data-rel=\"lightbox-gallery-ysqvx6Aa\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-313\" src=\"http:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLEventQueryWinwordResult-300x126.png\" alt=\"XML Query result (3 logs)\" width=\"300\" height=\"126\" srcset=\"https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLEventQueryWinwordResult-300x126.png 300w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLEventQueryWinwordResult-660x277.png 660w, https:\/\/eventlogxp.com\/blog\/wp-content\/uploads\/2017\/10\/XMLEventQueryWinwordResult.png 701w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h4>Advantages of this method<\/h4>\n<p>Such XML query provides great performance and works not only with Event Log Explorer, but with Windows Event Viewer or other event log programs which support XML queries.<\/p>\n<p>Some applications and services logs don&#8217;t display all the information about event in the description, but still store their details under UserData or EventData elements (I described one of such logs in <a href=\"http:\/\/eventlogxp.com\/blog\/windows-boot-performance-diagnostics-1\/\">this article<\/a>). So, filtering by description won&#8217;t work for such events,\u00a0 but the XPath queries will.<\/p>\n<h4>Limitations<\/h4>\n<p>Although this approach lets you filter quickly by description details, it is limited by XPath 1.0 implementation for event logs. E.g. you can use only 3 functions: &#8220;position&#8221;, &#8220;Band&#8221; (binary and) and &#8220;timediff&#8221;. Function &#8220;contains&#8221; is not supported, so it&#8217;s impossible to filter just by filename (winword.exe). If you need to filter just by file name, you should use general filter by description.<\/p>\n<p>Can we do something to bypass these limitations? I think so. Filtering by description parameters during log loading stage (and without forming descriptions) should work faster than general filter by description and it will be more flexible than Xpath. But it would be really great if Microsoft extends XPath functionality for event logs.<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309&#038;t=The%20fastest%20way%20to%20filter%20events%20by%20description&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309&#038;p&#091;images&#093;&#091;0&#093;=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-content%2Fuploads%2F2017%2F10%2Fcheetah.jpg&#038;p&#091;title&#093;=The%20fastest%20way%20to%20filter%20events%20by%20description\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none\" src=\"https:\/\/eventlogxp.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309&#038;text=Check%20this%20Event%20Log%20Explorer%20blog%20post\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none\" src=\"https:\/\/eventlogxp.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-reddit nolightbox\" data-provider=\"reddit\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Reddit\" href=\"https:\/\/www.reddit.com\/submit?url=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309&#038;title=The%20fastest%20way%20to%20filter%20events%20by%20description\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img alt=\"reddit\" title=\"Share on Reddit\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none\" src=\"https:\/\/eventlogxp.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/reddit.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-pinterest nolightbox\" data-provider=\"pinterest\" target=\"_blank\" rel=\"nofollow\" title=\"Pin it with Pinterest\" href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309&#038;media=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-content%2Fuploads%2F2017%2F10%2Fcheetah.jpg&#038;description=The%20fastest%20way%20to%20filter%20events%20by%20description\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img alt=\"pinterest\" title=\"Pin it with Pinterest\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none\" src=\"https:\/\/eventlogxp.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/pinterest.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309&#038;title=The%20fastest%20way%20to%20filter%20events%20by%20description\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none\" src=\"https:\/\/eventlogxp.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=The%20fastest%20way%20to%20filter%20events%20by%20description&#038;body=Check%20this%20Event%20Log%20Explorer%20blog%20post:%20https%3A%2F%2Feventlogxp.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F309\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none\" src=\"https:\/\/eventlogxp.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>Filtering events by description is one of the most asked questions to us. Some time ago I wrote an article devoted to this problem. Recently we had to check all events in the security log linked with a certain file (let&#8217;s say, it&#8217;s winword.exe, C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE). The easiest solution was to use Filter command and type file name in the &#8220;Text in description&#8221;\u2026 <span class=\"read-more\"><a href=\"https:\/\/eventlogxp.com\/blog\/the-fastest-way-to-filter-events-by-description\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":315,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[19,34,35],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/posts\/309"}],"collection":[{"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/comments?post=309"}],"version-history":[{"count":6,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/posts\/309\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/posts\/309\/revisions\/320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/media\/315"}],"wp:attachment":[{"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/media?parent=309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/categories?post=309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eventlogxp.com\/blog\/wp-json\/wp\/v2\/tags?post=309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}