LEK stack for node.js
1) node access log file
1. node access log json formatting
(/Users/mac/git/fuji/config/express.js)
app.use(expressWinston.logger({
transports: [
new winston.transports.DailyRotateFile({
json: true,
filename: config.logs_dir + '/access-',
datePattern: 'yyyy-MM-dd.log'
})
]
}));
2) logstash
1. logstash download
http://logstash.net/
extract file to mac:/data1/logstash-1.4.0
2. make config file
mac:/data1/logstash-1.4.0> vi logstash-node.conf
input{
file{
codec => json
path => ["/Users/mac/git/fuji/logs/access*.log"]
start_position => "beginning"
}
}
output{
elasticsearch {
cluster => "locketCast"
node_name => "logstash"
host => "127.0.0.1"
index => "updatelogs"
}
}
cf. index => "%{es_index}"
index_type => "%{es_type}"
document_id => "%{es_id}"
3. run logstash
mac:/data1/logstash-1.4.0> bin/logstash -f logstash-node.conf
3) kibana
1. download
https://github.com/elasticsearch/kibana
/data1/elasticsearch/kibana>
2. add ngix virtual host for kibana
brew install nginx
sudo nginx -s stop
sudo nginx
/usr/local/etc/nginx/conf.d> vi vm.conf
server {
listen 7001;
server_name localhost;
#access_log logs/localhost.access.log main;
location / {
root /data1/elasticsearch/kibana;
index index.html index.htm;
}
}
3. check out the site
http://localhost:7001 |
Comments
Post a Comment