2017-04-12 25 views
0

我是新來的grok。 我想用grok解析器解析Microsoft active directory logs。 我正在使用java grok庫。使用grok進行Active Directory日誌解析很慢

日誌看起來像

<13> 10.200.3.7 10.20.211.15 07/04/2017 15:34:00 PM SERVER01 07/04/2017 15:34:00 PM LogName=Security SourceName=Microsoft Windows security auditing. EventCode=4624 EventType=0 Type=Information ComputerName=SERVER01.network.local TaskCategory=Logon OpCode=Info RecordNumber=1809490942 Keywords=Audit Success Message=An account was successfully logged on.  Subject:  Security ID:  S-1-0-0  Account Name:  User-330 Account Domain:  -  Logon ID:  0x0  Logon Type:   3  New Logon:  Security ID:  S-1-5-18 Account Name:  SERVER01$  Account Domain:  DOMAIN  Logon ID:  0x12393ab39  Logon GUID:  \{C893D0A2-6498-BBE3-560D-0A1088FA4D9E\}  Process Information:  Process ID:  0x0  Process Name:  -  Network Information:  Workstation Name:  Source Network Address: 1.68.4.213  Source Port:  57261  Detailed Authentication Information:  Logon Process:  Kerberos Authentication Package: Kerberos Transited Services: -  Package Name (NTLM only): -  Key Length:  0  This event is generated when a logon session is created. It is generated on the computer that was accessed.  The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.  The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network).  The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on.  The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.  The authentication information fields provide detailed information about this specific logon request.  - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event.  - Transited services indicate which intermediate services have participated in this logon request.  - Package name\ 
<13> 10.200.3.7 10.20.211.15 07/04/2017 15:34:00 PM SERVER01 07/04/2017 15:34:00 PM LogName=Security SourceName=Microsoft Windows security auditing. EventCode=4624 EventType=0 Type=Information ComputerName=SERVER01.network.local TaskCategory=Logon OpCode=Info RecordNumber=1809490942 Keywords=Audit Success Message=An account was successfully logged on.  Subject:  Security ID:  S-1-0-0  Account Name:  User-331 Account Domain:  -  Logon ID:  0x0  Logon Type:   3  New Logon:  Security ID:  S-1-5-18 Account Name:  SERVER01$  Account Domain:  DOMAIN  Logon ID:  0x12393ab39  Logon GUID:  \{C893D0A2-6498-BBE3-560D-0A1088FA4D9E\}  Process Information:  Process ID:  0x0  Process Name:  -  Network Information:  Workstation Name:  Source Network Address: 1.68.4.214  Source Port:  57261  Detailed Authentication Information:  Logon Process:  Kerberos Authentication Package: Kerberos Transited Services: -  Package Name (NTLM only): -  Key Length:  0  This event is generated when a logon session is created. It is generated on the computer that was accessed.  The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.  The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network).  The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on.  The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.  The authentication information fields provide detailed information about this specific logon request.  - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event.  - Transited services indicate which intermediate services have participated in this logon request.  - Package name\ 

我神交模式

\<%{USER:hField1}\> %{IPV4:hIp1} %{IPV4:hIp2} %{DATESTAMP_12HOUR:hTime1;date;dd/MM/yyyy hh:mm:ss a} %{USER:hField2} %{DATESTAMP_12HOUR:hTime2;date;dd/MM/yyyy hh:mm:ss a} LogName=%{USER:logname}%{SPACE}SourceName=%{GREEDYDATA:sourceName}%{SPACE}EventCode=%{GREEDYDATA:eventCode}%{SPACE}EventType=%{GREEDYDATA:eventType}%{SPACE}Type=%{GREEDYDATA:typeField}%{SPACE} ComputerName=%{GREEDYDATA:computerName}%{SPACE}TaskCategory=%{GREEDYDATA:taskCategory}%{SPACE}OpCode=%{GREEDYDATA:opCode}%{SPACE}RecordNumber=%{GREEDYDATA:recordNumber}%{SPACE}Keywords=%{GREEDYDATA:keywords}%{SPACE}Message=%{NON_DOT_DELIMITER:message}.%{SPACE}%{GREEDYDATA:jsonData} 

的問題是,它是相對於我的自定義Java解析器非常緩慢。 我的自定義Java解析器需要2.5秒來解析50K記錄,而使用grok模式解析時需要60秒來處理相同的數據。

解析器有問題嗎?

+0

您是否使用相同的RegEx模式來搜索兩者? –

+0

我共享的樣本日誌包含兩條記錄,我正在按照記錄申請grok。 – banjara

回答

0

與任何正則表達式一樣,當正則表達式解釋器不得不猜測較少時,您將獲得加速。所以當你在grok模式周圍使用錨點^(行首)和$(行尾)時,你可能會獲得很好的收益。