LaMirek
LaMirek

Reputation: 43

How can I search log files for lines containing two specific words?

Hope someone can figure this one.

I've few log files (500 000 lines in total) that I need to search for specific words contained in a single line. The log files look something like this:

08/06/15 13:50:11 (WARN) [thread-132] \\172.22.17.126\\root\cimv2?SCAGNT\admin; class=Win32_PerfRawData_W3SVC_WebService; property=TotalGetRequests; Name="_Total"; queryId=929775; Timeout in queue after 34 sec

08/06/15 13:50:11 (WARN) [thread-136] \\\\172.22.17.14\LogicalDisk(HarddiskVolume1)\% Disk Read Time\?SCAGNT\admin; class=; property=; ; queryId=929779; Timeout in queue after 34 sec

08/06/15 13:50:11 (WARN) [thread-142] \\172.22.5.42\\root\cimv2?scagnt\administrator; class=Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases; property=ActiveTransactions; Name="RTP2016"; queryId=929785; Timeout in queue after 34 sec

08/06/15 13:50:11 (WARN) [thread-146] \\172.22.17.129\\root\cimv2?SCAGNT\admin; class=Win32_PerfRawData_MSSQLSERVER_SQLServerLocks; property=LockRequestsPersec; Name="Extent"; queryId=929789; Timeout in queue after 34 sec

08/06/15 13:50:11 (WARN) [thread-152] \\172.22.17.126\\root\cimv2?SCAGNT\admin; class=Win32_PerfRawData_W3SVC_WebService; property=CurrentAnonymousUsers; Name="_Total"; queryId=929796; Timeout in queue after 34 sec

08/06/15 13:50:11 (WARN) [thread-158] \\\\172.22.17.14\LogicalDisk(C:)\% Disk Read Time\?SCAGNT\admin; class=; property=; ; queryId=929802; Timeout in queue after 34 sec

08/06/15 13:50:11 (WARN) [thread-166] \\\\64.79.135.145\LogicalDisk(HarddiskVolume1)\Split IO/Sec\?SCAGNT\admin; class=; property=; ; queryId=929810; Timeout in queue after 34 sec

I need to find all lines that contain eg. "172.22.17.126" AND "Timeout in queue" - just need to see how many times a timeout has occurred for the 172.22.17.126 device

I'm trying to use Notepad++'s regular expressions, but just can't figure out that should the query look like.

Anyone?

Upvotes: 0

Views: 230

Answers (2)

Lars Fischer
Lars Fischer

Reputation: 10179

There is a plugin called linefilter2 which I like to use for things like that:

  1. you would enter "172.22.17.126" in the dialog and the plugin creates a second file with the lines that have only the ip address
  2. then you would use the plugin again on the second file and filter for "Timeout in queue"

The plugin allows to use regex, to invert the matching and many more options: LineFilter2 settings

You end up with a file that contains the desired lines. In many cases that is easier than working with the Search Result Window.

Upvotes: 0

dimitrisli
dimitrisli

Reputation: 21401

You can use Regular expression: ^.*172\.22\.17\.126.*Timeout in queue.*$

enter image description here

Upvotes: 1

Related Questions