Windows 8.1, Windows Server 2012 R2 에서는 이전 포스트의 컨피그로 구동했을 시에
아래와 같은 에러 메시지와 함께 로그 전달이 실패할 수 있다.
"ERROR Couldn't read next event, corrupted eventlog?;"
이럴 시에는 아래와 같이 Input의 Query 구문을 추가하여 NXLog 로 읽어 올 Windows Eventlog의 항목을 지정해주어야 한다.
아래 Query 구문의 Path 는 윈도우 이벤트 로그의 <Channel> 항목의 값이며, <Channel> 항목의 정확한 값을 확인하기 위해서는 이벤트 로그의 XML RAW 데이터를 확인하면 된다.
-------- nxlog.conf
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension gelf>
Module xm_gelf
</Extension>
<Input in>
Module im_msvistalog
ReadFromLast FALSE
SavePos FALSE
Query <QueryList>\
<Query Id="0">\
<Select Path="Application">*</Select>\
<Select Path="System">*</Select>\
<Select Path="Security">*</Select>\
<Select Path="Setup">*</Select>\
<Select Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational">*</Select>\
</Query>\
</QueryList>
</Input>
<Output out>
Module om_udp
Host log.wign21.net
Port 5415
OutputType GELF
</Output>
<Route 1>
Path in => out
</Route>
2016년 9월 27일 화요일
2016년 9월 26일 월요일
GrayLog 사용하기 - NXLog Setup (2)
IIS 웹 로그와 이벤트 로그를 한꺼번에 GrayLog 로 보내는 NXLog 설정을 알아보자.
아래 설정 시 주의할 점은 IIS 웹 로그의 포멧을 맞추는 것이다.
---- nxlog.conf
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension gelf>
Module xm_gelf
</Extension>
<Extension fileop>
Module xm_fileop
</Extension>
<Extension json>
Module xm_json
</Extension>
# Create the parse rule for IIS logs. You can copy these from the header of the IIS log file.
<Extension w3c>
Module xm_csv
Fields $date, $time, $s-ip, $cs-method, $cs-uri-stem, $cs-uri-query, $s-port, $cs-username, $c-ip, $csUser-Agent, $cs-Referer, $sc-status, $sc-substatus, $sc-win32-status, $time-taken
FieldTypes string, string, string, string, string, string, integer, string, string, string, string, integer, integer, integer, integer
Delimiter ' '
QuoteChar '"'
EscapeControl FALSE
UndefValue -
</Extension>
<Input iis>
Module im_file
File "C:\\inetpub\\logs\\LogFiles\\W3SVC1\\u_ex*"
SavePos TRUE
Exec if $raw_event =~ /^#/ drop(); \
else \
{ \
w3c->parse_csv(); \
$EventTime = parsedate($date + " " + $time); \
$EventTime = strftime($EventTime, "%Y-%m-%dT%H:%M:%SZ"); \
$SourceName = "IIS"; \
$Message = to_json(); \
}
</Input>
<Input eventlog>
Module im_msvistalog
</Input>
<Output graylog>
Module om_udp
Host log.wign21.net
Port 5415
OutputType GELF
#Use the following line for debugging (uncomment the fileop extension above as well)
Exec file_write("C:\\Program Files (x86)\\nxlog\\data\\nxlog_output.log", $raw_event);
</Output>
<Route eventlog>
Path eventlog => graylog
</Route>
<Route iis-to-graylog>
Path iis => graylog
</Route>
아래 설정 시 주의할 점은 IIS 웹 로그의 포멧을 맞추는 것이다.
---- nxlog.conf
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension gelf>
Module xm_gelf
</Extension>
<Extension fileop>
Module xm_fileop
</Extension>
<Extension json>
Module xm_json
</Extension>
# Create the parse rule for IIS logs. You can copy these from the header of the IIS log file.
<Extension w3c>
Module xm_csv
Fields $date, $time, $s-ip, $cs-method, $cs-uri-stem, $cs-uri-query, $s-port, $cs-username, $c-ip, $csUser-Agent, $cs-Referer, $sc-status, $sc-substatus, $sc-win32-status, $time-taken
FieldTypes string, string, string, string, string, string, integer, string, string, string, string, integer, integer, integer, integer
Delimiter ' '
QuoteChar '"'
EscapeControl FALSE
UndefValue -
</Extension>
<Input iis>
Module im_file
File "C:\\inetpub\\logs\\LogFiles\\W3SVC1\\u_ex*"
SavePos TRUE
Exec if $raw_event =~ /^#/ drop(); \
else \
{ \
w3c->parse_csv(); \
$EventTime = parsedate($date + " " + $time); \
$EventTime = strftime($EventTime, "%Y-%m-%dT%H:%M:%SZ"); \
$SourceName = "IIS"; \
$Message = to_json(); \
}
</Input>
<Input eventlog>
Module im_msvistalog
</Input>
<Output graylog>
Module om_udp
Host log.wign21.net
Port 5415
OutputType GELF
#Use the following line for debugging (uncomment the fileop extension above as well)
Exec file_write("C:\\Program Files (x86)\\nxlog\\data\\nxlog_output.log", $raw_event);
</Output>
<Route eventlog>
Path eventlog => graylog
</Route>
<Route iis-to-graylog>
Path iis => graylog
</Route>
GrayLog 사용하기 - NXLog Setup (1)
윈도우 서버의 이벤트 로그를 수집하여 GrayLog 서버로 보내기 위해 NXLog 를 사용해보자.
먼저 NXLog 의 설치 파일 다운로드를 위해 NXLog 홈페이지로 이동하자.
http://nxlog-ce.sourceforge.net/
페이지 상단의 Download 메뉴로 이동하면 각 OS 플랫폼에 맞는 다운로드 패키지가 제공되는 다운로드용 미러 사이트로 이동하는 링크가 있다.
우리는 윈도우 서버에 NXLog를 설치할 예정이기 때문에 .msi 파일을 다운로드 받아야 한다. 패키지 파일의 사이즈는 3 MB 정도로 굉장히 작아서 다운로드는 금방 이루어질 것이다.
패키지 파일을 다운로드 받아서 설치를 진행하면 아래 위치에 NXLog 구동에 필요할 파일들이 생성되며, 윈도우 서비스에 보면 NXLog 가 자동 시작 유형으로 생성된 것을 확인할 수 있다.
C:\Program Files (x86)\nxlog
초기 설치 이후에 NXLog 서비스는 아직 시작되지 않은 상태다.
NXLog 를 서비스를 시작하기 전에 먼저 설정 파일을 편집하자.
설정 파일의 위치는 아래와 같다.
C:\Program Files (x86)\nxlog\conf\nxlog.conf
설정 파일을 아래와 같이 설정하여 저장하고 nxlog 서비스를 시작하자.
아래 설정 파일은 새로 발생하는 모든 윈도우 이벤트 로그를 GrayLog 서버로 전달하는 설정이다.
--- nxlog.conf 파일 설정 방법
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension gelf>
Module xm_gelf
</Extension>
<Input eventlog>
# For windows vista/2008 and above use:
Module im_msvistalog
# For windows 2003 and earlier use the following:
# Module im_mseventlog
</Input>
<Output out>
Module om_udp
Host graylog.wign21.net
Port 5415
OutputType GELF
</Output>
<Route 1>
Path eventlog => out
</Route>
먼저 NXLog 의 설치 파일 다운로드를 위해 NXLog 홈페이지로 이동하자.
http://nxlog-ce.sourceforge.net/
페이지 상단의 Download 메뉴로 이동하면 각 OS 플랫폼에 맞는 다운로드 패키지가 제공되는 다운로드용 미러 사이트로 이동하는 링크가 있다.
우리는 윈도우 서버에 NXLog를 설치할 예정이기 때문에 .msi 파일을 다운로드 받아야 한다. 패키지 파일의 사이즈는 3 MB 정도로 굉장히 작아서 다운로드는 금방 이루어질 것이다.
패키지 파일을 다운로드 받아서 설치를 진행하면 아래 위치에 NXLog 구동에 필요할 파일들이 생성되며, 윈도우 서비스에 보면 NXLog 가 자동 시작 유형으로 생성된 것을 확인할 수 있다.
C:\Program Files (x86)\nxlog
초기 설치 이후에 NXLog 서비스는 아직 시작되지 않은 상태다.
NXLog 를 서비스를 시작하기 전에 먼저 설정 파일을 편집하자.
설정 파일의 위치는 아래와 같다.
C:\Program Files (x86)\nxlog\conf\nxlog.conf
설정 파일을 아래와 같이 설정하여 저장하고 nxlog 서비스를 시작하자.
아래 설정 파일은 새로 발생하는 모든 윈도우 이벤트 로그를 GrayLog 서버로 전달하는 설정이다.
--- nxlog.conf 파일 설정 방법
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension gelf>
Module xm_gelf
</Extension>
<Input eventlog>
# For windows vista/2008 and above use:
Module im_msvistalog
# For windows 2003 and earlier use the following:
# Module im_mseventlog
</Input>
<Output out>
Module om_udp
Host graylog.wign21.net
Port 5415
OutputType GELF
</Output>
<Route 1>
Path eventlog => out
</Route>
피드 구독하기:
글 (Atom)
GrayLog 사용하기 - NXLog Setup (3)
Windows 8.1, Windows Server 2012 R2 에서는 이전 포스트의 컨피그로 구동했을 시에 아래와 같은 에러 메시지와 함께 로그 전달이 실패할 수 있다. "ERROR Couldn't read next event,...
-
윈도우 서버의 이벤트 로그를 수집하여 GrayLog 서버로 보내기 위해 NXLog 를 사용해보자. 먼저 NXLog 의 설치 파일 다운로드를 위해 NXLog 홈페이지로 이동하자. http://nxlog-ce.sourceforge.net/ 페이...
-
IIS 웹 로그와 이벤트 로그를 한꺼번에 GrayLog 로 보내는 NXLog 설정을 알아보자. 아래 설정 시 주의할 점은 IIS 웹 로그의 포멧을 맞추는 것이다. ---- nxlog.conf define ROOT C:\Program Files...
-
Windows 8.1, Windows Server 2012 R2 에서는 이전 포스트의 컨피그로 구동했을 시에 아래와 같은 에러 메시지와 함께 로그 전달이 실패할 수 있다. "ERROR Couldn't read next event,...