개발자의 노트
반응형

Fluentd 설치 참조 : http://misoin.tistory.com/43

MongoDB 설치 참조 : http://misoin.tistory.com/21


 

nginx access 로그를 수집하도록 설정

# vi /etc/td-agent/td-agent.conf

# nginx access log

<source>

  type tail

  path /log/nginx/access.log

  tag nginx.log.access

  format apache

  time_format %d/%b/%Y:%H:%M:%S %z

</source>

 

<match nginx.log.access>

  type mongo

  database nginx

  collection access

  host 192.168.0.204

  port 27017

  flush_interval 10s

</match>

# /etc/init.d/td-agent restart

 

자료 몇 개 때려넣고

# ab -n 100 -c 10 http://192.168.0.201/

 

몽고디비에서 확인해보자

# mongo

MongoDB shell version: 2.2.1

connecting to: test

> use nginx

switched to db nginx

> db.access.find()

{ "_id" : ObjectId("50a79176e1382305f5000009"), "host" : "192.168.0.201", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "612", "referer" : "-", "agent" : "ApacheBench/2.0.40-dev", "time" : ISODate("2012-11-17T13:30:24Z") }

{ "_id" : ObjectId("50a79176e1382305f500000a"), "host" : "192.168.0.201", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "612", "referer" : "-", "agent" : "ApacheBench/2.0.40-dev", "time" : ISODate("2012-11-17T13:30:24Z") }

{ "_id" : ObjectId("50a79176e1382305f500000b"), "host" : "192.168.0.201", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "612", "referer" : "-", "agent" : "ApacheBench/2.0.40-dev", "time" : ISODate("2012-11-17T13:30:24Z") }

{ "_id" : ObjectId("50a79176e1382305f500000c"), "host" : "192.168.0.201", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "612", "referer" : "-", "agent" : "ApacheBench/2.0.40-dev", "time" : ISODate("2012-11-17T13:30:24Z") }

{ "_id" : ObjectId("50a79176e1382305f500000d"), "host" : "192.168.0.201", "user" : "-", "method" : "GET", "path" : "/", "code" : "200", "size" : "612", "referer" : "-", "agent" : "ApacheBench/2.0.40-dev", "time" : ISODate("2012-11-17T13:30:24Z") }

profile

개발자의 노트

@곽코딩

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!